add services related to auth

merge-requests/13/head
Elham Rababah 6 years ago
parent abd02a7973
commit 4dece11a43

@ -14,6 +14,10 @@ const INSERT_DEVICE_IMEI =
const SELECT_DEVICE_IMEI = const SELECT_DEVICE_IMEI =
'https://hmgwebservices.com/Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; 'https://hmgwebservices.com/Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI';
const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE =
'https://hmgwebservices.com/Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType';
const MEMBER_CHECK_ACTIVATION_CODE_NEW ='https://hmgwebservices.com/Services/Sentry.svc/REST/MemberCheckActivationCode_New';
class AuthProvider with ChangeNotifier { class AuthProvider with ChangeNotifier {
Client client = Client client =
HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]);
@ -63,4 +67,28 @@ class AuthProvider with ChangeNotifier {
throw error; throw error;
} }
} }
Future<Map> sendActivationCodeByOtpNotificationType(activationCodeModel) async{
const url = SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE;
try {
final response = await client.post(url, body: json.encode(activationCodeModel));
return Future.value(json.decode(response.body));
} catch (error) {
print(error);
throw error;
}
}
Future<Map> memberCheckActivationCodeNew(activationCodeModel) async{
const url = MEMBER_CHECK_ACTIVATION_CODE_NEW;
try {
final response = await client.post(url, body: json.encode(activationCodeModel));
return Future.value(json.decode(response.body));
} catch (error) {
print(error);
throw error;
}
}
} }

@ -12,7 +12,7 @@ import './screens/patients/patient_search_screen.dart';
import './screens/patients/patients_screen.dart'; import './screens/patients/patients_screen.dart';
import './screens/settings/settings_screen.dart'; import './screens/settings/settings_screen.dart';
const String INIT_ROUTE = LOGIN; const String INIT_ROUTE = VERIFICATION_METHODS;
const String HOME = '/'; const String HOME = '/';
const String LOGIN = 'login'; const String LOGIN = 'login';
const String CHANGE_PASSWORD = 'change-password'; const String CHANGE_PASSWORD = 'change-password';

@ -14,7 +14,7 @@ class VerifyAccountScreen extends StatelessWidget {
body: SafeArea( body: SafeArea(
child: ListView(children: <Widget>[ child: ListView(children: <Widget>[
Container( Container(
margin: EdgeInsetsDirectional.fromSTEB(30, 0, 0, 0), margin: EdgeInsetsDirectional.fromSTEB(30, 0, 30, 0),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[

@ -24,10 +24,12 @@ import 'package:flutter_flexible_toast/flutter_flexible_toast.dart';
FlutterFlexibleToast.showToast( FlutterFlexibleToast.showToast(
message: msg, message: msg,
toastLength: Toast.LENGTH_SHORT, toastLength: Toast.LENGTH_SHORT,
toastGravity: ToastGravity.TOP,
backgroundColor: Colors.red, backgroundColor: Colors.red,
icon: ICON.CLOSE, icon: ICON.CLOSE,
fontSize: 16, fontSize: 16,
imageSize: 35, imageSize: 35,
timeInSeconds: 110,
textColor: Colors.white); textColor: Colors.white);
} }

@ -1,7 +1,10 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../config/size_config.dart';
import '../util/dr_app_toast_msg.dart';
DrAppToastMsg toastMsg = DrAppToastMsg();
/* /*
*@author: Elham Rababah *@author: Elham Rababah
*@Date:12/4/2020 *@Date:12/4/2020
@ -56,4 +59,14 @@ class Helpers {
), ),
); );
} }
showErrorToast([msg = null]) {
String localMsg = 'Something wrong happened, please contact the admin';
if (msg != null) {
localMsg = msg.toString();
}
toastMsg.showErrorToast(localMsg);
}
} }

@ -80,12 +80,14 @@ class _KnownUserLoginState extends State<KnownUserLogin> {
2; //res['SELECTDeviceIMEIbyIMEI_List'][0]['LogInType']; 2; //res['SELECTDeviceIMEIbyIMEI_List'][0]['LogInType'];
}).catchError((err) { }).catchError((err) {
print('${err}'); print('${err}');
toastMsg.showErrorToast(err);
}); });
switch (snapshot.connectionState) { switch (snapshot.connectionState) {
case ConnectionState.waiting: case ConnectionState.waiting:
return DrAppCircularProgressIndeicator(); return DrAppCircularProgressIndeicator();
default: default:
if (snapshot.hasError) { if (snapshot.hasError) {
toastMsg.showErrorToast('Error: ${snapshot.error}');
return Text('Error: ${snapshot.error}'); return Text('Error: ${snapshot.error}');
} else { } else {
return Column( return Column(

@ -1,4 +1,3 @@
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
@ -14,10 +13,12 @@ import '../../providers/projects_provider.dart';
import '../../routes.dart'; import '../../routes.dart';
import '../../util/dr_app_shared_pref.dart'; import '../../util/dr_app_shared_pref.dart';
import '../../util/dr_app_toast_msg.dart'; import '../../util/dr_app_toast_msg.dart';
import '../../util/helpers.dart';
DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); DrAppSharedPreferances sharedPref = DrAppSharedPreferances();
DrAppToastMsg toastMsg = DrAppToastMsg(); DrAppToastMsg toastMsg = DrAppToastMsg();
Helpers helpers = Helpers(); Helpers helpers = Helpers();
class LoginForm extends StatefulWidget with DrAppToastMsg { class LoginForm extends StatefulWidget with DrAppToastMsg {
LoginForm({ LoginForm({
Key key, Key key,
@ -126,7 +127,7 @@ class _LoginFormState extends State<LoginForm> {
controller: projectIdController, controller: projectIdController,
onTap: () { onTap: () {
helpers.showCupertinoPicker( helpers.showCupertinoPicker(
context,projectsList, 'Desciption', onSelectProject); context, projectsList, 'Desciption', onSelectProject);
}, },
showCursor: false, showCursor: false,
readOnly: true, readOnly: true,
@ -151,9 +152,6 @@ class _LoginFormState extends State<LoginForm> {
return 'Please enter your porject'; return 'Please enter your porject';
} }
return null; return null;
},
onSaved: (value) {
userInfo.Password = value;
}), }),
buildSizedBox(), buildSizedBox(),
Row( Row(
@ -175,9 +173,9 @@ class _LoginFormState extends State<LoginForm> {
), ),
RaisedButton( RaisedButton(
onPressed: () { onPressed: () {
Navigator.of(context).pushNamed(VERIFICATION_METHODS); // Navigator.of(context).pushNamed(VERIFICATION_METHODS);
// login(context, authProv); login(context, authProv);
}, },
textColor: Colors.white, textColor: Colors.white,
elevation: 0.0, elevation: 0.0,
@ -221,16 +219,18 @@ class _LoginFormState extends State<LoginForm> {
loginFormKey.currentState.save(); loginFormKey.currentState.save();
authProv.login(userInfo).then((res) { authProv.login(userInfo).then((res) {
if (res['MessageStatus'] == 1) { if (res['MessageStatus'] == 1) {
insertDeviceImei(res, authProv); // insertDeviceImei(res, authProv);
saveObjToString('loggedUser', res);
Navigator.of(context).pushNamed(VERIFICATION_METHODS);
} else { } else {
// handel error // handel error
// widget.showCenterShortLoadingToast("watting"); // widget.showCenterShortLoadingToast("watting");
showLoginError(res['ErrorEndUserMessage']); helpers.showErrorToast(res['ErrorEndUserMessage']);
} }
// Navigator.of(context).pushNamed(HOME); // Navigator.of(context).pushNamed(HOME);
}).catchError((err) { }).catchError((err) {
print('$err'); print('$err');
showLoginError(); helpers.showErrorToast();
}); });
} }
} }
@ -260,11 +260,11 @@ class _LoginFormState extends State<LoginForm> {
// save imei on shared preferance // save imei on shared preferance
} else { } else {
// handel error // handel error
showLoginError(res['ErrorEndUserMessage']); helpers.showErrorToast(res['ErrorEndUserMessage']);
} }
}).catchError((err) { }).catchError((err) {
print(err); print(err);
showLoginError(); helpers.showErrorToast();
}); });
} }
} }
@ -315,15 +315,7 @@ class _LoginFormState extends State<LoginForm> {
}); });
} }
showLoginError([msg = null]) {
String localMsg = 'Something wrong happened, please contact the admin';
if (msg != null) {
localMsg = msg.toString();
}
toastMsg.showErrorToast(localMsg);
}
saveObjToString(String key, value) async { saveObjToString(String key, value) async {
sharedPref.setObj(key, value); sharedPref.setObj(key, value);
@ -335,5 +327,4 @@ class _LoginFormState extends State<LoginForm> {
projectIdController.text = projectsList[index]['Desciption']; projectIdController.text = projectsList[index]['Desciption'];
}); });
} }
} }

@ -1,149 +1,186 @@
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 '../../config/size_config.dart'; import '../../config/size_config.dart';
import '../../providers/auth_provider.dart';
import '../../routes.dart'; import '../../routes.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../util/dr_app_toast_msg.dart';
import '../../util/helpers.dart';
import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
class VerifyAccount extends StatelessWidget { DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
DrAppToastMsg toastMsg = DrAppToastMsg();
Helpers helpers = Helpers();
class VerifyAccount extends StatefulWidget {
@override
_VerifyAccountState createState() => _VerifyAccountState();
}
class _VerifyAccountState extends State<VerifyAccount> {
final verifyAccountForm = GlobalKey<FormState>(); final verifyAccountForm = GlobalKey<FormState>();
Map verifyAccountFormValue = {
'digit1': null,
'digit2': null,
'digit3': null,
'digit4': null,
};
Future _loggedUserFuture;
var _loggedUser;
@override
void initState() {
super.initState();
_loggedUserFuture = getSharedPref();
}
Future<void> getSharedPref() async {
sharedPref.getObj('loggedUser').then((userInfo) {
_loggedUser = userInfo;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Form( AuthProvider authProv = Provider.of<AuthProvider>(context);
key: verifyAccountForm,
child: Container( return FutureBuilder(
width: SizeConfig.realScreenWidth * 0.90, future: Future.wait([_loggedUserFuture]),
child: Column( builder: (BuildContext context, AsyncSnapshot snapshot) {
crossAxisAlignment: CrossAxisAlignment.start, switch (snapshot.connectionState) {
children: <Widget>[ case ConnectionState.waiting:
buildSizedBox(30), return DrAppCircularProgressIndeicator();
Row( default:
mainAxisAlignment: MainAxisAlignment.spaceAround, if (snapshot.hasError) {
children: <Widget>[ toastMsg.showErrorToast('Error: ${snapshot.error}');
Container( return Text('Error: ${snapshot.error}');
width:SizeConfig.realScreenWidth*0.20, } else {
child: TextFormField( return Form(
decoration: InputDecoration( key: verifyAccountForm,
// ts/images/password_icon.png child: Container(
contentPadding: width: SizeConfig.realScreenWidth * 0.90,
EdgeInsets.only(top: 30, bottom: 30), child: Column(
enabledBorder: OutlineInputBorder( crossAxisAlignment: CrossAxisAlignment.start,
borderRadius: children: <Widget>[
BorderRadius.all(Radius.circular(10)), buildSizedBox(30),
borderSide: BorderSide(color: Colors.black), Row(
), mainAxisAlignment:
focusedBorder: OutlineInputBorder( MainAxisAlignment.spaceAround,
borderRadius: children: <Widget>[
BorderRadius.all(Radius.circular(10.0)), Container(
borderSide: BorderSide( width: SizeConfig.realScreenWidth * 0.20,
color: Theme.of(context).primaryColor), child: TextFormField(
)), decoration:
onChanged: (_) {}, buildInputDecoration(context),
)), onSaved: (val) {
Container( verifyAccountFormValue['digit1'] =
width:SizeConfig.realScreenWidth*0.20, val;
child: TextFormField( },
decoration: InputDecoration( validator: validateCodeDigit,
// ts/images/password_icon.png )),
contentPadding: Container(
EdgeInsets.only(top: 30, bottom: 30), width: SizeConfig.realScreenWidth * 0.20,
enabledBorder: OutlineInputBorder( child: TextFormField(
borderRadius: decoration:
BorderRadius.all(Radius.circular(10)), buildInputDecoration(context),
borderSide: BorderSide(color: Colors.black), onSaved: (val) {
), verifyAccountFormValue['digit2'] =
focusedBorder: OutlineInputBorder( val;
borderRadius: },
BorderRadius.all(Radius.circular(10.0)), validator: validateCodeDigit)),
borderSide: BorderSide( Container(
color: Theme.of(context).primaryColor), width: SizeConfig.realScreenWidth * 0.20,
)), child: TextFormField(
onChanged: (_) {}, decoration:
)), buildInputDecoration(context),
Container( onSaved: (val) {
width:SizeConfig.realScreenWidth*0.20, verifyAccountFormValue['digit3'] =
child: TextFormField( val;
decoration: InputDecoration( },
// ts/images/password_icon.png validator: validateCodeDigit)),
contentPadding: Container(
EdgeInsets.only(top: 30, bottom: 30), width: SizeConfig.realScreenWidth * 0.20,
enabledBorder: OutlineInputBorder( child: TextFormField(
borderRadius: decoration:
BorderRadius.all(Radius.circular(10)), buildInputDecoration(context),
borderSide: BorderSide(color: Colors.black), onSaved: (val) {
verifyAccountFormValue['digit4'] =
val;
},
validator: validateCodeDigit))
],
),
// buildSizedBox(40),
buildSizedBox(20),
buildText(),
// buildSizedBox(10.0),
// Text()
buildSizedBox(40),
// buildSizedBox(),
RaisedButton(
onPressed: () {
verifyAccount(authProv);
// Navigator.of(context).pushNamed(HOME);
},
elevation: 0.0,
child: Container(
width: double.infinity,
height: 50,
child: Center(
child: Text(
'Verfiy'.toUpperCase(),
// textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize:
3 * SizeConfig.textMultiplier),
),
),
), ),
focusedBorder: OutlineInputBorder( shape: RoundedRectangleBorder(
borderRadius: borderRadius: BorderRadius.circular(10),
BorderRadius.all(Radius.circular(10.0)), side: BorderSide(
borderSide: BorderSide( width: 0.5,
color: Theme.of(context).primaryColor), color: Hexcolor('#CCCCCC'))),
)), ),
onChanged: (_) {}, buildSizedBox(20),
)), Center(
Container( child: Text(
width:SizeConfig.realScreenWidth*0.20, "Resend in 4.20",
child: TextFormField( style: TextStyle(
decoration: InputDecoration( fontSize: 3.0 * SizeConfig.textMultiplier,
// ts/images/password_icon.png ),
contentPadding:
EdgeInsets.only(top: 30, bottom: 30),
enabledBorder: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(10)),
borderSide: BorderSide(color: Colors.black),
), ),
focusedBorder: OutlineInputBorder( ),
borderRadius: buildSizedBox(10),
BorderRadius.all(Radius.circular(10.0)), ])));
borderSide: BorderSide( }
color: Theme.of(context).primaryColor), }
)), });
onChanged: (_) {}, }
))
], String validateCodeDigit(value) {
), if (value.isEmpty) {
// buildSizedBox(40), return 'Please enter your Password';
buildSizedBox(20), }
buildText(), return null;
// buildSizedBox(10.0), }
// Text()
InputDecoration buildInputDecoration(BuildContext context) {
buildSizedBox(40), return InputDecoration(
// ts/images/password_icon.png
// buildSizedBox(), contentPadding: EdgeInsets.only(top: 30, bottom: 30),
RaisedButton( enabledBorder: OutlineInputBorder(
onPressed: () { borderRadius: BorderRadius.all(Radius.circular(10)),
Navigator.of(context).pushNamed(HOME); borderSide: BorderSide(color: Colors.black),
}, ),
elevation: 0.0, focusedBorder: OutlineInputBorder(
child: Container( borderRadius: BorderRadius.all(Radius.circular(10.0)),
width: double.infinity, borderSide: BorderSide(color: Theme.of(context).primaryColor),
height: 50, ));
child: Center(
child: Text(
'Verfiy'.toUpperCase(),
// textAlign: TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 3 * SizeConfig.textMultiplier),
),
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
side:
BorderSide(width: 0.5, color: Hexcolor('#CCCCCC'))),
),
buildSizedBox(20),
Center(
child: Text(
"Resend in 4.20",
style: TextStyle(
fontSize: 3.0 * SizeConfig.textMultiplier,
),
),
),
buildSizedBox(10),
])));
} }
RichText buildText() { RichText buildText() {
@ -158,7 +195,7 @@ class VerifyAccount extends StatelessWidget {
style: TextStyle(fontWeight: FontWeight.w700)), style: TextStyle(fontWeight: FontWeight.w700)),
new TextSpan(text: 'By SMS, Please enter the code') new TextSpan(text: 'By SMS, Please enter the code')
])); ]));
return text; return text;
} }
SizedBox buildSizedBox([double height = 20]) { SizedBox buildSizedBox([double height = 20]) {
@ -166,4 +203,51 @@ class VerifyAccount extends StatelessWidget {
height: height, height: height,
); );
} }
/*
*@author: Elham Rababah
*@Date:15/4/2020
*@param: authProv
*@return:
*@desc: verify Account func call sendActivationCodeByOtpNotificationType service
*/
verifyAccount(AuthProvider authProv) {
if (verifyAccountForm.currentState.validate()) {
verifyAccountForm.currentState.save();
final activationCode = verifyAccountFormValue['digit1'] +
verifyAccountFormValue['digit2'] +
verifyAccountFormValue['digit3'] +
verifyAccountFormValue['digit4'];
print(activationCode);
Map model = {
"activationCode": activationCode,
"DoctorID": _loggedUser['List_MemberInformation'][0]['MemberID'],
"LogInTokenID": _loggedUser['LogInTokenID'],
"ProjectID": 15,
"LanguageID": 2,
"stamp": "2020-02-26T14:48:27.221Z",
"IPAdress": "11.11.11.11",
"VersionID": 1.2,
"Channel": 9,
"TokenID": "",
"SessionID": "i1UJwCTSqt",
"IsLoginForDoctorApp": true,
"IsSilentLogIN": false
};
authProv.sendActivationCodeByOtpNotificationType(model).then((res) {
// Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
if (res['MessageStatus'] == 1) {
Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
} else {
helpers.showErrorToast(res['ErrorEndUserMessage']);
}
}).catchError((err) {
print('$err');
helpers.showErrorToast();
});
}
}
} }

@ -1,7 +1,16 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/routes.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 '../../config/size_config.dart';
import '../../providers/auth_provider.dart';
import '../../routes.dart';
import '../../util/dr_app_shared_pref.dart';
import '../../util/helpers.dart';
import '../../widgets/shared/dr_app_circular_progress_Indeicator.dart';
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
Helpers helpers = Helpers();
/* /*
*@author: Elham Rababah *@author: Elham Rababah
@ -10,86 +19,114 @@ import 'package:hexcolor/hexcolor.dart';
*@return: *@return:
*@desc: Verification Methods widget *@desc: Verification Methods widget
*/ */
class VerificationMethods extends StatelessWidget { class VerificationMethods extends StatefulWidget {
MainAxisAlignment spaceBetweenMethods =MainAxisAlignment.spaceBetween; @override
_VerificationMethodsState createState() => _VerificationMethodsState();
}
class _VerificationMethodsState extends State<VerificationMethods> {
MainAxisAlignment spaceBetweenMethods = MainAxisAlignment.spaceBetween;
Future _loggedUserFuture;
var _loggedUser;
@override
void initState() {
super.initState();
_loggedUserFuture = getSharedPref();
}
Future<void> getSharedPref() async {
sharedPref.getObj('loggedUser').then((userInfo) {
_loggedUser = userInfo;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// if(!SizeConfig.isMobile) { AuthProvider authProv = Provider.of<AuthProvider>(context);
// spaceBetweenMethods = MainAxisAlignment.spaceAround; return FutureBuilder(
// } future: Future.wait([_loggedUserFuture]),
return Container( builder: (BuildContext context, AsyncSnapshot snapshot) {
width: SizeConfig.realScreenWidth * 0.90, switch (snapshot.connectionState) {
child: Column( case ConnectionState.waiting:
crossAxisAlignment: CrossAxisAlignment.start, return DrAppCircularProgressIndeicator();
children: <Widget>[ default:
Text( if (snapshot.hasError) {
"Please choose one of the Following option to verify", helpers.showErrorToast('Error: ${snapshot.error}');
style: TextStyle( return Text('Error: ${snapshot.error}');
fontSize: 3.5 * SizeConfig.textMultiplier, } else {
), return Container(
), width: SizeConfig.realScreenWidth * 0.90,
SizedBox( child: Column(
height: 40, crossAxisAlignment: CrossAxisAlignment.start,
), children: <Widget>[
Container( Text(
width: SizeConfig.realScreenWidth * 80, "Please choose one of the Following option to verify",
child: Column( style: TextStyle(
crossAxisAlignment: CrossAxisAlignment.start, fontSize: 3.5 * SizeConfig.textMultiplier,
children: <Widget>[ ),
Row( ),
mainAxisAlignment: spaceBetweenMethods, SizedBox(
children: <Widget>[ height: 40,
buildVerificationMethod(context, ),
'assets/images/verification_fingerprint_icon.png', Container(
'Fingerprint', width: SizeConfig.realScreenWidth * 80,
() {}), child: Column(
buildVerificationMethod(context, crossAxisAlignment: CrossAxisAlignment.start,
'assets/images/verification_faceid_icon.png', children: <Widget>[
'Face ID', Row(
() {}), mainAxisAlignment: spaceBetweenMethods,
], children: <Widget>[
), buildVerificationMethod(
SizedBox( context,
height: 40, 'assets/images/verification_fingerprint_icon.png',
), 'Fingerprint',
Row( () {}),
mainAxisAlignment: spaceBetweenMethods, buildVerificationMethod(
children: <Widget>[ context,
buildVerificationMethod(context, 'assets/images/verification_faceid_icon.png',
'assets/images/verification_whatsapp_icon.png', 'Face ID',
'WhatsApp', () {}),
() {}), ],
buildVerificationMethod(context, ),
'assets/images/verification_sms_icon.png', SizedBox(
'SMS', height: 40,
() {}), ),
], Row(
) mainAxisAlignment: spaceBetweenMethods,
], children: <Widget>[
), buildVerificationMethod(
), context,
SizedBox( 'assets/images/verification_whatsapp_icon.png',
height: SizeConfig.heightMultiplier * 2, 'WhatsApp', () {
) sendActivationCodeByOtpNotificationType(
], 2, authProv);
), }),
); buildVerificationMethod(
context,
'assets/images/verification_sms_icon.png',
'SMS', () {
sendActivationCodeByOtpNotificationType(
1, authProv);
}),
],
)
],
),
),
SizedBox(
height: SizeConfig.heightMultiplier * 2,
)
],
),
);
}
}
});
} }
/* InkWell buildVerificationMethod(context, url, dec, Function fun) {
*@author: Elham Rababah
*@Date:07/4/2020
*@param: url , dec, fun
*@return: InkWell widget
*@desc: Build Verification Method
*/
InkWell buildVerificationMethod(context,url, dec, fun) {
return InkWell( return InkWell(
onTap: (){ onTap: fun,
Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
},
child: Container( child: Container(
// height: SizeConfig.heightMultiplier *2, // height: SizeConfig.heightMultiplier *2,
height: SizeConfig.heightMultiplier * 19, height: SizeConfig.heightMultiplier * 19,
@ -117,10 +154,54 @@ class VerificationMethods extends StatelessWidget {
SizedBox( SizedBox(
height: 10, height: 10,
), ),
Text(dec, style: TextStyle(fontSize:SizeConfig.textMultiplier*2 ),) Text(
dec,
style: TextStyle(fontSize: SizeConfig.textMultiplier * 2),
)
], ],
), ),
), ),
); );
} }
/*
*@author: Elham Rababah
*@Date:15/4/2020
*@param: oTPSendType
*@return:
*@desc: send Activation Code By Otp Notification Type
*/
sendActivationCodeByOtpNotificationType(oTPSendType, AuthProvider authProv) {
// TODO : build enum for verfication method
if (oTPSendType == 1 || oTPSendType == 2) {
Map model = {
"LogInTokenID": _loggedUser['LogInTokenID'],
"Channel": 9,
"MobileNumber": _loggedUser['MobileNumber'],
"IPAdress": "11.11.11.11",
"LanguageID": 2,
"ProjectID": 15, //TODO : this should become daynamci
"ZipCode": _loggedUser['ZipCode'],
"UserName": _loggedUser['List_MemberInformation'][0]['MemberID'],
"OTP_SendType": oTPSendType
};
print('$_loggedUser');
print(oTPSendType);
authProv.sendActivationCodeByOtpNotificationType(model).then((res) {
Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
if (res['MessageStatus'] == 1) {
Navigator.of(context).pushNamed(VERIFY_ACCOUNT);
} else {
helpers.showErrorToast(res['ErrorEndUserMessage']);
}
// Navigator.of(context).pushNamed(HOME);
}).catchError((err) {
print('$err');
helpers.showErrorToast();
});
} else {
// TODO route to this page with parameters to inicate we should present 2 option
}
}
} }

Loading…
Cancel
Save