merge-update-with-lab-changes
Aamir Muhammad 6 months ago committed by haroon amjad
parent ff12e832ab
commit e64d1088a6

@ -21,8 +21,8 @@ var PACKAGES_ORDERS = '/api/orders';
var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_ORDER_HISTORY = '/api/orders/items';
var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara';
// var BASE_URL = 'http://10.50.100.198:2018/'; // var BASE_URL = 'http://10.50.100.198:2018/';
// var BASE_URL = 'https://uat.hmgwebservices.com/'; var BASE_URL = 'https://uat.hmgwebservices.com/';
var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'https://hmgwebservices.com/';
// var BASE_URL = 'http://10.201.204.103/'; // var BASE_URL = 'http://10.201.204.103/';
// var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/';
// var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/';

@ -2329,7 +2329,7 @@ const Map localizedValues = {
"clickPrivacyPolicy": {"en": "Please click here to view the privacy policy", "ar": "الرجاء الضغط هنا لعرض سياسة الخصوصية"}, "clickPrivacyPolicy": {"en": "Please click here to view the privacy policy", "ar": "الرجاء الضغط هنا لعرض سياسة الخصوصية"},
"welcomeToDrSulaiman": {"en": "Welcome to Dr. Sulaiman Al Habib Medical Group", "ar": "مرحباً بكم في مجموعة الدكتور سليمان الحبيب الطبية"}, "welcomeToDrSulaiman": {"en": "Welcome to Dr. Sulaiman Al Habib Medical Group", "ar": "مرحباً بكم في مجموعة الدكتور سليمان الحبيب الطبية"},
"dontHaveAccount": {"en": "Dont have an account?", "ar": "ليس لديك حساب؟"}, "dontHaveAccount": {"en": "Dont have an account?", "ar": "ليس لديك حساب؟"},
"loginByOTP": {"en": "Login By SMS", "ar":" تسجيل الدخول بواسطة الرسائل القصيرة"}, "loginByOTP": {"en": "Login By OTP", "ar":"تسجيل الدخول بواسطة OTP"},
"loginBy": {"en": "Login By", "ar":"تسجيل الدخول بواسطة"}, "loginBy": {"en": "Login By", "ar":"تسجيل الدخول بواسطة"},
"prepareToElevate": {"en": "Prepared to elevate your health and well-being?", "ar": "هل أنت مستعد لتحسين صحتك ورفاهتك؟"}, "prepareToElevate": {"en": "Prepared to elevate your health and well-being?", "ar": "هل أنت مستعد لتحسين صحتك ورفاهتك؟"},
"alreadyHaveAccount": {"en": "Already have an account?", "ar": "هل لديك حساب بالفعل؟"}, "alreadyHaveAccount": {"en": "Already have an account?", "ar": "هل لديك حساب بالفعل؟"},
@ -2363,6 +2363,8 @@ const Map localizedValues = {
"otpVerification": {"en": "OTP Verification", "ar":"التحقق من OTP"}, "otpVerification": {"en": "OTP Verification", "ar":"التحقق من OTP"},
"submiT": {"en": "Submit", "ar":"إرسال"}, "submiT": {"en": "Submit", "ar":"إرسال"},
"notice": {"en": "Notice", "ar":"إشعار"}, "notice": {"en": "Notice", "ar":"إشعار"},
"receiveOtpToast": {"en": "Where would you like to receive OTP?", "ar":"أين تود تلقي رمز التحقق OTP؟"},
"pleaseChooseOption": {"en": "Please select from the below options to receive OTP.", "ar":"الرجاء اختيار من الخيارات أدناه لتلقي رمز التحقق OTP."},

@ -93,7 +93,7 @@ class _ExceptionBottomSheetState extends State<ExceptionBottomSheet> {
), ),
Expanded( Expanded(
child: CustomButton( child: CustomButton(
text: TranslationBase.of(context).ok, text: widget.showCancel ? TranslationBase.of(context).confirm : TranslationBase.of(context).ok,
onPressed: widget.onOkPressed, onPressed: widget.onOkPressed,
backgroundColor: CustomColors.bgRedColor, backgroundColor: CustomColors.bgRedColor,
borderColor: CustomColors.bgRedBorderColor, borderColor: CustomColors.bgRedBorderColor,

@ -19,11 +19,9 @@ class GenericBottomSheet extends StatefulWidget {
final bool isEnableCountryDropdown; final bool isEnableCountryDropdown;
final bool isFromSavedLogin; final bool isFromSavedLogin;
Function(String?)? onChange; Function(String?)? onChange;
FocusNode? focusNode;
GenericBottomSheet( GenericBottomSheet(
{Key? key, {this.countryCode = "",
this.countryCode = "",
this.initialPhoneNumber = "", this.initialPhoneNumber = "",
required this.buttons, required this.buttons,
this.textController, this.textController,
@ -31,9 +29,7 @@ class GenericBottomSheet extends StatefulWidget {
this.onCountryChange, this.onCountryChange,
this.isEnableCountryDropdown = false, this.isEnableCountryDropdown = false,
this.isFromSavedLogin = false, this.isFromSavedLogin = false,
this.focusNode, this.onChange});
this.onChange})
: super(key: key);
@override @override
_GenericBottomSheetState createState() => _GenericBottomSheetState(); _GenericBottomSheetState createState() => _GenericBottomSheetState();
@ -64,9 +60,7 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
// Only unfocus if the tap is not on the text field area // Only unfocus if the tap is not on the text field area
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
}, },
child: Builder(builder: (context) { child: Directionality(
// final isRtl = Directionality.of(context) == TextDirection.rtl;
return Directionality(
textDirection: Directionality.of(context), textDirection: Directionality.of(context),
child: Container( child: Container(
padding: const EdgeInsets.all(24), padding: const EdgeInsets.all(24),
@ -82,32 +76,86 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
// Title // Title
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
AppText(widget.isForEmail ? TranslationBase.of(context).enterEmail : TranslationBase.of(context).enterPhoneNumber, Flexible(
fontSize: 28, letterSpacing: -2, color: Color(0xFF2E3039), fontWeight: FontWeight.w600), child: AppText(
widget.isFromSavedLogin
? TranslationBase.of(context).receiveOtpToast
: widget.isForEmail
? TranslationBase.of(context).enterEmail
: TranslationBase.of(context).enterPhoneNumber,
fontSize: 28,
letterSpacing: -2,
color: Color(0xFF2E3039),
fontWeight: FontWeight.w600),
),
InkWell( InkWell(
onTap: () { onTap: () {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
child: SvgPicture.asset("assets/images/svg/cross-circle.svg", width: 24, height: 24)), child: Padding(
padding: const EdgeInsets.only(top: 10),
child: SvgPicture.asset("assets/images/svg/cross-circle.svg", width: 24, height: 24),
)),
], ],
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
// Subtitle // Subtitle
AppText(widget.isForEmail ? TranslationBase.of(context).enterEmailDesc : TranslationBase.of(context).enterPhoneDesc, AppText(
fontSize: 16, color: Color(0xFF2E3039), fontWeight: FontWeight.w500), widget.isFromSavedLogin
? TranslationBase.of(context).pleaseChooseOption
: widget.isForEmail
? TranslationBase.of(context).enterEmailDesc
: TranslationBase.of(context).enterPhoneDesc,
fontSize: 16,
color: Color(0xFF2E3039),
fontWeight: FontWeight.w500),
const SizedBox(height: 10), const SizedBox(height: 10),
if (widget.isFromSavedLogin)
...[]
else ...[
widget.textController != null widget.textController != null
? Column( ? Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
// Directionality(
// textDirection: TextDirection.ltr,
// child: newInputWidget(
// labelText: widget.isForEmail ? TranslationBase.of(context).email : TranslationBase.of(context).phoneNumber,
// hintText: widget.isForEmail ? "demo@gmail.com" : "5xxxxxxxx",
// controller: widget.textController,
// padding: const EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8),
// keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number,
// onChange: (value) {
// if (value != null) {
// widget.textController?.text = value;
// widget.onChange?.call(value);
// }
// },
// isEnable: true,
// autoFocus: true,
// keepFocus: true,
// refocusOnChange: true,
// isReadOnly: widget.isFromSavedLogin,
// prefix: widget.isForEmail ? null : widget.countryCode,
// hasSelection: false,
// isBorderAllowed: false,
// isAllowLeadingIcon: true,
// countryList: Country.values,
// isCountryDropDown: widget.isEnableCountryDropdown,
// onCountryChange: widget.onCountryChange,
// leadingIcon: widget.isForEmail ? "assets/images/svg/email.svg" : "assets/images/svg/smart-phone.svg",
// ),
// ),
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: newInputWidget( child: newInputWidget(
widget.isForEmail ? TranslationBase.of(context).email : TranslationBase.of(context).phoneNumber, widget.isForEmail ? TranslationBase.of(context).email : TranslationBase.of(context).phoneNumber,
widget.isForEmail ? "demo@gmail.com" : "5xxxxxxxx", widget.isForEmail ? "demo@gmail.com" : "5xxxxxxxx",
widget.textController!, widget.textController!,
focusNode: widget.focusNode!, // focusNode: widget.focusNode!,
padding: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8), padding: EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8),
keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number, keyboardType: widget.isForEmail ? TextInputType.emailAddress : TextInputType.number,
onChange: (value) { onChange: (value) {
@ -134,13 +182,14 @@ class _GenericBottomSheetState extends State<GenericBottomSheet> {
], ],
) )
: SizedBox(), : SizedBox(),
],
SizedBox(height: 24), SizedBox(height: 24),
...widget.buttons, ...widget.buttons,
], ],
), ),
), ),
); ),
}),
), ),
); );
} }

@ -42,27 +42,37 @@ class _CarbsState extends State<Carbs> {
double? fCalMeal; double? fCalMeal;
void calculateDietRatios() { void calculateDietRatios() {
if (dropdownValue == TranslationBase.of(context).dietVeryLow) { if (dropdownValue == TranslationBase
.of(context)
.dietVeryLow) {
meals = 3; meals = 3;
protein = 45; protein = 45;
carbs = 10; carbs = 10;
fat = 45; fat = 45;
} else if (dropdownValue == TranslationBase.of(context).dietLow) { } else if (dropdownValue == TranslationBase
.of(context)
.dietLow) {
meals = 3; meals = 3;
protein = 40; protein = 40;
carbs = 30; carbs = 30;
fat = 30; fat = 30;
} else if (dropdownValue == TranslationBase.of(context).dietModerate) { } else if (dropdownValue == TranslationBase
.of(context)
.dietModerate) {
meals = 3; meals = 3;
protein = 25; protein = 25;
carbs = 50; carbs = 50;
fat = 25; fat = 25;
} else if (dropdownValue == TranslationBase.of(context).dietUSDA) { } else if (dropdownValue == TranslationBase
.of(context)
.dietUSDA) {
meals = 3; meals = 3;
protein = 15; protein = 15;
carbs = 55; carbs = 55;
fat = 30; fat = 30;
} else if (dropdownValue == TranslationBase.of(context).dietZone) { } else if (dropdownValue == TranslationBase
.of(context)
.dietZone) {
meals = 3; meals = 3;
protein = 30; protein = 30;
carbs = 40; carbs = 40;
@ -88,13 +98,17 @@ class _CarbsState extends State<Carbs> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
dropdownValue = TranslationBase.of(context).dietVeryLow; dropdownValue = TranslationBase
.of(context)
.dietVeryLow;
return AppScaffold( return AppScaffold(
isShowAppBar: true, isShowAppBar: true,
isShowDecPage: false, isShowDecPage: false,
showNewAppBarTitle: true, showNewAppBarTitle: true,
showNewAppBar: true, showNewAppBar: true,
appBarTitle: TranslationBase.of(context).carbohydrate, appBarTitle: TranslationBase
.of(context)
.carbohydrate,
appBarIcons: [ appBarIcons: [
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0), padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 7.0),
@ -114,7 +128,9 @@ class _CarbsState extends State<Carbs> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
TranslationBase.of(context).carbProteinDesc, TranslationBase
.of(context)
.carbProteinDesc,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
@ -129,7 +145,9 @@ class _CarbsState extends State<Carbs> {
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
inputWidget(TranslationBase.of(context).calDay, "0", textController), inputWidget(TranslationBase
.of(context)
.calDay, "0", textController),
InkWell( InkWell(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
@ -140,8 +158,14 @@ class _CarbsState extends State<Carbs> {
child: Padding( child: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
child: Text( child: Text(
TranslationBase.of(context).notSure, TranslationBase
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, letterSpacing: -0.56, color: CustomColors.accentColor, decoration: TextDecoration.underline), .of(context)
.notSure,
style: TextStyle(fontSize: 12,
fontWeight: FontWeight.w600,
letterSpacing: -0.56,
color: CustomColors.accentColor,
decoration: TextDecoration.underline),
), ),
), ),
) )
@ -166,7 +190,9 @@ class _CarbsState extends State<Carbs> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
TranslationBase.of(context).selectDiet, TranslationBase
.of(context)
.selectDiet,
style: TextStyle( style: TextStyle(
fontSize: 11, fontSize: 11,
letterSpacing: -0.44, letterSpacing: -0.44,
@ -195,11 +221,21 @@ class _CarbsState extends State<Carbs> {
}); });
}, },
items: <String>[ items: <String>[
TranslationBase.of(context).dietVeryLow, TranslationBase
TranslationBase.of(context).dietLow, .of(context)
TranslationBase.of(context).dietModerate, .dietVeryLow,
TranslationBase.of(context).dietUSDA, TranslationBase
TranslationBase.of(context).dietZone .of(context)
.dietLow,
TranslationBase
.of(context)
.dietModerate,
TranslationBase
.of(context)
.dietUSDA,
TranslationBase
.of(context)
.dietZone
].map<DropdownMenuItem<String>>((String value) { ].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>( return DropdownMenuItem<String>(
value: value, value: value,
@ -233,7 +269,9 @@ class _CarbsState extends State<Carbs> {
margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0),
color: Colors.white, color: Colors.white,
child: SecondaryButton( child: SecondaryButton(
label: TranslationBase.of(context).calculate, label: TranslationBase
.of(context)
.calculate,
color: CustomColors.accentColor, color: CustomColors.accentColor,
onTap: () { onTap: () {
setState(() { setState(() {
@ -308,8 +346,7 @@ class _CarbsState extends State<Carbs> {
// } // }
} }
Widget inputWidget( Widget inputWidget(String _labelText,
String _labelText,
String _hintText, String _hintText,
TextEditingController? _controller, { TextEditingController? _controller, {
Function(String?)? onChange, Function(String?)? onChange,
@ -332,7 +369,7 @@ Widget inputWidget(
Function(bool)? onCalendarTypeChanged, Function(bool)? onCalendarTypeChanged,
EdgeInsetsGeometry? padding, EdgeInsetsGeometry? padding,
String lang = 'en', String lang = 'en',
}) { }) {
return Builder( return Builder(
builder: (context) { builder: (context) {
final isRtl = Directionality.of(context) == TextDirection.rtl; final isRtl = Directionality.of(context) == TextDirection.rtl;
@ -409,7 +446,8 @@ Widget inputWidget(
), ),
items: dropdownItems items: dropdownItems
?.map( ?.map(
(e) => PopupMenuItem<String>( (e) =>
PopupMenuItem<String>(
value: e, value: e,
child: Text(e), child: Text(e),
), ),
@ -458,9 +496,7 @@ Widget inputWidget(
}, },
); );
if (picked != null && onChange != null) { if (picked != null && onChange != null) {
print(picked.toIso8601String());
if (onCalendarTypeChanged != null) { if (onCalendarTypeChanged != null) {
print(isGregorian.toString());
onCalendarTypeChanged.call(isGregorian); onCalendarTypeChanged.call(isGregorian);
} }
onChange(picked.toIso8601String()); onChange(picked.toIso8601String());
@ -593,7 +629,8 @@ Widget newInputWidget(
FocusNode? focusNode, FocusNode? focusNode,
bool autoFocus = false, bool autoFocus = false,
Function(Country)? onCountryChange, Function(Country)? onCountryChange,
}) { Key? key,
}) {
return Builder( return Builder(
builder: (context) { builder: (context) {
// final isRtl = Directionality.of(context) == TextDirection.ltr; // final isRtl = Directionality.of(context) == TextDirection.ltr;
@ -699,6 +736,7 @@ Widget newInputWidget(
switcherIcon: SvgPicture.asset("assets/images/svg/language.svg", width: 24), switcherIcon: SvgPicture.asset("assets/images/svg/language.svg", width: 24),
// fontFamily: FontUtils.getFontFamily(context), // fontFamily: FontUtils.getFontFamily(context),
language: lang, language: lang,
fontFamily: FontUtils.getFontFamilyForLanguage(context.selectedLanguage == "ar" ? true : false),
initialShowGregorian: true, initialShowGregorian: true,
initialDate: DateTime.now(), initialDate: DateTime.now(),
okWidget: Padding( okWidget: Padding(
@ -760,13 +798,13 @@ Widget newInputWidget(
) )
: TextField( : TextField(
enabled: isEnable, enabled: isEnable,
key: key,
scrollPadding: EdgeInsets.zero, scrollPadding: EdgeInsets.zero,
keyboardType: keyboardType, keyboardType: keyboardType,
controller: _controller, controller: _controller,
readOnly: isReadOnly, readOnly: isReadOnly,
textAlignVertical: TextAlignVertical.top, textAlignVertical: TextAlignVertical.top,
textAlign: TextAlign.left, textAlign: TextAlign.left,
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
onChanged: onChange, onChanged: onChange,
focusNode: focusNode, focusNode: focusNode,
@ -817,8 +855,260 @@ Widget newInputWidget(
); );
} }
// Widget newInputWidget(String _labelText,
// String _hintText,
// TextEditingController? _controller, {
// Function(String?)? onChange,
// String? prefix,
// bool isEnable = true,
// bool hasSelection = false,
// bool hasSelectionCustomIcon = false,
// String? selectionCustomIcon,
// bool isBorderAllowed = true,
// bool isAllowLeadingIcon = false,
// bool isLeadingCountry = false,
// String? leadingIcon,
// bool removePadding = false,
// bool isAllowRadius = true,
// bool isReadOnly = false,
// TextInputType keyboardType = TextInputType.number,
// List<String>? dropdownItems,
// String? selectedValue,
// SelectionType? selectionType,
// Function(bool)? onCalendarTypeChanged,
// EdgeInsetsGeometry? padding,
// String lang = 'en',
// bool isCountryDropDown = false,
// List<Country> countryList = const [],
// FocusNode? focusNode,
// bool autoFocus = false,
// Function(Country)? onCountryChange,
// Key? key,
// }) {
// return Builder(
// builder: (context) {
// // final isRtl = Directionality.of(context) == TextDirection.ltr;
// return Container(
// padding: padding,
// // padding: removePadding && isAllowLeadingIcon && prefix == null
// // ? const EdgeInsets.only(top: 8, bottom: 8, left: 8, right: 8)
// // : removePadding && !hasSelection
// // ? const EdgeInsets.only(top: 8, bottom: 8, left: 0, right: 0)
// // : removePadding && hasSelection
// // ? null
// // : const EdgeInsets.symmetric(horizontal: 16, vertical: 15),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// borderRadius: isAllowRadius ? BorderRadius.circular(15) : null,
// color: Colors.white,
// border: isBorderAllowed ? Border.all(color: const Color(0xffefefef), width: 1) : null,
// ),
// child: Row(
// textDirection: Directionality.of(context),
// children: [
// if (isAllowLeadingIcon && leadingIcon != null)
// isCountryDropDown
// ? _CustomCountryDropdown(
// logo: SvgPicture.asset(
// prefix == "966" ? "assets/images/svg/ksa.svg" : "assets/images/svg/uae.svg",
// width: 40,
// height: 40,
// fit: BoxFit.cover,
// ),
// countryList: countryList,
// onCountryChange: onCountryChange,
// isRtl: Directionality.of(context) == TextDirection.rtl,
// )
// : Container(
// height: 40,
// width: 40,
// margin: const EdgeInsets.only(right: 10),
// padding: isLeadingCountry ? null : const EdgeInsets.all(8),
// decoration: const BoxDecoration(
// color: Color(0xFFEFEFF0),
// borderRadius: BorderRadius.all(Radius.circular(10)),
// ),
// child: SvgPicture.asset(
// leadingIcon,
// width: 24,
// height: 24,
// fit: BoxFit.cover,
// ),
// ),
// Expanded(
// child: Column(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text(
// _labelText,
// style: context.dynamicTextStyle(
// fontSize: 12,
// fontWeight: FontWeight.w500,
// color: const Color(0xff898A8D),
// letterSpacing: -0.2,
// height: 18 / 12,
// ),
// ),
// hasSelection
// ? GestureDetector(
// onTap: isEnable && !isReadOnly
// ? () async {
// if (selectionType == SelectionType.dropdown) {
// final renderBox = context.findRenderObject() as RenderBox;
// final offset = renderBox.localToGlobal(Offset.zero);
// final selected = await showMenu<String>(
// context: context,
// position: RelativeRect.fromLTRB(
// offset.dx,
// offset.dy + renderBox.size.height,
// offset.dx + renderBox.size.width,
// 0,
// ),
// items: dropdownItems
// ?.map(
// (e) =>
// PopupMenuItem<String>(
// value: e,
// child: Text(e),
// ),
// )
// .toList() ??
// [],
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(12),
// ),
// );
//
// if (selected != null) {
// _handleOnChange(selected);
// }
// } else if (widget.selectionType == SelectionType.calendar) {
// bool isGregorian = true;
// final picked = await showHijriGregBottomSheet(
// context,
// switcherIcon: SvgPicture.asset("assets/images/svg/language.svg", width: 24),
// language: widget.lang,
// fontFamily: FontUtils.getFontFamilyForLanguage(context.selectedLanguage == "ar" ? true : false),
// initialShowGregorian: true,
// initialDate: DateTime.now(),
// okWidget: Padding(
// padding: const EdgeInsets.only(right: 8.0),
// child: SvgPicture.asset(
// "assets/images/svg/confirm.svg",
// width: 24,
// height: 24,
// ),
// ),
// cancelWidget: Padding(
// padding: const EdgeInsets.only(right: 8.0),
// child: SvgPicture.asset(
// "assets/images/svg/cancel.svg",
// colorFilter: ColorFilter.mode(
// Colors.white,
// BlendMode.srcIn,
// ),
// width: 24,
// height: 24,
// ),
// ),
// onCalendarTypeChanged: (bool value) {
// isGregorian = value;
// },
// );
// if (picked != null) {
// if (widget.onCalendarTypeChanged != null) {
// widget.onCalendarTypeChanged!.call(isGregorian);
// }
// _handleOnChange(picked.toIso8601String());
// }
// }
// }
// : null,
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// Expanded(
// child: Text((selectedValue == null || selectedValue.isEmpty) ? _hintText : selectedValue,
// textAlign: TextAlign.left,
// textDirection: TextDirection.ltr,
// style: context.dynamicTextStyle(
// fontSize: 14,
// height: 21 / 14,
// fontWeight: FontWeight.w500,
// color: (selectedValue != null && selectedValue.isNotEmpty) ? const Color(0xff2E3039) : const Color(0xffB0B0B0),
// letterSpacing: -0.2,
// )),
// ),
// if (hasSelectionCustomIcon && selectionCustomIcon != null)
// SvgPicture.asset(selectionCustomIcon, width: 24, height: 24)
// else
// const Icon(Icons.keyboard_arrow_down_outlined),
// ],
// ),
// )
// : TextField(
// enabled: isEnable,
// key: key,
// scrollPadding: EdgeInsets.zero,
// keyboardType: keyboardType,
// controller: _controller,
// readOnly: isReadOnly,
// textAlignVertical: TextAlignVertical.top,
// textAlign: TextAlign.left,
// textDirection: TextDirection.ltr,
// onChanged: onChange,
// focusNode: focusNode,
// autofocus: autoFocus,
// style: context.dynamicTextStyle(
// fontSize: 14,
// height: 21 / 14,
// fontWeight: FontWeight.w500,
// color: const Color(0xff2E3039),
// letterSpacing: -0.2,
// ),
// decoration: InputDecoration(
// isDense: true,
// hintText: _hintText,
// hintStyle: context.dynamicTextStyle(
// fontSize: 14,
// height: 21 / 16,
// fontWeight: FontWeight.w500,
// color: const Color(0xff898A8D),
// letterSpacing: -0.2,
// ),
// prefixIconConstraints: const BoxConstraints(minWidth: 45),
// prefixIcon: prefix == null
// ? null
// : Text(
// "+" + prefix,
// style: context.dynamicTextStyle(
// fontSize: 14,
// height: 21 / 14,
// fontWeight: FontWeight.w500,
// color: const Color(0xff2E303A),
// letterSpacing: -0.2,
// ),
// ),
// contentPadding: EdgeInsets.zero,
// border: InputBorder.none,
// focusedBorder: InputBorder.none,
// enabledBorder: InputBorder.none,
// ),
// ),
// ],
// ),
// ),
// ],
// ),
// );
// },
// );
// }
extension BorderedContainer on Widget { extension BorderedContainer on Widget {
Widget get withBorderedContainer => Container( Widget get withBorderedContainer =>
Container(
padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15),
alignment: Alignment.center, alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
@ -891,7 +1181,8 @@ class __CustomCountryDropdownState extends State<_CustomCountryDropdown> {
Offset offset = renderBox.localToGlobal(Offset.zero); Offset offset = renderBox.localToGlobal(Offset.zero);
_overlayEntry = OverlayEntry( _overlayEntry = OverlayEntry(
builder: (context) => Stack( builder: (context) =>
Stack(
children: [ children: [
// Dismiss dropdown when tapping outside // Dismiss dropdown when tapping outside
Positioned.fill( Positioned.fill(
@ -920,7 +1211,8 @@ class __CustomCountryDropdownState extends State<_CustomCountryDropdown> {
child: Column( child: Column(
children: widget.countryList children: widget.countryList
.map( .map(
(country) => GestureDetector( (country) =>
GestureDetector(
onTap: () { onTap: () {
setState(() { setState(() {
selectedCountry = country; selectedCountry = country;
@ -965,3 +1257,364 @@ class __CustomCountryDropdownState extends State<_CustomCountryDropdown> {
}); });
} }
} }
class NewInputField extends StatefulWidget {
final String labelText;
final String hintText;
final TextEditingController? controller;
final Function(String?)? onChange;
final String? prefix;
final bool isEnable;
final bool hasSelection;
final bool hasSelectionCustomIcon;
final String? selectionCustomIcon;
final bool isBorderAllowed;
final bool isAllowLeadingIcon;
final bool isLeadingCountry;
final String? leadingIcon;
final bool removePadding;
final bool isAllowRadius;
final bool isReadOnly;
final TextInputType keyboardType;
final List<String>? dropdownItems;
final String? selectedValue;
final SelectionType? selectionType;
final Function(bool)? onCalendarTypeChanged;
final EdgeInsetsGeometry? padding;
final String lang;
final bool isCountryDropDown;
final List<Country> countryList;
final bool autoFocus;
final Function(Country)? onCountryChange;
final bool keepFocus; // New parameter to maintain focus
final bool refocusOnChange; // New parameter to refocus when onChange is triggered
const NewInputField({
required this.labelText,
required this.hintText,
this.controller,
this.onChange,
this.prefix,
this.isEnable = true,
this.hasSelection = false,
this.hasSelectionCustomIcon = false,
this.selectionCustomIcon,
this.isBorderAllowed = true,
this.isAllowLeadingIcon = false,
this.isLeadingCountry = false,
this.leadingIcon,
this.removePadding = false,
this.isAllowRadius = true,
this.isReadOnly = false,
this.keyboardType = TextInputType.number,
this.dropdownItems,
this.selectedValue,
this.selectionType,
this.onCalendarTypeChanged,
this.padding,
this.lang = 'en',
this.isCountryDropDown = false,
this.countryList = const [],
this.autoFocus = false,
this.onCountryChange,
this.keepFocus = false,
this.refocusOnChange = false,
});
@override
State<NewInputField> createState() => _NewInputFieldState();
}
class _NewInputFieldState extends State<NewInputField> {
late FocusNode _internalFocusNode;
bool _isInitialFocusSet = false;
bool _shouldMaintainFocus = false;
@override
void initState() {
super.initState();
_internalFocusNode = FocusNode();
_shouldMaintainFocus = widget.keepFocus;
// Add listener to handle focus loss if keepFocus is enabled
if (widget.keepFocus) {
_internalFocusNode.addListener(_handleFocusChange);
}
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (widget.autoFocus && !_isInitialFocusSet) {
_isInitialFocusSet = true;
_requestFocus();
}
}
@override
void didUpdateWidget(NewInputField oldWidget) {
super.didUpdateWidget(oldWidget);
// Update focus management settings if they changed
if (oldWidget.keepFocus != widget.keepFocus) {
_shouldMaintainFocus = widget.keepFocus;
if (widget.keepFocus) {
_internalFocusNode.addListener(_handleFocusChange);
} else {
_internalFocusNode.removeListener(_handleFocusChange);
}
}
}
void _handleFocusChange() {
// If keepFocus is enabled and focus is lost, regain it
if (_shouldMaintainFocus && !_internalFocusNode.hasFocus && mounted) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted && _internalFocusNode.canRequestFocus && !_internalFocusNode.hasFocus) {
_internalFocusNode.requestFocus();
}
});
}
}
void _requestFocus() {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted && _internalFocusNode.canRequestFocus) {
_internalFocusNode.requestFocus();
}
});
}
void _handleOnChange(String? value) {
// Call the original onChange callback
if (widget.onChange != null) {
widget.onChange!(value);
}
// If refocusOnChange is enabled, refocus the field
if (widget.refocusOnChange && mounted) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted && _internalFocusNode.canRequestFocus) {
_internalFocusNode.requestFocus();
}
});
}
}
@override
void dispose() {
_internalFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
padding: widget.padding,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: widget.isAllowRadius ? BorderRadius.circular(15) : null,
color: Colors.white,
border: widget.isBorderAllowed ? Border.all(color: const Color(0xffefefef), width: 1) : null,
),
child: Row(
textDirection: Directionality.of(context),
children: [
if (widget.isAllowLeadingIcon && widget.leadingIcon != null)
widget.isCountryDropDown
? _CustomCountryDropdown(
logo: SvgPicture.asset(
widget.prefix == "966" ? "assets/images/svg/ksa.svg" : "assets/images/svg/uae.svg",
width: 40,
height: 40,
fit: BoxFit.cover,
),
countryList: widget.countryList,
onCountryChange: widget.onCountryChange,
isRtl: Directionality.of(context) == TextDirection.rtl,
)
: Container(
height: 40,
width: 40,
margin: const EdgeInsets.only(right: 10),
padding: widget.isLeadingCountry ? null : const EdgeInsets.all(8),
decoration: const BoxDecoration(
color: Color(0xFFEFEFF0),
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: SvgPicture.asset(
widget.leadingIcon!,
width: 24,
height: 24,
fit: BoxFit.cover,
),
),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.labelText,
style: context.dynamicTextStyle(
fontSize: 12,
fontWeight: FontWeight.w500,
color: const Color(0xff898A8D),
letterSpacing: -0.2,
height: 18 / 12,
),
),
widget.hasSelection
? GestureDetector(
onTap: widget.isEnable && !widget.isReadOnly
? () async {
if (widget.selectionType == SelectionType.dropdown) {
final renderBox = context.findRenderObject() as RenderBox;
final offset = renderBox.localToGlobal(Offset.zero);
final selected = await showMenu<String>(
context: context,
position: RelativeRect.fromLTRB(
offset.dx,
offset.dy + renderBox.size.height,
offset.dx + renderBox.size.width,
0,
),
items: widget.dropdownItems
?.map(
(e) =>
PopupMenuItem<String>(
value: e,
child: Text(e),
),
)
.toList() ??
[],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
);
if (selected != null) {
_handleOnChange(selected);
}
} else if (widget.selectionType == SelectionType.calendar) {
bool isGregorian = true;
final picked = await showHijriGregBottomSheet(
context,
switcherIcon: SvgPicture.asset("assets/images/svg/language.svg", width: 24),
language: widget.lang,
fontFamily: FontUtils.getFontFamilyForLanguage(context.selectedLanguage == "ar" ? true : false),
initialShowGregorian: true,
initialDate: DateTime.now(),
okWidget: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: SvgPicture.asset(
"assets/images/svg/confirm.svg",
width: 24,
height: 24,
),
),
cancelWidget: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: SvgPicture.asset(
"assets/images/svg/cancel.svg",
colorFilter: ColorFilter.mode(
Colors.white,
BlendMode.srcIn,
),
width: 24,
height: 24,
),
),
onCalendarTypeChanged: (bool value) {
isGregorian = value;
},
);
if (picked != null) {
if (widget.onCalendarTypeChanged != null) {
widget.onCalendarTypeChanged!.call(isGregorian);
}
_handleOnChange(picked.toIso8601String());
}
}
}
: null,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: Text((widget.selectedValue == null || widget.selectedValue!.isEmpty) ? widget.hintText : widget.selectedValue!,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
style: context.dynamicTextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w500,
color: (widget.selectedValue != null && widget.selectedValue!.isNotEmpty) ? const Color(0xff2E3039) : const Color(0xffB0B0B0),
letterSpacing: -0.2,
)),
),
if (widget.hasSelectionCustomIcon && widget.selectionCustomIcon != null)
SvgPicture.asset(widget.selectionCustomIcon!, width: 24, height: 24)
else
const Icon(Icons.keyboard_arrow_down_outlined),
],
),
)
: TextField(
enabled: widget.isEnable,
scrollPadding: EdgeInsets.zero,
keyboardType: widget.keyboardType,
controller: widget.controller,
readOnly: widget.isReadOnly,
textAlignVertical: TextAlignVertical.top,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
onChanged:_handleOnChange,
focusNode: _internalFocusNode,
autofocus: widget.autoFocus,
style: context.dynamicTextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w500,
color: const Color(0xff2E3039),
letterSpacing: -0.2,
),
decoration: InputDecoration(
isDense: true,
hintText: widget.hintText,
hintStyle: context.dynamicTextStyle(
fontSize: 14,
height: 21 / 16,
fontWeight: FontWeight.w500,
color: const Color(0xff898A8D),
letterSpacing: -0.2,
),
prefixIconConstraints: const BoxConstraints(minWidth: 45),
prefixIcon: widget.prefix == null
? null
: Text(
"+" + widget.prefix!,
style: context.dynamicTextStyle(
fontSize: 14,
height: 21 / 14,
fontWeight: FontWeight.w500,
color: const Color(0xff2E303A),
letterSpacing: -0.2,
),
),
contentPadding: EdgeInsets.zero,
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
),
),
],
),
),
],
),
);
}
}

@ -548,31 +548,34 @@ class _RegisterNew extends State<RegisterNew> {
request.isRegister = true; request.isRegister = true;
request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
request.isHijri = isHijri ?? 0; request.isHijri = isHijri ?? 0;
this.checkPatientForRegisteration(registrationData: request, type: type); checkPatientForRegistration(registrationData: request, type: type);
// } // }
} }
checkPatientForRegisteration({required CheckPatientForRegistration registrationData, type}) { checkPatientForRegistration({required CheckPatientForRegistration registrationData, type}) {
int languageID = Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 1 : 2; int languageID = Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 1 : 2;
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
authService.checkPatientForRegisteration(registrationData, languageID).then((response) => {checkUserStatus(response, registrationData, type)}).catchError((err) { authService.checkPatientForRegisteration(registrationData, languageID).then((response) => {
// Keep loader active, continue to next step
checkUserStatus(response, registrationData, type)
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
ConfirmDialog dialog = ConfirmDialog(
context: context, context.showBottomSheet(
confirmMessage: err, child: ExceptionBottomSheet(
okText: TranslationBase.of(context).confirm, showCancel: true,
cancelText: TranslationBase.of(context).cancel_nocaps, message: err,
okFunction: () => { onOkPressed: () {
ConfirmDialog.closeAlertDialog(context), Navigator.of(context).pop();
Navigator.of(context).push(FadePage(page: RegisterNew())), Navigator.of(context).push(FadePage(page: RegisterNew()));
}, },
cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)}); ),
dialog.showAlertDialog(context); );
}); });
} }
checkUserStatus(response, CheckPatientForRegistration request, type) async { checkUserStatus(response, CheckPatientForRegistration request, type) async {
GifLoaderDialogUtils.hideDialog(context); // No loader shown here since it's already hidden in checkPatientForRegisteration
if (response is Map) { if (response is Map) {
var nRequest = request.toJson(); var nRequest = request.toJson();
nRequest['LogInTokenID'] = response['LogInTokenID']; nRequest['LogInTokenID'] = response['LogInTokenID'];
@ -609,20 +612,19 @@ class _RegisterNew extends State<RegisterNew> {
} else { } else {
// if (response['ErrorCode'] == '-986') { // if (response['ErrorCode'] == '-986') {
//AppToast.showErrorToast(message: response); //AppToast.showErrorToast(message: response);
AlertDialogBox( context.showBottomSheet(
context: context, child: ExceptionBottomSheet(
confirmMessage: response, message: response,
okText: TranslationBase.of(context).ok, onOkPressed: () {
okFunction: () {
AlertDialogBox.closeAlertDialog(context);
Navigator.of(context).pop(); Navigator.of(context).pop();
}).showAlertDialog(context); },
//} ),
);
} }
} }
chekUserData(loginToken, int type) { chekUserData(loginToken, int type) {
GifLoaderDialogUtils.showMyDialog(context); // Keep existing loader active, don't show new one
var request = CheckUserStatusRequest(); var request = CheckUserStatusRequest();
request.patientIdentificationID = nationalIDorFile.text; request.patientIdentificationID = nationalIDorFile.text;
request.dOB = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); request.dOB = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
@ -630,19 +632,17 @@ class _RegisterNew extends State<RegisterNew> {
request.patientOutSA = selectedCountry.countryCode == '966' ? 0 : 1; request.patientOutSA = selectedCountry.countryCode == '966' ? 0 : 1;
this.authService.checkUserStatus(request).then((result) { this.authService.checkUserStatus(request).then((result) {
GifLoaderDialogUtils.hideDialog(context); // Keep loader active, continue to next step
if (result is Map) { if (result is Map) {
RegisterInfoResponse? resultSet; RegisterInfoResponse? resultSet;
CheckUserStatusResponse res = CheckUserStatusResponse.fromJson(result as Map<String, dynamic>); CheckUserStatusResponse res = CheckUserStatusResponse.fromJson(result as Map<String, dynamic>);
nHICData = res; nHICData = res;
sharedPref.setObject(NHIC_DATA, res.toJson()); sharedPref.setObject(NHIC_DATA, res.toJson());
resultSet = RegisterInfoResponse.fromJson(res.toJson()); resultSet = RegisterInfoResponse.fromJson(res.toJson());
// widget.changePageViewIndex!(1),
// Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex, fromRegistration: true))),
sendActivationCode(type, loginToken, resultSet, isSkipRegistration); sendActivationCode(type, loginToken, resultSet, isSkipRegistration);
} else { } else {
GifLoaderDialogUtils.hideDialog(context);
context.showBottomSheet( context.showBottomSheet(
child: ExceptionBottomSheet( child: ExceptionBottomSheet(
message: result != null ? result : TranslationBase.of(context).somethingWentWrong, message: result != null ? result : TranslationBase.of(context).somethingWentWrong,
@ -653,6 +653,17 @@ class _RegisterNew extends State<RegisterNew> {
), ),
); );
} }
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
context.showBottomSheet(
child: ExceptionBottomSheet(
message: err.toString(),
showCancel: false,
onOkPressed: () {
Navigator.of(context).pop();
},
),
);
}); });
} }
@ -666,13 +677,12 @@ class _RegisterNew extends State<RegisterNew> {
patientOutSA: selectedCountry.countryCode == "966" ? 0 : 1, patientOutSA: selectedCountry.countryCode == "966" ? 0 : 1,
loginTokenID: LoginTokenID, loginTokenID: LoginTokenID,
selectedOption: type, selectedOption: type,
type: type,
user: SelectDeviceIMEIRES()); user: SelectDeviceIMEIRES());
request.isRegister = true; request.isRegister = true;
request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!); request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
request.sMSSignature = await SMSOTP.getSignature(); request.sMSSignature = await SMSOTP.getSignature();
// print(request.oTPSendType); print("Otp Send Type =" + request.oTPSendType.toString());
// request.oTPSendType = type;
GifLoaderDialogUtils.showMyDialog(context);
if (selectedCountry.countryCode == "966" && !skipRegistration) { if (selectedCountry.countryCode == "966" && !skipRegistration) {
request.healthId = nHICData!.healthId; request.healthId = nHICData!.healthId;
@ -683,11 +693,13 @@ class _RegisterNew extends State<RegisterNew> {
request.patientIdentificationID = nationalIDorFile.text; request.patientIdentificationID = nationalIDorFile.text;
} }
request.isHijri = isHijri ?? 0; request.isHijri = isHijri ?? 0;
// request.oTPSendType = type;
if (skipRegistration) { if (skipRegistration) {
// Keep existing loader active, don't show new one
var req = getCommonRequest(type: type); var req = getCommonRequest(type: type);
req.logInTokenID = ""; req.logInTokenID = "";
var request = CheckPatientAuthenticationReq.fromJson(req.toJson()); var request = CheckPatientAuthenticationReq.fromJson(req.toJson());
authService.checkPatientAuthentication(request).then((value) async { authService.checkPatientAuthentication(request).then((value) async {
if (value['isSMSSent']) { if (value['isSMSSent']) {
sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']); sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']);
@ -700,6 +712,7 @@ class _RegisterNew extends State<RegisterNew> {
request.isHijri = 0; request.isHijri = 0;
await authService.sendActivationCode(request).then((result) { await authService.sendActivationCode(request).then((result) {
// Hide loader before navigation to SMS OTP
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if (result != null && result['isSMSSent'] == true) { if (result != null && result['isSMSSent'] == true) {
startSMSService(request.loginType, skipRegistration); startSMSService(request.loginType, skipRegistration);
@ -718,7 +731,12 @@ class _RegisterNew extends State<RegisterNew> {
}); });
} else { } else {
if (value['IsAuthenticated']) { if (value['IsAuthenticated']) {
checkActivationCode(onWrongActivationCode: (String? message, bool? isReroute) {}); // Keep loader active and proceed to checkActivationCode
checkActivationCode(onWrongActivationCode: (String? message, bool? isReroute) {
GifLoaderDialogUtils.hideDialog(context);
});
} else {
GifLoaderDialogUtils.hideDialog(context);
} }
} }
}).catchError((err) { }).catchError((err) {
@ -736,11 +754,12 @@ class _RegisterNew extends State<RegisterNew> {
); );
}); });
} else { } else {
// Keep existing loader active, don't show new one
await this.authService.sendActivationCodeRegister(request).then((result) { await this.authService.sendActivationCodeRegister(request).then((result) {
// Hide loader before navigation to SMS OTP
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if (result != null && result['isSMSSent'] == true) { if (result != null && result['isSMSSent'] == true) {
print(result); print(result);
// LoginTokenID = result["LogInTokenID"];
startSMSService(type, skipRegistration); startSMSService(type, skipRegistration);
} }
}).catchError((r) { }).catchError((r) {
@ -840,6 +859,7 @@ class _RegisterNew extends State<RegisterNew> {
result = await authService.checkActivationCodeRegister(req.toJson(), value); result = await authService.checkActivationCodeRegister(req.toJson(), value);
if (result is Map) { if (result is Map) {
final activation = CheckActivationCode.fromJson(result as Map<String, dynamic>); final activation = CheckActivationCode.fromJson(result as Map<String, dynamic>);
GifLoaderDialogUtils.hideDialog(context);
Navigator.of(context).push( Navigator.of(context).push(
FadePage(page: RegisterNewStep2(nHICData, req)), FadePage(page: RegisterNewStep2(nHICData, req)),
); );
@ -916,6 +936,7 @@ class _RegisterNew extends State<RegisterNew> {
startSMSService(type, skipRegistration) { startSMSService(type, skipRegistration) {
late SMSOTP smsOtp; late SMSOTP smsOtp;
smsOtp = SMSOTP( smsOtp = SMSOTP(
context, context,
type, type,

@ -191,9 +191,9 @@ class _SavedLogin extends State<SavedLogin> {
checkUserAuthentication(val); checkUserAuthentication(val);
} }
}, },
backgroundColor: Color(0xffFEE9EA), backgroundColor: Color(0xffED1C2B),
borderColor: Color(0xffFEE9EA), borderColor: Color(0xffFEE9EA),
textColor: Color(0xffED1C2B), textColor: Colors.white,
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
borderRadius: 12, borderRadius: 12,
@ -217,37 +217,120 @@ class _SavedLogin extends State<SavedLogin> {
widget.savedLoginData.logInType != null && widget.savedLoginData.logInType != 1 widget.savedLoginData.logInType != null && widget.savedLoginData.logInType != 1
? Column( ? Column(
children: [ children: [
widget.savedLoginData.logInType !=1 ? CustomButton( widget.savedLoginData.logInType != 1
? CustomButton(
text: TranslationBase.of(context).loginByOTP, text: TranslationBase.of(context).loginByOTP,
onPressed: () { onPressed: () {
showModalBottomSheet(
context: context,
isScrollControlled: true,
isDismissible: false,
useSafeArea: true,
backgroundColor: Colors.transparent,
enableDrag: false,
// Prevent dragging to avoid focus conflicts
builder: (bottomSheetContext) => StatefulBuilder(builder: (BuildContext context, StateSetter setModalState) {
return Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(bottomSheetContext).viewInsets.bottom),
child: SingleChildScrollView(
child: GenericBottomSheet(
countryCode: selectedCountry.countryCode,
initialPhoneNumber: phoneNumber != null ? phoneNumber : "",
textController: phoneController,
isFromSavedLogin: true,
isEnableCountryDropdown: true,
onCountryChange: (value) {
selectedCountry = value;
setModalState(() {});
},
onChange: (String? value) {
phoneNumber = value;
},
buttons: [
Padding(
padding: const EdgeInsets.only(bottom: 10),
child: CustomButton(
text: TranslationBase.of(context).sendOTPSMS,
onPressed: () {
// int? val = Utils.onOtpBtnPressed(OTPType.sms, phoneNumber, context);
// if (val != null) checkUserAuthentication(val);
Navigator.of(context).pop();
widget.savedLoginData.logInType = 1; widget.savedLoginData.logInType = 1;
int? val = widget.savedLoginData.logInType!; int? val = widget.savedLoginData.logInType!;
checkUserAuthentication(val); checkUserAuthentication(val);
}, },
backgroundColor: Colors.white, backgroundColor: CustomColors.bgRedColor,
borderColor: Color(0xFF2E3039), borderColor: CustomColors.bgRedBorderColor,
textColor: Color(0xFF2E3039), textColor: Colors.white,
borderWidth: 2, icon: "assets/images/svg/message.svg",
padding: EdgeInsets.fromLTRB(0, 14, 0, 14),
icon: "assets/images/svg/password-validation.svg",
) : Container(),
SizedBox(
height: 20,
), ),
widget.savedLoginData.logInType !=4 ? CustomButton( ),
text: "${TranslationBase.of(context).loginBy} ${getType(4, context)}", Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: AppText(
TranslationBase.of(context).oR,
fontSize: 16,
color: Color(0xFF2E3039),
fontWeight: FontWeight.w500,
),
),
],
),
Padding(
padding: const EdgeInsets.only(bottom: 10, top: 10),
child: CustomButton(
text: TranslationBase.of(context).sendOTPWHATSAPP,
onPressed: () { onPressed: () {
Navigator.of(context).pop();
widget.savedLoginData.logInType = 4; widget.savedLoginData.logInType = 4;
int? val = widget.savedLoginData.logInType!; int? val = widget.savedLoginData.logInType!;
checkUserAuthentication(val); checkUserAuthentication(val);
// int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, phoneNumber, context);
// if (val != null) checkUserAuthentication(val);
},
backgroundColor: Colors.white,
borderColor: Color(0xFF2E3039),
textColor: Color(0xFF2E3039),
icon: "assets/images/svg/whatsapp.svg",
),
),
],
),
),
);
}),
);
}, },
backgroundColor: Colors.white, backgroundColor: Colors.white,
borderColor: Color(0xFF2E3039), borderColor: Color(0xFF2E3039),
textColor: Color(0xFF2E3039), textColor: Color(0xFF2E3039),
borderWidth: 2, borderWidth: 2,
padding: EdgeInsets.fromLTRB(0, 14, 0, 14), padding: EdgeInsets.fromLTRB(0, 14, 0, 14),
icon: "assets/images/svg/whatsapp.svg", icon: "assets/images/svg/password-validation.svg",
) : Container(), )
: Container(),
SizedBox(
height: 20,
),
// widget.savedLoginData.logInType !=4 ? CustomButton(
// text: "${TranslationBase.of(context).loginBy} ${getType(4, context)}",
// onPressed: () {
// widget.savedLoginData.logInType = 4;
// int? val = widget.savedLoginData.logInType!;
// checkUserAuthentication(val);
// },
// backgroundColor: Colors.white,
// borderColor: Color(0xFF2E3039),
// textColor: Color(0xFF2E3039),
// borderWidth: 2,
// padding: EdgeInsets.fromLTRB(0, 14, 0, 14),
// icon: "assets/images/svg/whatsapp.svg",
// ) : Container(),
], ],
) )
: CustomButton( : CustomButton(
@ -276,33 +359,78 @@ class _SavedLogin extends State<SavedLogin> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
TextButton( Expanded(
child: Container(
height: 56,
child: CustomButton(
text: TranslationBase.of(context).guest,
onPressed: () { onPressed: () {
Navigator.of(context).pushReplacement( Navigator.of(context).pushReplacement(
MaterialPageRoute( MaterialPageRoute(builder: (BuildContext context) => LandingPage()),
builder: (BuildContext context) => LandingPage(),
),
); );
}, },
child: Text( backgroundColor: Color(0xffFEE9EA),
TranslationBase.of(context).guest, borderColor: Color(0xffFEE9EA),
style: context.dynamicTextStyle(color: CustomColors.bgRedColor, fontSize: 16, fontWeight: FontWeight.w500, height: 16 / 26), textColor: Color(0xffED1C2B),
fontSize: 12,
fontWeight: FontWeight.w500,
borderRadius: 12,
padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
// icon: "assets/images/svg/apple-finder.svg",
),
), ),
), ),
const SizedBox(width: 24), SizedBox(
TextButton( width: 24,
),
Expanded(
child: Container(
height: 56,
child: CustomButton(
text: TranslationBase.of(context).switchAccount,
onPressed: () { onPressed: () {
Navigator.of(context).pushReplacement( Navigator.of(context).pushReplacement(
MaterialPageRoute( MaterialPageRoute(builder: (BuildContext context) => WelcomeLogin()),
builder: (BuildContext context) => WelcomeLogin(),
),
); );
}, },
child: Text( backgroundColor: Color(0xffFEE9EA),
TranslationBase.of(context).switchAccount, borderColor: Color(0xffFEE9EA),
style: context.dynamicTextStyle(color: CustomColors.bgRedColor, fontSize: 16, fontWeight: FontWeight.w500, height: 16 / 26), textColor: Color(0xffED1C2B),
fontSize: 12,
fontWeight: FontWeight.w500,
borderRadius: 12,
padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
// icon: "assets/images/svg/apple-finder.svg",
),
), ),
), ),
// TextButton(
// onPressed: () {
// Navigator.of(context).pushReplacement(
// MaterialPageRoute(
// builder: (BuildContext context) => LandingPage(),
// ),
// );
// },
// child: Text(
// TranslationBase.of(context).guest,
// style: context.dynamicTextStyle(color: CustomColors.bgRedColor, fontSize: 16, fontWeight: FontWeight.w500, height: 16 / 26),
// ),
// ),
// const SizedBox(width: 24),
// TextButton(
// onPressed: () {
// Navigator.of(context).pushReplacement(
// MaterialPageRoute(
// builder: (BuildContext context) => WelcomeLogin(),
// ),
// );
// },
// child: Text(
// TranslationBase.of(context).switchAccount,
// style: context.dynamicTextStyle(color: CustomColors.bgRedColor, fontSize: 16, fontWeight: FontWeight.w500, height: 16 / 26),
// ),
// ),
], ],
), ),
const SizedBox(height: 20), const SizedBox(height: 20),

@ -90,19 +90,16 @@ class _WelcomeLogin extends State<WelcomeLogin> {
late int isHijri; late int isHijri;
var healthId; var healthId;
late FocusNode _focusNode;
@override @override
void initState() { void initState() {
isLoading = true; isLoading = true;
super.initState(); super.initState();
_focusNode = FocusNode();
phoneController = TextEditingController(); phoneController = TextEditingController();
} }
@override @override
void dispose() { void dispose() {
_focusNode.dispose();
super.dispose(); super.dispose();
} }
@ -210,7 +207,6 @@ class _WelcomeLogin extends State<WelcomeLogin> {
countryCode: selectedCountry.countryCode, countryCode: selectedCountry.countryCode,
initialPhoneNumber: phoneNumber != null ? phoneNumber : "", initialPhoneNumber: phoneNumber != null ? phoneNumber : "",
textController: phoneController, textController: phoneController,
focusNode: _focusNode,
isEnableCountryDropdown: true, isEnableCountryDropdown: true,
onCountryChange: (value) { onCountryChange: (value) {
selectedCountry = value; selectedCountry = value;
@ -218,15 +214,6 @@ class _WelcomeLogin extends State<WelcomeLogin> {
}, },
onChange: (String? value) { onChange: (String? value) {
phoneNumber = value; phoneNumber = value;
// WidgetsBinding.instance.addPostFrameCallback((_) {
// Future.delayed(Duration(milliseconds: 300), () {
// if (mounted && _focusNode.canRequestFocus) {
// _focusNode.requestFocus();
// }
// });
// });
FocusNode().requestFocus(_focusNode);
}, },
buttons: [ buttons: [
Padding( Padding(

@ -3510,6 +3510,8 @@ class TranslationBase {
String get otpVerfication => localizedValues["otpVerification"][locale.languageCode]; String get otpVerfication => localizedValues["otpVerification"][locale.languageCode];
String get submiT => localizedValues["submiT"][locale.languageCode]; String get submiT => localizedValues["submiT"][locale.languageCode];
String get notice => localizedValues["notice"][locale.languageCode]; String get notice => localizedValues["notice"][locale.languageCode];
String get receiveOtpToast => localizedValues["receiveOtpToast"][locale.languageCode];
String get pleaseChooseOption => localizedValues["pleaseChooseOption"][locale.languageCode];
String get readMore => localizedValues["readMore"][locale.languageCode]; String get readMore => localizedValues["readMore"][locale.languageCode];
String get showLess => localizedValues["showLess"][locale.languageCode]; String get showLess => localizedValues["showLess"][locale.languageCode];

@ -136,7 +136,7 @@ class SMSOTP {
child: OTPWidget( child: OTPWidget(
autoFocus: true, autoFocus: true,
controller: _pinPutController, controller: _pinPutController,
defaultBorderColor: Color(0xffE0E0E0), // Changed from white to light gray defaultBorderColor: Color(0xffffffff),
maxLength: 4, maxLength: 4,
onTextChanged: (text) {}, onTextChanged: (text) {},
pinBoxColor: Colors.white, pinBoxColor: Colors.white,

@ -165,28 +165,11 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
} }
} }
// Updated: Accept context to access MediaQuery // Updated: Always use full screen width for responsive design
double _width(BuildContext context) { double _width(BuildContext context) {
// For tablets, use full screen width
if (MediaQuery.of(context).size.shortestSide >= 600) {
return MediaQuery.of(context).size.width; return MediaQuery.of(context).size.width;
} }
// For phones, use original fixed width
var width = 0.0;
for (var i = 0; i < widget.maxLength; i++) {
width += widget.pinBoxWidth;
if (i == 0) {
width += widget.pinBoxOuterPadding.left;
} else if (i + 1 == widget.maxLength) {
width += widget.pinBoxOuterPadding.right;
} else {
width += widget.pinBoxOuterPadding.left;
}
}
return width;
}
@override @override
void dispose() { void dispose() {
if (widget.focusNode == null) { if (widget.focusNode == null) {
@ -298,31 +281,27 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
Widget _pinBoxRow(BuildContext context) { Widget _pinBoxRow(BuildContext context) {
_calculateStrList(); _calculateStrList();
// Determine if it's a tablet // Calculate dynamic width for all screen sizes to prevent scrolling
bool isTablet = MediaQuery.of(context).size.shortestSide >= 600;
double boxWidth = widget.pinBoxWidth;
// Calculate dynamic width for tablets
if (isTablet) {
double screenWidth = MediaQuery.of(context).size.width; double screenWidth = MediaQuery.of(context).size.width;
double totalMargin = (widget.maxLength - 1) * double totalHorizontalPadding = widget.pinBoxOuterPadding.left + widget.pinBoxOuterPadding.right;
(widget.pinBoxOuterPadding.left + widget.pinBoxOuterPadding.right); double totalMargin = widget.maxLength * totalHorizontalPadding;
double availableWidth = screenWidth - totalMargin; double availableWidth = screenWidth - totalMargin - 32; // 32 for additional safe padding
boxWidth = (availableWidth / widget.maxLength).clamp(100.0, 180.0); // Reasonable limits double boxWidth = (availableWidth / widget.maxLength).clamp(60.0, 200.0); // Reasonable limits
}
List<Widget> pinCodes = List.generate(widget.maxLength, (int i) { List<Widget> pinCodes = List.generate(widget.maxLength, (int i) {
return _buildPinCode(i, context, boxWidth); // Pass dynamic width return Expanded(
child: Container(
margin: widget.pinBoxOuterPadding,
child: _buildPinCode(i, context, boxWidth),
),
);
}); });
return SingleChildScrollView( return Row(
scrollDirection: Axis.horizontal,
child: Row(
children: pinCodes, children: pinCodes,
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
),
); );
} }
@ -353,14 +332,12 @@ class OTPWidgetState extends State<OTPWidget> with SingleTickerProviderStateMixi
return Container( return Container(
key: ValueKey<String>("container$i"), key: ValueKey<String>("container$i"),
alignment: Alignment.center, alignment: Alignment.center,
margin: widget.pinBoxOuterPadding,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
decoration: BoxDecoration( decoration: BoxDecoration(
color: bgColor, color: bgColor,
border: Border.all(color: borderColor, width: 1), border: Border.all(color: borderColor, width: 1),
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
), ),
width: boxWidth, // Use dynamic width
height: widget.pinBoxHeight, height: widget.pinBoxHeight,
child: _animatedTextBox( child: _animatedTextBox(
strList[i], strList[i],

@ -40,7 +40,7 @@ dependencies:
url_launcher: ^6.3.1 url_launcher: ^6.3.1
url_launcher_ios: ^6.3.2 url_launcher_ios: ^6.3.2
shared_preferences: ^2.5.3 shared_preferences: ^2.5.3
# fluttertoast: ^8.0.8 # fluttertoast: ^8.0.8
fluttertoast: ^8.2.12 fluttertoast: ^8.2.12
flutter_progress_hud: ^2.0.2 flutter_progress_hud: ^2.0.2

Loading…
Cancel
Save