add loader to verify account

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

@ -27,12 +27,14 @@ class MyApp extends StatelessWidget {
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.red,
primaryColor: Hexcolor('#B8382C'),
buttonColor: Hexcolor('#B8382C'),
fontFamily: 'WorkSans',),
primarySwatch: Colors.red,
primaryColor: Hexcolor('#B8382C'),
buttonColor: Hexcolor('#B8382C'),
fontFamily: 'WorkSans',
),
initialRoute: INIT_ROUTE,
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) {
setState(() {
_isLoading = isLoading;

@ -12,23 +12,45 @@ import '../../widgets/auth/verification_methods.dart';
*@return:
*@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
Widget build(BuildContext context) {
// return Container()];
return AppScaffold(
pageOnly: true,
isloading: _isLoading,
body: ListView(children: <Widget>[
Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AuthHeader(loginType.verificationMethods),
VerificationMethods(),
],
),
),
]));
Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AuthHeader(loginType.verificationMethods),
VerificationMethods(changeLoadingStata:
changeLoadingStata,),
],
),
),
]));
}
}

@ -5,25 +5,46 @@ import '../../widgets/auth/auth_header.dart';
import '../../widgets/auth/verfiy_account.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
Widget build(BuildContext context) {
// return Container()];
return AppScaffold(
isloading: _isLoading,
pageOnly: true,
body: SafeArea(
child: ListView(children: <Widget>[
Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AuthHeader(loginType.verifyPassword),
VerifyAccount(),
],
),
),
]),
));
child: ListView(children: <Widget>[
Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AuthHeader(loginType.verifyPassword),
VerifyAccount(changeLoadingStata:changeLoadingStata),
],
),
),
]),
));
}
}

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

@ -20,6 +20,8 @@ Helpers helpers = Helpers();
*@desc: Verification Methods widget
*/
class VerificationMethods extends StatefulWidget {
VerificationMethods({this.changeLoadingStata});
final Function changeLoadingStata;
@override
_VerificationMethodsState createState() => _VerificationMethodsState();
}
@ -172,16 +174,17 @@ class _VerificationMethodsState extends State<VerificationMethods> {
*@desc: send Activation Code By Otp Notification Type
*/
sendActivationCodeByOtpNotificationType(oTPSendType, AuthProvider authProv) {
widget.changeLoadingStata(true);
// TODO : build enum for verfication method
if (oTPSendType == 1 || oTPSendType == 2) {
Map model = {
"LogInTokenID": _loggedUser['LogInTokenID'],
"Channel": 9,
"MobileNumber": 785228065,//_loggedUser['MobileNumber'],
"MobileNumber": 785228065, //_loggedUser['MobileNumber'],
"IPAdress": "11.11.11.11",
"LanguageID": 2,
"ProjectID": 15, //TODO : this should become daynamci
"ZipCode":962, //_loggedUser['ZipCode'],
"ZipCode": 962, //_loggedUser['ZipCode'],
"UserName": _loggedUser['List_MemberInformation'][0]['MemberID'],
"OTP_SendType": oTPSendType
};
@ -189,6 +192,7 @@ class _VerificationMethodsState extends State<VerificationMethods> {
print(oTPSendType);
authProv.sendActivationCodeByOtpNotificationType(model).then((res) {
// Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
widget.changeLoadingStata(false);
if (res['MessageStatus'] == 1) {
Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
@ -198,6 +202,8 @@ class _VerificationMethodsState extends State<VerificationMethods> {
// Navigator.of(context).pushNamed(HOME);
}).catchError((err) {
print('$err');
widget.changeLoadingStata(false);
helpers.showErrorToast();
});
} else {

@ -1,8 +1,13 @@
import 'package:flutter/material.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 {
AppLoaderWidget({Key key, this.title}) : super(key: key);
@ -14,13 +19,16 @@ class AppLoaderWidget extends StatefulWidget {
class _AppLoaderWidgetState extends State<AppLoaderWidget> {
ProgressHUD _progressHUD;
// bool _loading = false;
@override
void initState() {
super.initState();
/*
*@author: Elham Rababah
*@Date:19/4/2020
*@param:
*@return:
*@desc: create loader the desing
*/
_progressHUD = new ProgressHUD(
backgroundColor: Colors.black12,
color: Colors.black,
@ -32,19 +40,6 @@ class _AppLoaderWidgetState extends State<AppLoaderWidget> {
@override
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