π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Wait for a visible progress dialog frame
Neeraj Guptac41d729f3352
diff --git a/mobile/packages/ui/lib/components/progress_dialog.dart b/mobile/packages/ui/lib/components/progress_dialog.dartindex 13f83b7225..4aff7bef5e 100644--- a/mobile/packages/ui/lib/components/progress_dialog.dart+++ b/mobile/packages/ui/lib/components/progress_dialog.dart@@ -175,7 +175,12 @@ class ProgressDialog {if (identical(_route, route)) _route = null;}),);- await WidgetsBinding.instance.endOfFrame;+ final animation = route.animation;+ do {+ await WidgetsBinding.instance.endOfFrame;+ // DialogRoute's first frame can be fully transparent. Let a visible+ // frame paint before callers can start synchronous work.+ } while (route.isActive && animation != null && animation.value == 0);if (_showLogs) debugPrint('ProgressDialog shown');return true;}diff --git a/mobile/packages/ui/test/components/progress_dialog_test.dart b/mobile/packages/ui/test/components/progress_dialog_test.dartindex 68ca2bec2b..06270e4745 100644--- a/mobile/packages/ui/test/components/progress_dialog_test.dart+++ b/mobile/packages/ui/test/components/progress_dialog_test.dart@@ -3,7 +3,9 @@ import 'package:flutter/material.dart';import 'package:flutter_test/flutter_test.dart';void main() {- testWidgets('show waits for a frame before completing', (tester) async {+ testWidgets('show waits for a visible frame before completing', (+ tester,+ ) async {final context = await _pumpPage(tester);final dialog = _dialog(context, 'Pending');var completed = false;@@ -14,6 +16,11 @@ void main() {await tester.idle();expect(completed, isFalse);await tester.pump();+ expect(completed, isFalse);+ expect(_dialogOpacity(tester), 0);++ await tester.pump(const Duration(milliseconds: 1));+ expect(_dialogOpacity(tester), greaterThan(0));expect(await shown, isTrue);final hidden = dialog.hide();@@ -104,6 +111,18 @@ void main() {});}+double _dialogOpacity(WidgetTester tester) {+ final transition = tester.widget<FadeTransition>(+ find+ .ancestor(+ of: find.text('Pending'),+ matching: find.byType(FadeTransition),+ )+ .last,+ );+ return transition.opacity.value;+}+ProgressDialog _dialog(BuildContext context, String message) {return ProgressDialog(context)..style(message: message, progressWidget: const SizedBox.shrink());