@ -5,12 +5,15 @@ import 'package:hmg_patient_app_new/core/app_state.dart';
import ' package:hmg_patient_app_new/core/common_models/nationality_country_model.dart ' ;
import ' package:hmg_patient_app_new/core/dependencies.dart ' ;
import ' package:hmg_patient_app_new/core/enums.dart ' ;
import ' package:hmg_patient_app_new/core/utils/date_util.dart ' ;
import ' package:hmg_patient_app_new/core/utils/size_utils.dart ' ;
import ' package:hmg_patient_app_new/core/utils/validation_utils.dart ' ;
import ' package:hmg_patient_app_new/extensions/string_extensions.dart ' ;
import ' package:hmg_patient_app_new/extensions/widget_extensions.dart ' ;
import ' package:hmg_patient_app_new/features/authentication/authentication_view_model.dart ' ;
import ' package:hmg_patient_app_new/features/insurance/insurance_view_model.dart ' ;
import ' package:hmg_patient_app_new/generated/locale_keys.g.dart ' ;
import ' package:hmg_patient_app_new/presentation/insurance/widgets/patient_insurance_card.dart ' ;
import ' package:hmg_patient_app_new/theme/colors.dart ' ;
import ' package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart ' ;
import ' package:hmg_patient_app_new/widgets/bottomsheet/generic_bottom_sheet.dart ' ;
@ -28,11 +31,22 @@ class RegisterNewStep2 extends StatefulWidget {
class _RegisterNew extends State < RegisterNewStep2 > {
AuthenticationViewModel ? authVM ;
InsuranceViewModel ? insuranceVM ;
@ override
void initState ( ) {
super . initState ( ) ;
authVM = context . read < AuthenticationViewModel > ( ) ;
insuranceVM = context . read < InsuranceViewModel > ( ) ;
/ / Call insurance API to fetch data
WidgetsBinding . instance . addPostFrameCallback ( ( _ ) {
debugPrint ( " Registration Step 2: Calling insurance API " ) ;
/ / Reset the flag to ensure API gets called
insuranceVM ? . setIsInsuranceDataToBeLoaded ( true ) ;
insuranceVM ? . initInsuranceProvider ( ) ;
debugPrint ( " Registration Step 2: Insurance API call initiated " ) ;
} ) ;
}
@ override
@ -59,6 +73,59 @@ class _RegisterNew extends State<RegisterNewStep2> {
onLanguageChanged: ( lang ) { } ,
hideLogoAndLang: true ,
) ,
bottomSheet: Container (
/ / height: 200. h ,
width: MediaQuery . of ( context ) . size . width ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
customBorder: BorderRadius . only ( topLeft: Radius . circular ( 24 ) , topRight: Radius . circular ( 24 ) ) ,
hasShadow: true ,
) ,
child: Row (
children: [
Expanded (
child: CustomButton (
text: LocaleKeys . cancel . tr ( ) ,
icon: AppAssets . cancel ,
onPressed: ( ) {
Navigator . of ( context ) . pop ( ) ;
/ / authVM ! . clearDefaultInputValues ( ) ;
} ,
backgroundColor: AppColors . secondaryLightRedColor ,
borderColor: AppColors . secondaryLightRedColor ,
textColor: AppColors . primaryRedColor ,
iconColor: AppColors . primaryRedColor ,
) ,
) ,
SizedBox ( width: 16. w ) ,
Expanded (
child: CustomButton (
backgroundColor: AppColors . primaryRedColor ,
borderColor: AppColors . primaryRedColor ,
textColor: AppColors . whiteColor ,
text: LocaleKeys . confirm . tr ( ) ,
icon: AppAssets . confirm ,
iconColor: AppColors . whiteColor ,
onPressed: ( ) {
if ( appState . getUserRegistrationPayload . zipCode ! = CountryEnum . saudiArabia . countryCode ) {
if ( ValidationUtils . validateUaeRegistration (
name: authVM ! . nameController . text ,
gender: authVM ! . genderType ,
country: authVM ! . pickedCountryByUAEUser ,
maritalStatus: authVM ! . maritalStatus ,
onOkPress: ( ) {
Navigator . of ( context ) . pop ( ) ;
} ) ) {
showModel ( context: context ) ;
}
} else {
showModel ( context: context ) ;
}
} ,
) ,
)
] ,
) . paddingAll ( 16. h ) , ) ,
body: GestureDetector (
onTap: ( ) {
FocusScope . of ( context ) . unfocus ( ) ;
@ -75,6 +142,29 @@ class _RegisterNew extends State<RegisterNewStep2> {
children: < Widget > [
LocaleKeys . personalDetailsVerification . tr ( ) . toText26 ( color: AppColors . textColor , weight: FontWeight . w600 , letterSpacing: - 2 ) ,
SizedBox ( height: 24. h ) ,
/ / Insurance Card Section
Consumer < InsuranceViewModel > (
builder: ( context , insuranceVM , child ) {
/ / Only show if insurance data is available and not loading
if ( ! insuranceVM . isInsuranceLoading & & insuranceVM . patientInsuranceList . isNotEmpty ) {
return Column (
children: [
PatientInsuranceCard (
insuranceCardDetailsModel: insuranceVM . patientInsuranceList . first ,
isInsuranceExpired: DateTime . now ( ) . isAfter (
DateUtil . convertStringToDate ( insuranceVM . patientInsuranceList . first . cardValidTo ) ,
) ,
) ,
SizedBox ( height: 24. h ) ,
] ,
) ;
}
/ / Don ' t show anything if loading or no data
return SizedBox . shrink ( ) ;
} ,
) ,
Container (
decoration: BoxDecoration ( color: Colors . white , borderRadius: BorderRadius . circular ( 24 ) ) ,
padding: EdgeInsets . only ( left: 16. h , right: 16. h ) ,
@ -97,7 +187,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
isReadOnly: authVM ! . isUserFromUAE ( ) ? false : true ,
leadingIcon: AppAssets . user_circle ,
labelColor: AppColors . textColor ,
) . paddingSymmetrical ( 0. h , 16 .h ) ,
) . paddingSymmetrical ( 0. h , 8 .h ) ,
Divider ( height: 1. h , color: AppColors . greyColor ) ,
TextInputWidget (
labelText: LocaleKeys . nationalIdNumber . tr ( ) ,
@ -111,7 +201,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
isReadOnly: true ,
labelColor: AppColors . textColor ,
leadingIcon: AppAssets . student_card )
. paddingSymmetrical ( 0. h , 16 .h ) ,
. paddingSymmetrical ( 0. h , 8 .h ) ,
Divider ( height: 1 , color: AppColors . greyColor ) ,
authVM ! . isUserFromUAE ( )
? Selector < AuthenticationViewModel , GenderTypeEnum ? > (
@ -148,7 +238,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
leadingIcon: AppAssets . user_full ,
labelColor: AppColors . textColor ,
onChange: ( value ) { } )
. paddingSymmetrical ( 0. h , 16 .h ) ,
. paddingSymmetrical ( 0. h , 8 .h ) ,
Divider ( height: 1 , color: AppColors . greyColor ) ,
authVM ! . isUserFromUAE ( )
? Selector < AuthenticationViewModel , MaritalStatusTypeEnum ? > (
@ -187,7 +277,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
labelColor: AppColors . textColor ,
leadingIcon: AppAssets . smart_phone ,
onChange: ( value ) { } )
. paddingSymmetrical ( 0. h , 16 .h ) ,
. paddingSymmetrical ( 0. h , 8 .h ) ,
Divider ( height: 1. h , color: AppColors . greyColor ) ,
authVM ! . isUserFromUAE ( )
? Selector < AuthenticationViewModel , ( { List < NationalityCountries > ? countriesList , NationalityCountries ? selectedCountry , bool isArabic } ) > (
@ -237,14 +327,14 @@ class _RegisterNew extends State<RegisterNewStep2> {
labelColor: AppColors . textColor ,
leadingIcon: AppAssets . globe ,
onChange: ( value ) { } )
. paddingSymmetrical ( 0. h , 16 .h ) ,
. paddingSymmetrical ( 0. h , 8 .h ) ,
Divider (
height: 1 ,
color: AppColors . greyColor ,
) ,
TextInputWidget (
labelText: LocaleKeys . mobileNumber . tr ( ) ,
hintText: ( appState . getUserRegistrationPayload . patientMobileNumber . toString ( ) ? ? " " ) ,
hintText: appState . getUserRegistrationPayload . patientMobileNumber . toString ( ) ,
controller: null ,
isEnable: false ,
prefix: null ,
@ -254,7 +344,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
labelColor: AppColors . textColor ,
isReadOnly: true ,
leadingIcon: AppAssets . call )
. paddingSymmetrical ( 0. h , 16 .h ) ,
. paddingSymmetrical ( 0. h , 8 .h ) ,
Divider (
height: 1. h ,
color: AppColors . greyColor ,
@ -271,56 +361,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
labelColor: AppColors . textColor ,
leadingIcon: AppAssets . birthday_cake ,
selectionType: null ,
) . paddingSymmetrical ( 0. h , 16 .h ) ,
) . paddingSymmetrical ( 0. h , 8 .h ) ,
] ,
) ,
) ,
SizedBox ( height: 50. h ) ,
Row (
children: [
Expanded (
child: CustomButton (
text: LocaleKeys . cancel . tr ( ) ,
icon: AppAssets . cancel ,
onPressed: ( ) {
Navigator . of ( context ) . pop ( ) ;
/ / authVM ! . clearDefaultInputValues ( ) ;
} ,
backgroundColor: AppColors . secondaryLightRedColor ,
borderColor: AppColors . secondaryLightRedColor ,
textColor: AppColors . primaryRedColor ,
iconColor: AppColors . primaryRedColor ,
) ,
) ,
SizedBox ( width: 16. w ) ,
Expanded (
child: CustomButton (
backgroundColor: AppColors . primaryRedColor ,
borderColor: AppColors . primaryRedColor ,
textColor: AppColors . whiteColor ,
text: LocaleKeys . confirm . tr ( ) ,
icon: AppAssets . confirm ,
iconColor: AppColors . whiteColor ,
onPressed: ( ) {
if ( appState . getUserRegistrationPayload . zipCode ! = CountryEnum . saudiArabia . countryCode ) {
if ( ValidationUtils . validateUaeRegistration (
name: authVM ! . nameController . text ,
gender: authVM ! . genderType ,
country: authVM ! . pickedCountryByUAEUser ,
maritalStatus: authVM ! . maritalStatus ,
onOkPress: ( ) {
Navigator . of ( context ) . pop ( ) ;
} ) ) {
showModel ( context: context ) ;
}
} else {
showModel ( context: context ) ;
}
} ,
) ,
)
] ,
) ,
SizedBox ( height: 120. h ) ,
] ,
) ,
) ,