diff --git a/packages/harbour/lib/l10n/en.arb b/packages/harbour/lib/l10n/en.arb index 73ba4c67..58a39dbd 100644 --- a/packages/harbour/lib/l10n/en.arb +++ b/packages/harbour/lib/l10n/en.arb @@ -102,6 +102,7 @@ "filesName": "Files", "filesUploadFiles": "Upload files", "filesUploadImages": "Upload images", + "filesUploadCamera": "Upload from camera", "filesCreateFolder": "Create folder", "filesFolderName": "Folder name", "filesRenameFolder": "Rename folder", diff --git a/packages/harbour/lib/l10n/localizations.dart b/packages/harbour/lib/l10n/localizations.dart index f6554cc1..e700b019 100644 --- a/packages/harbour/lib/l10n/localizations.dart +++ b/packages/harbour/lib/l10n/localizations.dart @@ -455,6 +455,12 @@ abstract class AppLocalizations { /// **'Upload images'** 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. /// /// In en, this message translates to: diff --git a/packages/harbour/lib/l10n/localizations_en.dart b/packages/harbour/lib/l10n/localizations_en.dart index 4bfce803..a25e7175 100644 --- a/packages/harbour/lib/l10n/localizations_en.dart +++ b/packages/harbour/lib/l10n/localizations_en.dart @@ -200,6 +200,9 @@ class AppLocalizationsEn extends AppLocalizations { @override String get filesUploadImages => 'Upload images'; + @override + String get filesUploadCamera => 'Upload from camera'; + @override String get filesCreateFolder => 'Create folder'; diff --git a/packages/harbour/lib/src/apps/files/app.dart b/packages/harbour/lib/src/apps/files/app.dart index bba39fb6..601dcca5 100644 --- a/packages/harbour/lib/src/apps/files/app.dart +++ b/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:harbour/src/apps/files/blocs/browser.dart'; import 'package:harbour/src/harbour.dart'; +import 'package:image_picker/image_picker.dart'; import 'package:intersperse/intersperse.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:nextcloud/nextcloud.dart'; diff --git a/packages/harbour/lib/src/apps/files/dialogs/choose_create.dart b/packages/harbour/lib/src/apps/files/dialogs/choose_create.dart index 8e5eff0c..e5c6c2a5 100644 --- a/packages/harbour/lib/src/apps/files/dialogs/choose_create.dart +++ b/packages/harbour/lib/src/apps/files/dialogs/choose_create.dart @@ -49,6 +49,24 @@ class FilesChooseCreateDialog extends StatelessWidget { await upload(FileType.image); }, ), + if (Provider.of(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( leading: Icon( MdiIcons.folderPlus, diff --git a/packages/harbour/lib/src/platforms/abstract.dart b/packages/harbour/lib/src/platforms/abstract.dart index 306b0146..a64f974d 100644 --- a/packages/harbour/lib/src/platforms/abstract.dart +++ b/packages/harbour/lib/src/platforms/abstract.dart @@ -7,6 +7,7 @@ abstract class HarbourPlatform { required this.canUseQuickActions, required this.canUseSystemTray, required this.canUseWindowManager, + required this.canUseCamera, required this.getApplicationCachePath, required this.getUserAccessibleAppDataPath, this.init, @@ -22,6 +23,8 @@ abstract class HarbourPlatform { final bool canUseWindowManager; + final bool canUseCamera; + final Future Function() getApplicationCachePath; final Future Function() getUserAccessibleAppDataPath; diff --git a/packages/harbour/lib/src/platforms/android.dart b/packages/harbour/lib/src/platforms/android.dart index 2cdbf235..e9dac549 100644 --- a/packages/harbour/lib/src/platforms/android.dart +++ b/packages/harbour/lib/src/platforms/android.dart @@ -8,6 +8,7 @@ class AndroidHarbourPlatform extends HarbourPlatform { canUseQuickActions: true, canUseSystemTray: false, canUseWindowManager: false, + canUseCamera: true, getApplicationCachePath: () async => (await getTemporaryDirectory()).absolute.path, getUserAccessibleAppDataPath: () async { if (!await Permission.storage.request().isGranted) { diff --git a/packages/harbour/lib/src/platforms/linux.dart b/packages/harbour/lib/src/platforms/linux.dart index ad2711cc..4016b831 100644 --- a/packages/harbour/lib/src/platforms/linux.dart +++ b/packages/harbour/lib/src/platforms/linux.dart @@ -8,6 +8,7 @@ class LinuxHarbourPlatform extends HarbourPlatform { canUseQuickActions: false, canUseSystemTray: true, canUseWindowManager: true, + canUseCamera: false, getApplicationCachePath: () async => p.join( xdg.cacheHome.absolute.path, 'de.provokateurin.harbour', diff --git a/packages/harbour/pubspec.lock b/packages/harbour/pubspec.lock index 23763b40..41869ada 100644 --- a/packages/harbour/pubspec.lock +++ b/packages/harbour/pubspec.lock @@ -148,6 +148,13 @@ packages: url: "https://pub.dartlang.org" source: hosted 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: dependency: "direct main" description: @@ -345,6 +352,41 @@ packages: url: "https://pub.dartlang.org" source: hosted 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: dependency: "direct main" description: diff --git a/packages/harbour/pubspec.yaml b/packages/harbour/pubspec.yaml index 06df11b3..15a7f826 100644 --- a/packages/harbour/pubspec.yaml +++ b/packages/harbour/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: flutter_svg: ^1.0.3 html: ^0.15.0 http: ^0.13.4 + image_picker: ^0.8.5+3 intersperse: ^2.0.0 intl: ^0.17.0 json_annotation: ^4.5.0