Skip to content

Commit

Permalink
Improvement (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-pratik-k authored Apr 25, 2024
1 parent 0fba5d6 commit ad8c771
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 16 deletions.
12 changes: 10 additions & 2 deletions app/lib/ui/flow/home/components/app_media_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ class _AppMediaItemState extends State<AppMediaItem>
),
if (widget.process?.status.isProcessing ?? false)
_BackgroundContainer(
margin: EdgeInsets.symmetric(
vertical: 4,
horizontal:
widget.media.sources.contains(AppMediaSource.googleDrive)
? 0
: 4),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down Expand Up @@ -157,13 +163,15 @@ class _AppMediaItemState extends State<AppMediaItem>

class _BackgroundContainer extends StatelessWidget {
final Widget child;
final EdgeInsets margin;

const _BackgroundContainer({required this.child});
const _BackgroundContainer(
{required this.child, this.margin = const EdgeInsets.all(4)});

@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.all(4),
margin: margin,
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: context.colorScheme.surface.withOpacity(0.6),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class MultiSelectionDoneButton extends ConsumerWidget {
),
title: context.l10n.common_delete_from_google_drive,
onPressed: () {
context.pop();
showAppAlertDialog(
context: context,
title: context.l10n.common_delete_from_google_drive,
Expand Down Expand Up @@ -150,7 +151,8 @@ class MultiSelectionDoneButton extends ConsumerWidget {
color: context.colorScheme.textSecondary,
),
title: context.l10n.download_from_google_drive_text,
onPressed: () {
onPressed: () async {
context.pop();
showAppAlertDialog(
context: context,
title: context.l10n.download_from_google_drive_text,
Expand All @@ -167,11 +169,13 @@ class MultiSelectionDoneButton extends ConsumerWidget {
isDestructiveAction: true,
title: context.l10n.common_download,
onPressed: () {
notifier.downloadMediaFromGoogleDrive();
context.pop();
},
),
],
);

},
),
if (showShareButton)
Expand Down
1 change: 1 addition & 0 deletions app/lib/ui/flow/home/home_screen_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ class HomeViewStateNotifier extends StateNotifier<HomeViewState>
state.selectedMedias.where((element) => element.isGoogleDriveStored);
_googleDriveProcessRepo.downloadMediasFromGoogleDrive(
medias: medias.toList());
state = state.copyWith(selectedMedias: []);
} catch (e) {
state = state.copyWith(error: e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class DownloadRequireView extends StatelessWidget {
width: double.infinity,
media.thumbnailLink ?? '',
fit: BoxFit.cover,
errorBuilder: (context, error, stackTrace) {
return const SizedBox();
},
),
),
Container(
Expand Down
6 changes: 3 additions & 3 deletions app/lib/ui/flow/media_transfer/media_transfer_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class _MediaTransferScreenState extends ConsumerState<MediaTransferScreen> {
key: ValueKey(upload[index].id),
process: upload[index],
onCancelTap: () {
notifier.onTerminateProcess(upload[index].id, true);
notifier.onTerminateUploadProcess(upload[index].id);
}),
);
});
Expand All @@ -131,7 +131,7 @@ class _MediaTransferScreenState extends ConsumerState<MediaTransferScreen> {
}

return ListView.separated(
padding: const EdgeInsets.symmetric(horizontal: 16),
padding: const EdgeInsets.all(16),
itemCount: download.length,
separatorBuilder: (context, index) => const SizedBox(
height: 8,
Expand All @@ -140,7 +140,7 @@ class _MediaTransferScreenState extends ConsumerState<MediaTransferScreen> {
key: ValueKey(download[index].id),
process: download[index],
onCancelTap: () {
notifier.onTerminateProcess(download[index].id, false);
notifier.onTerminateDownloadProcess(download[index].id);
},
),
);
Expand Down
12 changes: 6 additions & 6 deletions app/lib/ui/flow/media_transfer/media_transfer_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class MediaTransferStateNotifier extends StateNotifier<MediaTransferState> {
state = state.copyWith(page: value);
}

void onTerminateProcess(String id, bool isUploading) {
if (isUploading) {
_googleDriveProcessRepo.terminateUploadProcess(id);
} else {
_googleDriveProcessRepo.terminateDownloadProcess(id);
}
void onTerminateUploadProcess(String id) {
_googleDriveProcessRepo.terminateUploadProcess(id);
}

void onTerminateDownloadProcess(String id) {
_googleDriveProcessRepo.terminateDownloadProcess(id);
}

@override
Expand Down
2 changes: 1 addition & 1 deletion data/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"photo_manager","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.5/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_android-2.2.2/","native_build":true,"dependencies":[]},{"name":"photo_manager","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.1/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"photo_manager","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.5/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+3/","dependencies":[]},{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"photo_manager","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-04-22 15:04:02.576376","version":"3.19.3"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"photo_manager","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.5/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"google_sign_in_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_android-6.1.21/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_android-2.2.2/","native_build":true,"dependencies":[]},{"name":"photo_manager","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_android-2.2.1/","native_build":true,"dependencies":[]}],"macos":[{"name":"google_sign_in_ios","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_ios-5.7.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_foundation-2.3.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"photo_manager","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/photo_manager-3.0.0/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.3.5/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.3.2/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/path_provider_windows-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.3.2/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"google_sign_in_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/google_sign_in_web-0.12.3+3/","dependencies":[]},{"name":"package_info_plus","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/package_info_plus-7.0.0/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/pratikcanopas/.pub-cache/hosted/pub.dev/shared_preferences_web-2.3.0/","dependencies":[]}]},"dependencyGraph":[{"name":"google_sign_in","dependencies":["google_sign_in_android","google_sign_in_ios","google_sign_in_web"]},{"name":"google_sign_in_android","dependencies":[]},{"name":"google_sign_in_ios","dependencies":[]},{"name":"google_sign_in_web","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"photo_manager","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-04-25 11:18:03.858602","version":"3.19.3"}
6 changes: 3 additions & 3 deletions data/lib/repositories/google_drive_process_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class GoogleDriveProcessRepo extends ChangeNotifier {
),
);
} catch (error) {
if(error is RequestCancelledByUser){
if (error is RequestCancelledByUser) {
return;
} else if (error is BackUpFolderNotFound) {
_backUpFolderID = await _googleDriveService.getBackupFolderId();
Expand Down Expand Up @@ -235,7 +235,7 @@ class GoogleDriveProcessRepo extends ChangeNotifier {
response: localMedia.mergeGoogleDriveMedia(updatedMedia)),
);
} catch (error) {
if(error is RequestCancelledByUser){
if (error is RequestCancelledByUser) {
return;
}
_downloadQueue.updateWhere(
Expand Down Expand Up @@ -271,7 +271,7 @@ class GoogleDriveProcessRepo extends ChangeNotifier {
}

void terminateDownloadProcess(String id) {
_uploadQueue.updateWhere(
_downloadQueue.updateWhere(
where: (element) => element.id == id,
update: (element) =>
element.copyWith(status: AppProcessStatus.terminated));
Expand Down

0 comments on commit ad8c771

Please sign in to comment.