Browse Source

harbour: Add uploading from camera

pull/23/head
jld3103 2 years ago
parent
commit
8f94f01eba
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 1
      packages/harbour/lib/l10n/en.arb
  2. 6
      packages/harbour/lib/l10n/localizations.dart
  3. 3
      packages/harbour/lib/l10n/localizations_en.dart
  4. 1
      packages/harbour/lib/src/apps/files/app.dart
  5. 18
      packages/harbour/lib/src/apps/files/dialogs/choose_create.dart
  6. 3
      packages/harbour/lib/src/platforms/abstract.dart
  7. 1
      packages/harbour/lib/src/platforms/android.dart
  8. 1
      packages/harbour/lib/src/platforms/linux.dart
  9. 42
      packages/harbour/pubspec.lock
  10. 1
      packages/harbour/pubspec.yaml

1
packages/harbour/lib/l10n/en.arb

@ -102,6 +102,7 @@
"filesName": "Files", "filesName": "Files",
"filesUploadFiles": "Upload files", "filesUploadFiles": "Upload files",
"filesUploadImages": "Upload images", "filesUploadImages": "Upload images",
"filesUploadCamera": "Upload from camera",
"filesCreateFolder": "Create folder", "filesCreateFolder": "Create folder",
"filesFolderName": "Folder name", "filesFolderName": "Folder name",
"filesRenameFolder": "Rename folder", "filesRenameFolder": "Rename folder",

6
packages/harbour/lib/l10n/localizations.dart

@ -455,6 +455,12 @@ abstract class AppLocalizations {
/// **'Upload images'** /// **'Upload images'**
String get filesUploadImages; String get filesUploadImages;
/// No description provided for @filesUploadCamera.
///
/// In en, this message translates to:
/// **'Upload from camera'**
String get filesUploadCamera;
/// No description provided for @filesCreateFolder. /// No description provided for @filesCreateFolder.
/// ///
/// In en, this message translates to: /// In en, this message translates to:

3
packages/harbour/lib/l10n/localizations_en.dart

@ -200,6 +200,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override @override
String get filesUploadImages => 'Upload images'; String get filesUploadImages => 'Upload images';
@override
String get filesUploadCamera => 'Upload from camera';
@override @override
String get filesCreateFolder => 'Create folder'; String get filesCreateFolder => 'Create folder';

1
packages/harbour/lib/src/apps/files/app.dart

@ -13,6 +13,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_rx_bloc/flutter_rx_bloc.dart'; import 'package:flutter_rx_bloc/flutter_rx_bloc.dart';
import 'package:harbour/src/apps/files/blocs/browser.dart'; import 'package:harbour/src/apps/files/blocs/browser.dart';
import 'package:harbour/src/harbour.dart'; import 'package:harbour/src/harbour.dart';
import 'package:image_picker/image_picker.dart';
import 'package:intersperse/intersperse.dart'; import 'package:intersperse/intersperse.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';

18
packages/harbour/lib/src/apps/files/dialogs/choose_create.dart

@ -49,6 +49,24 @@ class FilesChooseCreateDialog extends StatelessWidget {
await upload(FileType.image); await upload(FileType.image);
}, },
), ),
if (Provider.of<HarbourPlatform>(context, listen: false).canUseCamera) ...[
ListTile(
leading: Icon(
MdiIcons.cameraPlus,
color: Theme.of(context).colorScheme.primary,
),
title: Text(AppLocalizations.of(context).filesUploadCamera),
onTap: () async {
Navigator.of(context).pop();
final picker = ImagePicker();
final result = await picker.pickImage(source: ImageSource.camera);
if (result != null) {
bloc.uploadFile([...basePath, result.name], result.path);
}
},
),
],
ListTile( ListTile(
leading: Icon( leading: Icon(
MdiIcons.folderPlus, MdiIcons.folderPlus,

3
packages/harbour/lib/src/platforms/abstract.dart

@ -7,6 +7,7 @@ abstract class HarbourPlatform {
required this.canUseQuickActions, required this.canUseQuickActions,
required this.canUseSystemTray, required this.canUseSystemTray,
required this.canUseWindowManager, required this.canUseWindowManager,
required this.canUseCamera,
required this.getApplicationCachePath, required this.getApplicationCachePath,
required this.getUserAccessibleAppDataPath, required this.getUserAccessibleAppDataPath,
this.init, this.init,
@ -22,6 +23,8 @@ abstract class HarbourPlatform {
final bool canUseWindowManager; final bool canUseWindowManager;
final bool canUseCamera;
final Future<String> Function() getApplicationCachePath; final Future<String> Function() getApplicationCachePath;
final Future<String> Function() getUserAccessibleAppDataPath; final Future<String> Function() getUserAccessibleAppDataPath;

1
packages/harbour/lib/src/platforms/android.dart

@ -8,6 +8,7 @@ class AndroidHarbourPlatform extends HarbourPlatform {
canUseQuickActions: true, canUseQuickActions: true,
canUseSystemTray: false, canUseSystemTray: false,
canUseWindowManager: false, canUseWindowManager: false,
canUseCamera: true,
getApplicationCachePath: () async => (await getTemporaryDirectory()).absolute.path, getApplicationCachePath: () async => (await getTemporaryDirectory()).absolute.path,
getUserAccessibleAppDataPath: () async { getUserAccessibleAppDataPath: () async {
if (!await Permission.storage.request().isGranted) { if (!await Permission.storage.request().isGranted) {

1
packages/harbour/lib/src/platforms/linux.dart

@ -8,6 +8,7 @@ class LinuxHarbourPlatform extends HarbourPlatform {
canUseQuickActions: false, canUseQuickActions: false,
canUseSystemTray: true, canUseSystemTray: true,
canUseWindowManager: true, canUseWindowManager: true,
canUseCamera: false,
getApplicationCachePath: () async => p.join( getApplicationCachePath: () async => p.join(
xdg.cacheHome.absolute.path, xdg.cacheHome.absolute.path,
'de.provokateurin.harbour', 'de.provokateurin.harbour',

42
packages/harbour/pubspec.lock

@ -148,6 +148,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.2" version: "3.0.2"
cross_file:
dependency: transitive
description:
name: cross_file
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3+1"
crypto: crypto:
dependency: "direct main" dependency: "direct main"
description: description:
@ -345,6 +352,41 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.2.0" version: "3.2.0"
image_picker:
dependency: "direct main"
description:
name: image_picker
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.5+3"
image_picker_android:
dependency: transitive
description:
name: image_picker_android
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.5+1"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.8"
image_picker_ios:
dependency: transitive
description:
name: image_picker_ios
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.5+6"
image_picker_platform_interface:
dependency: transitive
description:
name: image_picker_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
intersperse: intersperse:
dependency: "direct main" dependency: "direct main"
description: description:

1
packages/harbour/pubspec.yaml

@ -26,6 +26,7 @@ dependencies:
flutter_svg: ^1.0.3 flutter_svg: ^1.0.3
html: ^0.15.0 html: ^0.15.0
http: ^0.13.4 http: ^0.13.4
image_picker: ^0.8.5+3
intersperse: ^2.0.0 intersperse: ^2.0.0
intl: ^0.17.0 intl: ^0.17.0
json_annotation: ^4.5.0 json_annotation: ^4.5.0

Loading…
Cancel
Save