Skip to content

Commit

Permalink
TW-147: Add loading when using registration on TWP
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev committed Nov 27, 2024
1 parent 85a27a3 commit 478ec70
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/pages/twake_welcome/twake_welcome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -71,8 +72,12 @@ class TwakeWelcomeController extends State<TwakeWelcome> 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),
Expand All @@ -86,8 +91,10 @@ class TwakeWelcomeController extends State<TwakeWelcome> 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);
}
}

Expand Down
23 changes: 23 additions & 0 deletions lib/utils/dialog/twake_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(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),
Expand Down

0 comments on commit 478ec70

Please sign in to comment.