diff --git a/app/assets/locales/app_en.arb b/app/assets/locales/app_en.arb index c251037..be9890e 100644 --- a/app/assets/locales/app_en.arb +++ b/app/assets/locales/app_en.arb @@ -14,6 +14,7 @@ "common_yesterday": "Yesterday", "common_tomorrow": "Tomorrow", + "common_info":"Info", "common_upload":"Upload", "common_download":"Download", "common_delete": "Delete", diff --git a/app/lib/ui/flow/home/components/multi_selection_done_button.dart b/app/lib/ui/flow/home/components/multi_selection_done_button.dart index e18db56..315534a 100644 --- a/app/lib/ui/flow/home/components/multi_selection_done_button.dart +++ b/app/lib/ui/flow/home/components/multi_selection_done_button.dart @@ -43,10 +43,20 @@ class MultiSelectionDoneButton extends ConsumerWidget { children: [ if (showUploadToDriveButton) AppSheetAction( - icon: SvgPicture.asset( - Assets.images.icons.googleDrive, - height: 24, - width: 24, + icon: Stack( + alignment: Alignment.bottomRight, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 0, right: 8), + child: Icon(CupertinoIcons.cloud_upload, + color: context.colorScheme.textSecondary, size: 22), + ), + SvgPicture.asset( + Assets.images.icons.googleDrive, + width: 14, + height: 14, + ), + ], ), title: context.l10n.back_up_on_google_drive_text, onPressed: () { diff --git a/app/lib/ui/flow/home/home_view_model_helper_mixin.dart b/app/lib/ui/flow/home/home_view_model_helper_mixin.dart index 9665c37..5aa73c7 100644 --- a/app/lib/ui/flow/home/home_view_model_helper_mixin.dart +++ b/app/lib/ui/flow/home/home_view_model_helper_mixin.dart @@ -47,10 +47,10 @@ mixin HomeViewModelHelperMixin { Map> removeGoogleDriveRefFromMediaMap( {required Map> medias, List? removeFromIds}) { - return medias.map((key, value) { - return MapEntry(key, - value..removeGoogleDriveRefFromMedias(removeFromIds: removeFromIds)); - }); + return sortMedias( + medias: medias.values.expand((element) => element).toList() + ..removeGoogleDriveRefFromMedias(removeFromIds: removeFromIds), + ); } Map> addGoogleDriveRefInMediaMap({ diff --git a/app/lib/ui/flow/media_preview/components/top_bar.dart b/app/lib/ui/flow/media_preview/components/top_bar.dart index c4ddf76..8b47b04 100644 --- a/app/lib/ui/flow/media_preview/components/top_bar.dart +++ b/app/lib/ui/flow/media_preview/components/top_bar.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:cloud_gallery/domain/extensions/context_extensions.dart'; import 'package:cloud_gallery/ui/navigation/app_router.dart'; +import 'package:data/models/media/media.dart'; import 'package:data/models/media/media_extension.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -20,8 +21,10 @@ import '../media_preview_view_model.dart'; class PreviewTopBar extends StatelessWidget { final AutoDisposeStateNotifierProvider provider; + final void Function() onAction; - const PreviewTopBar({super.key, required this.provider}); + const PreviewTopBar( + {super.key, required this.provider, required this.onAction}); @override Widget build(BuildContext context) { @@ -40,130 +43,155 @@ class PreviewTopBar extends StatelessWidget { actions: [ ActionButton( onPressed: () { - AppRouter.mediaMetaDataDetails(media: media).push(context); - }, - icon: Icon( - CupertinoIcons.info, - color: context.colorScheme.textSecondary, - size: 22, - ), - ), - if(media.isGoogleDriveStored) - ActionButton( - padding: const EdgeInsets.all(4), - onPressed: () { - notifier.downloadMediaFromGoogleDrive(media: media); - }, - icon: Icon( - CupertinoIcons.cloud_download, - color: context.colorScheme.textSecondary, - size: 22, - ), - ), - if(media.isLocalStored) - ActionButton( - padding: const EdgeInsets.all(4), - onPressed: () { - notifier.uploadMediaInGoogleDrive(media: media); - }, - icon: Icon( - CupertinoIcons.cloud_upload, - color: context.colorScheme.textSecondary, - size: 22, - ), - ), - ActionButton( - onPressed: () async { - if (media.isCommonStored && media.driveMediaRefId != null) { - showMenu( + showMenu( context: context, - position: RelativeRect.fromLTRB( - double.infinity, - kToolbarHeight + MediaQuery.of(context).padding.top, - 0, - 0), + position: RelativeRect.fromSize( + Rect.fromLTRB(context.mediaQuerySize.width, 50, 0, 0), + // Placeholder rect, will be overwritten + context.mediaQuerySize, // Size of the screen + ), + elevation: 1, surfaceTintColor: context.colorScheme.surface, color: context.colorScheme.surface, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), - items: [ + items: [ PopupMenuItem( - onTap: () async { - _showDeleteFromDriveDialog( - context: context, - onDelete: () { - notifier.deleteMediaFromGoogleDrive( - media.driveMediaRefId); - context.pop(); - }); + onTap: () { + onAction(); + AppRouter.mediaMetaDataDetails(media: media) + .push(context); }, child: Row( children: [ - SvgPicture.asset( - Assets.images.icons.googleDrive, - width: 20, - height: 20, + Icon( + CupertinoIcons.info, + color: context.colorScheme.textSecondary, + size: 22, ), const SizedBox(width: 16), - Text(context.l10n.common_delete_from_google_drive, + Text(context.l10n.common_info, style: AppTextStyles.body2.copyWith( color: context.colorScheme.textPrimary, )), ], ), ), - PopupMenuItem( - onTap: () async { - _showDeleteFromDeviceDialog( - context: context, - onDelete: () { - notifier.deleteMediaFromLocal(media.id); - context.pop(); - }); - }, - child: Row( - children: [ - Icon(CupertinoIcons.trash, + if (media.isGoogleDriveStored) + PopupMenuItem( + onTap: () { + notifier.downloadMediaFromGoogleDrive(media: media); + }, + child: Row( + children: [ + Icon( + CupertinoIcons.cloud_download, color: context.colorScheme.textSecondary, - size: 22), - const SizedBox(width: 16), - Text( - context.l10n.common_delete_from_device, - style: AppTextStyles.body2.copyWith( - color: context.colorScheme.textPrimary, + size: 22, ), - ), - ], + const SizedBox(width: 16), + Text( + context.l10n.common_download, + style: AppTextStyles.body2.copyWith( + color: context.colorScheme.textPrimary, + ), + ), + ], + ), ), - ), - ], - ); - } else if (media.isGoogleDriveStored && - media.driveMediaRefId != null) { - _showDeleteFromDriveDialog( - context: context, - onDelete: () { - notifier - .deleteMediaFromGoogleDrive(media.driveMediaRefId); - context.pop(); - }); - } else if (media.isLocalStored) { - _showDeleteFromDeviceDialog( - context: context, - onDelete: () { - notifier.deleteMediaFromLocal(media.id); - context.pop(); - }); - } + if (media.isLocalStored) + PopupMenuItem( + onTap: () { + notifier.uploadMediaInGoogleDrive(media: media); + }, + child: Row( + children: [ + Icon( + CupertinoIcons.cloud_upload, + color: context.colorScheme.textSecondary, + size: 22, + ), + const SizedBox(width: 16), + Text( + context.l10n.common_upload, + style: AppTextStyles.body2.copyWith( + color: context.colorScheme.textPrimary, + ), + ), + ], + ), + ), + if (media.sources.contains(AppMediaSource.googleDrive)) + PopupMenuItem( + onTap: () async { + _showDeleteFromDriveDialog( + context: context, + onDelete: () { + notifier.deleteMediaFromGoogleDrive( + media.driveMediaRefId); + context.pop(); + }); + }, + child: Row( + children: [ + Stack( + alignment: Alignment.bottomRight, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 2, right: 2), + child: Icon(CupertinoIcons.trash, + color: context.colorScheme.textSecondary, + size: 22), + ), + SvgPicture.asset( + Assets.images.icons.googleDrive, + width: 14, + height: 14, + ), + ], + ), + const SizedBox(width: 16), + Text(context.l10n.common_delete_from_google_drive, + style: AppTextStyles.body2.copyWith( + color: context.colorScheme.textPrimary, + )), + ], + ), + ), + if (media.sources.contains(AppMediaSource.local)) + PopupMenuItem( + onTap: () async { + _showDeleteFromDeviceDialog( + context: context, + onDelete: () { + notifier.deleteMediaFromLocal(media.id); + context.pop(); + }); + }, + child: Row( + children: [ + Icon(CupertinoIcons.trash, + color: context.colorScheme.textSecondary, + size: 22), + const SizedBox(width: 16), + Text( + (media.isLocalStored) + ? context.l10n.common_delete + : context.l10n.common_delete_from_device, + style: AppTextStyles.body2.copyWith( + color: context.colorScheme.textPrimary, + ), + ), + ], + ), + ), + ]); }, - icon: Padding( - padding: const EdgeInsets.all(4.0), - child: Icon( - CupertinoIcons.delete, - color: context.colorScheme.textSecondary, - size: 22, - ), + icon: Icon( + Icons.more_vert_rounded, + color: context.colorScheme.textSecondary, + size: 22, ), ), if (!Platform.isIOS && !Platform.isMacOS) const SizedBox(width: 8), diff --git a/app/lib/ui/flow/media_preview/media_preview_screen.dart b/app/lib/ui/flow/media_preview/media_preview_screen.dart index a34973b..d122b46 100644 --- a/app/lib/ui/flow/media_preview/media_preview_screen.dart +++ b/app/lib/ui/flow/media_preview/media_preview_screen.dart @@ -153,7 +153,14 @@ class _MediaPreviewState extends ConsumerState { _preview(context: context, media: state.medias[index]), ), ), - PreviewTopBar(provider: _provider), + PreviewTopBar( + provider: _provider, + onAction: () { + if(_videoPlayerController != null && (_videoPlayerController?.value.isInitialized ?? false)){ + _videoPlayerController?.pause(); + } + }, + ), _videoActions(context), _videoDurationSlider(context), ], diff --git a/app/lib/ui/flow/onboard/onboard_screen.dart b/app/lib/ui/flow/onboard/onboard_screen.dart index 2fdebd4..803c869 100644 --- a/app/lib/ui/flow/onboard/onboard_screen.dart +++ b/app/lib/ui/flow/onboard/onboard_screen.dart @@ -4,6 +4,7 @@ import 'package:cloud_gallery/ui/navigation/app_router.dart'; import 'package:data/storage/app_preferences.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:style/extensions/context_extensions.dart'; import 'package:style/text/app_text_style.dart'; @@ -16,26 +17,44 @@ class OnBoardScreen extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return AppPage( - body: SafeArea( - child: Padding( - padding: const EdgeInsets.all(16), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - _appLogo(context), - _onBoardDescription(context), - _getStartedButton( - context: context, - onGetStartedTap: () { - ref.read(AppPreferences.isOnBoardComplete.notifier).state = - true; - AppRouter.home.go(context); - }, - ) - ], + body: Stack( + children: [ + Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.transparent, + context.colorScheme.primary.withOpacity(0.2), + Colors.transparent, + ], + ), + ), ), - ), + SafeArea( + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + _appLogo(context), + _onBoardDescription(context), + _getStartedButton( + context: context, + onGetStartedTap: () { + ref + .read(AppPreferences.isOnBoardComplete.notifier) + .state = true; + AppRouter.home.go(context); + }, + ) + ], + ), + ), + ), + ], ), ); }