You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
457 lines
21 KiB
Dart
457 lines
21 KiB
Dart
import 'package:flutter/gestures.dart';
|
|
import 'package:hmg_patient_app/config/shared_pref_kay.dart';
|
|
import 'package:hmg_patient_app/config/size_config.dart';
|
|
import 'package:hmg_patient_app/core/service/AuthenticatedUserObject.dart';
|
|
import 'package:hmg_patient_app/core/viewModels/project_view_model.dart';
|
|
import 'package:hmg_patient_app/extensions/string_extensions.dart';
|
|
import 'package:hmg_patient_app/locator.dart';
|
|
import 'package:hmg_patient_app/models/Appointments/toDoCountProviderModel.dart';
|
|
import 'package:hmg_patient_app/models/Authentication/check_activation_code_response.dart';
|
|
import 'package:hmg_patient_app/models/Authentication/check_user_status_reponse.dart';
|
|
import 'package:hmg_patient_app/models/Authentication/register_info_response.dart';
|
|
import 'package:hmg_patient_app/models/Authentication/send_activation_request.dart';
|
|
import 'package:hmg_patient_app/new_ui/otp/otp_validation_bootmsheet_widget.dart';
|
|
import 'package:hmg_patient_app/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart';
|
|
import 'package:hmg_patient_app/pages/login/login-type.dart';
|
|
import 'package:hmg_patient_app/pages/login/register-info.dart';
|
|
import 'package:hmg_patient_app/pages/login/register.dart';
|
|
import 'package:hmg_patient_app/services/authentication/auth_provider.dart';
|
|
import 'package:hmg_patient_app/theme/colors.dart';
|
|
import 'package:hmg_patient_app/uitl/app_shared_preferences.dart';
|
|
import 'package:hmg_patient_app/uitl/app_toast.dart';
|
|
import 'package:hmg_patient_app/uitl/date_uitl.dart';
|
|
import 'package:hmg_patient_app/uitl/gif_loader_dialog_utils.dart';
|
|
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
|
|
import 'package:hmg_patient_app/uitl/utils.dart';
|
|
import 'package:hmg_patient_app/uitl/utils_new.dart';
|
|
import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hmg_patient_app/widgets/text/app_texts_widget.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../widgets/dialogs/confirm_dialog.dart';
|
|
import 'package:hijri/hijri_calendar.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class RegisterNewStep2 extends StatefulWidget {
|
|
CheckUserStatusResponse nHICData;
|
|
SendActivationRequest payload;
|
|
|
|
RegisterNewStep2(this.nHICData, this.payload, {Key? key}) : super(key: key);
|
|
|
|
@override
|
|
_RegisterNew createState() => _RegisterNew();
|
|
}
|
|
|
|
class _RegisterNew extends State<RegisterNewStep2> {
|
|
final emailAddress = TextEditingController();
|
|
final int loginType = LoginType.loginType;
|
|
late String mobileNo;
|
|
String countryCode = '966';
|
|
final authService = new AuthProvider();
|
|
final sharedPref = new AppSharedPreferences();
|
|
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
|
|
late ProjectViewModel projectViewModel;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
projectViewModel = Provider.of(context);
|
|
return AppScaffold(
|
|
appBarTitle: "Personal Details Verification",
|
|
isShowDecPage: false,
|
|
isShowAppBar: true,
|
|
isshowBackButton: true,
|
|
showNewAppBar: true,
|
|
backgroundColor: Color(0xffF8F8F8),
|
|
showNewAppBarTitle: true,
|
|
showDropDown: false,
|
|
isShowLanguageChanger: false,
|
|
showHomeAppBarIcon: false,
|
|
resizeToAvoidBottomInset: true,
|
|
appBarIcons: [],
|
|
dropDownIndexChange: (value) {
|
|
Utils.changeAppLanguage(context: context);
|
|
},
|
|
body: SafeArea(
|
|
child: SingleChildScrollView(
|
|
reverse: false,
|
|
padding: EdgeInsets.only(left: 24, right: 24, top: 24),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Directionality(
|
|
textDirection: Directionality.of(context),
|
|
child: Container(
|
|
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(24)),
|
|
padding: EdgeInsets.only(left: 16, right: 16),
|
|
child: Column(
|
|
children: [
|
|
inputWidget(TranslationBase.of(context).name, (widget.nHICData.firstNameEn!.toUpperCase() + " " + widget.nHICData.lastNameEn!.toUpperCase()), null,
|
|
isEnable: true,
|
|
prefix: null,
|
|
removePadding: true,
|
|
isAllowRadius: false,
|
|
hasSelection: false,
|
|
isBorderAllowed: false,
|
|
isAllowLeadingIcon: true,
|
|
isReadOnly: true,
|
|
leadingIcon: "assets/images/svg/user-circle.svg",
|
|
onChange: (value) {}),
|
|
Divider(height: 1),
|
|
inputWidget(TranslationBase.of(context).nationalIdNumber, (widget.nHICData.idNumber ?? ""), null,
|
|
isEnable: true,
|
|
prefix: null,
|
|
removePadding: true,
|
|
isAllowRadius: false,
|
|
hasSelection: false,
|
|
isBorderAllowed: false,
|
|
isAllowLeadingIcon: true,
|
|
isReadOnly: true,
|
|
leadingIcon: "assets/images/svg/student-card.svg",
|
|
onChange: (value) {}),
|
|
Divider(height: 1),
|
|
inputWidget(TranslationBase.of(context).gender, (widget.nHICData.gender ?? ""), null,
|
|
isEnable: true,
|
|
prefix: null,
|
|
removePadding: true,
|
|
isAllowRadius: false,
|
|
hasSelection: false,
|
|
isBorderAllowed: false,
|
|
isAllowLeadingIcon: true,
|
|
isReadOnly: true,
|
|
leadingIcon: "assets/images/svg/user-full.svg",
|
|
onChange: (value) {}),
|
|
Divider(height: 1),
|
|
inputWidget(TranslationBase.of(context).maritalStatus, (widget.nHICData.maritalStatus ?? ""), null,
|
|
isEnable: true,
|
|
prefix: null,
|
|
removePadding: true,
|
|
isAllowRadius: false,
|
|
hasSelection: false,
|
|
isBorderAllowed: false,
|
|
isAllowLeadingIcon: true,
|
|
isReadOnly: true,
|
|
leadingIcon: "assets/images/svg/smart-phone.svg",
|
|
onChange: (value) {}),
|
|
Divider(height: 1),
|
|
inputWidget(TranslationBase.of(context).nationality, (widget.nHICData.nationality ?? ""), null,
|
|
isEnable: true,
|
|
prefix: null,
|
|
removePadding: true,
|
|
isAllowRadius: false,
|
|
hasSelection: false,
|
|
isBorderAllowed: false,
|
|
isAllowLeadingIcon: true,
|
|
isReadOnly: true,
|
|
leadingIcon: "assets/images/svg/globe.svg",
|
|
onChange: (value) {}),
|
|
Divider(height: 1),
|
|
inputWidget(TranslationBase.of(context).mobileNumber, (widget.payload.mobileNo ?? ""), null,
|
|
isEnable: true,
|
|
prefix: null,
|
|
removePadding: true,
|
|
isAllowRadius: false,
|
|
hasSelection: false,
|
|
isBorderAllowed: false,
|
|
isAllowLeadingIcon: true,
|
|
isReadOnly: true,
|
|
leadingIcon: "assets/images/svg/call.svg",
|
|
onChange: (value) {}),
|
|
Divider(height: 1),
|
|
inputWidget(TranslationBase.of(context).dob, (widget.nHICData.dateOfBirth ?? ""), null,
|
|
isEnable: true,
|
|
prefix: null,
|
|
hasSelection: false,
|
|
removePadding: true,
|
|
isBorderAllowed: false,
|
|
isAllowLeadingIcon: true,
|
|
hasSelectionCustomIcon: false,
|
|
isReadOnly: true,
|
|
selectionType: SelectionType.calendar,
|
|
selectedValue: widget.payload.dob != null ? Utils.formatDateToDisplay(widget.payload.dob.toString()) : null,
|
|
selectionCustomIcon: "assets/images/svg/calendar.svg",
|
|
leadingIcon: "assets/images/svg/birthday-cake.svg",
|
|
onChange: (value) {}),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
SizedBox(height: 150),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: CustomButton(
|
|
text: TranslationBase.of(context).cancel,
|
|
icon: "assets/images/svg/cancel.svg",
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
fontFamily: context.fontFamily,
|
|
backgroundColor: Color(0xFFFEE9EA),
|
|
borderColor: Color(0xFFFEE9EA),
|
|
textColor: Color(0xFFED1C2B),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 16,
|
|
),
|
|
Expanded(
|
|
child: CustomButton(
|
|
text: TranslationBase.of(context).confirm,
|
|
icon: "assets/images/svg/confirm.svg",
|
|
onPressed: () {
|
|
showModalBottomSheet(
|
|
context: context,
|
|
isScrollControlled: true,
|
|
isDismissible: false,
|
|
backgroundColor: Colors.transparent,
|
|
builder: (bottomSheetContext) => Padding(
|
|
padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom),
|
|
child: SingleChildScrollView(
|
|
child: GenericBottomSheet(
|
|
textController: emailAddress,
|
|
isForEmail: true,
|
|
buttons: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 10),
|
|
child: CustomButton(
|
|
text: "Submit",
|
|
onPressed: () {
|
|
if (emailAddress.text.isEmpty) {
|
|
Utils.showErrorToast("Please enter your email address.");
|
|
return;
|
|
} else {
|
|
Navigator.of(context).pop();
|
|
registerNow();
|
|
}
|
|
},
|
|
backgroundColor: Colors.red,
|
|
borderColor: Colors.red,
|
|
textColor: Colors.white),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
fontFamily: context.fontFamily,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
SizedBox(height: 14),
|
|
],
|
|
),
|
|
),
|
|
));
|
|
}
|
|
|
|
Widget showProgress({String? title, String? status, Color? color, bool isNeedBorder = true}) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
width: 26,
|
|
height: 26,
|
|
decoration: containerRadius(color!, 200),
|
|
child: Icon(
|
|
Icons.done,
|
|
color: Colors.white,
|
|
size: 16,
|
|
),
|
|
),
|
|
if (isNeedBorder)
|
|
Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: mDivider(Colors.grey),
|
|
)),
|
|
],
|
|
),
|
|
mHeight(8),
|
|
Text(
|
|
title!,
|
|
style: TextStyle(
|
|
fontSize: 11,
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: -0.44,
|
|
),
|
|
),
|
|
mHeight(2),
|
|
Container(
|
|
padding: EdgeInsets.all(5),
|
|
decoration: containerRadius(color.withOpacity(0.2), 4),
|
|
child: Text(
|
|
status!,
|
|
style: TextStyle(
|
|
fontSize: 8,
|
|
fontWeight: FontWeight.w600,
|
|
letterSpacing: -0.32,
|
|
color: color,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
);
|
|
}
|
|
|
|
registerNow() {
|
|
dynamic request;
|
|
if (!widget.payload.zipCode!.contains("966"))
|
|
request = getTempUserRequestDubai();
|
|
else
|
|
request = getTempUserRequest();
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context, barrierDismissible: true);
|
|
dynamic res;
|
|
|
|
authService
|
|
.registerUser(request)
|
|
.then((result) async => {
|
|
if (result is String)
|
|
{
|
|
GifLoaderDialogUtils.hideDialog(context),
|
|
new ConfirmDialog(
|
|
context: context,
|
|
confirmMessage: result,
|
|
okText: TranslationBase.of(context).ok,
|
|
cancelText: TranslationBase.of(context).cancel_nocaps,
|
|
okFunction: () => {ConfirmDialog.closeAlertDialog(context)},
|
|
cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)}).showAlertDialog(context)
|
|
}
|
|
else
|
|
{
|
|
res = result,
|
|
result = CheckActivationCode.fromJson(result),
|
|
// result.list.isFamily = false,
|
|
// sharedPref.setObject(USER_PROFILE, result.list),
|
|
// this.sharedPref.setObject(MAIN_USER, result.list),
|
|
// sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
|
|
// sharedPref.setString(TOKEN, result.authenticationTokenID),
|
|
// this.setUser(result),
|
|
sharedPref.remove(FAMILY_FILE),
|
|
result.list.isFamily = false,
|
|
|
|
await sharedPref.setString(BLOOD_TYPE, result.patientBloodType ?? ""),
|
|
authenticatedUserObject.user = result.list,
|
|
projectViewModel.setPrivilege(privilegeList: res),
|
|
await sharedPref.setObject(MAIN_USER, result.list),
|
|
await sharedPref.setObject(USER_PROFILE, result.list),
|
|
|
|
await sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
|
|
await sharedPref.setString(TOKEN, result.authenticationTokenID),
|
|
AppToast.showSuccessToast(message: TranslationBase.of(context).successRegister),
|
|
projectViewModel.analytics.loginRegistration.registration_confirmation()
|
|
}
|
|
})
|
|
.catchError((err) {
|
|
// GifLoaderDialogUtils.hideDialog(context);
|
|
ConfirmDialog dialog = ConfirmDialog(
|
|
context: context,
|
|
confirmMessage: err,
|
|
okText: TranslationBase.of(context).confirm,
|
|
cancelText: TranslationBase.of(context).cancel_nocaps,
|
|
okFunction: () => {ConfirmDialog.closeAlertDialog(context)},
|
|
cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)});
|
|
dialog.showAlertDialog(context);
|
|
projectViewModel.analytics.loginRegistration.registration_fail(errorType: "");
|
|
});
|
|
}
|
|
|
|
getTempUserRequest() {
|
|
DateFormat dateFormat = DateFormat("mm/dd/yyyy");
|
|
print(dateFormat.parse(widget.nHICData.dateOfBirth!));
|
|
var hDate = new HijriCalendar.fromDate(dateFormat.parse(widget.nHICData.dateOfBirth!));
|
|
var date = hDate.toString();
|
|
return {
|
|
"Patientobject": {
|
|
"TempValue": true,
|
|
"PatientIdentificationType": widget.nHICData.idNumber!.substring(0, 1) == "1" ? 1 : 2,
|
|
"PatientIdentificationNo": widget.nHICData.idNumber,
|
|
"MobileNumber": int.parse(widget.payload.mobileNo!),
|
|
"PatientOutSA": (widget.payload.zipCode == '966' || widget.payload.zipCode == '+966') ? 0 : 1,
|
|
"FirstNameN": widget.nHICData.firstNameAr,
|
|
"FirstName": widget.nHICData.firstNameEn,
|
|
"MiddleNameN": widget.nHICData.secondNameAr,
|
|
"MiddleName": widget.nHICData.secondNameEn,
|
|
"LastNameN": widget.nHICData.lastNameAr,
|
|
"LastName": widget.nHICData.lastNameEn,
|
|
"StrDateofBirth": widget.nHICData.dateOfBirth,
|
|
"DateofBirth": DateUtil.convertISODateToJsonDate(widget.nHICData.dateOfBirth!.replaceAll('/', '-')),
|
|
"Gender": widget.nHICData.gender == 'M' ? 1 : 2,
|
|
"NationalityID": widget.nHICData.nationalityCode,
|
|
"eHealthIDField": widget.nHICData.healthId,
|
|
"DateofBirthN": date,
|
|
"EmailAddress": emailAddress.text,
|
|
"SourceType": (widget.payload.zipCode == '966' || widget.payload.zipCode == '+966') ? 1 : 2,
|
|
"PreferredLanguage": context.selectedLanguage == "ar" ? 1 : 2,
|
|
// "OccupationID": registerInfo.occupationID,
|
|
"Marital": widget.nHICData.maritalStatusCode == 'U'
|
|
? '0'
|
|
: widget.nHICData.maritalStatusCode == 'M'
|
|
? '1'
|
|
: '2',
|
|
},
|
|
"PatientIdentificationID": widget.nHICData.idNumber,
|
|
"PatientMobileNumber": widget.payload.mobileNo.toString()[0] == '0' ? widget.payload.mobileNo : '0' + widget.payload.mobileNo.toString()
|
|
};
|
|
}
|
|
|
|
getTempUserRequestDubai() {
|
|
DateFormat dateFormat = DateFormat("mm/dd/yyyy");
|
|
// print(dateFormat.parse(registerd_data.dob!));
|
|
var hDate = new HijriCalendar.fromDate(dateFormat.parse(widget.nHICData.dateOfBirth!));
|
|
var date = hDate.toString();
|
|
final DateFormat dateFormat1 = DateFormat('MM/dd/yyyy');
|
|
final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy');
|
|
|
|
return {
|
|
"Patientobject": {
|
|
"TempValue": true,
|
|
"PatientIdentificationType": widget.nHICData.idNumber!.substring(0, 1) == "1" ? "1" : "2",
|
|
"PatientIdentificationNo": widget.nHICData.idNumber,
|
|
"MobileNumber": int.parse(widget.payload.mobileNo ?? ""),
|
|
"PatientOutSA": (widget.payload.zipCode == '966' || widget.payload.zipCode == '+966') ? 0 : 1,
|
|
"FirstNameN": widget.nHICData.firstNameAr ?? "",
|
|
"FirstName": widget.nHICData.firstNameEn ?? "",
|
|
"MiddleNameN": widget.nHICData.secondNameAr ?? ".",
|
|
"MiddleName": widget.nHICData.secondNameEn ?? ".",
|
|
"LastNameN": widget.nHICData.lastNameAr ?? "",
|
|
"LastName": widget.nHICData.lastNameEn ?? "",
|
|
"StrDateofBirth": dateFormat1.format(dateFormat2.parse(widget.nHICData.dateOfBirth!)),
|
|
"DateofBirth": DateUtil.convertISODateToJsonDate(widget.nHICData.dateOfBirth!.replaceAll('/', '-')),
|
|
"Gender": widget.nHICData.gender == 'M' ? 1 : 2,
|
|
"NationalityID": widget.nHICData.nationalityCode,
|
|
"eHealthIDField": null,
|
|
"DateofBirthN": date,
|
|
"EmailAddress": emailAddress.text,
|
|
"SourceType": (widget.payload.zipCode == '966' || widget.payload.zipCode == '+966') ? 1 : 2,
|
|
"PreferredLanguage": context.selectedLanguage == "ar" ? 1 : 2,
|
|
"Marital": widget.nHICData.maritalStatusCode == 'U'
|
|
? '0'
|
|
: widget.nHICData.maritalStatusCode == 'M'
|
|
? '1'
|
|
: '2',
|
|
},
|
|
"PatientIdentificationID": widget.nHICData.idNumber,
|
|
"PatientMobileNumber": widget.payload.mobileNo.toString()[0] == '0' ? widget.payload.mobileNo : '0' + widget.payload.mobileNo.toString(),
|
|
"DOB": widget.nHICData.dateOfBirth,
|
|
"IsHijri": widget.payload.isHijri
|
|
};
|
|
}
|
|
}
|