From e903fbf9bcc15b2fb10a6f27c144e37e119ddae7 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Thu, 25 Apr 2024 11:50:02 +0530 Subject: [PATCH] [mob][photos] Continue showing pair dialog in case of error --- .../ui/viewer/gallery/gallery_app_bar_widget.dart | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart index 7b45ae53f..9e53014ed 100644 --- a/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart +++ b/mobile/lib/ui/viewer/gallery/gallery_app_bar_widget.dart @@ -880,11 +880,11 @@ class _GalleryAppBarWidgetState extends State { ); } if (result == ButtonAction.second) { - await _pairWithPin(gw); + await _pairWithPin(gw, ''); } } - Future _pairWithPin(CastGateway gw) async { + Future _pairWithPin(CastGateway gw, String code) async { await showTextInputDialog( context, title: context.l10n.playOnTv, @@ -892,12 +892,17 @@ class _GalleryAppBarWidgetState extends State { submitButtonLabel: S.of(context).pair, textInputType: TextInputType.streetAddress, hintText: context.l10n.deviceCodeHint, + showOnlyLoadingState: true, + alwaysShowSuccessState: false, + initialValue: code, onSubmit: (String text) async { try { - final code = text.trim(); + code = text.trim(); final String? publicKey = await gw.getPublicKey(code); if (publicKey == null) { showToast(context, S.of(context).deviceNotFound); + // show _pairPin again + Future.delayed(Duration.zero, () => _pairWithPin(gw, code)); return; } final String castToken = const Uuid().v4().toString(); @@ -912,6 +917,7 @@ class _GalleryAppBarWidgetState extends State { } catch (e, s) { _logger.severe("Failed to cast album", e, s); await showGenericErrorDialog(context: context, error: e); + Future.delayed(Duration.zero, () => _pairWithPin(gw, code)); } }, );