add loader to verify account

merge-requests/13/head
Elham Rababah 6 years ago
parent c41669ec4e
commit a7d79b2ea4

@ -30,9 +30,11 @@ class MyApp extends StatelessWidget {
primarySwatch: Colors.red, primarySwatch: Colors.red,
primaryColor: Hexcolor('#B8382C'), primaryColor: Hexcolor('#B8382C'),
buttonColor: Hexcolor('#B8382C'), buttonColor: Hexcolor('#B8382C'),
fontFamily: 'WorkSans',), fontFamily: 'WorkSans',
),
initialRoute: INIT_ROUTE, initialRoute: INIT_ROUTE,
routes: routes, routes: routes,
debugShowCheckedModeBanner: false,
), ),
); );
}); });

@ -40,6 +40,13 @@ class _LoginsreenState extends State<Loginsreen> {
}); });
} }
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param: isLoading
*@return:
*@desc: Change Isloading attribute in order to show or hide loader
*/
void changeLoadingStata(isLoading) { void changeLoadingStata(isLoading) {
setState(() { setState(() {
_isLoading = isLoading; _isLoading = isLoading;

@ -12,12 +12,33 @@ import '../../widgets/auth/verification_methods.dart';
*@return: *@return:
*@desc: Verification Methods screen *@desc: Verification Methods screen
*/ */
class VerificationMethodsScreen extends StatelessWidget { class VerificationMethodsScreen extends StatefulWidget {
@override
_VerificationMethodsScreenState createState() =>
_VerificationMethodsScreenState();
}
class _VerificationMethodsScreenState extends State<VerificationMethodsScreen> {
bool _isLoading = false;
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param: isLoading
*@return:
*@desc: Change Isloading attribute in order to show or hide loader
*/
void changeLoadingStata(isLoading) {
setState(() {
_isLoading = isLoading;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// return Container()];
return AppScaffold( return AppScaffold(
pageOnly: true, pageOnly: true,
isloading: _isLoading,
body: ListView(children: <Widget>[ body: ListView(children: <Widget>[
Container( Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0), margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
@ -25,7 +46,8 @@ class VerificationMethodsScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
AuthHeader(loginType.verificationMethods), AuthHeader(loginType.verificationMethods),
VerificationMethods(), VerificationMethods(changeLoadingStata:
changeLoadingStata,),
], ],
), ),
), ),

@ -5,11 +5,32 @@ import '../../widgets/auth/auth_header.dart';
import '../../widgets/auth/verfiy_account.dart'; import '../../widgets/auth/verfiy_account.dart';
import '../../widgets/shared/app_scaffold_widget.dart'; import '../../widgets/shared/app_scaffold_widget.dart';
class VerifyAccountScreen extends StatelessWidget { class VerifyAccountScreen extends StatefulWidget {
@override
_VerifyAccountScreenState createState() => _VerifyAccountScreenState();
}
class _VerifyAccountScreenState extends State<VerifyAccountScreen> {
bool _isLoading = false;
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param: isLoading
*@return:
*@desc: Change Isloading attribute in order to show or hide loader
*/
void changeLoadingStata(isLoading) {
setState(() {
_isLoading = isLoading;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// return Container()]; // return Container()];
return AppScaffold( return AppScaffold(
isloading: _isLoading,
pageOnly: true, pageOnly: true,
body: SafeArea( body: SafeArea(
child: ListView(children: <Widget>[ child: ListView(children: <Widget>[
@ -19,7 +40,7 @@ class VerifyAccountScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
AuthHeader(loginType.verifyPassword), AuthHeader(loginType.verifyPassword),
VerifyAccount(), VerifyAccount(changeLoadingStata:changeLoadingStata),
], ],
), ),
), ),

@ -1,4 +1,3 @@
import 'package:doctor_app_flutter/widgets/home/home_item.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@ -16,6 +15,8 @@ DrAppToastMsg toastMsg = DrAppToastMsg();
Helpers helpers = Helpers(); Helpers helpers = Helpers();
class VerifyAccount extends StatefulWidget { class VerifyAccount extends StatefulWidget {
VerifyAccount({this.changeLoadingStata});
final Function changeLoadingStata;
@override @override
_VerifyAccountState createState() => _VerifyAccountState(); _VerifyAccountState createState() => _VerifyAccountState();
} }
@ -72,6 +73,10 @@ class _VerifyAccountState extends State<VerifyAccount> {
Container( Container(
width: SizeConfig.realScreenWidth * 0.20, width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField( child: TextFormField(
style: buildTextStyle(),
maxLength: 1,
textAlign: TextAlign.center,
keyboardType: TextInputType.number,
decoration: decoration:
buildInputDecoration(context), buildInputDecoration(context),
onSaved: (val) { onSaved: (val) {
@ -83,6 +88,11 @@ class _VerifyAccountState extends State<VerifyAccount> {
Container( Container(
width: SizeConfig.realScreenWidth * 0.20, width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField( child: TextFormField(
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration: decoration:
buildInputDecoration(context), buildInputDecoration(context),
onSaved: (val) { onSaved: (val) {
@ -93,6 +103,10 @@ class _VerifyAccountState extends State<VerifyAccount> {
Container( Container(
width: SizeConfig.realScreenWidth * 0.20, width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField( child: TextFormField(
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration: decoration:
buildInputDecoration(context), buildInputDecoration(context),
onSaved: (val) { onSaved: (val) {
@ -103,6 +117,10 @@ class _VerifyAccountState extends State<VerifyAccount> {
Container( Container(
width: SizeConfig.realScreenWidth * 0.20, width: SizeConfig.realScreenWidth * 0.20,
child: TextFormField( child: TextFormField(
maxLength: 1,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType: TextInputType.number,
decoration: decoration:
buildInputDecoration(context), buildInputDecoration(context),
onSaved: (val) { onSaved: (val) {
@ -123,7 +141,8 @@ class _VerifyAccountState extends State<VerifyAccount> {
// buildSizedBox(), // buildSizedBox(),
RaisedButton( RaisedButton(
onPressed: () { onPressed: () {
verifyAccount(authProv); verifyAccount(
authProv, widget.changeLoadingStata);
// Navigator.of(context).pushNamed(HOME); // Navigator.of(context).pushNamed(HOME);
}, },
elevation: 0.0, elevation: 0.0,
@ -133,7 +152,6 @@ class _VerifyAccountState extends State<VerifyAccount> {
child: Center( child: Center(
child: Text( child: Text(
'Verfiy'.toUpperCase(), 'Verfiy'.toUpperCase(),
// textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: fontSize:
@ -163,6 +181,19 @@ class _VerifyAccountState extends State<VerifyAccount> {
}); });
} }
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param:
*@return:
*@desc: change the style for the input field
*/
TextStyle buildTextStyle() {
return TextStyle(
fontSize: SizeConfig.textMultiplier * 3,
);
}
String validateCodeDigit(value) { String validateCodeDigit(value) {
if (value.isEmpty) { if (value.isEmpty) {
return 'Please enter your Password'; return 'Please enter your Password';
@ -205,7 +236,6 @@ class _VerifyAccountState extends State<VerifyAccount> {
); );
} }
/* /*
*@author: Elham Rababah *@author: Elham Rababah
*@Date:15/4/2020 *@Date:15/4/2020
@ -213,8 +243,10 @@ class _VerifyAccountState extends State<VerifyAccount> {
*@return: *@return:
*@desc: verify Account func call sendActivationCodeByOtpNotificationType service *@desc: verify Account func call sendActivationCodeByOtpNotificationType service
*/ */
verifyAccount(AuthProvider authProv) { verifyAccount(AuthProvider authProv, Function changeLoadingStata) {
if (verifyAccountForm.currentState.validate()) { if (verifyAccountForm.currentState.validate()) {
changeLoadingStata(true);
verifyAccountForm.currentState.save(); verifyAccountForm.currentState.save();
final activationCode = verifyAccountFormValue['digit1'] + final activationCode = verifyAccountFormValue['digit1'] +
verifyAccountFormValue['digit2'] + verifyAccountFormValue['digit2'] +
@ -237,18 +269,24 @@ class _VerifyAccountState extends State<VerifyAccount> {
"IsLoginForDoctorApp": true, "IsLoginForDoctorApp": true,
"IsSilentLogIN": false "IsSilentLogIN": false
}; };
changeLoadingStata(true);
authProv.memberCheckActivationCodeNew(model).then((res) {
// Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
if (res['MessageStatus'] == 1) {
Navigator.of(context).pushNamed(HOME); Navigator.of(context).pushNamed(HOME);
// authProv.memberCheckActivationCodeNew(model).then((res) {
// changeLoadingStata(false);
// if (res['MessageStatus'] == 1) {
// Navigator.of(context).pushNamed(HOME);
// } else {
// helpers.showErrorToast(res['ErrorEndUserMessage']);
// }
// }).catchError((err) {
// changeLoadingStata(false);
// print('$err');
// helpers.showErrorToast();
// });
} else { } else {
helpers.showErrorToast(res['ErrorEndUserMessage']); // changeLoadingStata(false);
}
}).catchError((err) {
print('$err');
helpers.showErrorToast();
});
} }
} }
} }

@ -20,6 +20,8 @@ Helpers helpers = Helpers();
*@desc: Verification Methods widget *@desc: Verification Methods widget
*/ */
class VerificationMethods extends StatefulWidget { class VerificationMethods extends StatefulWidget {
VerificationMethods({this.changeLoadingStata});
final Function changeLoadingStata;
@override @override
_VerificationMethodsState createState() => _VerificationMethodsState(); _VerificationMethodsState createState() => _VerificationMethodsState();
} }
@ -172,6 +174,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
*@desc: send Activation Code By Otp Notification Type *@desc: send Activation Code By Otp Notification Type
*/ */
sendActivationCodeByOtpNotificationType(oTPSendType, AuthProvider authProv) { sendActivationCodeByOtpNotificationType(oTPSendType, AuthProvider authProv) {
widget.changeLoadingStata(true);
// TODO : build enum for verfication method // TODO : build enum for verfication method
if (oTPSendType == 1 || oTPSendType == 2) { if (oTPSendType == 1 || oTPSendType == 2) {
Map model = { Map model = {
@ -189,6 +192,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
print(oTPSendType); print(oTPSendType);
authProv.sendActivationCodeByOtpNotificationType(model).then((res) { authProv.sendActivationCodeByOtpNotificationType(model).then((res) {
// Navigator.of(context).pushNamed(VERIFY_ACCOUNT); // Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
widget.changeLoadingStata(false);
if (res['MessageStatus'] == 1) { if (res['MessageStatus'] == 1) {
Navigator.of(context).pushNamed(VERIFY_ACCOUNT); Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
@ -198,6 +202,8 @@ class _VerificationMethodsState extends State<VerificationMethods> {
// Navigator.of(context).pushNamed(HOME); // Navigator.of(context).pushNamed(HOME);
}).catchError((err) { }).catchError((err) {
print('$err'); print('$err');
widget.changeLoadingStata(false);
helpers.showErrorToast(); helpers.showErrorToast();
}); });
} else { } else {

@ -1,8 +1,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:progress_hud_v2/progress_hud.dart'; import 'package:progress_hud_v2/progress_hud.dart';
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param:
*@return: Positioned
*@desc: AppLoaderWidget to create loader
*/
class AppLoaderWidget extends StatefulWidget { class AppLoaderWidget extends StatefulWidget {
AppLoaderWidget({Key key, this.title}) : super(key: key); AppLoaderWidget({Key key, this.title}) : super(key: key);
@ -14,13 +19,16 @@ class AppLoaderWidget extends StatefulWidget {
class _AppLoaderWidgetState extends State<AppLoaderWidget> { class _AppLoaderWidgetState extends State<AppLoaderWidget> {
ProgressHUD _progressHUD; ProgressHUD _progressHUD;
// bool _loading = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param:
*@return:
*@desc: create loader the desing
*/
_progressHUD = new ProgressHUD( _progressHUD = new ProgressHUD(
backgroundColor: Colors.black12, backgroundColor: Colors.black12,
color: Colors.black, color: Colors.black,
@ -32,19 +40,6 @@ class _AppLoaderWidgetState extends State<AppLoaderWidget> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// void dismissProgressHUD() {
// setState(() {
// if (_loading) {
// _progressHUD.state.dismiss();
// } else {
// _progressHUD.state.show();
// }
// _loading = !_loading;
// });
// }
return Positioned(child: _progressHUD); return Positioned(child: _progressHUD);
} }
} }
Loading…
Cancel
Save