From c939f6a899d660b8fddf7c8bf83310d606a58e57 Mon Sep 17 00:00:00 2001 From: KhaledNjim Date: Mon, 10 Jun 2024 05:34:08 +0100 Subject: [PATCH] Updated ui for context menu in sharedSpace and mySpace --- .../context_menu/context_menu_builder.dart | 2 +- .../simple_bottom_sheet_header_builder.dart | 5 +- .../widget/myspace/my_space_viewmodel.dart | 18 +++++-- .../widget/myspace/my_space_widget.dart | 47 ++++++++++++++++--- .../shared_space_document_viewmodel.dart | 43 ++++++++++++----- .../shared_space_document_widget.dart | 32 ++++++++++--- pubspec.yaml | 4 ++ 7 files changed, 118 insertions(+), 33 deletions(-) diff --git a/lib/presentation/view/context_menu/context_menu_builder.dart b/lib/presentation/view/context_menu/context_menu_builder.dart index 1c5aef833..4f2186531 100644 --- a/lib/presentation/view/context_menu/context_menu_builder.dart +++ b/lib/presentation/view/context_menu/context_menu_builder.dart @@ -101,7 +101,7 @@ class ContextMenuBuilder { child: Wrap( children: [ _header ?? SizedBox.shrink(), - Divider(), + Divider(thickness: 1,), areTilesHorizontal ? Row( mainAxisAlignment: alignment, diff --git a/lib/presentation/view/header/simple_bottom_sheet_header_builder.dart b/lib/presentation/view/header/simple_bottom_sheet_header_builder.dart index 91bcfca68..878cd4e32 100644 --- a/lib/presentation/view/header/simple_bottom_sheet_header_builder.dart +++ b/lib/presentation/view/header/simple_bottom_sheet_header_builder.dart @@ -63,12 +63,13 @@ class SimpleBottomSheetHeaderBuilder { key: _key, title: Transform( transform: _transformPadding ?? Matrix4.translationValues(12, 5, 0.0), - child: Text( + child: Center( + child:Text( _label ?? '', style: _textStyle ?? TextStyle( fontSize: 20.0, color: AppColor.uploadFileFileNameTextColor), ), - )); + ))); } } diff --git a/lib/presentation/widget/myspace/my_space_viewmodel.dart b/lib/presentation/widget/myspace/my_space_viewmodel.dart index b55cc5a98..0f38cce2c 100644 --- a/lib/presentation/widget/myspace/my_space_viewmodel.dart +++ b/lib/presentation/widget/myspace/my_space_viewmodel.dart @@ -52,7 +52,7 @@ import 'package:linshare_flutter_app/presentation/redux/online_thunk_action.dart import 'package:linshare_flutter_app/presentation/redux/states/app_state.dart'; import 'package:linshare_flutter_app/presentation/redux/states/my_space_state.dart'; import 'package:linshare_flutter_app/presentation/redux/states/ui_state.dart'; -import 'package:linshare_flutter_app/presentation/util/media_Picker_From_Camera.dart'; +import 'package:linshare_flutter_app/presentation/util/media_picker_from_camera.dart'; import 'package:linshare_flutter_app/presentation/util/extensions/validator_failure_extension.dart'; import 'package:linshare_flutter_app/presentation/util/local_file_picker.dart'; import 'package:linshare_flutter_app/presentation/util/router/app_navigation.dart'; @@ -442,7 +442,7 @@ class MySpaceViewModel extends BaseViewModel { _appNavigation.popBack(); store.dispatch(_pickFileAction(context, fileType)); } - + void openCameraPicker(BuildContext context) { _appNavigation.popBack(); store.dispatch(_openCameraAction(context)); @@ -521,6 +521,7 @@ class MySpaceViewModel extends BaseViewModel { return (Store store) async { ContextMenuBuilder(context) .addHeader(SimpleBottomSheetHeaderBuilder(Key('file_picker_bottom_sheet_header_builder')) + .addTransformPadding(Matrix4.translationValues(0, 0, 0.0)) .addLabel(AppLocalizations.of(context).upload_file_title) .build()) .addTiles(actionTiles) @@ -734,11 +735,15 @@ class MySpaceViewModel extends BaseViewModel { }; } - ThunkAction _pickFileSuccessAction(FilePickerSuccessViewState success) { + ThunkAction _pickFileSuccessAction(Success success) { return (Store store) async { store.dispatch(UploadFileAction(Right(success))); await _appNavigation.push(RoutePaths.uploadDocumentRoute, - arguments: UploadFileArguments(success.pickedFiles)); + arguments: UploadFileArguments(success is FilePickerSuccessViewState + ? success.pickedFiles + : success is MediaPickerSuccessViewState + ? success.file + : [])); }; } @@ -905,6 +910,11 @@ class MySpaceViewModel extends BaseViewModel { } } + void openAudioRecorder(BuildContext context) { + _appNavigation.popBack(); + _appNavigation.push(RoutePaths.audioRecorder); + } + @override void onDisposed() { cancelSelection(); diff --git a/lib/presentation/widget/myspace/my_space_widget.dart b/lib/presentation/widget/myspace/my_space_widget.dart index f444c5966..f4995e63e 100644 --- a/lib/presentation/widget/myspace/my_space_widget.dart +++ b/lib/presentation/widget/myspace/my_space_widget.dart @@ -473,8 +473,18 @@ class _MySpaceWidgetState extends State { List _uploadFileMenuActionTiles(BuildContext context) { return [ _pickPhotoAndVideoAction(context), + Divider( + thickness: 1, + ), _browseFileAction(context), + Divider( + thickness: 1, + ), _openCameraPickerAction(context), + Divider( + thickness: 1, + ), + _openAudioRecorderAction(context) ]; } @@ -482,7 +492,11 @@ class _MySpaceWidgetState extends State { return SimpleContextMenuActionBuilder( Key('pick_photo_and_video_context_menu_action'), SvgPicture.asset(imagePath.icPhotoLibrary, - width: 24, height: 24, fit: BoxFit.fill), + width: 24, + height: 24, + fit: BoxFit.fill, + color: AppColor.primaryColor, + ), AppLocalizations.of(context).photos_and_videos) .onActionClick((_) => mySpaceViewModel.openFilePickerByType(context, FileType.media)) .build(); @@ -492,18 +506,39 @@ class _MySpaceWidgetState extends State { return SimpleContextMenuActionBuilder( Key('pick_from_camera_context_menu_action'), SvgPicture.asset(imagePath.icCamera, - width: 24, height: 24, fit: BoxFit.fill), - //AppLocalizations.of(context).take_a_photo - 'Take a photo' ) + width: 24, + height: 24, + fit: BoxFit.fill, + color: AppColor.primaryColor, + ), + AppLocalizations.of(context).camera) .onActionClick((_) => mySpaceViewModel.openCameraPicker(context)) .build(); } + + Widget _openAudioRecorderAction(BuildContext context) { + return SimpleContextMenuActionBuilder( + Key('record_audio_context_menu_action'), + SvgPicture.asset(imagePath.icMicrophone, + width: 24, + height: 24, + fit: BoxFit.fill, + color: AppColor.primaryColor), + AppLocalizations.of(context).audio_recording) + .onActionClick((_) => mySpaceViewModel.openAudioRecorder(context)) + .build(); + } Widget _browseFileAction(BuildContext context) { return SimpleContextMenuActionBuilder( Key('browse_file_context_menu_action'), - SvgPicture.asset(imagePath.icMore, - width: 24, height: 24, fit: BoxFit.fill), + SvgPicture.asset( + imagePath.icFolder, + width: 24, + height: 24, + fit: BoxFit.fill, + color: AppColor.primaryColor, + ), AppLocalizations.of(context).browse) .onActionClick((_) => mySpaceViewModel.openFilePickerByType(context, FileType.any)) .build(); diff --git a/lib/presentation/widget/shared_space_document/shared_space_document_viewmodel.dart b/lib/presentation/widget/shared_space_document/shared_space_document_viewmodel.dart index f1ae51aa1..37582e080 100644 --- a/lib/presentation/widget/shared_space_document/shared_space_document_viewmodel.dart +++ b/lib/presentation/widget/shared_space_document/shared_space_document_viewmodel.dart @@ -59,7 +59,7 @@ import 'package:linshare_flutter_app/presentation/redux/states/app_state.dart'; import 'package:linshare_flutter_app/presentation/redux/states/shared_space_document_destination_picker_state.dart'; import 'package:linshare_flutter_app/presentation/redux/states/shared_space_document_state.dart'; import 'package:linshare_flutter_app/presentation/redux/states/ui_state.dart'; -import 'package:linshare_flutter_app/presentation/util/media_Picker_From_Camera.dart'; +import 'package:linshare_flutter_app/presentation/util/media_picker_from_camera.dart'; import 'package:linshare_flutter_app/presentation/util/extensions/advance_search_extension.dart'; import 'package:linshare_flutter_app/presentation/util/extensions/suggest_name_type_extension.dart'; import 'package:linshare_flutter_app/presentation/util/local_file_picker.dart'; @@ -457,20 +457,21 @@ class SharedSpaceDocumentNodeViewModel extends BaseViewModel { }; } - ThunkAction _pickFileSuccessAction(FilePickerSuccessViewState success) { + ThunkAction _pickFileSuccessAction(Success success) { return (Store store) async { store.dispatch(UploadFileAction(Right(success))); - + List pickedFiles = success is FilePickerSuccessViewState + ? success.pickedFiles + : success is MediaPickerSuccessViewState + ? success.file + : []; await _appNavigation.push(RoutePaths.uploadDocumentRoute, - arguments: UploadFileArguments(success.pickedFiles, - shareType: ShareType.none, - workGroupDocumentUploadInfo: WorkGroupDocumentUploadInfo( - getSharedSpaceNodeNested(), - getWorkGroupNode(), - getSharedSpaceDocumentType() - ) - ) - ); + arguments: UploadFileArguments(pickedFiles, + shareType: ShareType.none, + workGroupDocumentUploadInfo: WorkGroupDocumentUploadInfo( + getSharedSpaceNodeNested(), + getWorkGroupNode(), + getSharedSpaceDocumentType()))); }; } @@ -489,6 +490,18 @@ class SharedSpaceDocumentNodeViewModel extends BaseViewModel { }; } + void openAudioRecorder() { + _appNavigation.popBack(); + _appNavigation.push(RoutePaths.audioRecorder, + arguments: UploadFileArguments([], + shareType: ShareType.none, + workGroupDocumentUploadInfo: WorkGroupDocumentUploadInfo( + getSharedSpaceNodeNested(), + getWorkGroupNode(), + getSharedSpaceDocumentType()))); + } + + void openSearchState(BuildContext context) { var destinationName = AppLocalizations.of(context).shared_space; if(isRootFolder()) { @@ -502,9 +515,12 @@ class SharedSpaceDocumentNodeViewModel extends BaseViewModel { ThunkAction _handleAddNewFileOrFolderMenuAction(BuildContext context, List actionTiles) { return (Store store) async { - ContextMenuBuilder(context, areTilesHorizontal: true,alignment: MainAxisAlignment.spaceEvenly) + ContextMenuBuilder(context, + areTilesHorizontal: true, + alignment: MainAxisAlignment.spaceEvenly) .addHeader(SimpleBottomSheetHeaderBuilder( Key('add_new_file_or_folders_bottom_sheet_header_builder')) + .addTransformPadding(Matrix4.translationValues(0, 0, 0.0)) .addLabel(AppLocalizations.of(context).add_new_file_or_folder) .build()) .addTiles(actionTiles) @@ -518,6 +534,7 @@ class SharedSpaceDocumentNodeViewModel extends BaseViewModel { .addHeader(SimpleBottomSheetHeaderBuilder( Key('file_picker_bottom_sheet_header_builder')) .addLabel(AppLocalizations.of(context).upload_file_title) + .addTransformPadding(Matrix4.translationValues(0, 0, 0.0)) .build()) .addTiles(actionTiles) .build(); diff --git a/lib/presentation/widget/shared_space_document/shared_space_document_widget.dart b/lib/presentation/widget/shared_space_document/shared_space_document_widget.dart index 3c04271c3..c4b70751d 100644 --- a/lib/presentation/widget/shared_space_document/shared_space_document_widget.dart +++ b/lib/presentation/widget/shared_space_document/shared_space_document_widget.dart @@ -854,7 +854,6 @@ class _SharedSpaceDocumentWidgetState extends State { return [ uploadFileAction(), addNewFolderAction(), - takePhotoAction() ]; } @@ -877,26 +876,45 @@ class _SharedSpaceDocumentWidgetState extends State { .build(); } Widget takePhotoAction() { - return SimpleHorizontalContextMenuActionBuilder( + return SimpleContextMenuActionBuilder( Key('take_photo_context_menu_action'), SvgPicture.asset(imagePath.icCamera, width: 24, height: 24, fit: BoxFit.fill, color: AppColor.primaryColor), - //AppLocalizations.of(context).upload_file_title - 'Take a photo') + AppLocalizations.of(context).camera) .onActionClick((_) => sharedSpaceDocumentViewModel.openCameraPicker(context)) .build(); } +Widget recordAudioAction() { + return SimpleContextMenuActionBuilder( + Key('record_audio_context_menu_action'), + SvgPicture.asset(imagePath.icMicrophone, + width: 24, + height: 24, + fit: BoxFit.fill, + color: AppColor.primaryColor), + AppLocalizations.of(context).audio_recording) + .onActionClick((_) => sharedSpaceDocumentViewModel.openAudioRecorder()) + .build(); + } + + List uploadFileMenuActionTiles(BuildContext context) { return [ pickPhotoAndVideoAction(), - browseFileAction() + Divider(thickness: 1), + browseFileAction(), + Divider(thickness: 1), + takePhotoAction(), + Divider(thickness: 1), + recordAudioAction() + ]; } Widget pickPhotoAndVideoAction() { return SimpleContextMenuActionBuilder( Key('pick_photo_and_video_context_menu_action'), - SvgPicture.asset(imagePath.icPhotoLibrary, width: 24, height: 24, fit: BoxFit.fill), + SvgPicture.asset(imagePath.icPhotoLibrary, width: 24, height: 24, fit: BoxFit.fill,color: AppColor.primaryColor,), AppLocalizations.of(context).photos_and_videos) .onActionClick((_) => sharedSpaceDocumentViewModel.openFilePickerByType(FileType.media)) .build(); @@ -905,7 +923,7 @@ class _SharedSpaceDocumentWidgetState extends State { Widget browseFileAction() { return SimpleContextMenuActionBuilder( Key('browse_file_context_menu_action'), - SvgPicture.asset(imagePath.icMore, width: 24, height: 24, fit: BoxFit.fill), + SvgPicture.asset(imagePath.icFolder, width: 24, height: 24, fit: BoxFit.fill,color: AppColor.primaryColor,), AppLocalizations.of(context).browse) .onActionClick((_) => sharedSpaceDocumentViewModel.openFilePickerByType(FileType.any)) .build(); diff --git a/pubspec.yaml b/pubspec.yaml index 7584d7422..8fa504ad2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -124,6 +124,10 @@ dependencies: # camera picker wechat_camera_picker: 3.8.0 + # audio recording and displaying waveforms + audio_waveforms: 0.1.5+1 + + async: 2.8.2 firebase_core: 1.19.1