check activation code

merge-requests/878/head
hussam al-habibeh 5 years ago
parent 9eadc0f0b1
commit 13c42b297a

@ -39,20 +39,21 @@ class PatientRegistrationService extends BaseService {
{SendActivationCodeByOTPNotificationTypeForRegistrationModel {SendActivationCodeByOTPNotificationTypeForRegistrationModel
registrationModel, registrationModel,
int otpType, int otpType,
PatientRegistrationViewModel user}) async { PatientRegistrationViewModel user,
CheckPatientForRegistrationModel
checkPatientForRegistrationModel}) async {
registrationModel = registrationModel =
SendActivationCodeByOTPNotificationTypeForRegistrationModel( SendActivationCodeByOTPNotificationTypeForRegistrationModel(
oTPSendType: otpType, oTPSendType: otpType,
patientIdentificationID: patientIdentificationID:
user.checkPatientForRegistrationModel.patientIdentificationID, checkPatientForRegistrationModel.patientIdentificationID,
patientMobileNumber: patientMobileNumber: checkPatientForRegistrationModel.patientMobileNumber,
user.checkPatientForRegistrationModel.patientMobileNumber, zipCode: checkPatientForRegistrationModel.zipCode,
zipCode: user.checkPatientForRegistrationModel.zipCode,
patientOutSA: false, patientOutSA: false,
healthId: "30000018540264", healthId: "30000018540264",
dOB: user.checkPatientForRegistrationModel.dOB, dOB: checkPatientForRegistrationModel.dOB,
isRegister: user.checkPatientForRegistrationModel.isRegister, isRegister: checkPatientForRegistrationModel.isRegister,
isHijri: user.checkPatientForRegistrationModel.isHijri, isHijri: checkPatientForRegistrationModel.isHijri,
); );
hasError = false; hasError = false;
await baseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOT_TYPE, await baseAppClient.post(SEND_ACTIVATION_CODE_BY_OTP_NOT_TYPE,
@ -69,8 +70,9 @@ class PatientRegistrationService extends BaseService {
checkActivationCode(CheckActivationCodeModel registrationModel) async { checkActivationCode(CheckActivationCodeModel registrationModel) async {
hasError = false; hasError = false;
await baseAppClient.post(CHECK_ACTIVATION_CODE_FOR_PATIENT, await baseAppClient.post(CHECK_ACTIVATION_CODE_FOR_PATIENT,
onSuccess: (dynamic response, int statusCode) {}, onSuccess: (dynamic response, int statusCode) {
onFailure: (String error, int statusCode) { registrationModel = CheckActivationCodeModel.fromJson(response);
}, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = error;
}, body: registrationModel.toJson()); }, body: registrationModel.toJson());

@ -14,19 +14,17 @@ class PatientRegistrationViewModel extends BaseViewModel {
PatientRegistrationService _patientRegistrationService = PatientRegistrationService _patientRegistrationService =
locator<PatientRegistrationService>(); locator<PatientRegistrationService>();
GetPatientInfoResponseModel get getPatientInfoResponseModel =>_patientRegistrationService.getPatientInfoResponseModel;
CheckPatientForRegistrationModel checkPatientForRegistrationModel ;
GetPatientInfoResponseModel get getPatientInfoResponseModel => GetPatientInfoResponseModel get getPatientInfoResponseModel =>
_patientRegistrationService.getPatientInfoResponseModel; _patientRegistrationService.getPatientInfoResponseModel;
CheckPatientForRegistrationModel checkPatientForRegistrationModel; CheckPatientForRegistrationModel checkPatientForRegistrationModel;
Future checkPatientForRegistration( Future checkPatientForRegistration(
CheckPatientForRegistrationModel registrationModel) async { CheckPatientForRegistrationModel registrationModel) async {
checkPatientForRegistrationModel = registrationModel; checkPatientForRegistrationModel = registrationModel;
checkPatientForRegistrationModel =CheckPatientForRegistrationModel.fromJson(registrationModel.toJson()); checkPatientForRegistrationModel =
CheckPatientForRegistrationModel.fromJson(registrationModel.toJson());
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
await _patientRegistrationService await _patientRegistrationService
.checkPatientForRegistration(registrationModel); .checkPatientForRegistration(registrationModel);
@ -40,8 +38,10 @@ class PatientRegistrationViewModel extends BaseViewModel {
Future getPatientInfo( Future getPatientInfo(
GetPatientInfoRequestModel getPatientInfoRequestModel) async { GetPatientInfoRequestModel getPatientInfoRequestModel) async {
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
/// TODO Elham* return call service when it working /// TODO Elham* return call service when it working
_patientRegistrationService.getPatientInfoResponseModel = GetPatientInfoResponseModel.fromJson({ _patientRegistrationService.getPatientInfoResponseModel =
GetPatientInfoResponseModel.fromJson({
"Date": null, "Date": null,
"LanguageID": 0, "LanguageID": 0,
"ServiceName": 0, "ServiceName": 0,
@ -137,13 +137,6 @@ class PatientRegistrationViewModel extends BaseViewModel {
// error = _patientRegistrationService.error; // error = _patientRegistrationService.error;
// setState(ViewState.ErrorLocal); // setState(ViewState.ErrorLocal);
// } else // } else
// setState(ViewState.Idle);
await _patientRegistrationService
.getPatientInfo(getPatientInfoRequestModel);
if (_patientRegistrationService.hasError) {
error = _patientRegistrationService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle); setState(ViewState.Idle);
} }
@ -153,8 +146,12 @@ class PatientRegistrationViewModel extends BaseViewModel {
int otpType, int otpType,
PatientRegistrationViewModel user}) async { PatientRegistrationViewModel user}) async {
setState(ViewState.Busy); setState(ViewState.Busy);
print(checkPatientForRegistrationModel);
print(checkPatientForRegistrationModel);
await _patientRegistrationService.sendActivationCodeByOTPNotificationType( await _patientRegistrationService.sendActivationCodeByOTPNotificationType(
otpType: otpType); otpType: otpType,
checkPatientForRegistrationModel: checkPatientForRegistrationModel);
if (_patientRegistrationService.hasError) { if (_patientRegistrationService.hasError) {
error = _patientRegistrationService.error; error = _patientRegistrationService.error;
setState(ViewState.Error); setState(ViewState.Error);

@ -99,16 +99,16 @@ class _RegisterPatientPageState extends State<RegisterPatientPage>
}, },
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
children: <Widget>[ children: <Widget>[
RegisterSearchPatientPage(changePageViewIndex: changePageViewIndex,model: model),
RegisterConfirmationPatientPage(model: model,),
RegisterSearchPatientPage( RegisterSearchPatientPage(
changePageViewIndex: changePageViewIndex, changePageViewIndex: changePageViewIndex,
), model: model),
ActivationPage( ActivationPage(
user: model, model: model,
changePageViewIndex: changePageViewIndex,
),
RegisterConfirmationPatientPage(
model: model,
), ),
RegisterConfirmationPatientPage(),
]), ]),
), ),
), ),

@ -2,29 +2,59 @@ import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/model/PatientRegistration/CheckPatientForRegistrationModel.dart'; import 'package:doctor_app_flutter/core/model/PatientRegistration/CheckPatientForRegistrationModel.dart';
import 'package:doctor_app_flutter/core/viewModel/PatientRegistrationViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/PatientRegistrationViewModel.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
class ActivationPage extends StatefulWidget { class ActivationPage extends StatefulWidget {
PatientRegistrationViewModel user = PatientRegistrationViewModel(); final PatientRegistrationViewModel model;
ActivationPage({this.user}); final Function changePageViewIndex;
ActivationPage({this.model, this.changePageViewIndex});
@override @override
_ActivationPageState createState() => _ActivationPageState(); _ActivationPageState createState() => _ActivationPageState();
} }
class _ActivationPageState extends State<ActivationPage> { class _ActivationPageState extends State<ActivationPage> {
bool isSendOtp = false;
final verifyAccountForm = GlobalKey<FormState>();
TextStyle buildTextStyle() {
return TextStyle(
fontSize: SizeConfig.textMultiplier * 3,
);
}
Map verifyAccountFormValue = {
'digit1': '',
'digit2': '',
'digit3': '',
'digit4': '',
};
final focusD1 = FocusNode();
final focusD2 = FocusNode();
final focusD3 = FocusNode();
final focusD4 = FocusNode();
TextEditingController digit1 = TextEditingController(text: "");
TextEditingController digit2 = TextEditingController(text: "");
TextEditingController digit3 = TextEditingController(text: "");
TextEditingController digit4 = TextEditingController(text: "");
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<PatientRegistrationViewModel>( return AppScaffold(
builder: (_, model, w) => AppScaffold( baseViewModel: widget.model,
baseViewModel: model,
isShowAppBar: false, isShowAppBar: false,
body: Column( body: Column(
children: [ children: [
Container( Visibility(
//visible: isSendOtp,
child: !isSendOtp
? Container(
width: double.infinity, width: double.infinity,
margin: EdgeInsets.all(16.0), margin: EdgeInsets.all(16.0),
child: SingleChildScrollView( child: SingleChildScrollView(
@ -43,13 +73,19 @@ class _ActivationPageState extends State<ActivationPage> {
children: [ children: [
Expanded( Expanded(
child: InkWell( child: InkWell(
onTap: () { onTap: () async {
model.sendActivationCodeByOTPNotificationType( setState(() {
isSendOtp = true;
});
await widget.model
.sendActivationCodeByOTPNotificationType(
otpType: 1); otpType: 1);
}, },
child: Container( child: Container(
height: height:
MediaQuery.of(context).size.height * 0.233, MediaQuery.of(context).size.height *
0.233,
margin: EdgeInsets.all(10), margin: EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
@ -57,7 +93,8 @@ class _ActivationPageState extends State<ActivationPage> {
Radius.circular(10), Radius.circular(10),
), ),
border: Border.all( border: Border.all(
color: HexColor('#707070'), width: 0.1), color: HexColor('#707070'),
width: 0.1),
), ),
child: Column( child: Column(
children: [ children: [
@ -65,11 +102,13 @@ class _ActivationPageState extends State<ActivationPage> {
children: [ children: [
Image.asset( Image.asset(
"assets/images/verify-sms.png", "assets/images/verify-sms.png",
height: height: MediaQuery.of(context)
MediaQuery.of(context).size.height * .size
.height *
0.15, 0.15,
width: width: MediaQuery.of(context)
MediaQuery.of(context).size.width * .size
.width *
0.15, 0.15,
), ),
], ],
@ -90,13 +129,16 @@ class _ActivationPageState extends State<ActivationPage> {
), ),
Expanded( Expanded(
child: InkWell( child: InkWell(
onTap: () { onTap: () async {
model.sendActivationCodeByOTPNotificationType( isSendOtp = false;
otpType: 1); await widget.model
.sendActivationCodeByOTPNotificationType(
otpType: 1, user: widget.model);
}, },
child: Container( child: Container(
height: height:
MediaQuery.of(context).size.height * 0.233, MediaQuery.of(context).size.height *
0.233,
margin: EdgeInsets.all(10), margin: EdgeInsets.all(10),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
@ -104,7 +146,8 @@ class _ActivationPageState extends State<ActivationPage> {
Radius.circular(10), Radius.circular(10),
), ),
border: Border.all( border: Border.all(
color: HexColor('#707070'), width: 0.1), color: HexColor('#707070'),
width: 0.1),
), ),
child: Column( child: Column(
children: [ children: [
@ -112,11 +155,13 @@ class _ActivationPageState extends State<ActivationPage> {
children: [ children: [
Image.asset( Image.asset(
"assets/images/verify-whtsapp.png", "assets/images/verify-whtsapp.png",
height: height: MediaQuery.of(context)
MediaQuery.of(context).size.height * .size
.height *
0.15, 0.15,
width: width: MediaQuery.of(context)
MediaQuery.of(context).size.width * .size
.width *
0.15, 0.15,
), ),
], ],
@ -141,8 +186,291 @@ class _ActivationPageState extends State<ActivationPage> {
), ),
), ),
) )
: Container(
width: double.infinity,
margin: EdgeInsets.all(16.0),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
"Please enter the verification code sent to 02221552",
fontFamily: 'Poppins',
fontSize: SizeConfig.textMultiplier * 2.2,
fontWeight: FontWeight.w800,
),
Row(
children: [
Center(
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Form(
key: verifyAccountForm,
child: Padding(
padding: EdgeInsets.only(top: 20),
child: Directionality(
textDirection: TextDirection.ltr,
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
children: <Widget>[
Container(
width: SizeConfig
.realScreenWidth *
0.16,
margin: EdgeInsets.all(5),
child: TextFormField(
textInputAction:
TextInputAction.next,
style: buildTextStyle(),
autofocus: true,
maxLength: 1,
controller: digit1,
textAlign: TextAlign.center,
keyboardType:
TextInputType.number,
decoration:
buildInputDecoration(
context),
onSaved: (val) {},
//validator: validateCodeDigit,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(
focusD2);
},
onChanged: (val) {
if (val.length == 1) {
FocusScope.of(context)
.requestFocus(
focusD2);
verifyAccountFormValue[
'digit1'] =
val.trim();
//checkValue();
}
},
),
),
Container(
width: SizeConfig
.realScreenWidth *
0.16,
margin: EdgeInsets.all(5),
child: TextFormField(
focusNode: focusD2,
textInputAction:
TextInputAction.next,
maxLength: 1,
controller: digit2,
textAlign: TextAlign.center,
style: buildTextStyle(),
keyboardType:
TextInputType.number,
decoration:
buildInputDecoration(
context),
onSaved: (val) {},
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(
focusD3);
},
onChanged: (val) {
if (val.length == 1) {
FocusScope.of(context)
.requestFocus(
focusD3);
verifyAccountFormValue[
'digit2'] =
val.trim();
//checkValue();
}
},
//validator: validateCodeDigit,
),
),
Container(
margin: EdgeInsets.all(5),
width: SizeConfig
.realScreenWidth *
0.16,
child: TextFormField(
focusNode: focusD3,
textInputAction:
TextInputAction.next,
maxLength: 1,
controller: digit3,
textAlign:
TextAlign.center,
style: buildTextStyle(),
keyboardType:
TextInputType.number,
decoration:
buildInputDecoration(
context),
onSaved: (val) {},
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(
focusD4);
},
onChanged: (val) {
if (val.length == 1) {
FocusScope.of(context)
.requestFocus(
focusD4);
verifyAccountFormValue[
'digit3'] =
val.trim();
//checkValue();
}
},
// validator:
// validateCodeDigit,
)),
Container(
margin: EdgeInsets.all(5),
width: SizeConfig
.realScreenWidth *
0.16,
child: TextFormField(
focusNode: focusD4,
maxLength: 1,
textAlign:
TextAlign.center,
style: buildTextStyle(),
controller: digit4,
keyboardType:
TextInputType.number,
decoration:
buildInputDecoration(
context),
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(
focusD4);
},
onChanged: (val) {
if (val.length == 1) {
verifyAccountFormValue[
'digit4'] =
val.trim();
//checkValue();
}
},
// validator:
// validateCodeDigit,
)),
], ],
)),
),
),
Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
AppText(
TranslationBase.of(context)
.validationMessage +
' ',
fontWeight: FontWeight.w600,
fontSize: 14,
),
// AppText(
// displayTime,
// color: Colors.red,
// textAlign: TextAlign.start,
// fontWeight: FontWeight.bold,
// fontSize: 14,
// )
]),
)
],
))),
],
),
],
),
),
),
)
],
),
bottomSheet: isSendOtp
? Container(
height: 60,
margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16),
child: Row(
children: [
Expanded(
child: Container(
child: AppButton(
title: TranslationBase.of(context).cancel,
hasBorder: true,
vPadding: 12,
hPadding: 8,
borderColor: Color(0xFFeaeaea),
color: Color(0xFFeaeaea),
fontColor: Colors.black,
fontSize: 2.2,
onPressed: () {
Navigator.of(context).pop();
},
),
),
),
SizedBox(
width: 8,
),
Expanded(
child: Container(
child: AppButton(
title: TranslationBase.of(context).next,
hasBorder: true,
vPadding: 12,
hPadding: 8,
borderColor: Color(0xFFB8382B),
color: Color(0xFFB8382B),
fontColor: Colors.white,
fontSize: 2.0,
onPressed: () async {
//widget.model.checkActivationCode(),
},
),
),
),
],
),
)
: null);
}
InputDecoration buildInputDecoration(BuildContext context) {
return InputDecoration(
counterText: " ",
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
borderSide: BorderSide(color: Colors.grey[300]),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Colors.grey[300]),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Colors.grey[300]),
), ),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Theme.of(context).errorColor),
), ),
); );
} }

Loading…
Cancel
Save