|
|
|
@ -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,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|