From 478ec704431bc0d87ca42c61aa641b92dd3fa73f Mon Sep 17 00:00:00 2001 From: HuyNguyen Date: Wed, 27 Nov 2024 11:47:47 +0700 Subject: [PATCH] TW-147: Add loading when using registration on TWP --- lib/pages/twake_welcome/twake_welcome.dart | 9 ++++++++- lib/utils/dialog/twake_dialog.dart | 23 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/pages/twake_welcome/twake_welcome.dart b/lib/pages/twake_welcome/twake_welcome.dart index 23b886708..6f4d9471e 100644 --- a/lib/pages/twake_welcome/twake_welcome.dart +++ b/lib/pages/twake_welcome/twake_welcome.dart @@ -5,6 +5,7 @@ import 'package:equatable/equatable.dart'; import 'package:fluffychat/presentation/mixins/connect_page_mixin.dart'; import 'package:fluffychat/pages/twake_welcome/twake_welcome_view.dart'; import 'package:fluffychat/utils/client_manager.dart'; +import 'package:fluffychat/utils/dialog/twake_dialog.dart'; import 'package:fluffychat/utils/twake_snackbar.dart'; import 'package:fluffychat/utils/url_launcher.dart'; import 'package:fluffychat/widgets/matrix.dart'; @@ -71,8 +72,12 @@ class TwakeWelcomeController extends State with ConnectPageMixin { void _redirectRegistrationUrl(String url) async { try { + TwakeDialog.showLoadingTwakeWelcomeDialog(context); final homeserverExisted = await _homeserverExisted(); - if (homeserverExisted) return; + if (homeserverExisted) { + TwakeDialog.hideLoadingDialog(context); + return; + } matrix.loginHomeserverSummary = await matrix.getLoginClient().checkHomeserver( Uri.parse(AppConfig.twakeWorkplaceHomeserver), @@ -86,8 +91,10 @@ class TwakeWelcomeController extends State with ConnectPageMixin { ); Logs().d("TwakeIdController:_redirectRegistrationUrl: URI - $uri"); await handleTokenFromRegistrationSite(matrix: matrix, uri: uri); + TwakeDialog.hideLoadingDialog(context); } catch (e) { Logs().e("TwakeIdController::_redirectRegistrationUrl: $e"); + TwakeDialog.hideLoadingDialog(context); } } diff --git a/lib/utils/dialog/twake_dialog.dart b/lib/utils/dialog/twake_dialog.dart index 5ae93aa6d..880ee072d 100644 --- a/lib/utils/dialog/twake_dialog.dart +++ b/lib/utils/dialog/twake_dialog.dart @@ -37,6 +37,29 @@ class TwakeDialog { } } + static void showLoadingTwakeWelcomeDialog(BuildContext context) { + showGeneralDialog( + barrierColor: LinagoraSysColors.material().onPrimary, + useRootNavigator: false, + transitionDuration: const Duration(milliseconds: 700), + transitionBuilder: (context, animation, secondaryAnimation, child) { + return FadeTransition( + opacity: Tween(begin: 0, end: 1).animate(animation), + child: const PopScope( + canPop: false, + child: ProgressDialog( + lottieSize: lottieSizeMobile, + ), + ), + ); + }, + context: context, + pageBuilder: (c, a1, a2) { + return const SizedBox(); + }, + ); + } + static void showLoadingDialog(BuildContext context) { showGeneralDialog( barrierColor: LinagoraSysColors.material().onPrimary.withOpacity(0.75),