From bc301a3aac0d68422c52ddd32c10f4bcf6e2fe81 Mon Sep 17 00:00:00 2001 From: Peter Ombodi Date: Tue, 10 Feb 2026 16:35:27 +0200 Subject: [PATCH] feat(mobile): open ACTION_VIEW fallback in AssetViewer drop ExternalMediaViewer route --- .../pages/external_media_viewer.page.dart | 39 ------------------ .../view_intent_handler.provider.dart | 18 +++++++- mobile/lib/routing/router.dart | 3 -- mobile/lib/routing/router.gr.dart | 41 ------------------- 4 files changed, 16 insertions(+), 85 deletions(-) delete mode 100644 mobile/lib/presentation/pages/external_media_viewer.page.dart diff --git a/mobile/lib/presentation/pages/external_media_viewer.page.dart b/mobile/lib/presentation/pages/external_media_viewer.page.dart deleted file mode 100644 index bfebfc76ab..0000000000 --- a/mobile/lib/presentation/pages/external_media_viewer.page.dart +++ /dev/null @@ -1,39 +0,0 @@ -import 'dart:io'; - -import 'package:auto_route/auto_route.dart'; -import 'package:flutter/material.dart'; -import 'package:immich_mobile/models/view_intent/view_intent_attachment.model.dart'; -import 'package:immich_mobile/widgets/photo_view/photo_view.dart'; - -@RoutePage() -class ExternalMediaViewerPage extends StatelessWidget { - const ExternalMediaViewerPage({super.key, required this.attachment}); - - final ViewIntentAttachment attachment; - - @override - Widget build(BuildContext context) { - final file = File(attachment.path); - - return Scaffold( - backgroundColor: Colors.black, - appBar: AppBar( - backgroundColor: Colors.black, - foregroundColor: Colors.white, - title: Text(attachment.fileName, overflow: TextOverflow.ellipsis), - ), - body: Center( - child: attachment.isImage - ? PhotoView( - index: 0, - imageProvider: FileImage(file), - backgroundDecoration: const BoxDecoration(color: Colors.black), - ) - : AspectRatio( - aspectRatio: 16 / 9, - child: Center(child: Icon(Icons.videocam, size: 64, color: Colors.white.withValues(alpha: 0.8))), - ), - ), - ); - } -} diff --git a/mobile/lib/providers/asset_viewer/view_intent_handler.provider.dart b/mobile/lib/providers/asset_viewer/view_intent_handler.provider.dart index d0482785b4..6ad98a5710 100644 --- a/mobile/lib/providers/asset_viewer/view_intent_handler.provider.dart +++ b/mobile/lib/providers/asset_viewer/view_intent_handler.provider.dart @@ -76,7 +76,6 @@ class ViewIntentHandler { await _localAssetRepository.updateHashes({localAssetId: checksum}); } } - //todo clarify logic for assets not presented into MainTimeline (locked folder, deleted etc) final timelineMatch = await _openFromMainTimeline(localAssetId, checksum: checksum); if (timelineMatch) { return; @@ -86,7 +85,8 @@ class ViewIntentHandler { } } - await _router.push(ExternalMediaViewerRoute(attachment: attachment)); + final fallbackAsset = _toViewIntentAsset(attachment); + _openAssetViewer(fallbackAsset, _timelineFactory.fromAssets([fallbackAsset], TimelineOrigin.deepLink), 0); } Future _openFromMainTimeline(String localAssetId, {String? checksum}) async { @@ -152,4 +152,18 @@ class ViewIntentHandler { return null; } } + + LocalAsset _toViewIntentAsset(ViewIntentAttachment attachment) { + final now = DateTime.now(); + + return LocalAsset( + id: attachment.path, + name: attachment.fileName, + checksum: null, + type: attachment.isVideo ? AssetType.video : AssetType.image, + createdAt: now, + updatedAt: now, + isEdited: false, + ); + } } diff --git a/mobile/lib/routing/router.dart b/mobile/lib/routing/router.dart index bfc66464f2..9468b105e5 100644 --- a/mobile/lib/routing/router.dart +++ b/mobile/lib/routing/router.dart @@ -16,7 +16,6 @@ import 'package:immich_mobile/models/memories/memory.model.dart'; import 'package:immich_mobile/models/search/search_filter.model.dart'; import 'package:immich_mobile/models/shared_link/shared_link.model.dart'; import 'package:immich_mobile/models/upload/share_intent_attachment.model.dart'; -import 'package:immich_mobile/models/view_intent/view_intent_attachment.model.dart'; import 'package:immich_mobile/pages/album/album_additional_shared_user_selection.page.dart'; import 'package:immich_mobile/pages/album/album_asset_selection.page.dart'; import 'package:immich_mobile/pages/album/album_options.page.dart'; @@ -105,7 +104,6 @@ import 'package:immich_mobile/presentation/pages/drift_place_detail.page.dart'; import 'package:immich_mobile/presentation/pages/drift_recently_taken.page.dart'; import 'package:immich_mobile/presentation/pages/drift_remote_album.page.dart'; import 'package:immich_mobile/presentation/pages/drift_trash.page.dart'; -import 'package:immich_mobile/presentation/pages/external_media_viewer.page.dart'; import 'package:immich_mobile/presentation/pages/drift_user_selection.page.dart'; import 'package:immich_mobile/presentation/pages/drift_video.page.dart'; import 'package:immich_mobile/presentation/pages/editing/drift_crop.page.dart'; @@ -342,7 +340,6 @@ class AppRouter extends RootStackRouter { AutoRoute(page: DownloadInfoRoute.page, guards: [_authGuard, _duplicateGuard]), AutoRoute(page: ImmichUIShowcaseRoute.page, guards: [_authGuard, _duplicateGuard]), AutoRoute(page: CleanupPreviewRoute.page, guards: [_authGuard, _duplicateGuard]), - AutoRoute(page: ExternalMediaViewerRoute.page, guards: [_authGuard, _duplicateGuard]), // required to handle all deeplinks in deep_link.service.dart // auto_route_library#1722 RedirectRoute(path: '*', redirectTo: '/'), diff --git a/mobile/lib/routing/router.gr.dart b/mobile/lib/routing/router.gr.dart index cfb7654005..b287d73114 100644 --- a/mobile/lib/routing/router.gr.dart +++ b/mobile/lib/routing/router.gr.dart @@ -1653,47 +1653,6 @@ class EditImageRouteArgs { } } -/// generated route for -/// [ExternalMediaViewerPage] -class ExternalMediaViewerRoute - extends PageRouteInfo { - ExternalMediaViewerRoute({ - Key? key, - required ViewIntentAttachment attachment, - List? children, - }) : super( - ExternalMediaViewerRoute.name, - args: ExternalMediaViewerRouteArgs(key: key, attachment: attachment), - initialChildren: children, - ); - - static const String name = 'ExternalMediaViewerRoute'; - - static PageInfo page = PageInfo( - name, - builder: (data) { - final args = data.argsAs(); - return ExternalMediaViewerPage( - key: args.key, - attachment: args.attachment, - ); - }, - ); -} - -class ExternalMediaViewerRouteArgs { - const ExternalMediaViewerRouteArgs({this.key, required this.attachment}); - - final Key? key; - - final ViewIntentAttachment attachment; - - @override - String toString() { - return 'ExternalMediaViewerRouteArgs{key: $key, attachment: $attachment}'; - } -} - /// generated route for /// [FailedBackupStatusPage] class FailedBackupStatusRoute extends PageRouteInfo {