This commit is contained in:
venbaittech 2025-06-10 13:14:29 +05:30
parent 7f448d3e2f
commit c61183c472
3 changed files with 326 additions and 270 deletions

View File

@ -93,11 +93,13 @@ class _groupState extends State<Group> {
String? bodyStringColor = await getBodyColor();
setState(() {
layoutColor = layoutString != null
layoutColor =
layoutString != null
? Color(int.parse(layoutString))
: Colors.redAccent;
bodyColor = bodyStringColor != null
bodyColor =
bodyStringColor != null
? Color(int.parse(bodyStringColor))
: Colors.white;
});
@ -154,10 +156,7 @@ class _groupState extends State<Group> {
errorMessages.clear(); // Reset errors
// Required fields that must not be empty
List<String> requiredFields = [
"name",
"description",
];
List<String> requiredFields = ["name", "description"];
// Check validation for each field
for (String field in requiredFields) {
@ -165,6 +164,14 @@ class _groupState extends State<Group> {
errorMessages[field] = "Required";
}
}
// At least one of the two policies must be selected
if ((selectedDomestic == null || selectedDomestic!.isEmpty) &&
(selectedInternational == null || selectedInternational!.isEmpty)) {
errorMessages["domestic_policy_id"] = "Select at least one policy";
errorMessages["international_policy_id"] = "Select at least one policy";
}
return errorMessages.isEmpty;
return errorMessages.isEmpty; // Valid if there are no errors
}
@ -223,7 +230,8 @@ class _groupState extends State<Group> {
}
try {
final response = await (isEdit
final response =
await (isEdit
? http.put(
Uri.parse(apiUrlData),
headers: {
@ -320,8 +328,10 @@ class _groupState extends State<Group> {
@override
Widget build(BuildContext context) {
return ResponsiveBuilder(builder: (context, sizingInfo) {
bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop;
return ResponsiveBuilder(
builder: (context, sizingInfo) {
bool isDesktop =
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
return Scaffold(
// backgroundColor: Colors.white,
@ -329,23 +339,27 @@ class _groupState extends State<Group> {
appBar: CustomAppBar(isDesktop: isDesktop),
drawer: CustomDrawer(isDesktop: false),
body: Padding(
padding: isDesktop
padding:
isDesktop
? EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width *
horizontal:
MediaQuery.of(context).size.width *
0.1, // 30% of screen width as horizontal padding
vertical: MediaQuery.of(context).size.height *
vertical:
MediaQuery.of(context).size.height *
0, // 5% of screen height as vertical padding
)
: EdgeInsets.all(8),
child: Row(
children: [
// if (isDesktop) CustomDrawer(isDesktop: true),
Expanded(child: buildData(isDesktop, context))
Expanded(child: buildData(isDesktop, context)),
],
),
),
);
});
},
);
}
Widget buildData(bool isDesktop, context) {
@ -367,7 +381,8 @@ class _groupState extends State<Group> {
Container(
color: Colors.white,
padding: const EdgeInsets.all(8.0),
child: isDesktop
child:
isDesktop
? Row(
mainAxisAlignment: MainAxisAlignment.end,
children: _buildSubmit(isDesktop),
@ -387,7 +402,8 @@ class _groupState extends State<Group> {
// margin: isDesktop
// ? EdgeInsets.all(10.0)
// : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0),
height: isDesktop
height:
isDesktop
? MediaQuery.of(context).size.height * 0.98
: MediaQuery.of(context).size.height,
// decoration: BoxDecoration(
@ -414,10 +430,7 @@ class _groupState extends State<Group> {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Create Group",
style: GoogleFonts.poppins(fontSize: 18),
),
Text("Create Group", style: GoogleFonts.poppins(fontSize: 18)),
// Container(
// color: Color(0xFFE9EBF6),
// child: IconButton(
@ -466,9 +479,7 @@ class _groupState extends State<Group> {
children: _buildFirstRow(isDesktop),
),
SizedBox(
height: 10,
),
SizedBox(height: 10),
isDesktop
? Row(
@ -482,7 +493,8 @@ class _groupState extends State<Group> {
// SizedBox(height: 15),
],
)),
),
),
],
),
);
@ -498,13 +510,15 @@ class _groupState extends State<Group> {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xFF575A74)),
color: Color(0xFF575A74),
),
),
SizedBox(height: 5),
CustomTextFieldWrapper(
isFocused: false,
isDesktop: isDesktop,
width: isDesktop
width:
isDesktop
? MediaQuery.of(context).size.width * 0.34
: MediaQuery.of(context).size.width * 0.85,
child: SizedBox(
@ -542,13 +556,15 @@ class _groupState extends State<Group> {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xFF575A74)),
color: Color(0xFF575A74),
),
),
SizedBox(height: 5),
CustomTextFieldWrapper(
isFocused: false,
isDesktop: isDesktop,
width: isDesktop
width:
isDesktop
? MediaQuery.of(context).size.width * 0.34
: MediaQuery.of(context).size.width * 0.85,
child: SizedBox(
@ -591,18 +607,21 @@ class _groupState extends State<Group> {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xFF575A74)),
color: Color(0xFF575A74),
),
),
SizedBox(height: 5),
CustomTextFieldWrapper(
isFocused: false,
isDesktop: isDesktop,
width: isDesktop
width:
isDesktop
? MediaQuery.of(context).size.width * 0.34
: MediaQuery.of(context).size.width * 0.85,
child: SizedBox(
height: 40,
child: apiForDomestic == null
child:
apiForDomestic == null
? Center(
child: Transform.scale(
scale: 0.5,
@ -610,12 +629,15 @@ class _groupState extends State<Group> {
),
)
: DropdownSearch<String>(
selectedItem: selectedDomestic == null
selectedItem:
selectedDomestic == null
? null
: apiForDomestic!
.firstWhere((policy) =>
.firstWhere(
(policy) =>
policy['policy_id'] ==
selectedDomestic)['name']
selectedDomestic,
)['name']
.toString(),
popupProps: PopupProps.menu(
showSearchBox: true,
@ -624,12 +646,14 @@ class _groupState extends State<Group> {
searchFieldProps: TextFieldProps(
decoration: InputDecoration(
hintText: "Search Policy...",
contentPadding:
EdgeInsets.symmetric(horizontal: 10),
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
),
),
),
items: apiForDomestic!
),
items:
apiForDomestic!
.map((policy) => policy['name'].toString())
.toList(),
dropdownDecoratorProps: DropDownDecoratorProps(
@ -638,7 +662,8 @@ class _groupState extends State<Group> {
contentPadding: EdgeInsets.symmetric(horizontal: 1),
),
),
dropdownBuilder: (context, selectedItem) => Align(
dropdownBuilder:
(context, selectedItem) => Align(
alignment: Alignment.centerLeft,
child: Text(
selectedItem ?? "Select",
@ -647,14 +672,15 @@ class _groupState extends State<Group> {
),
onChanged: (String? newValue) {
setState(() {
selectedDomestic = apiForDomestic!.firstWhere(
(policy) =>
policy['name'] == newValue)['policy_id'];
selectedDomestic =
apiForDomestic!.firstWhere(
(policy) => policy['name'] == newValue,
)['policy_id'];
});
},
),
),
)
),
],
),
Column(
@ -665,18 +691,21 @@ class _groupState extends State<Group> {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xFF575A74)),
color: Color(0xFF575A74),
),
),
SizedBox(height: 5),
CustomTextFieldWrapper(
isFocused: false,
isDesktop: isDesktop,
width: isDesktop
width:
isDesktop
? MediaQuery.of(context).size.width * 0.34
: MediaQuery.of(context).size.width * 0.85,
child: SizedBox(
height: 40,
child: apiForInternational == null
child:
apiForInternational == null
? Center(
child: Transform.scale(
scale: 0.5,
@ -684,12 +713,15 @@ class _groupState extends State<Group> {
),
)
: DropdownSearch<String>(
selectedItem: selectedInternational == null
selectedItem:
selectedInternational == null
? null
: apiForInternational!
.firstWhere((policy) =>
.firstWhere(
(policy) =>
policy['policy_id'] ==
selectedInternational)['name']
selectedInternational,
)['name']
.toString(),
popupProps: PopupProps.menu(
showSearchBox: true,
@ -698,12 +730,14 @@ class _groupState extends State<Group> {
searchFieldProps: TextFieldProps(
decoration: InputDecoration(
hintText: "Search Policy...",
contentPadding:
EdgeInsets.symmetric(horizontal: 10),
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
),
),
),
items: apiForInternational!
),
items:
apiForInternational!
.map((policy) => policy['name'].toString())
.toList(),
dropdownDecoratorProps: DropDownDecoratorProps(
@ -712,7 +746,8 @@ class _groupState extends State<Group> {
contentPadding: EdgeInsets.symmetric(horizontal: 1),
),
),
dropdownBuilder: (context, selectedItem) => Align(
dropdownBuilder:
(context, selectedItem) => Align(
alignment: Alignment.centerLeft,
child: Text(
selectedItem ?? "Select",
@ -721,14 +756,15 @@ class _groupState extends State<Group> {
),
onChanged: (String? newValue) {
setState(() {
selectedInternational = apiForInternational!
.firstWhere((policy) =>
policy['name'] == newValue)['policy_id'];
selectedInternational =
apiForInternational!.firstWhere(
(policy) => policy['name'] == newValue,
)['policy_id'];
});
},
),
),
)
),
],
),
];
@ -749,10 +785,9 @@ class _groupState extends State<Group> {
onPressed: () {
context.go('/group');
},
child: Text("Cancel")),
SizedBox(
width: 20,
child: Text("Cancel"),
),
SizedBox(width: 20),
MouseRegion(
// cursor: widget.isViewMode
// ? SystemMouseCursors.forbidden
@ -773,7 +808,7 @@ class _groupState extends State<Group> {
onPressed: handleSubmit, // Disable when in view mode
child: Text("Submit"),
),
)
),
];
}
}

View File

@ -53,6 +53,7 @@ class _ForexScreenState extends State<ForexScreen> {
int fifteenPercent = 0;
int remainingAmount = 0;
bool isWidget = false;
Map<String, FocusNode> focusNodes = {};
Map<String, bool> focusStates = {};
@ -419,12 +420,16 @@ class _ForexScreenState extends State<ForexScreen> {
selectedCashPercent = int.tryParse(
widget.selectedItem!["cash_percentage"]?.toString() ?? "",
);
print("selectedCashPercentUPdae - $selectedCashPercent");
selectedPerdiemAmount = widget.selectedItem!["perdiem_amount"] as String?;
isChecked =
widget.selectedItem!["have_card"] == "1"; // Convert string to bool
textControllers["_cardNumber"]?.text =
widget.selectedItem!["card_number"]?.toString() ?? "";
isWidget = true;
// if (textControllers["_cardNumber"] != null) {
// print("userCardNumber11 - $userCardNumber");
// textControllers["_cardNumber"]!.text = userCardNumber ?? '';
@ -548,6 +553,13 @@ class _ForexScreenState extends State<ForexScreen> {
selectedQuotedAmount =
((perdiemAmount + calclateVal).toString() ?? 0) as String?;
if (isWidget) {
print("IsWidget Update");
int? quotedAmount = int.tryParse(selectedQuotedAmount!);
fifteenPercent = (quotedAmount! * selectedCashPercent!) ~/ 100;
}
});
if (userEdited) {
@ -612,7 +624,8 @@ class _ForexScreenState extends State<ForexScreen> {
);
if (enteredAmount == null || calculateAmnt > qouteAmount!) {
errorMessages["deposit_on_card"] = "Amount cannot exceed $qouteAmount";
errorMessages["deposit_on_card"] =
"Sum of cash card cannot exceed $qouteAmount";
} else if (checkValidAmount < qouteAmount) {
errorMessages["deposit_on_card"] =
"Enter Valid Amount"; // Clear error if valid
@ -627,6 +640,7 @@ class _ForexScreenState extends State<ForexScreen> {
void _validateCashAmount(String value) {
// errorMessages["deposit_on_card"] = " ";
errorMessages.remove("deposit_on_cash");
print("_validateCashAmount - $value - $fifteenPercent");
int? enteredAmount = int.tryParse(value);
@ -652,6 +666,7 @@ class _ForexScreenState extends State<ForexScreen> {
errorMessages["deposit_on_card"] =
"Enter Valid Amount"; // Clear error if valid
}
print("CASHfifteenPercent - $fifteenPercent");
errorMessages["deposit_on_cash"] = "Amount cannot exceed $fifteenPercent";
} else if (checkValidAmount == quotedAmount) {
errorMessages.remove("deposit_on_cash");
@ -1688,7 +1703,9 @@ class _ForexScreenState extends State<ForexScreen> {
errorMessages.remove("deposit_on_cash");
errorMessages.remove("deposit_on_card");
// errorMessages["deposit_on_card"] = "";
setState(() {
userEdited = true;
});
_validateCashAmount(
value,
); // Call validation when text changes
@ -1744,6 +1761,7 @@ class _ForexScreenState extends State<ForexScreen> {
onChanged: (value) {
errorMessages.remove("deposit_on_cash");
errorMessages.remove("deposit_on_card");
userEdited = true;
_validateCardAmount(
value,
); // Call validation when text changes

View File

@ -409,10 +409,13 @@ class _FlightListWidgetState extends State<FlightListWidget> {
fontWeight: FontWeight.w700,
),
),
Image.asset(
Padding(
padding: const EdgeInsets.only(left: 10),
child: Image.asset(
'assets/images/IconsImg/alternate.png',
width: 25,
height: 25,
width: 20,
height: 20,
),
),
Text(
"$toPlaceCountry",