Skip to content

Commit

Permalink
Updated ui for context menu in sharedSpace and mySpace
Browse files Browse the repository at this point in the history
  • Loading branch information
KhaledNjim committed Jun 10, 2024
1 parent 611fa52 commit c939f6a
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ContextMenuBuilder {
child: Wrap(
children: [
_header ?? SizedBox.shrink(),
Divider(),
Divider(thickness: 1,),
areTilesHorizontal
? Row(
mainAxisAlignment: alignment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
));
)));
}
}
18 changes: 14 additions & 4 deletions lib/presentation/widget/myspace/my_space_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -521,6 +521,7 @@ class MySpaceViewModel extends BaseViewModel {
return (Store<AppState> 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)
Expand Down Expand Up @@ -734,11 +735,15 @@ class MySpaceViewModel extends BaseViewModel {
};
}

ThunkAction<AppState> _pickFileSuccessAction(FilePickerSuccessViewState success) {
ThunkAction<AppState> _pickFileSuccessAction(Success success) {
return (Store<AppState> 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
: []));
};
}

Expand Down Expand Up @@ -905,6 +910,11 @@ class MySpaceViewModel extends BaseViewModel {
}
}

void openAudioRecorder(BuildContext context) {
_appNavigation.popBack();
_appNavigation.push(RoutePaths.audioRecorder);
}

@override
void onDisposed() {
cancelSelection();
Expand Down
47 changes: 41 additions & 6 deletions lib/presentation/widget/myspace/my_space_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -473,16 +473,30 @@ class _MySpaceWidgetState extends State<MySpaceWidget> {
List<Widget> _uploadFileMenuActionTiles(BuildContext context) {
return [
_pickPhotoAndVideoAction(context),
Divider(
thickness: 1,
),
_browseFileAction(context),
Divider(
thickness: 1,
),
_openCameraPickerAction(context),
Divider(
thickness: 1,
),
_openAudioRecorderAction(context)
];
}

Widget _pickPhotoAndVideoAction(BuildContext context) {
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();
Expand All @@ -492,18 +506,39 @@ class _MySpaceWidgetState extends State<MySpaceWidget> {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -457,20 +457,21 @@ class SharedSpaceDocumentNodeViewModel extends BaseViewModel {
};
}

ThunkAction<AppState> _pickFileSuccessAction(FilePickerSuccessViewState success) {
ThunkAction<AppState> _pickFileSuccessAction(Success success) {
return (Store<AppState> store) async {
store.dispatch(UploadFileAction(Right(success)));

List<FileInfo> 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())));
};
}

Expand All @@ -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()) {
Expand All @@ -502,9 +515,12 @@ class SharedSpaceDocumentNodeViewModel extends BaseViewModel {

ThunkAction<AppState> _handleAddNewFileOrFolderMenuAction(BuildContext context, List<Widget> actionTiles) {
return (Store<AppState> 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)
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,6 @@ class _SharedSpaceDocumentWidgetState extends State<SharedSpaceDocumentWidget> {
return [
uploadFileAction(),
addNewFolderAction(),
takePhotoAction()
];
}

Expand All @@ -877,26 +876,45 @@ class _SharedSpaceDocumentWidgetState extends State<SharedSpaceDocumentWidget> {
.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<Widget> 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();
Expand All @@ -905,7 +923,7 @@ class _SharedSpaceDocumentWidgetState extends State<SharedSpaceDocumentWidget> {
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();
Expand Down
4 changes: 4 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c939f6a

Please sign in to comment.