From b0db8ed6c476084b7fe0c89ba7e22aec9da75833 Mon Sep 17 00:00:00 2001 From: shenlong <139912620+shenlong-tanwen@users.noreply.github.com> Date: Tue, 28 Nov 2023 22:05:13 +0000 Subject: [PATCH] style(mobile): asset selection animation (#5322) * refactor: replace navigator.pop with context.pop * mobile: use demo instance credentials for test login * style(mobile): centre align add partner button * mobile: add thumbnail selection animation * differnt gesture for test instance --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex Tran --- .../extensions/build_context_extensions.dart | 2 +- .../album/ui/add_to_album_bottom_sheet.dart | 2 +- .../modules/album/ui/album_viewer_appbar.dart | 16 +++++++-------- .../album/views/album_options_part.dart | 4 ++-- .../asset_viewer/views/gallery_viewer.dart | 8 ++++---- .../home/ui/asset_grid/thumbnail_image.dart | 4 +++- mobile/lib/modules/login/ui/login_form.dart | 7 +++++++ .../lib/modules/memories/ui/memory_lane.dart | 2 +- .../modules/partner/views/partner_page.dart | 20 +++++++++++-------- .../modules/settings/views/settings_page.dart | 5 ++--- 10 files changed, 41 insertions(+), 29 deletions(-) diff --git a/mobile/lib/extensions/build_context_extensions.dart b/mobile/lib/extensions/build_context_extensions.dart index b2e6ed4720..6151bd1a5c 100644 --- a/mobile/lib/extensions/build_context_extensions.dart +++ b/mobile/lib/extensions/build_context_extensions.dart @@ -45,7 +45,7 @@ extension ContextHelper on BuildContext { ) => AutoRouter.of(this).navigate(route); -// Auto-Push replace route from the current context + // Auto-Push replace route from the current context Future autoReplace(PageRouteInfo route) => AutoRouter.of(this).replace(route); diff --git a/mobile/lib/modules/album/ui/add_to_album_bottom_sheet.dart b/mobile/lib/modules/album/ui/add_to_album_bottom_sheet.dart index 650d4da0d4..25747177a5 100644 --- a/mobile/lib/modules/album/ui/add_to_album_bottom_sheet.dart +++ b/mobile/lib/modules/album/ui/add_to_album_bottom_sheet.dart @@ -65,7 +65,7 @@ class AddToAlbumBottomSheet extends HookConsumerWidget { } ref.invalidate(albumDetailProvider(album.id)); - Navigator.pop(context); + context.pop(); } return Card( diff --git a/mobile/lib/modules/album/ui/album_viewer_appbar.dart b/mobile/lib/modules/album/ui/album_viewer_appbar.dart index fbab831f7b..766b55f9b3 100644 --- a/mobile/lib/modules/album/ui/album_viewer_appbar.dart +++ b/mobile/lib/modules/album/ui/album_viewer_appbar.dart @@ -89,7 +89,7 @@ class AlbumViewerAppbar extends HookConsumerWidget ), actions: [ TextButton( - onPressed: () => Navigator.pop(context, 'Cancel'), + onPressed: () => context.pop('Cancel'), child: Text( 'Cancel', style: TextStyle( @@ -100,7 +100,7 @@ class AlbumViewerAppbar extends HookConsumerWidget ), TextButton( onPressed: () { - Navigator.pop(context, 'Confirm'); + context.pop('Confirm'); deleteAlbum(); }, child: Text( @@ -131,7 +131,7 @@ class AlbumViewerAppbar extends HookConsumerWidget context .autoNavigate(const TabControllerRoute(children: [SharingRoute()])); } else { - Navigator.pop(context); + context.pop(); ImmichToast.show( context: context, msg: "album_viewer_appbar_share_err_leave".tr(), @@ -153,12 +153,12 @@ class AlbumViewerAppbar extends HookConsumerWidget ); if (isSuccess) { - Navigator.pop(context); + context.pop(); selectionDisabled(); ref.watch(albumProvider.notifier).getAllAlbums(); ref.invalidate(albumDetailProvider(album.id)); } else { - Navigator.pop(context); + context.pop(); ImmichToast.show( context: context, msg: "album_viewer_appbar_share_err_remove".tr(), @@ -253,7 +253,7 @@ class AlbumViewerAppbar extends HookConsumerWidget ListTile( leading: const Icon(Icons.person_add_alt_rounded), onTap: () { - Navigator.pop(context); + context.pop(); onAddUsers!(album); }, title: const Text( @@ -265,7 +265,7 @@ class AlbumViewerAppbar extends HookConsumerWidget leading: const Icon(Icons.share_rounded), onTap: () { context.autoPush(SharedLinkEditRoute(albumId: album.remoteId)); - Navigator.pop(context); + context.pop(); }, title: const Text( "control_bottom_app_bar_share", @@ -286,7 +286,7 @@ class AlbumViewerAppbar extends HookConsumerWidget ListTile( leading: const Icon(Icons.add_photo_alternate_outlined), onTap: () { - Navigator.pop(context); + context.pop(); onAddPhotos!(album); }, title: const Text( diff --git a/mobile/lib/modules/album/views/album_options_part.dart b/mobile/lib/modules/album/views/album_options_part.dart index 6974a63907..979cec7cd4 100644 --- a/mobile/lib/modules/album/views/album_options_part.dart +++ b/mobile/lib/modules/album/views/album_options_part.dart @@ -27,7 +27,7 @@ class AlbumOptionsPage extends HookConsumerWidget { final isOwner = owner?.id == userId; void showErrorMessage() { - Navigator.pop(context); + context.pop(); ImmichToast.show( context: context, msg: "shared_album_section_people_action_error".tr(), @@ -70,7 +70,7 @@ class AlbumOptionsPage extends HookConsumerWidget { showErrorMessage(); } - Navigator.pop(context); + context.pop(); ImmichLoadingOverlayController.appLoader.hide(); } diff --git a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart index bdb2bb50ca..9948ab4cc9 100644 --- a/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart +++ b/mobile/lib/modules/asset_viewer/views/gallery_viewer.dart @@ -514,7 +514,7 @@ class GalleryViewerPage extends HookConsumerWidget { currentAsset, stackElements.elementAt(stackIndex.value), ); - Navigator.pop(ctx); + ctx.pop(); context.autoPop(); }, title: const Text( @@ -541,7 +541,7 @@ class GalleryViewerPage extends HookConsumerWidget { stackElements.elementAt(1), childrenToRemove: [currentAsset], ); - Navigator.pop(ctx); + ctx.pop(); context.autoPop(); } else { await ref.read(assetStackServiceProvider).updateStack( @@ -551,7 +551,7 @@ class GalleryViewerPage extends HookConsumerWidget { ], ); removeAssetFromStack(); - Navigator.pop(ctx); + ctx.pop(); } }, title: const Text( @@ -569,7 +569,7 @@ class GalleryViewerPage extends HookConsumerWidget { currentAsset, childrenToRemove: stack, ); - Navigator.pop(ctx); + ctx.pop(); context.autoPop(); }, title: const Text( diff --git a/mobile/lib/modules/home/ui/asset_grid/thumbnail_image.dart b/mobile/lib/modules/home/ui/asset_grid/thumbnail_image.dart index c99e08fb3b..694279c0d6 100644 --- a/mobile/lib/modules/home/ui/asset_grid/thumbnail_image.dart +++ b/mobile/lib/modules/home/ui/asset_grid/thumbnail_image.dart @@ -197,7 +197,9 @@ class ThumbnailImage extends StatelessWidget { }, child: Stack( children: [ - Container( + AnimatedContainer( + duration: const Duration(milliseconds: 300), + curve: Curves.decelerate, decoration: BoxDecoration( border: multiselectEnabled && isSelected ? Border.all( diff --git a/mobile/lib/modules/login/ui/login_form.dart b/mobile/lib/modules/login/ui/login_form.dart index 835907d052..5f2aaa222c 100644 --- a/mobile/lib/modules/login/ui/login_form.dart +++ b/mobile/lib/modules/login/ui/login_form.dart @@ -127,6 +127,12 @@ class LoginForm extends HookConsumerWidget { ); populateTestLoginInfo() { + usernameController.text = 'demo@immich.app'; + passwordController.text = 'demo'; + serverEndpointController.text = 'https://demo.immich.app'; + } + + populateTestLoginInfo1() { usernameController.text = 'testuser@email.com'; passwordController.text = 'password'; serverEndpointController.text = 'http://10.1.15.216:2283/api'; @@ -387,6 +393,7 @@ class LoginForm extends HookConsumerWidget { children: [ GestureDetector( onDoubleTap: () => populateTestLoginInfo(), + onLongPress: () => populateTestLoginInfo1(), child: RotationTransition( turns: logoAnimationController, child: const ImmichLogo( diff --git a/mobile/lib/modules/memories/ui/memory_lane.dart b/mobile/lib/modules/memories/ui/memory_lane.dart index 7377d06181..0c709919b2 100644 --- a/mobile/lib/modules/memories/ui/memory_lane.dart +++ b/mobile/lib/modules/memories/ui/memory_lane.dart @@ -17,7 +17,7 @@ class MemoryLane extends HookConsumerWidget { .whenData( (memories) => memories != null ? Container( - margin: const EdgeInsets.only(top: 10), + margin: const EdgeInsets.only(top: 10, left: 10), height: 200, child: ListView.builder( scrollDirection: Axis.horizontal, diff --git a/mobile/lib/modules/partner/views/partner_page.dart b/mobile/lib/modules/partner/views/partner_page.dart index bb567b62bb..e90250df52 100644 --- a/mobile/lib/modules/partner/views/partner_page.dart +++ b/mobile/lib/modules/partner/views/partner_page.dart @@ -1,6 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:immich_mobile/extensions/build_context_extensions.dart'; import 'package:immich_mobile/modules/partner/providers/partner.provider.dart'; import 'package:immich_mobile/modules/partner/services/partner.service.dart'; import 'package:immich_mobile/shared/models/user.dart'; @@ -34,7 +35,7 @@ class PartnerPage extends HookConsumerWidget { children: [ for (User u in users) SimpleDialogOption( - onPressed: () => Navigator.pop(context, u), + onPressed: () => context.pop(u), child: Row( children: [ Padding( @@ -70,8 +71,7 @@ class PartnerPage extends HookConsumerWidget { builder: (BuildContext context) { return ConfirmDialog( title: "partner_page_stop_sharing_title", - content: - "partner_page_stop_sharing_content".tr(args: [u.name]), + content: "partner_page_stop_sharing_content".tr(args: [u.name]), onOk: () => ref.read(partnerServiceProvider).removePartner(u), ); }, @@ -118,6 +118,7 @@ class PartnerPage extends HookConsumerWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( padding: const EdgeInsets.symmetric(vertical: 8), @@ -126,12 +127,15 @@ class PartnerPage extends HookConsumerWidget { style: TextStyle(fontSize: 14), ).tr(), ), - ElevatedButton.icon( - onPressed: availableUsers.whenOrNull( - data: (data) => addNewUsersHandler, + Align( + alignment: Alignment.center, + child: ElevatedButton.icon( + onPressed: availableUsers.whenOrNull( + data: (data) => addNewUsersHandler, + ), + icon: const Icon(Icons.person_add), + label: const Text("partner_page_add_partner").tr(), ), - icon: const Icon(Icons.person_add), - label: const Text("partner_page_add_partner").tr(), ), ], ), diff --git a/mobile/lib/modules/settings/views/settings_page.dart b/mobile/lib/modules/settings/views/settings_page.dart index f6f66cb412..0a1651de95 100644 --- a/mobile/lib/modules/settings/views/settings_page.dart +++ b/mobile/lib/modules/settings/views/settings_page.dart @@ -1,6 +1,7 @@ import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:immich_mobile/extensions/build_context_extensions.dart'; import 'package:immich_mobile/modules/settings/ui/advanced_settings/advanced_settings.dart'; import 'package:immich_mobile/modules/settings/ui/asset_list_settings/asset_list_settings.dart'; import 'package:immich_mobile/modules/settings/ui/local_storage_settings/local_storage_settings.dart'; @@ -18,9 +19,7 @@ class SettingsPage extends HookConsumerWidget { leading: IconButton( iconSize: 20, splashRadius: 24, - onPressed: () { - Navigator.pop(context); - }, + onPressed: () => context.pop(), icon: const Icon(Icons.arrow_back_ios_new_rounded), ), automaticallyImplyLeading: false,