diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index baa6f7e..9abd673 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -23,13 +23,28 @@ class AuthenticationViewModel extends ChangeNotifier { final TextEditingController nationalIdController = TextEditingController(); final TextEditingController phoneNumberController = TextEditingController(); + CountryEnum selectedCountry = CountryEnum.saudiArabia; + bool isTermsAccepted = false; void login() { if (ValidationUtils.isValidatePhoneAndId(nationalId: nationalIdController.text, phoneNumber: phoneNumberController.text)) { - } else {} } + void onCountryChange(CountryEnum country) { + selectedCountry = country; + notifyListeners(); + } + + void onPhoneNumberChange(String? phoneNumber) { + phoneNumberController.text = phoneNumber!; + } + + void onTermAccepted() { + isTermsAccepted = !isTermsAccepted; + notifyListeners(); + } + Future selectDeviceImei({Function(dynamic)? onSuccess, Function(String)? onError}) async { String firebaseToken = "dOGRRszQQMGe_9wA5Hx3kO:APA91bFV5IcIJXvcCXXk0tc2ddtZgWwCPq7sGSuPr-YW7iiJpQZKgFGN9GAzCVOWL8MfheaP1slE8MdxB7lczdPBGdONQ7WbMmhgHcsUCUktq-hsapGXXqc"; final result = await authenticationRepo.selectDeviceByImei(firebaseToken: firebaseToken); diff --git a/lib/presentation/authentication/login.dart b/lib/presentation/authentication/login.dart index 2771b36..f171443 100644 --- a/lib/presentation/authentication/login.dart +++ b/lib/presentation/authentication/login.dart @@ -83,7 +83,7 @@ class _LoginScreen extends State { icon: AppAssets.login1, iconColor: Colors.white, onPressed: () { - showLoginModel(context: context, textController: authVm.phoneNumberController); + showLoginModel(context: context, authVM: authVm); // if (nationIdController.text.isNotEmpty) { // } else { @@ -140,7 +140,7 @@ class _LoginScreen extends State { ); } - void showLoginModel({required BuildContext context, TextEditingController? textController}) { + void showLoginModel({required BuildContext context, required AuthenticationViewModel authVM}) { context.showBottomSheet( isScrollControlled: true, isDismissible: false, @@ -151,12 +151,12 @@ class _LoginScreen extends State { padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), child: SingleChildScrollView( child: GenericBottomSheet( - countryCode: "966", + countryCode: authVM.selectedCountry.countryCode, initialPhoneNumber: "", - textController: textController, + textController: authVM.phoneNumberController, isEnableCountryDropdown: true, - onCountryChange: (value) {}, - onChange: (String? value) {}, + onCountryChange: authVM.onCountryChange, + onChange: authVM.onPhoneNumberChange, buttons: [ Padding( padding: EdgeInsets.only(bottom: 10.h), diff --git a/lib/presentation/authentication/register.dart b/lib/presentation/authentication/register.dart index 1e8a0c7..85ff402 100644 --- a/lib/presentation/authentication/register.dart +++ b/lib/presentation/authentication/register.dart @@ -9,6 +9,7 @@ import 'package:hmg_patient_app_new/core/utils/size_utils.dart'; import 'package:hmg_patient_app_new/core/utils/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/generated/locale_keys.g.dart'; import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/widgets/appbar/app_bar_widget.dart'; @@ -18,6 +19,7 @@ import 'package:hmg_patient_app_new/widgets/dropdown/country_dropdown_widget.dar import 'package:hmg_patient_app_new/widgets/dropdown/dropdown_widget.dart'; import 'package:hmg_patient_app_new/widgets/input_widget.dart'; import 'package:hmg_patient_app_new/widgets/otp/otp.dart'; +import 'package:provider/provider.dart'; class RegisterNew extends StatefulWidget { @override @@ -25,8 +27,6 @@ class RegisterNew extends StatefulWidget { } class _RegisterNew extends State { - bool isTermsAccepted = true; - @override void initState() { super.initState(); @@ -40,6 +40,8 @@ class _RegisterNew extends State { @override Widget build(BuildContext context) { AppState appState = getIt.get(); + AuthenticationViewModel authVm = context.read(); + return Scaffold( backgroundColor: AppColors.bgScaffoldColor, appBar: CustomAppBar( @@ -68,12 +70,7 @@ class _RegisterNew extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Utils.showLottie(context: context, - assetPath: 'assets/animations/lottie/register.json', - width: 200.h, - height: 200.h, - fit: BoxFit.cover, - repeat: true), + Utils.showLottie(context: context, assetPath: 'assets/animations/lottie/register.json', width: 200.h, height: 200.h, fit: BoxFit.cover, repeat: true), SizedBox(height: 16.h), LocaleKeys.prepareToElevate.tr().toText32(isBold: true), SizedBox(height: 24.h), @@ -125,22 +122,25 @@ class _RegisterNew extends State { ), SizedBox(height: 25.h), GestureDetector( - onTap: () {}, + onTap: authVm.onTermAccepted, child: Row( children: [ - AnimatedContainer( - duration: const Duration(milliseconds: 200), - height: 24.h, - width: 24.h, - decoration: BoxDecoration( - color: isTermsAccepted ? const Color(0xFFE92227) : Colors.transparent, - borderRadius: BorderRadius.circular(6), - border: Border.all( - color: isTermsAccepted ? const Color(0xFFE92227) : Colors.grey, - width: 2.h, - ), - ), - child: isTermsAccepted ? Icon(Icons.check, size: 16.fSize, color: Colors.white) : null, + Selector( + selector: (_, viewModel) => viewModel.isTermsAccepted, + shouldRebuild: (previous, next) => previous != next, + builder: (context, isTermsAccepted, child) { + return AnimatedContainer( + duration: const Duration(milliseconds: 200), + height: 24.h, + width: 24.h, + decoration: BoxDecoration( + color: isTermsAccepted ? AppColors.primaryRedColor : Colors.transparent, + borderRadius: BorderRadius.circular(6), + border: Border.all(color: isTermsAccepted ? AppColors.primaryRedBorderColor : AppColors.greyColor, width: 2.h), + ), + child: isTermsAccepted ? Icon(Icons.check, size: 16.fSize, color: Colors.white) : null, + ); + }, ), SizedBox(width: 12.h), Expanded( @@ -157,7 +157,7 @@ class _RegisterNew extends State { text: "Register", icon: AppAssets.note_edit, onPressed: () { - showRegisterModel(context: context); + showRegisterModel(context: context, authVM: authVm); }, ), SizedBox(height: 14), @@ -200,118 +200,116 @@ class _RegisterNew extends State { )); } - void showRegisterModel({required BuildContext context, TextEditingController? textController}) { + void showRegisterModel({required BuildContext context, required AuthenticationViewModel authVM}) { showModalBottomSheet( context: context, isScrollControlled: true, isDismissible: false, useSafeArea: true, backgroundColor: Colors.transparent, - builder: (bottomSheetContext) => - Padding( - padding: EdgeInsets.only(bottom: MediaQuery - .of(bottomSheetContext) - .viewInsets - .bottom), - child: SingleChildScrollView( - child: GenericBottomSheet( - countryCode: "966", - initialPhoneNumber: "", - textController: TextEditingController(), - isEnableCountryDropdown: true, - onChange: (String? value) {}, - buttons: [ - Padding( - padding: const EdgeInsets.only(bottom: 10), - child: CustomButton( - text: LocaleKeys.sendOTPSMS.tr(), - onPressed: () { - Navigator.of(context).push( - MaterialPageRoute(builder: (BuildContext context) => OTPVerificationPage(phoneNumber: '12234567',))); - + builder: (bottomSheetContext) => Padding( + padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), + child: SingleChildScrollView( + child: GenericBottomSheet( + countryCode: authVM.selectedCountry.countryCode, + initialPhoneNumber: "", + textController: authVM.phoneNumberController, + isEnableCountryDropdown: true, + onCountryChange: authVM.onCountryChange, + onChange: authVM.onPhoneNumberChange, + buttons: [ + Padding( + padding: const EdgeInsets.only(bottom: 10), + child: CustomButton( + text: LocaleKeys.sendOTPSMS.tr(), + onPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (BuildContext context) => OTPVerificationPage( + phoneNumber: '12234567', + ))); - // if (mobileNo.isEmpty) { - // context.showBottomSheet( - // child: ExceptionBottomSheet( - // message: TranslationBase.of(context).pleaseEnterMobile, - // showCancel: false, - // onOkPressed: () { - // Navigator.of(context).pop(); - // }, - // ), - // ); - // } else if (!Utils.validateMobileNumber(mobileNo)) { - // context.showBottomSheet( - // child: ExceptionBottomSheet( - // message: TranslationBase.of(context).pleaseEnterValidMobile, - // showCancel: false, - // onOkPressed: () { - // Navigator.of(context).pop(); - // }, - // ), - // ); - // } else { - // registerUser(1); - // } - Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => OTPVerificationPage(phoneNumber: '12234567'))); - }, - backgroundColor: AppColors.primaryRedColor, - borderColor: AppColors.primaryRedBorderColor, - textColor: AppColors.whiteColor, - icon: AppAssets.message, - ), - ), - Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding( - padding: EdgeInsets.symmetric(horizontal: 8.h), - child: LocaleKeys.oR.tr().toText16(color: AppColors.textColor), - ), - ], - ), + // if (mobileNo.isEmpty) { + // context.showBottomSheet( + // child: ExceptionBottomSheet( + // message: TranslationBase.of(context).pleaseEnterMobile, + // showCancel: false, + // onOkPressed: () { + // Navigator.of(context).pop(); + // }, + // ), + // ); + // } else if (!Utils.validateMobileNumber(mobileNo)) { + // context.showBottomSheet( + // child: ExceptionBottomSheet( + // message: TranslationBase.of(context).pleaseEnterValidMobile, + // showCancel: false, + // onOkPressed: () { + // Navigator.of(context).pop(); + // }, + // ), + // ); + // } else { + // registerUser(1); + // } + Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => OTPVerificationPage(phoneNumber: '12234567'))); + }, + backgroundColor: AppColors.primaryRedColor, + borderColor: AppColors.primaryRedBorderColor, + textColor: AppColors.whiteColor, + icon: AppAssets.message, + ), + ), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ Padding( - padding: EdgeInsets.only(bottom: 10.h, top: 10.h), - child: CustomButton( - text: LocaleKeys.sendOTPWHATSAPP.tr(), - onPressed: () { - // if (mobileNo.isEmpty) { - // context.showBottomSheet( - // child: ExceptionBottomSheet( - // message: TranslationBase.of(context).pleaseEnterMobile, - // showCancel: false, - // onOkPressed: () { - // Navigator.of(context).pop(); - // }, - // ), - // ); - // } else if (!Utils.validateMobileNumber(mobileNo)) { - // context.showBottomSheet( - // child: ExceptionBottomSheet( - // message: TranslationBase.of(context).pleaseEnterValidMobile, - // showCancel: false, - // onOkPressed: () { - // Navigator.of(context).pop(); - // }, - // ), - // ); - // } else { - // registerUser(4); - // } - // int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, mobileNo, context); - // registerUser(val); - }, - backgroundColor: AppColors.whiteColor, - borderColor: AppColors.borderOnlyColor, - textColor: AppColors.textColor, - icon: AppAssets.whatsapp, - ), + padding: EdgeInsets.symmetric(horizontal: 8.h), + child: LocaleKeys.oR.tr().toText16(color: AppColors.textColor), ), ], ), - ), + Padding( + padding: EdgeInsets.only(bottom: 10.h, top: 10.h), + child: CustomButton( + text: LocaleKeys.sendOTPWHATSAPP.tr(), + onPressed: () { + // if (mobileNo.isEmpty) { + // context.showBottomSheet( + // child: ExceptionBottomSheet( + // message: TranslationBase.of(context).pleaseEnterMobile, + // showCancel: false, + // onOkPressed: () { + // Navigator.of(context).pop(); + // }, + // ), + // ); + // } else if (!Utils.validateMobileNumber(mobileNo)) { + // context.showBottomSheet( + // child: ExceptionBottomSheet( + // message: TranslationBase.of(context).pleaseEnterValidMobile, + // showCancel: false, + // onOkPressed: () { + // Navigator.of(context).pop(); + // }, + // ), + // ); + // } else { + // registerUser(4); + // } + // int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, mobileNo, context); + // registerUser(val); + }, + backgroundColor: AppColors.whiteColor, + borderColor: AppColors.borderOnlyColor, + textColor: AppColors.textColor, + icon: AppAssets.whatsapp, + ), + ), + ], ), + ), + ), ); } } diff --git a/lib/presentation/authentication/register_step2.dart b/lib/presentation/authentication/register_step2.dart index 295dd8a..660ba69 100644 --- a/lib/presentation/authentication/register_step2.dart +++ b/lib/presentation/authentication/register_step2.dart @@ -53,8 +53,11 @@ class _RegisterNew extends State { Widget build(BuildContext context) { return Scaffold( - - appBar: CustomAppBar(onBackPressed: () {}, onLanguageChanged: (lang) {}, hideLogoAndLang: true,), + appBar: CustomAppBar( + onBackPressed: () {}, + onLanguageChanged: (lang) {}, + hideLogoAndLang: true, + ), body: SingleChildScrollView( reverse: false, padding: EdgeInsets.only(left: 24.h, right: 24.h, top: 24.h), @@ -69,30 +72,38 @@ class _RegisterNew extends State { child: Column( children: [ TextInputWidget( - labelText: isFromDubai ? LocaleKeys.fullName.tr() : LocaleKeys.name.tr(), - hintText: isFromDubai ? "name" ?? "" : (widget.nHICData!.firstNameEn!.toUpperCase() + " " + widget.nHICData!.lastNameEn!.toUpperCase()), - controller: null, - isEnable: true, - prefix: null, - isAllowRadius: false, - isBorderAllowed: false, - keyboardType: TextInputType.text, - isAllowLeadingIcon: true, - isReadOnly: isFromDubai ? false : true, - leadingIcon: AppAssets.user_circle).paddingSymmetrical(0.h,16.h), - Divider(height: 1, color: AppColors.greyColor,), + labelText: isFromDubai ? LocaleKeys.fullName.tr() : LocaleKeys.name.tr(), + hintText: isFromDubai ? "name" ?? "" : (widget.nHICData!.firstNameEn!.toUpperCase() + " " + widget.nHICData!.lastNameEn!.toUpperCase()), + controller: null, + isEnable: true, + prefix: null, + isAllowRadius: false, + isBorderAllowed: false, + keyboardType: TextInputType.text, + isAllowLeadingIcon: true, + isReadOnly: isFromDubai ? false : true, + leadingIcon: AppAssets.user_circle) + .paddingSymmetrical(0.h, 16.h), + Divider( + height: 1, + color: AppColors.greyColor, + ), TextInputWidget( - labelText: LocaleKeys.nationalIdNumber.tr(), - hintText: isFromDubai ? "widget.payload.nationalID!" : (widget.nHICData!.idNumber ?? ""), - controller: null, - isEnable: true, - prefix: null, - isAllowRadius: false, - isBorderAllowed: false, - isAllowLeadingIcon: true, - isReadOnly: true, - leadingIcon: AppAssets.student_card).paddingSymmetrical(0.h,16.h), - Divider(height: 1, color: AppColors.greyColor,), + labelText: LocaleKeys.nationalIdNumber.tr(), + hintText: isFromDubai ? "widget.payload.nationalID!" : (widget.nHICData!.idNumber ?? ""), + controller: null, + isEnable: true, + prefix: null, + isAllowRadius: false, + isBorderAllowed: false, + isAllowLeadingIcon: true, + isReadOnly: true, + leadingIcon: AppAssets.student_card) + .paddingSymmetrical(0.h, 16.h), + Divider( + height: 1, + color: AppColors.greyColor, + ), isFromDubai ? DropdownWidget( labelText: LocaleKeys.gender.tr(), @@ -109,22 +120,25 @@ class _RegisterNew extends State { isAllowRadius: false, padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), selectionCustomIcon: AppAssets.arrow_down, - leadingIcon: AppAssets.user_full, + leadingIcon: AppAssets.user_full, ).withVerticalPadding(8) : TextInputWidget( - labelText: LocaleKeys.gender.tr(), - hintText: (widget.nHICData!.gender ?? ""), - controller: null, - isEnable: true, - prefix: null, - isAllowRadius: false, - isBorderAllowed: false, - isAllowLeadingIcon: true, - isReadOnly: isFromDubai ? false : true, - leadingIcon: AppAssets.user_full, - - onChange: (value) {}).paddingSymmetrical(0.h,16.h), - Divider(height: 1, color: AppColors.greyColor,), + labelText: LocaleKeys.gender.tr(), + hintText: (widget.nHICData!.gender ?? ""), + controller: null, + isEnable: true, + prefix: null, + isAllowRadius: false, + isBorderAllowed: false, + isAllowLeadingIcon: true, + isReadOnly: isFromDubai ? false : true, + leadingIcon: AppAssets.user_full, + onChange: (value) {}) + .paddingSymmetrical(0.h, 16.h), + Divider( + height: 1, + color: AppColors.greyColor, + ), isFromDubai ? DropdownWidget( labelText: LocaleKeys.maritalStatus.tr(), @@ -138,22 +152,26 @@ class _RegisterNew extends State { isAllowRadius: false, padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), selectionCustomIcon: AppAssets.arrow_down, - leadingIcon: AppAssets.smart_phone, + leadingIcon: AppAssets.smart_phone, ).withVerticalPadding(8) : TextInputWidget( - labelText: LocaleKeys.maritalStatus.tr(), - hintText: appState!.isArabic() - ? (MaritalStatusTypeExtension.fromValue(widget.nHICData!.maritalStatusCode)!.typeAr) - : (MaritalStatusTypeExtension.fromValue(widget.nHICData!.maritalStatusCode)!.type), - isEnable: true, - prefix: null, - isAllowRadius: false, - isBorderAllowed: false, - isAllowLeadingIcon: true, - isReadOnly: true, - leadingIcon: AppAssets.smart_phone, - onChange: (value) {}).paddingSymmetrical(0.h,16.h), - Divider(height: 1, color: AppColors.greyColor,), + labelText: LocaleKeys.maritalStatus.tr(), + hintText: appState!.isArabic() + ? (MaritalStatusTypeExtension.fromValue(widget.nHICData!.maritalStatusCode)!.typeAr) + : (MaritalStatusTypeExtension.fromValue(widget.nHICData!.maritalStatusCode)!.type), + isEnable: true, + prefix: null, + isAllowRadius: false, + isBorderAllowed: false, + isAllowLeadingIcon: true, + isReadOnly: true, + leadingIcon: AppAssets.smart_phone, + onChange: (value) {}) + .paddingSymmetrical(0.h, 16.h), + Divider( + height: 1, + color: AppColors.greyColor, + ), isFromDubai ? DropdownWidget( labelText: LocaleKeys.country.tr(), @@ -170,46 +188,55 @@ class _RegisterNew extends State { leadingIcon: AppAssets.globe, ).withVerticalPadding(8) : TextInputWidget( - labelText: LocaleKeys.nationality.tr(), - hintText: appState!.isArabic() - ? (countriesList.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).nameN ?? "") - : (countriesList.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).name ?? ""), + labelText: LocaleKeys.nationality.tr(), + hintText: appState!.isArabic() + ? (countriesList.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).nameN ?? "") + : (countriesList.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).name ?? ""), + isEnable: true, + prefix: null, + isAllowRadius: false, + isBorderAllowed: false, + isAllowLeadingIcon: true, + isReadOnly: true, + leadingIcon: AppAssets.globe, + onChange: (value) {}) + .paddingSymmetrical(0.h, 16.h), + Divider( + height: 1, + color: AppColors.greyColor, + ), + TextInputWidget( + labelText: LocaleKeys.mobileNumber.tr(), + hintText: ("widget.payload.mobileNo" ?? ""), + controller: null, isEnable: true, prefix: null, isAllowRadius: false, isBorderAllowed: false, isAllowLeadingIcon: true, isReadOnly: true, - leadingIcon: AppAssets.globe, - onChange: (value) {}).paddingSymmetrical(0.h,16.h), - Divider(height: 1, color: AppColors.greyColor,), - TextInputWidget( - labelText: LocaleKeys.mobileNumber.tr(), - hintText: ("widget.payload.mobileNo" ?? ""), - controller: null, - isEnable: true, - prefix: null, - isAllowRadius: false, - isBorderAllowed: false, - isAllowLeadingIcon: true, - isReadOnly: true, - leadingIcon: AppAssets.call, - onChange: (value) {}).paddingSymmetrical(0.h,16.h), - Divider(height: 1, color: AppColors.greyColor,), + leadingIcon: AppAssets.call, + onChange: (value) {}) + .paddingSymmetrical(0.h, 16.h), + Divider( + height: 1, + color: AppColors.greyColor, + ), TextInputWidget( - labelText: LocaleKeys.dob.tr(), - hintText: isFromDubai ? "widget.payload.dob!" : (widget.nHICData!.dateOfBirth ?? ""), - controller: null, - isEnable: true, - prefix: null, - isBorderAllowed: false, - isAllowLeadingIcon: true, - isReadOnly: true, - // : SelectionType.calendar, - // selectedValue: widget.payload.dob != null ? Utils.formatDateToDisplay(widget.payload.dob.toString()) : null, - // selectionCustomIcon: AppAssets.calendar, - leadingIcon: AppAssets.birthday_cake, - onChange: (value) {}).paddingSymmetrical(0.h,16.h), + labelText: LocaleKeys.dob.tr(), + hintText: isFromDubai ? "widget.payload.dob!" : (widget.nHICData!.dateOfBirth ?? ""), + controller: null, + isEnable: true, + prefix: null, + isBorderAllowed: false, + isAllowLeadingIcon: true, + isReadOnly: true, + // : SelectionType.calendar, + // selectedValue: widget.payload.dob != null ? Utils.formatDateToDisplay(widget.payload.dob.toString()) : null, + // selectionCustomIcon: AppAssets.calendar, + leadingIcon: AppAssets.birthday_cake, + onChange: (value) {}) + .paddingSymmetrical(0.h, 16.h), ], ), ), diff --git a/lib/widgets/bottomsheet/generic_bottom_sheet.dart b/lib/widgets/bottomsheet/generic_bottom_sheet.dart index 1d07099..08bf849 100644 --- a/lib/widgets/bottomsheet/generic_bottom_sheet.dart +++ b/lib/widgets/bottomsheet/generic_bottom_sheet.dart @@ -46,8 +46,8 @@ class _GenericBottomSheetState extends State { void initState() { super.initState(); - if (!widget.isForEmail) { - widget.textController = TextEditingController(text: widget.initialPhoneNumber); + if (!widget.isForEmail && widget.textController != null) { + widget.textController!.text = widget.initialPhoneNumber!; } } @@ -116,13 +116,16 @@ class _GenericBottomSheetState extends State { padding: EdgeInsets.all(8.h), keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number, onChange: (value) { - widget.textController!.text = value!; if (widget.onChange != null) { widget.onChange!(value); } }, + onCountryChange: (value) { + if (widget.onCountryChange != null) { + widget.onCountryChange!(value); + } + }, isEnable: true, - // focusNode: widget.myFocusNode, isReadOnly: widget.isFromSavedLogin, prefix: widget.isForEmail ? null : widget.countryCode, isBorderAllowed: false, diff --git a/lib/widgets/input_widget.dart b/lib/widgets/input_widget.dart index b8d36e7..ca19ee6 100644 --- a/lib/widgets/input_widget.dart +++ b/lib/widgets/input_widget.dart @@ -28,11 +28,12 @@ class TextInputWidget extends StatelessWidget { final bool isCountryDropDown; final bool hasError; final String? errorMessage; + Function(CountryEnum)? onCountryChange; // final List countryList; // final Function(Country)? onCountryChange; - const TextInputWidget({ + TextInputWidget({ Key? key, required this.labelText, required this.hintText, @@ -52,6 +53,7 @@ class TextInputWidget extends StatelessWidget { this.isCountryDropDown = false, this.hasError = false, this.errorMessage, + this.onCountryChange, // this.countryList = const [], // this.onCountryChange, }) : super(key: key); @@ -74,32 +76,27 @@ class TextInputWidget extends StatelessWidget { child: Row( textDirection: Directionality.of(context), children: [ - if (isAllowLeadingIcon && leadingIcon != null && !isCountryDropDown) - _buildLeadingIcon(context), - isCountryDropDown - ? CustomCountryDropdown( - countryList: CountryEnum.values, - onCountryChange: (CountryEnum? value) { - print(value); - }, - isRtl: Directionality.of(context) == TextDirection.rtl, - isFromBottomSheet: isCountryDropDown, - isEnableTextField: true, - onPhoneNumberChanged: (value) { - print(value); - }, - textField: _buildTextField(context), - ) - : Expanded( - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _buildLabelText(), - _buildTextField(context), - ], - ), + if (isAllowLeadingIcon && leadingIcon != null && !isCountryDropDown) _buildLeadingIcon(context), + isCountryDropDown + ? CustomCountryDropdown( + countryList: CountryEnum.values, + onCountryChange: onCountryChange, + isRtl: Directionality.of(context) == TextDirection.rtl, + isFromBottomSheet: isCountryDropDown, + isEnableTextField: true, + onPhoneNumberChanged: onChange, + // textField: _buildTextField(context), + ) + : Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildLabelText(), + _buildTextField(context), + ], ), + ), ], ), ),