π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Show progress dialog when exporting edited video for better UX
ashilkn15ed5e9d7b1c
diff --git a/mobile/lib/ui/tools/editor/video_editor_page.dart b/mobile/lib/ui/tools/editor/video_editor_page.dartindex bc97f318f0..f5068ff7cd 100644--- a/mobile/lib/ui/tools/editor/video_editor_page.dart+++ b/mobile/lib/ui/tools/editor/video_editor_page.dart@@ -1,3 +1,4 @@+import "dart:async";import 'dart:io';import "dart:math";@@ -13,6 +14,7 @@ import "package:photos/generated/l10n.dart";import "package:photos/models/file/file.dart";import "package:photos/models/location/location.dart";import "package:photos/services/sync/sync_service.dart";+import "package:photos/ui/common/linear_progress_dialog.dart";import "package:photos/ui/notification/toast.dart";import "package:photos/ui/tools/editor/export_video_service.dart";import 'package:photos/ui/tools/editor/video_crop_page.dart';@@ -23,7 +25,6 @@ import "package:photos/ui/tools/editor/video_editor/video_editor_player_control.import "package:photos/ui/tools/editor/video_rotate_page.dart";import "package:photos/ui/tools/editor/video_trim_page.dart";import "package:photos/ui/viewer/file/detail_page.dart";-import "package:photos/utils/dialog_util.dart";import "package:photos/utils/exif_util.dart";import "package:photos/utils/navigation_util.dart";import "package:video_editor/video_editor.dart";@@ -45,7 +46,6 @@ class VideoEditorPage extends StatefulWidget {}class _VideoEditorPageState extends State<VideoEditorPage> {- final _exportingProgress = ValueNotifier<double>(0.0);final _isExporting = ValueNotifier<bool>(false);final _logger = Logger("VideoEditor");@@ -105,7 +105,6 @@ class _VideoEditorPageState extends State<VideoEditorPage> {@overridevoid dispose() async {- _exportingProgress.dispose();_isExporting.dispose();_controller?.dispose().ignore();ExportService.dispose().ignore();@@ -232,10 +231,23 @@ class _VideoEditorPageState extends State<VideoEditorPage> {}void exportVideo() async {- _exportingProgress.value = 0;_isExporting.value = true;- final dialog = createProgressDialog(context, S.of(context).savingEdits);- await dialog.show();++ final dialogKey = GlobalKey<LinearProgressDialogState>();+ final dialog = LinearProgressDialog(+ S.of(context).savingEdits,+ key: dialogKey,+ );++ unawaited(+ showDialog(+ useRootNavigator: false,+ context: context,+ builder: (context) {+ return dialog;+ },+ ),+ );final config = VideoFFmpegVideoEditorConfig(_controller!,@@ -253,8 +265,10 @@ class _VideoEditorPageState extends State<VideoEditorPage> {await ExportService.runFFmpegCommand(await config.getExecuteConfig(),onProgress: (stats) {- _exportingProgress.value =- config.getFFmpegProgress(stats.getTime().toInt());+ if (dialogKey.currentState != null) {+ dialogKey.currentState!+ .setProgress(config.getFFmpegProgress(stats.getTime().toInt()));+ }},onError: (e, s) => _logger.severe("Error exporting video", e, s),onCompleted: (result) async {@@ -310,7 +324,7 @@ class _VideoEditorPageState extends State<VideoEditorPage> {files.add(newFile);selectionIndex = files.length - 1;}- await dialog.hide();+ Navigator.of(dialogKey.currentContext!).pop('dialog');replacePage(context,@@ -322,12 +336,12 @@ class _VideoEditorPageState extends State<VideoEditorPage> {),);} catch (_) {- await dialog.hide();+ Navigator.of(dialogKey.currentContext!).pop('dialog');}},);} catch (_) {- await dialog.hide();+ Navigator.of(dialogKey.currentContext!).pop('dialog');} finally {await PhotoManager.startChangeNotify();}