Skip to content

Commit

Permalink
Improve up
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-pratik-k committed Apr 22, 2024
1 parent a70e56b commit 5fb069d
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 131 deletions.
1 change: 1 addition & 0 deletions app/assets/locales/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"common_yesterday": "Yesterday",
"common_tomorrow": "Tomorrow",

"common_info":"Info",
"common_upload":"Upload",
"common_download":"Download",
"common_delete": "Delete",
Expand Down
18 changes: 14 additions & 4 deletions app/lib/ui/flow/home/components/multi_selection_done_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: () {
Expand Down
8 changes: 4 additions & 4 deletions app/lib/ui/flow/home/home_view_model_helper_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ mixin HomeViewModelHelperMixin {
Map<DateTime, List<AppMedia>> removeGoogleDriveRefFromMediaMap(
{required Map<DateTime, List<AppMedia>> medias,
List<String>? 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<DateTime, List<AppMedia>> addGoogleDriveRefInMediaMap({
Expand Down
234 changes: 131 additions & 103 deletions app/lib/ui/flow/media_preview/components/top_bar.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,8 +21,10 @@ import '../media_preview_view_model.dart';
class PreviewTopBar extends StatelessWidget {
final AutoDisposeStateNotifierProvider<MediaPreviewStateNotifier,
MediaPreviewState> 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) {
Expand All @@ -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: <PopupMenuEntry>[
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),
Expand Down
9 changes: 8 additions & 1 deletion app/lib/ui/flow/media_preview/media_preview_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,14 @@ class _MediaPreviewState extends ConsumerState<MediaPreview> {
_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),
],
Expand Down
Loading

0 comments on commit 5fb069d

Please sign in to comment.