calender & signup fixes.

pull/8/head
aamir-csol 2 months ago
parent e41ffd583d
commit 3855ba276f

@ -22,13 +22,8 @@ class AppState {
set setUserLong(v) => userLong = v; set setUserLong(v) => userLong = v;
final PostParamsModel _postParamsInitConfig = PostParamsModel( final PostParamsModel _postParamsInitConfig =
channel: 3, PostParamsModel(channel: 3, versionID: ApiConsts.VERSION_ID, ipAddress: '10.20.10.20', generalId: 'Cs2020@2016\$2958', deviceTypeID: "2", sessionID: 'TMRhVmkGhOsvamErw');
versionID: ApiConsts.VERSION_ID,
ipAddress: '10.20.10.20',
generalId: 'Cs2020@2016\$2958',
deviceTypeID: "2",
sessionID: 'TMRhVmkGhOsvamErw');
void setPostParamsInitConfig() { void setPostParamsInitConfig() {
isAuthenticated = false; isAuthenticated = false;
@ -50,7 +45,9 @@ class AppState {
bool isArabic() => EasyLocalization.of(navigationService.navigatorKey.currentContext!)?.locale.languageCode == "ar"; bool isArabic() => EasyLocalization.of(navigationService.navigatorKey.currentContext!)?.locale.languageCode == "ar";
int getLanguageID(context) => EasyLocalization.of(context)?.locale.languageCode == "ar" ? 1 : 2; int getLanguageID() => EasyLocalization.of(navigationService.navigatorKey.currentContext!)?.locale.languageCode == "ar" ? 1 : 2;
String? getLanguageCode() => EasyLocalization.of(navigationService.navigatorKey.currentContext!)?.locale.languageCode;
AuthenticatedUser? _authenticatedUser; AuthenticatedUser? _authenticatedUser;

@ -1,8 +1,12 @@
import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_state.dart'; 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/enums.dart'; import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/request_utils.dart'; import 'package:hmg_patient_app_new/core/utils/request_utils.dart';
import 'package:hmg_patient_app_new/core/utils/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/features/authentication/authentication_repo.dart'; import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart';
import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_patient_authentication_request_model.dart'; import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_patient_authentication_request_model.dart';
import 'package:hmg_patient_app_new/services/dialog_service.dart'; import 'package:hmg_patient_app_new/services/dialog_service.dart';
@ -21,18 +25,53 @@ class AuthenticationViewModel extends ChangeNotifier {
required this.dialogService, required this.dialogService,
}); });
final TextEditingController nationalIdController = TextEditingController(); final TextEditingController nationalIdController = TextEditingController(), phoneNumberController = TextEditingController(), dobController = TextEditingController();
final TextEditingController phoneNumberController = TextEditingController(); CountryEnum selectedCountrySignup = CountryEnum.saudiArabia;
CountryEnum selectedCountry = CountryEnum.saudiArabia; MaritalStatusTypeEnum? maritalStatus;
GenderTypeEnum? genderType;
bool isTermsAccepted = false; bool isTermsAccepted = false;
List<NationalityCountries>? countriesList;
NationalityCountries? pickedCountryByUAEUser;
void login() { void login() {
if (ValidationUtils.isValidatePhoneAndId(nationalId: nationalIdController.text, phoneNumber: phoneNumberController.text)) { if (ValidationUtils.isValidatePhoneAndId(nationalId: nationalIdController.text, phoneNumber: phoneNumberController.text)) {
} else {} } else {}
} }
void clearDefaults() {
nationalIdController.clear();
phoneNumberController.clear();
dobController.clear();
maritalStatus = null;
genderType = null;
isTermsAccepted = false;
selectedCountrySignup = CountryEnum.saudiArabia;
pickedCountryByUAEUser = null;
}
void onCountryChange(CountryEnum country) { void onCountryChange(CountryEnum country) {
selectedCountry = country; selectedCountrySignup = country;
notifyListeners();
}
void loadCountriesData({required BuildContext context}) async {
final String response = await DefaultAssetBundle.of(context).loadString('assets/json/countriesList.json');
final List<dynamic> data = json.decode(response);
countriesList = data.map((e) => NationalityCountries.fromJson(e)).toList();
}
void onMaritalStatusChange(String? status) {
maritalStatus = MaritalStatusTypeExtension.fromType(status)!;
notifyListeners();
}
void onGenderChange(String? status) {
genderType = GenderTypeExtension.fromType(status)!;
notifyListeners();
}
void onUAEUserCountrySelection(String? value) {
pickedCountryByUAEUser = countriesList!.firstWhere((element) => element.name == value);
notifyListeners(); notifyListeners();
} }

@ -151,7 +151,7 @@ class _LoginScreen extends State<LoginScreen> {
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: SingleChildScrollView( child: SingleChildScrollView(
child: GenericBottomSheet( child: GenericBottomSheet(
countryCode: authVM.selectedCountry.countryCode, countryCode: authVM.selectedCountrySignup.countryCode,
initialPhoneNumber: "", initialPhoneNumber: "",
textController: authVM.phoneNumberController, textController: authVM.phoneNumberController,
isEnableCountryDropdown: true, isEnableCountryDropdown: true,

@ -83,30 +83,31 @@ class _RegisterNew extends State<RegisterNew> {
children: [ children: [
CustomCountryDropdown( CustomCountryDropdown(
countryList: CountryEnum.values, countryList: CountryEnum.values,
onCountryChange: (CountryEnum? value) {}, onCountryChange: authVm.onCountryChange,
isRtl: Directionality.of(context) == TextDirection.LTR, isRtl: Directionality.of(context) == TextDirection.LTR,
).withVerticalPadding(8.h), ).withVerticalPadding(8.h),
Divider(height: 1.h), Divider(height: 1.h),
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.nationalIdNumber.tr(), labelText: LocaleKeys.nationalIdNumber.tr(),
hintText: "xxxxxxxxx", hintText: "xxxxxxxxx",
controller: TextEditingController(), controller: authVm.nationalIdController,
isEnable: true, isEnable: true,
prefix: null, prefix: null,
isAllowRadius: true, isAllowRadius: true,
isBorderAllowed: false, isBorderAllowed: false,
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
autoFocus: true, autoFocus: true,
padding: EdgeInsets.symmetric(vertical: 8.h), padding: EdgeInsets.symmetric(vertical: 8.h),
leadingIcon: AppAssets.student_card, leadingIcon: AppAssets.student_card,
onChange: (value) { // onChange: (value) {
print(value); // print(value);
}).withVerticalPadding(8), // }
).withVerticalPadding(8),
Divider(height: 1), Divider(height: 1),
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.dob.tr(), labelText: LocaleKeys.dob.tr(),
hintText: "11 July, 1994", hintText: "11 July, 1994",
controller: TextEditingController(), controller: authVm.dobController,
isEnable: true, isEnable: true,
prefix: null, prefix: null,
isAllowRadius: true, isAllowRadius: true,
@ -114,7 +115,7 @@ class _RegisterNew extends State<RegisterNew> {
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
padding: EdgeInsets.symmetric(vertical: 8.h), padding: EdgeInsets.symmetric(vertical: 8.h),
leadingIcon: AppAssets.birthday_cake, leadingIcon: AppAssets.birthday_cake,
onChange: (value) {}, selectionType: SelectionTypeEnum.calendar,
).withVerticalPadding(8), ).withVerticalPadding(8),
], ],
), ),
@ -211,7 +212,7 @@ class _RegisterNew extends State<RegisterNew> {
padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom), padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom),
child: SingleChildScrollView( child: SingleChildScrollView(
child: GenericBottomSheet( child: GenericBottomSheet(
countryCode: authVM.selectedCountry.countryCode, countryCode: authVM.selectedCountrySignup.countryCode,
initialPhoneNumber: "", initialPhoneNumber: "",
textController: authVM.phoneNumberController, textController: authVM.phoneNumberController,
isEnableCountryDropdown: true, isEnableCountryDropdown: true,

@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:easy_localization/easy_localization.dart'; import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart'; import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart'; 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/common_models/nationality_country_model.dart';
@ -11,6 +12,7 @@ import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/extensions/context_extensions.dart'; import 'package:hmg_patient_app_new/extensions/context_extensions.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.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/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/generated/locale_keys.g.dart';
import 'package:hmg_patient_app_new/theme/colors.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/appbar/app_bar_widget.dart';
@ -18,6 +20,7 @@ import 'package:hmg_patient_app_new/widgets/bottomsheet/generic_bottom_sheet.dar
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart'; import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/dropdown/dropdown_widget.dart'; 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/input_widget.dart';
import 'package:provider/provider.dart';
class RegisterNewStep2 extends StatefulWidget { class RegisterNewStep2 extends StatefulWidget {
var nHICData; var nHICData;
@ -31,30 +34,31 @@ class RegisterNewStep2 extends StatefulWidget {
class _RegisterNew extends State<RegisterNewStep2> { class _RegisterNew extends State<RegisterNewStep2> {
bool isFromDubai = true; bool isFromDubai = true;
List<NationalityCountries> countriesList = []; AuthenticationViewModel? authVM;
AppState? appState;
GenderTypeEnum? selectedGenderType;
MaritalStatusTypeEnum? selectedMaritalStatusType;
CountryEnum? selectedCountry;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
authVM = context.read<AuthenticationViewModel>();
authVM!.loadCountriesData(context: context);
// isFromDubai = widget.payload.zipCode!.contains("971") || widget.payload.zipCode!.contains("+971"); // isFromDubai = widget.payload.zipCode!.contains("971") || widget.payload.zipCode!.contains("+971");
loadCountriesList();
} }
loadCountriesList() async { @override
appState = getIt.get<AppState>(); void dispose() {
final String response = await DefaultAssetBundle.of(context).loadString('assets/json/countriesList.json'); super.dispose();
final List<dynamic> data = json.decode(response); authVM!.clearDefaults();
countriesList = data.map((e) => NationalityCountries.fromJson(e)).toList();
} }
@override
Widget build(BuildContext context) { Widget build(BuildContext context) {
AppState appState = getIt.get<AppState>();
return Scaffold( return Scaffold(
appBar: CustomAppBar( appBar: CustomAppBar(
onBackPressed: () {}, onBackPressed: () {
Navigator.of(context).pop();
authVM!.clearDefaults();
},
onLanguageChanged: (lang) {}, onLanguageChanged: (lang) {},
hideLogoAndLang: true, hideLogoAndLang: true,
), ),
@ -84,10 +88,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
isReadOnly: isFromDubai ? false : true, isReadOnly: isFromDubai ? false : true,
leadingIcon: AppAssets.user_circle) leadingIcon: AppAssets.user_circle)
.paddingSymmetrical(0.h, 16.h), .paddingSymmetrical(0.h, 16.h),
Divider( Divider(height: 1, color: AppColors.greyColor),
height: 1,
color: AppColors.greyColor,
),
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.nationalIdNumber.tr(), labelText: LocaleKeys.nationalIdNumber.tr(),
hintText: isFromDubai ? "widget.payload.nationalID!" : (widget.nHICData!.idNumber ?? ""), hintText: isFromDubai ? "widget.payload.nationalID!" : (widget.nHICData!.idNumber ?? ""),
@ -100,28 +101,28 @@ class _RegisterNew extends State<RegisterNewStep2> {
isReadOnly: true, isReadOnly: true,
leadingIcon: AppAssets.student_card) leadingIcon: AppAssets.student_card)
.paddingSymmetrical(0.h, 16.h), .paddingSymmetrical(0.h, 16.h),
Divider( Divider(height: 1, color: AppColors.greyColor),
height: 1,
color: AppColors.greyColor,
),
isFromDubai isFromDubai
? DropdownWidget( ? Selector<AuthenticationViewModel, GenderTypeEnum?>(
labelText: LocaleKeys.gender.tr(), selector: (_, authViewModel) => authViewModel.genderType,
hintText: LocaleKeys.malE.tr(), shouldRebuild: (previous, next) => previous != next,
isEnable: true, builder: (context, genderType, child) {
dropdownItems: GenderTypeEnum.values.map((e) => appState!.isArabic() ? e.typeAr : e.type).toList(), final authVM = context.read<AuthenticationViewModel>();
selectedValue: appState!.isArabic() ? selectedGenderType!.typeAr : selectedGenderType?.type, return DropdownWidget(
// selectionType: SelectionType.dropdown, labelText: LocaleKeys.gender.tr(),
onChange: (val) { hintText: LocaleKeys.malE.tr(),
if (val != null) {} isEnable: true,
}, dropdownItems: GenderTypeEnum.values.map((e) => appState!.isArabic() ? e.typeAr : e.type).toList(),
isBorderAllowed: false, selectedValue: genderType != null ? (appState!.isArabic() ? genderType!.typeAr : genderType!.type) : "",
hasSelectionCustomIcon: true, onChange: authVM.onGenderChange,
isAllowRadius: false, isBorderAllowed: false,
padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), hasSelectionCustomIcon: true,
selectionCustomIcon: AppAssets.arrow_down, isAllowRadius: false,
leadingIcon: AppAssets.user_full, padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0),
).withVerticalPadding(8) selectionCustomIcon: AppAssets.arrow_down,
leadingIcon: AppAssets.user_full,
).withVerticalPadding(8);
})
: TextInputWidget( : TextInputWidget(
labelText: LocaleKeys.gender.tr(), labelText: LocaleKeys.gender.tr(),
hintText: (widget.nHICData!.gender ?? ""), hintText: (widget.nHICData!.gender ?? ""),
@ -135,25 +136,29 @@ class _RegisterNew extends State<RegisterNewStep2> {
leadingIcon: AppAssets.user_full, leadingIcon: AppAssets.user_full,
onChange: (value) {}) onChange: (value) {})
.paddingSymmetrical(0.h, 16.h), .paddingSymmetrical(0.h, 16.h),
Divider( Divider(height: 1, color: AppColors.greyColor),
height: 1,
color: AppColors.greyColor,
),
isFromDubai isFromDubai
? DropdownWidget( ? Selector<AuthenticationViewModel, MaritalStatusTypeEnum?>(
labelText: LocaleKeys.maritalStatus.tr(), selector: (_, authViewModel) => authViewModel.maritalStatus,
hintText: LocaleKeys.married.tr(), shouldRebuild: (previous, next) => previous != next,
isEnable: true, builder: (context, maritalStatus, child) {
dropdownItems: MaritalStatusTypeEnum.values.map((e) => appState!.isArabic() ? e.typeAr : e.type).toList(), final authVM = context.read<AuthenticationViewModel>(); // For onChange
selectedValue: appState!.isArabic() ? selectedMaritalStatusType!.typeAr : selectedMaritalStatusType?.type, return DropdownWidget(
onChange: (val) {}, labelText: LocaleKeys.maritalStatus.tr(),
isBorderAllowed: false, hintText: LocaleKeys.married.tr(),
hasSelectionCustomIcon: true, isEnable: true,
isAllowRadius: false, dropdownItems: MaritalStatusTypeEnum.values.map((e) => appState!.isArabic() ? e.typeAr : e.type).toList(),
padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), selectedValue: maritalStatus != null ? (appState!.isArabic() ? maritalStatus.typeAr : maritalStatus.type) : "",
selectionCustomIcon: AppAssets.arrow_down, onChange: authVM.onMaritalStatusChange,
leadingIcon: AppAssets.smart_phone, isBorderAllowed: false,
).withVerticalPadding(8) hasSelectionCustomIcon: true,
isAllowRadius: false,
padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0),
selectionCustomIcon: AppAssets.arrow_down,
leadingIcon: AppAssets.smart_phone,
).withVerticalPadding(8);
},
)
: TextInputWidget( : TextInputWidget(
labelText: LocaleKeys.maritalStatus.tr(), labelText: LocaleKeys.maritalStatus.tr(),
hintText: appState!.isArabic() hintText: appState!.isArabic()
@ -168,30 +173,41 @@ class _RegisterNew extends State<RegisterNewStep2> {
leadingIcon: AppAssets.smart_phone, leadingIcon: AppAssets.smart_phone,
onChange: (value) {}) onChange: (value) {})
.paddingSymmetrical(0.h, 16.h), .paddingSymmetrical(0.h, 16.h),
Divider( Divider(height: 1, color: AppColors.greyColor),
height: 1,
color: AppColors.greyColor,
),
isFromDubai isFromDubai
? DropdownWidget( ? Selector<AuthenticationViewModel, ({List<NationalityCountries>? countriesList, NationalityCountries? selectedCountry, bool isArabic})>(
labelText: LocaleKeys.country.tr(), selector: (context, authViewModel) {
hintText: LocaleKeys.uae.tr(), final appState = getIt.get<AppState>();
isEnable: true, return (countriesList: authViewModel.countriesList, selectedCountry: authViewModel.pickedCountryByUAEUser, isArabic: appState.isArabic());
dropdownItems: countriesList.map((e) => appState!.isArabic() ? e.nameN ?? "" : e.name ?? "").toList(), },
selectedValue: appState!.isArabic() ? selectedCountry!.nameArabic ?? "" : selectedCountry?.name ?? "", shouldRebuild: (previous, next) => previous.countriesList != next.countriesList || previous.selectedCountry != next.selectedCountry || previous.isArabic != next.isArabic,
onChange: (val) {}, builder: (context, data, child) {
isBorderAllowed: false, final authVM = context.read<AuthenticationViewModel>();
hasSelectionCustomIcon: true, return DropdownWidget(
isAllowRadius: false, labelText: LocaleKeys.country.tr(),
padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0), hintText: LocaleKeys.uae.tr(),
selectionCustomIcon: AppAssets.arrow_down, isEnable: true,
leadingIcon: AppAssets.globe, dropdownItems: (data.countriesList ?? []).map((e) => data.isArabic ? e.nameN ?? "" : e.name ?? "").toList(),
).withVerticalPadding(8) selectedValue: data.selectedCountry != null
? data.isArabic
? data.selectedCountry!.nameN ?? ""
: data.selectedCountry!.name ?? ""
: "",
onChange: authVM.onUAEUserCountrySelection,
isBorderAllowed: false,
hasSelectionCustomIcon: true,
isAllowRadius: false,
padding: const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0),
selectionCustomIcon: AppAssets.arrow_down,
leadingIcon: AppAssets.globe,
).withVerticalPadding(8);
},
)
: TextInputWidget( : TextInputWidget(
labelText: LocaleKeys.nationality.tr(), labelText: LocaleKeys.nationality.tr(),
hintText: appState!.isArabic() hintText: appState.isArabic()
? (countriesList.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).nameN ?? "") ? (authVM!.countriesList!.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).nameN ?? "")
: (countriesList.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).name ?? ""), : (authVM!.countriesList!.firstWhere((e) => e.id == (widget.nHICData!.nationalityCode ?? ""), orElse: () => NationalityCountries()).name ?? ""),
isEnable: true, isEnable: true,
prefix: null, prefix: null,
isAllowRadius: false, isAllowRadius: false,
@ -208,7 +224,7 @@ class _RegisterNew extends State<RegisterNewStep2> {
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.mobileNumber.tr(), labelText: LocaleKeys.mobileNumber.tr(),
hintText: ("widget.payload.mobileNo" ?? ""), hintText: ("widget.payload.mobileNo" ?? ""),
controller: null, controller: authVM!.phoneNumberController,
isEnable: true, isEnable: true,
prefix: null, prefix: null,
isAllowRadius: false, isAllowRadius: false,
@ -223,20 +239,17 @@ class _RegisterNew extends State<RegisterNewStep2> {
color: AppColors.greyColor, color: AppColors.greyColor,
), ),
TextInputWidget( TextInputWidget(
labelText: LocaleKeys.dob.tr(), labelText: LocaleKeys.dob.tr(),
hintText: isFromDubai ? "widget.payload.dob!" : (widget.nHICData!.dateOfBirth ?? ""), hintText: isFromDubai ? "widget.payload.dob!" : (widget.nHICData!.dateOfBirth ?? ""),
controller: null, controller: authVM!.dobController,
isEnable: true, isEnable: true,
prefix: null, prefix: null,
isBorderAllowed: false, isBorderAllowed: false,
isAllowLeadingIcon: true, isAllowLeadingIcon: true,
isReadOnly: true, isReadOnly: true,
// : SelectionType.calendar, leadingIcon: AppAssets.birthday_cake,
// selectedValue: widget.payload.dob != null ? Utils.formatDateToDisplay(widget.payload.dob.toString()) : null, selectionType: SelectionTypeEnum.calendar,
// selectionCustomIcon: AppAssets.calendar, ).paddingSymmetrical(0.h, 16.h),
leadingIcon: AppAssets.birthday_cake,
onChange: (value) {})
.paddingSymmetrical(0.h, 16.h),
], ],
), ),
), ),
@ -246,12 +259,12 @@ class _RegisterNew extends State<RegisterNewStep2> {
children: [ children: [
Expanded( Expanded(
child: CustomButton( child: CustomButton(
text: LocaleKeys.cancel, text: LocaleKeys.cancel.tr(),
icon: AppAssets.cancel, icon: AppAssets.cancel,
onPressed: () { onPressed: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
authVM!.clearDefaults();
}, },
// fontFamily: context.fontFamily,
backgroundColor: AppColors.secondaryLightRedColor, backgroundColor: AppColors.secondaryLightRedColor,
borderColor: AppColors.secondaryLightRedColor, borderColor: AppColors.secondaryLightRedColor,
textColor: AppColors.primaryRedColor, textColor: AppColors.primaryRedColor,

@ -1,11 +1,16 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hijri_gregorian_calendar/hijri_gregorian_calendar.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_export.dart'; import 'package:hmg_patient_app_new/core/app_export.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/enums.dart'; import 'package:hmg_patient_app_new/core/enums.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart'; import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/theme/colors.dart'; import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/dropdown/country_dropdown_widget.dart'; import 'package:hmg_patient_app_new/widgets/dropdown/country_dropdown_widget.dart';
import '../core/dependencies.dart';
// TODO: Import AppColors if bgRedColor is defined there // TODO: Import AppColors if bgRedColor is defined there
// import 'package:hmg_patient_app_new/core/ui_utils/app_colors.dart'; // import 'package:hmg_patient_app_new/core/ui_utils/app_colors.dart';
@ -29,6 +34,7 @@ class TextInputWidget extends StatelessWidget {
final bool hasError; final bool hasError;
final String? errorMessage; final String? errorMessage;
Function(CountryEnum)? onCountryChange; Function(CountryEnum)? onCountryChange;
SelectionTypeEnum? selectionType;
// final List<Country> countryList; // final List<Country> countryList;
// final Function(Country)? onCountryChange; // final Function(Country)? onCountryChange;
@ -54,6 +60,7 @@ class TextInputWidget extends StatelessWidget {
this.hasError = false, this.hasError = false,
this.errorMessage, this.errorMessage,
this.onCountryChange, this.onCountryChange,
this.selectionType,
// this.countryList = const [], // this.countryList = const [],
// this.onCountryChange, // this.onCountryChange,
}) : super(key: key); }) : super(key: key);
@ -97,6 +104,7 @@ class TextInputWidget extends StatelessWidget {
], ],
), ),
), ),
if (selectionType == SelectionTypeEnum.calendar) _buildTrailingIcon(context),
], ],
), ),
), ),
@ -128,6 +136,38 @@ class TextInputWidget extends StatelessWidget {
child: Utils.buildSvgWithAssets(icon: leadingIcon!)); child: Utils.buildSvgWithAssets(icon: leadingIcon!));
} }
Widget _buildTrailingIcon(BuildContext context) {
final AppState appState = getIt.get<AppState>();
return Container(
height: 40.h,
width: 40.h,
margin: EdgeInsets.zero,
padding: EdgeInsets.all(8.h),
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(borderRadius: 10.h, color: AppColors.whiteColor),
child: GestureDetector(
onTap: () async {
bool isGregorian = true;
final picked = await showHijriGregBottomSheet(context,
switcherIcon: Utils.buildSvgWithAssets(icon: AppAssets.language, width: 24.h, height: 24.h),
language: appState.getLanguageCode()!,
initialDate: DateTime.now(),
okWidget: Padding(padding: EdgeInsets.only(right: 8.h), child: Utils.buildSvgWithAssets(icon: AppAssets.confirm, width: 24.h, height: 24.h)),
cancelWidget: Padding(padding: EdgeInsets.only(right: 8.h), child: Utils.buildSvgWithAssets(icon: AppAssets.cancel, iconColor: Colors.white, width: 24.h, height: 24.h)),
onCalendarTypeChanged: (bool value) {
isGregorian = value;
});
if (picked != null && onChange != null) {
// if (onCalendarTypeChanged != null) {
// onCalendarTypeChanged.call(isGregorian);
// }
onChange!(picked.toIso8601String());
}
},
child: Utils.buildSvgWithAssets(icon: AppAssets.calendar),
),
);
}
Widget _buildLabelText() { Widget _buildLabelText() {
return Text( return Text(
labelText, labelText,
@ -154,23 +194,11 @@ class TextInputWidget extends StatelessWidget {
onChanged: onChange, onChanged: onChange,
focusNode: focusNode, focusNode: focusNode,
autofocus: autoFocus, autofocus: autoFocus,
style: TextStyle( style: TextStyle(fontSize: 14.fSize, height: 21 / 14, fontWeight: FontWeight.w500, color: AppColors.textColor, letterSpacing: -0.2),
fontSize: 14.fSize,
height: 21 / 14,
fontWeight: FontWeight.w500,
color: AppColors.textColor,
letterSpacing: -0.2,
),
decoration: InputDecoration( decoration: InputDecoration(
isDense: true, isDense: true,
hintText: hintText, hintText: hintText,
hintStyle: TextStyle( hintStyle: TextStyle(fontSize: 14.fSize, height: 21 / 16, fontWeight: FontWeight.w500, color: Color(0xff898A8D), letterSpacing: -0.2),
fontSize: 14.fSize,
height: 21 / 16,
fontWeight: FontWeight.w500,
color: Color(0xff898A8D),
letterSpacing: -0.2,
),
prefixIconConstraints: BoxConstraints(minWidth: 45.h), prefixIconConstraints: BoxConstraints(minWidth: 45.h),
prefixIcon: prefix == null prefixIcon: prefix == null
? null ? null

@ -742,6 +742,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "13.1.3" version: "13.1.3"
hijri_gregorian_calendar:
dependency: "direct main"
description:
name: hijri_gregorian_calendar
sha256: "9d23b52192783c1ad134b1ac001be7977342cb579c6b380647b6494fbd464d29"
url: "https://pub.dev"
source: hosted
version: "0.0.4"
html: html:
dependency: transitive dependency: transitive
description: description:
@ -1636,5 +1644,5 @@ packages:
source: hosted source: hosted
version: "6.5.0" version: "6.5.0"
sdks: sdks:
dart: ">=3.8.0-0 <4.0.0" dart: ">=3.8.1 <4.0.0"
flutter: ">=3.29.0" flutter: ">=3.29.0"

@ -68,6 +68,7 @@ dependencies:
web: any web: any
flutter_staggered_animations: ^1.1.1 flutter_staggered_animations: ^1.1.1
smooth_corner: ^1.1.1 smooth_corner: ^1.1.1
hijri_gregorian_calendar: ^0.0.4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save