Skip to content

Commit

Permalink
feat(mobile): improved logging page experience (immich-app#2158)
Browse files Browse the repository at this point in the history
* feat(mobile): improve logging page

* Use new API for share file

* removed unused code

* Better safe area on the home screen

* Added preparing share dialog to home screen
  • Loading branch information
alextran1502 authored Apr 3, 2023
1 parent 2dcccb3 commit d6f2ca6
Show file tree
Hide file tree
Showing 8 changed files with 313 additions and 35 deletions.
43 changes: 28 additions & 15 deletions mobile/lib/modules/home/views/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'package:immich_mobile/shared/providers/websocket.provider.dart';
import 'package:immich_mobile/shared/services/share.service.dart';
import 'package:immich_mobile/shared/ui/immich_loading_indicator.dart';
import 'package:immich_mobile/shared/ui/immich_toast.dart';
import 'package:immich_mobile/shared/ui/share_dialog.dart';

class HomePage extends HookConsumerWidget {
const HomePage({Key? key}) : super(key: key);
Expand Down Expand Up @@ -81,7 +82,19 @@ class HomePage extends HookConsumerWidget {
}

void onShareAssets() {
ref.watch(shareServiceProvider).shareAssets(selection.value.toList());
showDialog(
context: context,
builder: (BuildContext buildContext) {
ref
.watch(shareServiceProvider)
.shareAssets(selection.value.toList())
.then((_) => Navigator.of(buildContext).pop());
return const ShareDialog();
},
barrierDismissible: false,
);

// ref.watch(shareServiceProvider).shareAssets(selection.value.toList());
selectionEnabledHook.value = false;
}

Expand Down Expand Up @@ -244,6 +257,7 @@ class HomePage extends HookConsumerWidget {

return SafeArea(
top: true,
bottom: false,
child: Stack(
children: [
ref.watch(assetProvider).renderList == null ||
Expand All @@ -261,27 +275,26 @@ class HomePage extends HookConsumerWidget {
onRefresh: refreshAssets,
),
if (selectionEnabledHook.value)
SafeArea(
bottom: true,
child: ControlBottomAppBar(
onShare: onShareAssets,
onFavorite: onFavoriteAssets,
onDelete: onDelete,
onAddToAlbum: onAddToAlbum,
albums: albums,
sharedAlbums: sharedAlbums,
onCreateNewAlbum: onCreateNewAlbum,
),
ControlBottomAppBar(
onShare: onShareAssets,
onFavorite: onFavoriteAssets,
onDelete: onDelete,
onAddToAlbum: onAddToAlbum,
albums: albums,
sharedAlbums: sharedAlbums,
onCreateNewAlbum: onCreateNewAlbum,
),
],
),
);
}

return Scaffold(
appBar: HomePageAppBar(
onPopBack: reloadAllAsset,
),
appBar: !selectionEnabledHook.value
? HomePageAppBar(
onPopBack: reloadAllAsset,
)
: null,
drawer: const ProfileDrawer(),
body: buildBody(),
);
Expand Down
48 changes: 36 additions & 12 deletions mobile/lib/routing/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ import 'package:immich_mobile/routing/duplicate_guard.dart';
import 'package:immich_mobile/routing/gallery_permission_guard.dart';
import 'package:immich_mobile/shared/models/asset.dart';
import 'package:immich_mobile/shared/models/album.dart';
import 'package:immich_mobile/shared/models/logger_message.model.dart';
import 'package:immich_mobile/shared/providers/api.provider.dart';
import 'package:immich_mobile/shared/services/api.service.dart';
import 'package:immich_mobile/shared/views/app_log_detail_page.dart';
import 'package:immich_mobile/shared/views/app_log_page.dart';
import 'package:immich_mobile/shared/views/splash_screen.dart';
import 'package:immich_mobile/shared/views/tab_controller_page.dart';
Expand All @@ -47,8 +49,12 @@ part 'router.gr.dart';
replaceInRouteName: 'Page,Route',
routes: <AutoRoute>[
AutoRoute(page: SplashScreenPage, initial: true),
AutoRoute(page: PermissionOnboardingPage, guards: [AuthGuard, DuplicateGuard]),
AutoRoute(page: LoginPage,
AutoRoute(
page: PermissionOnboardingPage,
guards: [AuthGuard, DuplicateGuard],
),
AutoRoute(
page: LoginPage,
guards: [
DuplicateGuard,
],
Expand All @@ -65,7 +71,10 @@ part 'router.gr.dart';
],
transitionsBuilder: TransitionsBuilders.fadeIn,
),
AutoRoute(page: GalleryViewerPage, guards: [AuthGuard, DuplicateGuard, GalleryPermissionGuard]),
AutoRoute(
page: GalleryViewerPage,
guards: [AuthGuard, DuplicateGuard, GalleryPermissionGuard],
),
AutoRoute(page: VideoViewerPage, guards: [AuthGuard, DuplicateGuard]),
AutoRoute(page: BackupControllerPage, guards: [AuthGuard, DuplicateGuard]),
AutoRoute(page: SearchResultPage, guards: [AuthGuard, DuplicateGuard]),
Expand All @@ -75,7 +84,10 @@ part 'router.gr.dart';
AutoRoute(page: FavoritesPage, guards: [AuthGuard, DuplicateGuard]),
AutoRoute(page: AllVideosPage, guards: [AuthGuard, DuplicateGuard]),
AutoRoute(page: AllMotionPhotosPage, guards: [AuthGuard, DuplicateGuard]),
AutoRoute(page: RecentlyAddedPage, guards: [AuthGuard, DuplicateGuard],),
AutoRoute(
page: RecentlyAddedPage,
guards: [AuthGuard, DuplicateGuard],
),
CustomRoute<AssetSelectionPageResult?>(
page: AssetSelectionPage,
guards: [AuthGuard, DuplicateGuard],
Expand All @@ -92,14 +104,18 @@ part 'router.gr.dart';
guards: [AuthGuard, DuplicateGuard],
transitionsBuilder: TransitionsBuilders.slideBottom,
),
AutoRoute(page: BackupAlbumSelectionPage, guards: [AuthGuard, DuplicateGuard]),
AutoRoute(
page: BackupAlbumSelectionPage,
guards: [AuthGuard, DuplicateGuard],
),
AutoRoute(page: AlbumPreviewPage, guards: [AuthGuard, DuplicateGuard]),
CustomRoute(
page: FailedBackupStatusPage,
guards: [AuthGuard, DuplicateGuard],
transitionsBuilder: TransitionsBuilders.slideBottom,
),
AutoRoute(page: SettingsPage,
AutoRoute(
page: SettingsPage,
guards: [
AuthGuard,
DuplicateGuard,
Expand All @@ -109,21 +125,29 @@ part 'router.gr.dart';
page: AppLogPage,
transitionsBuilder: TransitionsBuilders.slideBottom,
),
AutoRoute(
page: AppLogDetailPage,
),
],
)
class AppRouter extends _$AppRouter {
// ignore: unused_field
final ApiService _apiService;

AppRouter(
this._apiService,
this._apiService,
GalleryPermissionNotifier galleryPermissionNotifier,
) : super(
authGuard: AuthGuard(_apiService),
) : super(
authGuard: AuthGuard(_apiService),
duplicateGuard: DuplicateGuard(),
galleryPermissionGuard: GalleryPermissionGuard(galleryPermissionNotifier),
galleryPermissionGuard:
GalleryPermissionGuard(galleryPermissionNotifier),
);
}

final appRouterProvider =
Provider((ref) => AppRouter(ref.watch(apiServiceProvider), ref.watch(galleryPermissionNotifier.notifier)));
final appRouterProvider = Provider(
(ref) => AppRouter(
ref.watch(apiServiceProvider),
ref.watch(galleryPermissionNotifier.notifier),
),
);
48 changes: 48 additions & 0 deletions mobile/lib/routing/router.gr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ class _$AppRouter extends RootStackRouter {
barrierDismissible: false,
);
},
AppLogDetailRoute.name: (routeData) {
final args = routeData.argsAs<AppLogDetailRouteArgs>();
return MaterialPageX<dynamic>(
routeData: routeData,
child: AppLogDetailPage(
key: args.key,
logMessage: args.logMessage,
),
);
},
HomeRoute.name: (routeData) {
return MaterialPageX<dynamic>(
routeData: routeData,
Expand Down Expand Up @@ -485,6 +495,10 @@ class _$AppRouter extends RootStackRouter {
AppLogRoute.name,
path: '/app-log-page',
),
RouteConfig(
AppLogDetailRoute.name,
path: '/app-log-detail-page',
),
];
}

Expand Down Expand Up @@ -974,6 +988,40 @@ class AppLogRoute extends PageRouteInfo<void> {
static const String name = 'AppLogRoute';
}

/// generated route for
/// [AppLogDetailPage]
class AppLogDetailRoute extends PageRouteInfo<AppLogDetailRouteArgs> {
AppLogDetailRoute({
Key? key,
required LoggerMessage logMessage,
}) : super(
AppLogDetailRoute.name,
path: '/app-log-detail-page',
args: AppLogDetailRouteArgs(
key: key,
logMessage: logMessage,
),
);

static const String name = 'AppLogDetailRoute';
}

class AppLogDetailRouteArgs {
const AppLogDetailRouteArgs({
this.key,
required this.logMessage,
});

final Key? key;

final LoggerMessage logMessage;

@override
String toString() {
return 'AppLogDetailRouteArgs{key: $key, logMessage: $logMessage}';
}
}

/// generated route for
/// [HomePage]
class HomeRoute extends PageRouteInfo<void> {
Expand Down
10 changes: 4 additions & 6 deletions mobile/lib/shared/services/immich_logger.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,13 @@ class ImmichLogger {
}

// Share file
// ignore: deprecated_member_use
await Share.shareFiles(
[filePath],
await Share.shareXFiles(
[XFile(filePath)],
subject: "Immich logs $dateTime",
sharePositionOrigin: Rect.zero,
).then(
(value) => logFile.delete(),
);

// Clean up temp file
await logFile.delete();
}

/// Flush pending log messages to persistent storage
Expand Down
1 change: 0 additions & 1 deletion mobile/lib/shared/services/share.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class ShareService {
}
});

// ignore: deprecated_member_use
Share.shareXFiles(
await Future.wait(downloadedXFiles),
sharePositionOrigin: Rect.zero,
Expand Down
1 change: 0 additions & 1 deletion mobile/lib/shared/services/sync.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ class SyncService {
List<AssetPathEntity> onDevice, [
Set<String>? excludedAssets,
]) async {
_log.info("Syncing ${onDevice.length} albums from device: $onDevice");
onDevice.sort((a, b) => a.id.compareTo(b.id));
final List<Album> inDb =
await _db.albums.where().localIdIsNotNull().sortByLocalId().findAll();
Expand Down
Loading

0 comments on commit d6f2ca6

Please sign in to comment.