diff --git a/assets/images/logos/loading_mohemm_logo.gif b/assets/images/logos/loading_mohemm_logo.gif new file mode 100644 index 0000000..ffefdb0 Binary files /dev/null and b/assets/images/logos/loading_mohemm_logo.gif differ diff --git a/lib/classes/utils.dart b/lib/classes/utils.dart index 94fd87b..d80fdf5 100644 --- a/lib/classes/utils.dart +++ b/lib/classes/utils.dart @@ -3,6 +3,7 @@ import 'package:fluttertoast/fluttertoast.dart'; // import 'package:fluttertoast/fluttertoast.dart'; import 'package:mohem_flutter_app/exceptions/api_exception.dart'; +import 'package:mohem_flutter_app/widgets/loading_dialog.dart'; class Utils { static bool _isLoadingVisible = false; @@ -33,13 +34,13 @@ class Utils { static void showLoading(BuildContext context) { WidgetsBinding.instance?.addPostFrameCallback((_) { _isLoadingVisible = true; - // showDialog( - // context: context, - // barrierColor: ColorConsts.primaryBlack.withOpacity(0.5), - // builder: (BuildContext context) => LoadingDialog(), - // ).then((value) { - // _isLoadingVisible = false; - // }); + showDialog( + context: context, + barrierColor: Colors.black.withOpacity(0.5), + builder: (BuildContext context) => LoadingDialog(), + ).then((value) { + _isLoadingVisible = false; + }); }); } diff --git a/lib/ui/login/login_screen.dart b/lib/ui/login/login_screen.dart index 1db57f1..5f0f266 100644 --- a/lib/ui/login/login_screen.dart +++ b/lib/ui/login/login_screen.dart @@ -44,19 +44,19 @@ class _LoginScreenState extends State { } void performLogin() async { - // Utils.showLoading(context); + Utils.showLoading(context); try { _checkMobileAppVersion = await LoginApiClient().checkMobileAppVersion(); _memberLoginList = await LoginApiClient().memberLogin(username.text, password.text); AppState().setMemberLoginListModel = _memberLoginList; AppState().username = username.text; print(_memberLoginList?.toJson()); - // Utils.hideLoading(context); + Utils.hideLoading(context); Navigator.pushNamed(context, AppRoutes.verifyLogin); } catch (ex) { print(ex); Utils.handleException(ex, null); - // Utils.hideLoading(context); + Utils.hideLoading(context); } } diff --git a/lib/widgets/loading_dialog.dart b/lib/widgets/loading_dialog.dart new file mode 100644 index 0000000..9c88a39 --- /dev/null +++ b/lib/widgets/loading_dialog.dart @@ -0,0 +1,47 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +class LoadingDialog extends StatefulWidget { + LoadingDialog({Key? key}) : super(key: key); + + @override + _LoadingDialogState createState() { + return _LoadingDialogState(); + } +} + +class _LoadingDialogState extends State { + @override + void initState() { + super.initState(); + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Dialog( + insetPadding: const EdgeInsets.symmetric(horizontal: 60.0, vertical: 24.0), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + elevation: 0, + backgroundColor: Colors.transparent, + child: Directionality( + textDirection: TextDirection.rtl, + child: Center( + child: Image.asset( + "assets/images/logos/loading_mohemm_logo.gif", + height: 96.0, + width: 96.0, + ), + ), + ), + ); + } +}