feat(mobile): open ACTION_VIEW fallback in AssetViewer

drop ExternalMediaViewer route
This commit is contained in:
Peter Ombodi
2026-02-10 16:35:27 +02:00
parent 3ab68a4bf8
commit bc301a3aac
4 changed files with 16 additions and 85 deletions
@@ -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))),
),
),
);
}
}
@@ -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<bool> _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,
);
}
}
-3
View File
@@ -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: '/'),
-41
View File
@@ -1653,47 +1653,6 @@ class EditImageRouteArgs {
}
}
/// generated route for
/// [ExternalMediaViewerPage]
class ExternalMediaViewerRoute
extends PageRouteInfo<ExternalMediaViewerRouteArgs> {
ExternalMediaViewerRoute({
Key? key,
required ViewIntentAttachment attachment,
List<PageRouteInfo>? 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<ExternalMediaViewerRouteArgs>();
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<void> {