π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Refactor collection and file popup menu handling; replace builders with dedicated widgets and streamline file opening logic
AmanRajSinghMouryada35c8dc32bd
diff --git a/mobile/apps/locker/lib/ui/components/collection_list_widget.dart b/mobile/apps/locker/lib/ui/components/collection_list_widget.dartindex 570b6893cb..c2408fe841 100644--- a/mobile/apps/locker/lib/ui/components/collection_list_widget.dart+++ b/mobile/apps/locker/lib/ui/components/collection_list_widget.dart@@ -6,8 +6,9 @@ import "package:locker/l10n/l10n.dart";import "package:locker/models/selected_collections.dart";import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";-import "package:locker/ui/components/collection_popup_menu_builder.dart";+import "package:locker/ui/components/collection_popup_menu_widget.dart";import "package:locker/ui/components/item_list_view.dart";+import "package:locker/ui/pages/collection_page.dart";class CollectionListWidget extends StatelessWidget {final Collection collection;@@ -96,7 +97,7 @@ class CollectionListWidget extends StatelessWidget {if (onTapCallback != null) {onTapCallback!(collection);} else {- CollectionPopupMenuBuilder.openCollection(context, collection);+ _openCollection(context);}},onLongPress: () {@@ -140,14 +141,9 @@ class CollectionListWidget extends StatelessWidget {iconButtonType: IconButtonType.secondary,iconColor: colorScheme.primary700,)- : PopupMenuButton<String>(- onSelected: (value) =>- CollectionPopupMenuBuilder.handleMenuAction(- context,- value,- collection,- overflowActions,- ),+ : CollectionPopupMenuWidget(+ collection: collection,+ overflowActions: overflowActions,child: Padding(padding: const EdgeInsets.all(12.0),child: HugeIcon(@@ -155,14 +151,6 @@ class CollectionListWidget extends StatelessWidget {color: getEnteColorScheme(context).iconColor,),),- itemBuilder: (BuildContext context) {- return CollectionPopupMenuBuilder- .buildPopupMenuItems(- context,- collection,- overflowActions,- );- },),),),@@ -173,4 +161,12 @@ class CollectionListWidget extends StatelessWidget {),);}++ void _openCollection(BuildContext context) {+ Navigator.of(context).push(+ MaterialPageRoute(+ builder: (context) => CollectionPage(collection: collection),+ ),+ );+ }}diff --git a/mobile/apps/locker/lib/ui/components/collection_popup_menu_builder.dart b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dartsimilarity index 51%rename from mobile/apps/locker/lib/ui/components/collection_popup_menu_builder.dartrename to mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dartindex 0e8cb92638..0b7fcee322 100644--- a/mobile/apps/locker/lib/ui/components/collection_popup_menu_builder.dart+++ b/mobile/apps/locker/lib/ui/components/collection_popup_menu_widget.dart@@ -1,4 +1,5 @@import "package:ente_events/event_bus.dart";+import "package:ente_ui/theme/ente_theme.dart";import "package:flutter/material.dart";import "package:hugeicons/hugeicons.dart";import "package:locker/events/collections_updated_event.dart";@@ -7,24 +8,38 @@ import "package:locker/services/collections/models/collection.dart";import "package:locker/services/collections/models/collection_view_type.dart";import "package:locker/services/configuration.dart";import "package:locker/ui/components/item_list_view.dart";-import "package:locker/ui/pages/collection_page.dart";import "package:locker/utils/collection_actions.dart";-/// Centralized builder for collection popup menus and actions-///-/// This class provides:-/// - Menu item building for collection popup menus-/// - Centralized action handling for edit, delete, and leave collection-/// - Navigation helper for opening collection pages-class CollectionPopupMenuBuilder {- /// Builds popup menu items based on collection view type and overflow actions- static List<PopupMenuItem<String>> buildPopupMenuItems(- BuildContext context,- Collection collection,- List<OverflowMenuAction>? overflowActions,- ) {- if (overflowActions != null && overflowActions.isNotEmpty) {- return overflowActions+class CollectionPopupMenuWidget extends StatelessWidget {+ final Collection collection;+ final List<OverflowMenuAction>? overflowActions;+ final Widget? child;++ const CollectionPopupMenuWidget({+ super.key,+ required this.collection,+ this.overflowActions,+ this.child,+ });++ @override+ Widget build(BuildContext context) {+ return PopupMenuButton<String>(+ onSelected: (value) => _handleMenuAction(context, value),+ child: child ??+ HugeIcon(+ icon: HugeIcons.strokeRoundedMoreVertical,+ color: getEnteColorScheme(context).iconColor,+ ),+ itemBuilder: (BuildContext context) {+ return _buildPopupMenuItems(context);+ },+ );+ }++ List<PopupMenuItem<String>> _buildPopupMenuItems(BuildContext context) {+ if (overflowActions != null && overflowActions!.isNotEmpty) {+ return overflowActions!.map((action) => PopupMenuItem<String>(value: action.id,@@ -43,8 +58,10 @@ class CollectionPopupMenuBuilder {.toList();}- final collectionViewType =- getCollectionViewType(collection, Configuration.instance.getUserID()!);+ final collectionViewType = getCollectionViewType(+ collection,+ Configuration.instance.getUserID()!,+ );return [if (collectionViewType == CollectionViewType.ownedCollection ||@@ -96,26 +113,9 @@ class CollectionPopupMenuBuilder {];}- /// Handles popup menu actions for collections- ///- /// This method centralizes all collection action handling:- /// - Custom overflow actions- /// - Edit collection (rename)- /// - Delete collection- /// - Leave shared collection- ///- /// Optional callbacks can be provided to override default behavior- static void handleMenuAction(- BuildContext context,- String action,- Collection collection,- List<OverflowMenuAction>? overflowActions, {- VoidCallback? onEditCallback,- VoidCallback? onDeleteCallback,- VoidCallback? onLeaveCollectionCallback,- }) {- if (overflowActions != null && overflowActions.isNotEmpty) {- final customAction = overflowActions.firstWhere(+ void _handleMenuAction(BuildContext context, String action) {+ if (overflowActions != null && overflowActions!.isNotEmpty) {+ final customAction = overflowActions!.firstWhere((a) => a.id == action,orElse: () => throw StateError('Action not found'),);@@ -125,49 +125,18 @@ class CollectionPopupMenuBuilder {switch (action) {case 'edit':- if (onEditCallback != null) {- onEditCallback();- } else {- editCollection(context, collection);- }+ _editCollection(context);break;case 'delete':- if (onDeleteCallback != null) {- onDeleteCallback();- } else {- deleteCollection(context, collection);- }+ _deleteCollection(context);break;case 'leave_collection':- if (onLeaveCollectionCallback != null) {- onLeaveCollectionCallback();- } else {- leaveCollection(context, collection);- }+ _leaveCollection(context);break;}}- /// Opens the collection page- ///- /// This is a centralized navigation helper that can be used by both- /// CollectionRowWidget and CollectionListWidget- static void openCollection(BuildContext context, Collection collection) {- Navigator.of(context).push(- MaterialPageRoute(- builder: (context) => CollectionPage(collection: collection),- ),- );- }-- /// Shows a dialog to edit/rename a collection- ///- /// This method wraps CollectionActions.editCollection and ensures- /// the UI is updated after a successful rename- static Future<void> editCollection(- BuildContext context,- Collection collection,- ) async {+ Future<void> _editCollection(BuildContext context) async {await CollectionActions.editCollection(context,collection,@@ -177,14 +146,7 @@ class CollectionPopupMenuBuilder {);}- /// Shows a confirmation dialog and deletes a collection- ///- /// This method wraps CollectionActions.deleteCollection and ensures- /// the UI is updated after a successful deletion- static Future<void> deleteCollection(- BuildContext context,- Collection collection,- ) async {+ Future<void> _deleteCollection(BuildContext context) async {await CollectionActions.deleteCollection(context,collection,@@ -194,14 +156,7 @@ class CollectionPopupMenuBuilder {);}- /// Shows a confirmation dialog and leaves a shared collection- ///- /// This method wraps CollectionActions.leaveCollection and ensures- /// the UI is updated after successfully leaving- static Future<void> leaveCollection(- BuildContext context,- Collection collection,- ) async {+ Future<void> _leaveCollection(BuildContext context) async {await CollectionActions.leaveCollection(context,collection,diff --git a/mobile/apps/locker/lib/ui/components/collection_row_widget.dart b/mobile/apps/locker/lib/ui/components/collection_row_widget.dartindex 99b9f752f9..56f13cac47 100644--- a/mobile/apps/locker/lib/ui/components/collection_row_widget.dart+++ b/mobile/apps/locker/lib/ui/components/collection_row_widget.dart@@ -5,8 +5,9 @@ import "package:locker/l10n/l10n.dart";import "package:locker/models/selected_collections.dart";import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";-import "package:locker/ui/components/collection_popup_menu_builder.dart";+import "package:locker/ui/components/collection_popup_menu_widget.dart";import "package:locker/ui/components/item_list_view.dart";+import "package:locker/ui/pages/collection_page.dart";class CollectionRowWidget extends StatelessWidget {final Collection collection;@@ -36,6 +37,8 @@ class CollectionRowWidget extends StatelessWidget {onTap: () {if (onTapCallback != null) {onTapCallback!(collection);+ } else {+ _openCollection(context);}},onLongPress: () {@@ -125,26 +128,9 @@ class CollectionRowWidget extends StatelessWidget {switchOutCurve: Curves.easeIn,child: isSelected? const SizedBox.shrink()- : PopupMenuButton<String>(- onSelected: (value) =>- CollectionPopupMenuBuilder.handleMenuAction(- context,- value,- collection,- overflowActions,- ),- child: HugeIcon(- icon: HugeIcons.strokeRoundedMoreVertical,- color: colorScheme.iconColor,- ),- itemBuilder: (BuildContext context) {- return CollectionPopupMenuBuilder- .buildPopupMenuItems(- context,- collection,- overflowActions,- );- },+ : CollectionPopupMenuWidget(+ collection: collection,+ overflowActions: overflowActions,),),],@@ -157,4 +143,12 @@ class CollectionRowWidget extends StatelessWidget {),);}++ void _openCollection(BuildContext context) {+ Navigator.of(context).push(+ MaterialPageRoute(+ builder: (context) => CollectionPage(collection: collection),+ ),+ );+ }}diff --git a/mobile/apps/locker/lib/ui/components/file_list_widget.dart b/mobile/apps/locker/lib/ui/components/file_list_widget.dartindex f7e22d2515..8e9407b29b 100644--- a/mobile/apps/locker/lib/ui/components/file_list_widget.dart+++ b/mobile/apps/locker/lib/ui/components/file_list_widget.dart@@ -8,6 +8,7 @@ import "package:locker/services/info_file_service.dart";import "package:locker/ui/components/file_popup_menu_widget.dart";import "package:locker/ui/components/item_list_view.dart";import "package:locker/utils/file_icon_utils.dart";+import "package:locker/utils/file_util.dart";import "package:locker/utils/info_item_utils.dart";class FileListWidget extends StatelessWidget {@@ -36,9 +37,10 @@ class FileListWidget extends StatelessWidget {flex: 6,child: Row(children: [- SizedBox(- height: 40,- width: 40,+ Container(+ padding: const EdgeInsets.all(10.0),+ height: 60,+ width: 60,child: _buildFileIcon(),),const SizedBox(width: 12),@@ -64,14 +66,12 @@ class FileListWidget extends StatelessWidget {if (onTapCallback != null) {onTapCallback!(file);} else {- FilePopupMenuWidget.openFile(context, file);+ FileUtil.openFile(context, file);}},onLongPress: () {if (onLongPressCallback != null) {onLongPressCallback!(file);- } else {- FilePopupMenuWidget.openFile(context, file);}},behavior: HitTestBehavior.opaque,diff --git a/mobile/apps/locker/lib/ui/components/file_popup_menu_builder.dart b/mobile/apps/locker/lib/ui/components/file_popup_menu_builder.dartdeleted file mode 100644index 1101dcfcd4..0000000000--- a/mobile/apps/locker/lib/ui/components/file_popup_menu_builder.dart+++ /dev/null@@ -1,111 +0,0 @@-import "package:flutter/material.dart";-import "package:hugeicons/hugeicons.dart";-import "package:locker/l10n/l10n.dart";-import "package:locker/services/files/sync/models/file.dart";-import "package:locker/ui/components/item_list_view.dart";--class FilePopupMenuBuilder {- static List<PopupMenuItem<String>> buildPopupMenuItems(- BuildContext context,- List<OverflowMenuAction>? overflowActions,- ) {- if (overflowActions != null && overflowActions.isNotEmpty) {- return overflowActions- .map(- (action) => PopupMenuItem<String>(- value: action.id,- child: Row(- children: [- Icon(- action.icon,- size: 16,- ),- const SizedBox(width: 8),- Text(action.label),- ],- ),- ),- )- .toList();- }-- return [- PopupMenuItem<String>(- value: 'edit',- child: Row(- children: [- const HugeIcon(- icon: HugeIcons.strokeRoundedEdit02,- size: 16,- ),- const SizedBox(width: 8),- Text(context.l10n.edit),- ],- ),- ),- PopupMenuItem<String>(- value: 'share_link',- child: Row(- children: [- const HugeIcon(- icon: HugeIcons.strokeRoundedShare03,- size: 16,- ),- const SizedBox(width: 8),- Text(context.l10n.share),- ],- ),- ),- PopupMenuItem<String>(- value: 'delete',- child: Row(- children: [- const HugeIcon(- icon: HugeIcons.strokeRoundedDelete01,- size: 16,- ),- const SizedBox(width: 8),- Text(context.l10n.delete),- ],- ),- ),- ];- }-- static void handleMenuAction(- BuildContext context,- String action,- EnteFile file,- List<OverflowMenuAction>? overflowActions, {- VoidCallback? onEditCallback,- VoidCallback? onShareLinkCallback,- VoidCallback? onDeleteCallback,- }) {- if (overflowActions != null && overflowActions.isNotEmpty) {- final customAction = overflowActions.firstWhere(- (a) => a.id == action,- orElse: () => throw StateError('Action not found'),- );- customAction.onTap(context, file, null);- return;- }-- switch (action) {- case 'edit':- if (onEditCallback != null) {- onEditCallback();- }- break;- case 'share_link':- if (onShareLinkCallback != null) {- onShareLinkCallback();- }- break;- case 'delete':- if (onDeleteCallback != null) {- onDeleteCallback();- }- break;- }- }-}diff --git a/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart b/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dartindex 5dbb897bb9..b013f5a728 100644--- a/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart+++ b/mobile/apps/locker/lib/ui/components/file_popup_menu_widget.dart@@ -1,5 +1,3 @@-import "dart:io";-import "package:ente_ui/components/buttons/button_widget.dart";import "package:ente_ui/components/buttons/models/button_type.dart";import "package:ente_ui/theme/ente_theme.dart";@@ -7,25 +5,15 @@ import "package:ente_ui/utils/dialog_util.dart";import "package:flutter/material.dart";import "package:hugeicons/hugeicons.dart";import "package:locker/l10n/l10n.dart";-import "package:locker/models/info/info_item.dart";import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";-import "package:locker/services/configuration.dart";-import "package:locker/services/files/download/file_downloader.dart";import "package:locker/services/files/links/links_service.dart";import "package:locker/services/files/sync/metadata_updater_service.dart";import "package:locker/services/files/sync/models/file.dart";-import "package:locker/services/info_file_service.dart";import "package:locker/ui/components/file_edit_dialog.dart";import "package:locker/ui/components/item_list_view.dart";import "package:locker/ui/components/share_link_dialog.dart";-import "package:locker/ui/pages/account_credentials_page.dart";-import "package:locker/ui/pages/base_info_page.dart";-import "package:locker/ui/pages/emergency_contact_page.dart";-import "package:locker/ui/pages/personal_note_page.dart";-import "package:locker/ui/pages/physical_records_page.dart";import "package:locker/utils/snack_bar_utils.dart";-import "package:open_file/open_file.dart";class FilePopupMenuWidget extends StatelessWidget {final EnteFile file;@@ -313,140 +301,4 @@ class FilePopupMenuWidget extends StatelessWidget {}}}-- static Future<void> openFile(BuildContext context, EnteFile file) async {- if (InfoFileService.instance.isInfoFile(file)) {- return _openInfoFile(context, file);- }-- if (file.localPath != null) {- final localFile = File(file.localPath!);- if (await localFile.exists()) {- await _launchFile(context, localFile, file.displayName);- return;- }- }-- final String cachedFilePath =- "${Configuration.instance.getCacheDirectory()}${file.displayName}";- final File cachedFile = File(cachedFilePath);- if (await cachedFile.exists()) {- await _launchFile(context, cachedFile, file.displayName);- return;- }-- final dialog = createProgressDialog(- context,- context.l10n.downloading,- isDismissible: false,- );-- try {- await dialog.show();- final fileKey = await CollectionService.instance.getFileKey(file);- final decryptedFile = await downloadAndDecrypt(- file,- fileKey,- progressCallback: (downloaded, total) {- if (total > 0 && downloaded >= 0) {- final percentage =- ((downloaded / total) * 100).clamp(0, 100).round();- dialog.update(- message: context.l10n.downloadingProgress(percentage),- );- } else {- dialog.update(message: context.l10n.downloading);- }- },- shouldUseCache: true,- );-- await dialog.hide();-- if (decryptedFile != null) {- await _launchFile(context, decryptedFile, file.displayName);- } else {- await showErrorDialog(- context,- context.l10n.downloadFailed,- context.l10n.failedToDownloadOrDecrypt,- );- }- } catch (e) {- await dialog.hide();- await showErrorDialog(- context,- context.l10n.errorOpeningFile,- context.l10n.errorOpeningFileMessage(e.toString()),- );- }- }-- static Future<void> _openInfoFile(BuildContext context, EnteFile file) async {- try {- final infoItem = InfoFileService.instance.extractInfoFromFile(file);- if (infoItem == null) {- await showErrorDialog(- context,- context.l10n.errorOpeningFile,- 'Unable to extract information from this file',- );- return;- }-- Widget page;- switch (infoItem.type) {- case InfoType.note:- page = PersonalNotePage(- mode: InfoPageMode.view,- existingFile: file,- );- break;- case InfoType.accountCredential:- page = AccountCredentialsPage(- mode: InfoPageMode.view,- existingFile: file,- );- break;- case InfoType.physicalRecord:- page = PhysicalRecordsPage(- mode: InfoPageMode.view,- existingFile: file,- );- break;- case InfoType.emergencyContact:- page = EmergencyContactPage(- mode: InfoPageMode.view,- existingFile: file,- );- break;- }-- await Navigator.of(context).push(- MaterialPageRoute(builder: (context) => page),- );- } catch (e) {- await showErrorDialog(- context,- context.l10n.errorOpeningFile,- 'Failed to open info file: ${e.toString()}',- );- }- }-- static Future<void> _launchFile(- BuildContext context,- File file,- String fileName,- ) async {- try {- await OpenFile.open(file.path);- } catch (e) {- await showErrorDialog(- context,- context.l10n.errorOpeningFile,- context.l10n.couldNotOpenFile(e.toString()),- );- }- }}diff --git a/mobile/apps/locker/lib/ui/components/file_row_widget.dart b/mobile/apps/locker/lib/ui/components/file_row_widget.dartindex b2b95c475d..8a4a5f322b 100644--- a/mobile/apps/locker/lib/ui/components/file_row_widget.dart+++ b/mobile/apps/locker/lib/ui/components/file_row_widget.dart@@ -6,6 +6,7 @@ import "package:locker/services/info_file_service.dart";import "package:locker/ui/components/file_popup_menu_widget.dart";import "package:locker/ui/components/item_list_view.dart";import "package:locker/utils/file_icon_utils.dart";+import "package:locker/utils/file_util.dart";import "package:locker/utils/info_item_utils.dart";class FileRowWidget extends StatelessWidget {@@ -35,11 +36,15 @@ class FileRowWidget extends StatelessWidget {onTap: () {if (onTapCallback != null) {onTapCallback!(file);+ } else {+ FileUtil.openFile(context, file);}},onLongPress: () {if (onLongPressCallback != null) {onLongPressCallback!(file);+ } else {+ FileUtil.openFile(context, file);}},child: ListenableBuilder(diff --git a/mobile/apps/locker/lib/utils/file_util.dart b/mobile/apps/locker/lib/utils/file_util.dartnew file mode 100644index 0000000000..7a7c74d315--- /dev/null+++ b/mobile/apps/locker/lib/utils/file_util.dart@@ -0,0 +1,155 @@+import "dart:io";++import "package:ente_ui/utils/dialog_util.dart";+import "package:flutter/material.dart";+import "package:locker/l10n/l10n.dart";+import "package:locker/models/info/info_item.dart";+import "package:locker/services/collections/collections_service.dart";+import "package:locker/services/configuration.dart";+import "package:locker/services/files/download/file_downloader.dart";+import "package:locker/services/files/sync/models/file.dart";+import "package:locker/services/info_file_service.dart";+import "package:locker/ui/pages/account_credentials_page.dart";+import "package:locker/ui/pages/base_info_page.dart";+import "package:locker/ui/pages/emergency_contact_page.dart";+import "package:locker/ui/pages/personal_note_page.dart";+import "package:locker/ui/pages/physical_records_page.dart";+import "package:open_file/open_file.dart";++class FileUtil {+ static Future<void> openFile(BuildContext context, EnteFile file) async {+ if (InfoFileService.instance.isInfoFile(file)) {+ return _openInfoFile(context, file);+ }++ if (file.localPath != null) {+ final localFile = File(file.localPath!);+ if (await localFile.exists()) {+ await _launchFile(context, localFile, file.displayName);+ return;+ }+ }++ final String cachedFilePath =+ "${Configuration.instance.getCacheDirectory()}${file.displayName}";+ final File cachedFile = File(cachedFilePath);+ if (await cachedFile.exists()) {+ await _launchFile(context, cachedFile, file.displayName);+ return;+ }++ final dialog = createProgressDialog(+ context,+ context.l10n.downloading,+ isDismissible: false,+ );++ try {+ await dialog.show();+ final fileKey = await CollectionService.instance.getFileKey(file);+ final decryptedFile = await downloadAndDecrypt(+ file,+ fileKey,+ progressCallback: (downloaded, total) {+ if (total > 0 && downloaded >= 0) {+ final percentage =+ ((downloaded / total) * 100).clamp(0, 100).round();+ dialog.update(+ message: context.l10n.downloadingProgress(percentage),+ );+ } else {+ dialog.update(message: context.l10n.downloading);+ }+ },+ shouldUseCache: true,+ );++ await dialog.hide();++ if (decryptedFile != null) {+ await _launchFile(context, decryptedFile, file.displayName);+ } else {+ await showErrorDialog(+ context,+ context.l10n.downloadFailed,+ context.l10n.failedToDownloadOrDecrypt,+ );+ }+ } catch (e) {+ await dialog.hide();+ await showErrorDialog(+ context,+ context.l10n.errorOpeningFile,+ context.l10n.errorOpeningFileMessage(e.toString()),+ );+ }+ }++ static Future<void> _openInfoFile(BuildContext context, EnteFile file) async {+ try {+ final infoItem = InfoFileService.instance.extractInfoFromFile(file);+ if (infoItem == null) {+ await showErrorDialog(+ context,+ context.l10n.errorOpeningFile,+ 'Unable to extract information from this file',+ );+ return;+ }++ Widget page;+ switch (infoItem.type) {+ case InfoType.note:+ page = PersonalNotePage(+ mode: InfoPageMode.view,+ existingFile: file,+ );+ break;+ case InfoType.accountCredential:+ page = AccountCredentialsPage(+ mode: InfoPageMode.view,+ existingFile: file,+ );+ break;+ case InfoType.physicalRecord:+ page = PhysicalRecordsPage(+ mode: InfoPageMode.view,+ existingFile: file,+ );+ break;+ case InfoType.emergencyContact:+ page = EmergencyContactPage(+ mode: InfoPageMode.view,+ existingFile: file,+ );+ break;+ }++ await Navigator.of(context).push(+ MaterialPageRoute(builder: (context) => page),+ );+ } catch (e) {+ await showErrorDialog(+ context,+ context.l10n.errorOpeningFile,+ 'Failed to open info file: ${e.toString()}',+ );+ }+ }++ static Future<void> _launchFile(+ BuildContext context,+ File file,+ String fileName,+ ) async {+ try {+ await OpenFile.open(file.path);+ } catch (e) {+ await showErrorDialog(+ context,+ context.l10n.errorOpeningFile,+ context.l10n.couldNotOpenFile(e.toString()),+ );+ }+ }+}