policy ui changes

This commit is contained in:
venbaittech 2025-04-04 16:56:26 +05:30
parent 4f9c353e02
commit 83d71279eb
4 changed files with 622 additions and 258 deletions

View File

@ -1,4 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:frontend/Screens/policy/policyCriteria.dart'; import 'package:frontend/Screens/policy/policyCriteria.dart';
import 'package:responsive_builder/responsive_builder.dart'; import 'package:responsive_builder/responsive_builder.dart';
@ -7,7 +8,6 @@ import '../../routes/custom_appBar.dart';
import '../../routes/custom_drawer.dart'; import '../../routes/custom_drawer.dart';
class Policy extends StatefulWidget { class Policy extends StatefulWidget {
const Policy({super.key}); const Policy({super.key});
@override @override
@ -15,10 +15,12 @@ class Policy extends StatefulWidget{
} }
class _PolicyState extends State<Policy> { class _PolicyState extends State<Policy> {
late String policyType = "domestic"; late String policyType = "domestic";
int? selectedServiceIndex = 1; int? selectedServiceIndex = 1;
late String selectedService; late String selectedService = "Train";
bool showClass = true;
bool showCost = true;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -41,7 +43,9 @@ class _PolicyState extends State<Policy>{
Widget buildPolicyLayout(bool isDesktop) { Widget buildPolicyLayout(bool isDesktop) {
return Container( return Container(
margin: EdgeInsets.all(20.0), margin: isDesktop
? EdgeInsets.all(20.0)
: EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 10.0),
height: MediaQuery.of(context).size.height, height: MediaQuery.of(context).size.height,
// color: Colors.grey, // color: Colors.grey,
child: Column( child: Column(
@ -52,11 +56,9 @@ class _PolicyState extends State<Policy>{
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Row( Row(
children: [ children: [
Expanded( Expanded(
child: Container( child: Container(
// color: Colors.amber, // color: Colors.amber,
// color: Color(0xFFF7F7FB), // color: Color(0xFFF7F7FB),
@ -64,84 +66,94 @@ class _PolicyState extends State<Policy>{
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
"Choose Policy Type", "Choose Policy Type",
style: TextStyle(fontSize: 20,), style: TextStyle(
fontSize: 18,
),
), ),
), ),
), ),
], ],
), ),
SizedBox(
SizedBox(height: 10,), height: 10,
),
Row ( Container(
child: Row(
children: [ children: [
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: (){ setState(() { onTap: () {
setState(() {
policyType = "domestic"; policyType = "domestic";
});}, });
},
child: Container( child: Container(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
color: policyType == "domestic" ? Colors.blueAccent.shade100 : Color(0xFFEBEBF7), color: policyType == "domestic"
? Colors.blueAccent.shade100
: Color(0xFFEBEBF7),
// color: Colors.blue.shade300, // color: Colors.blue.shade300,
child: Column( child: Column(
children: [ children: [
Text( Text(
"Domestic", "Domestic",
style: TextStyle(color: policyType == "domestic" ? Colors.white :Colors.black87, fontSize: 18,fontWeight: FontWeight.bold), style: TextStyle(
color: policyType == "domestic"
? Colors.white
: Colors.black87,
fontSize: 15,
fontWeight: FontWeight.bold),
), ),
], ],
), ),
), ),
), ),
), ),
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: (){ setState(() { onTap: () {
setState(() {
policyType = "international"; policyType = "international";
});}, });
},
child: Container( child: Container(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
// color: Color(0xFFEBEBF7), // color: Color(0xFFEBEBF7),
color: policyType == "international" ? Colors.blueAccent.shade100 : Color(0xFFEBEBF7), color: policyType == "international"
? Colors.blueAccent.shade100
: Color(0xFFEBEBF7),
// color: Color(0xFFE3F2FD), // color: Color(0xFFE3F2FD),
child: Column( child: Column(
children: [ children: [
Text( Text(
"International", "International",
style: TextStyle(color: policyType == "international" ? Colors.white :Colors.black87, fontSize: 18, fontWeight: FontWeight.bold), style: TextStyle(
color: policyType == "international"
? Colors.white
: Colors.black87,
fontSize: 15,
fontWeight: FontWeight.bold),
), ),
], ],
), ),
), ),
) )),
),
],
),
], ],
), ),
), ),
],
isDesktop ? ),
Expanded( ),
isDesktop
? Expanded(
child: Row( child: Row(
children: [ children: [
_buildPolicyCategoryList(isDesktop), _buildPolicyCategoryList(isDesktop),
_buildPolicyCategory(isDesktop), _buildPolicyCategory(isDesktop),
], ],
), ),
) )
: Expanded( : Expanded(
child: Column( child: Column(
children: [ children: [
@ -150,44 +162,44 @@ class _PolicyState extends State<Policy>{
], ],
), ),
) )
], ],
), ),
); );
} }
Widget _buildPolicyCategoryList(bool isDesktop) { Widget _buildPolicyCategoryList(bool isDesktop) {
return Container( return Container(
color: Colors.white, color: Colors.white,
// color: Colors.blueGrey.shade200, // color: Colors.blueGrey.shade200,
width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null, width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null,
child: isDesktop ? Column( child: isDesktop
? Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [_buildPolicySubCategoryList(isDesktop)],
_buildPolicySubCategoryList(isDesktop)
],
) )
: Container( : Container(
// color: Colors.amber, // color: Colors.amber,
child: Expanded( child: Expanded(
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [_buildPolicySubCategoryList(isDesktop)],
_buildPolicySubCategoryList(isDesktop)
],
), ),
), ),
), ),
); );
} }
Widget _buildPolicySubCategoryList(bool isDesktop) { Widget _buildPolicySubCategoryList(bool isDesktop) {
List<String> services = [ List<String> services = [
"Flight", "Train", "Bus", "Taxi", "Forex","Accommodation", "Flight",
"Insurance", "Visa", "Miscellaneous" "Train",
"Bus",
"Taxi",
"Forex",
"Accommodation",
"Insurance",
"Visa",
"Miscellaneous"
]; ];
return Expanded( return Expanded(
@ -195,64 +207,76 @@ class _PolicyState extends State<Policy>{
scrollDirection: isDesktop ? Axis.vertical : Axis.horizontal, scrollDirection: isDesktop ? Axis.vertical : Axis.horizontal,
child: Flex( child: Flex(
direction: isDesktop ? Axis.vertical : Axis.horizontal, direction: isDesktop ? Axis.vertical : Axis.horizontal,
children: services.asMap().entries.map((entry) { children: services.asMap().entries.map((entry) {
int index = entry.key; int index = entry.key;
String service = entry.value; String service = entry.value;
bool isSelected = selectedServiceIndex == index; bool isSelected = selectedServiceIndex == index;
return SizedBox( return SizedBox(
width: 180, width: isDesktop ? 180 : null,
height: isDesktop ? MediaQuery.of(context).size.height * 0.1 : 50, height: isDesktop
? max((MediaQuery.of(context).size.height * 0.085), 10)
: 45,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
print("Selected Services - $service - $index"); print("Selected Services - $service - $index");
setState(() { setState(() {
selectedServiceIndex = index; selectedServiceIndex = index;
selectedService = service; selectedService = service;
if (selectedService == "Flight" ||
selectedService == "Train") {
showClass = true;
showCost = true;
} else if (selectedService == "Accommodation") {
showClass = true;
showCost = false;
} else {
showClass = false;
showCost = false;
}
}); });
}, },
child: Container( child: Container(
margin: EdgeInsets.all(8), margin: EdgeInsets.all(8),
padding: EdgeInsets.all(8), padding: isDesktop
? EdgeInsets.all(8)
: EdgeInsets.only(top: 3, bottom: 3, left: 8, right: 8),
decoration: BoxDecoration( decoration: BoxDecoration(
// color: Colors.blue, // color: Colors.blue,
color: isSelected ? Colors.blueAccent.shade100 : Color(0xFFEBEBF7), color: isSelected
? Colors.blueAccent.shade100
: Colors.grey.shade100,
// : Color(0xFFEBEBF7),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
alignment: Alignment.center, alignment: Alignment.center,
child: Text( child: Text(
service, service,
style: TextStyle(color: isSelected ? Colors.white : Colors.black87, style: TextStyle(
color: isSelected ? Colors.white : Colors.black87,
fontSize: 13, fontSize: 13,
fontWeight: isSelected ? FontWeight.bold :FontWeight.w100), fontWeight:
isSelected ? FontWeight.bold : FontWeight.w100),
), ),
), ),
) ));
);
}).toList(), }).toList(),
), ),
), ),
); );
} }
Widget _buildPolicyCategory(bool isDesktop) { Widget _buildPolicyCategory(bool isDesktop) {
return Expanded( return Expanded(
child: Container( child: Container(
// color: Colors.brown.shade100, // color: Colors.brown.shade100,
color: Colors.white60, color: Colors.white60,
child: PolicyCriteria(
child: PolicyCriteria(isDesktop: isDesktop) isDesktop: isDesktop,
isClass: showClass,
isCost: showCost,
), selectedTab: selectedService)),
); );
} }
} }

View File

@ -1,56 +1,82 @@
import 'package:dropdown_search/dropdown_search.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../widgets/custom_text_field.dart'; import '../../widgets/custom_text_field.dart';
import '../../widgets/custom_user_form.dart'; import '../../widgets/custom_user_form.dart';
class PolicyCriteria extends StatefulWidget { class PolicyCriteria extends StatefulWidget {
bool isDesktop; bool isDesktop;
String selectedTab;
bool isClass = true;
bool isCost = true;
PolicyCriteria({super.key, required this.isDesktop}); PolicyCriteria(
{super.key,
required this.isDesktop,
required this.selectedTab,
required this.isClass,
required this.isCost});
@override @override
_PolicyCriteriaState createState() => _PolicyCriteriaState(); _PolicyCriteriaState createState() => _PolicyCriteriaState();
} }
class _PolicyCriteriaState extends State<PolicyCriteria> { class _PolicyCriteriaState extends State<PolicyCriteria> {
String? selectedFirstApprovarType;
String? selectedService;
// bool isClass = true;
// bool isCost = true;
@override
void initState() {
super.initState();
fieldForPolicy();
// selectedService = widget.selectedTab;
}
void fieldForPolicy() {
print("fieldForPolicy - ${widget.selectedTab}");
}
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
SizedBox(height: 15), SizedBox(height: 15),
Row( Row(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Text("Selected Policy Criteria For Flight", Text(
"Selected Policy Criteria For ${widget.selectedTab} ",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 13,
color:Colors.grey, color: Color(0xFF9E9DBD),
fontWeight: FontWeight.bold fontWeight: FontWeight.bold),
) )
,) ],
],), ),
if (widget.isClass!) SizedBox(height: 15),
SizedBox(height: 15),
Row( Row(
children: [ children: [
Expanded( Expanded(
child: Container( child: Container(
// color:Colors.grey, // color:Colors.grey,
padding: const EdgeInsets.only(top:5,bottom: 5,left:5, right: 5), padding:
const EdgeInsets.only(top: 5, bottom: 5, left: 5, right: 5),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (widget.isClass!)
Row( Row(
children: [ children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text("Class", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200, color: Colors.black)), Text("Class",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w200,
color: Colors.black)),
SizedBox(height: 5), SizedBox(height: 5),
CustomTextFieldUserWrapper( CustomTextFieldUserWrapper(
isFocused: false, isFocused: false,
@ -64,28 +90,33 @@ class _PolicyCriteriaState extends State<PolicyCriteria>{
onChanged: (value) {}, onChanged: (value) {},
decoration: InputDecoration( decoration: InputDecoration(
labelText: "Class", labelText: "Class",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey), labelStyle: TextStyle(
floatingLabelBehavior: FloatingLabelBehavior.never, fontSize: 12, color: Colors.grey),
floatingLabelBehavior:
FloatingLabelBehavior.never,
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(vertical: 16), contentPadding:
EdgeInsets.symmetric(vertical: 16),
), ),
), ),
), ),
), ),
], ],
), ),
], ],
), ),
SizedBox(height: 10), SizedBox(height: 10),
if (widget.isCost!)
Row( Row(
children: [ children: [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text("Cost", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200, color: Colors.black)), Text("Cost",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w200,
color: Colors.black)),
SizedBox(height: 5), SizedBox(height: 5),
CustomTextFieldUserWrapper( CustomTextFieldUserWrapper(
isFocused: false, isFocused: false,
@ -99,59 +130,370 @@ class _PolicyCriteriaState extends State<PolicyCriteria>{
onChanged: (value) {}, onChanged: (value) {},
decoration: InputDecoration( decoration: InputDecoration(
labelText: "Cost", labelText: "Cost",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey), labelStyle: TextStyle(
floatingLabelBehavior: FloatingLabelBehavior.never, fontSize: 12, color: Colors.grey),
floatingLabelBehavior:
FloatingLabelBehavior.never,
border: InputBorder.none, border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(vertical: 16), contentPadding:
EdgeInsets.symmetric(vertical: 16),
), ),
), ),
), ),
), ),
], ],
), ),
], ],
), ),
], ],
), ),
), ),
), ),
], ],
), ),
SizedBox(height: 15), if (widget.isCost!) SizedBox(height: 15),
Expanded( Expanded(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: null,
color: Color(0xFFEBEBF7), // border: Border.all(
// color: Color(0xFFEBEBF7),
), // ),
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
// color: Colors.brown.shade200, // color: Colors.brown.shade200,
), ),
child: SingleChildScrollView(
child: Row( scrollDirection: Axis.horizontal,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Expanded( Expanded(
child: Container( child: Container(
width: widget.isDesktop
? MediaQuery.of(context).size.width * 0.62
: 600,
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Colors.grey.shade50,
border: Border.all(
color: Colors.grey.shade50,
),
borderRadius: BorderRadius.circular(8)),
padding: const EdgeInsets.all(10),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text(
"Approver Name",
style: TextStyle(
color: Color(0xFF9E9DBD),
fontWeight: FontWeight.bold,
fontSize: 12),
),
Text(
"Notification",
style: TextStyle(
color: Color(0xFF9E9DBD),
fontWeight: FontWeight.bold,
fontSize: 12),
),
Text(
"Select",
style: TextStyle(
color: Color(0xFF9E9DBD),
fontWeight: FontWeight.bold,
fontSize: 12),
)
],
),
),
SizedBox(
height: 200,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Container(
// color: Colors.grey,
color: Colors.grey.shade50,
child: Column(children: [
Container(
padding: const EdgeInsets.all(10),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text("Approver 1"),
CustomTextFieldUserWrapper(
isFocused: false,
isDesktop: widget.isDesktop,
child: SizedBox(
height: 40,
child: DropdownSearch<String>(
selectedItem:
selectedFirstApprovarType,
// enabled: !isViewMode,
popupProps: PopupProps.menu(
// showSearchBox: true,
fit: FlexFit
.loose, // Allows flexible height
constraints: BoxConstraints(
maxHeight: 250),
),
items: [
"Approve",
"Notification",
],
dropdownDecoratorProps:
DropDownDecoratorProps(
dropdownSearchDecoration:
InputDecoration(
border: InputBorder.none,
contentPadding:
EdgeInsets.symmetric(
horizontal: 1,
),
),
),
dropdownBuilder:
(context, selectedItem) =>
Align(
// Center-align selected item
alignment:
Alignment.centerLeft,
child: Text( child: Text(
"policy Data 2" selectedItem ?? "Select",
style: TextStyle(
fontSize: 12,
color: Colors
.blueAccent),
), ),
), ),
onChanged:
(String? newValue) {
setState(() {
// Find the country_code based on selected country_name
selectedFirstApprovarType =
newValue;
// print("selectedUserType - $selectedUserType");
// if (selectedCountry!.isNotEmpty) {
// errorMessages.remove("country_code");
// }
});
},
),
),
),
Container(
height: 25,
width: 25,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.grey,
width: 2),
),
child: Icon(
Icons.check_circle,
size: 20,
// color: Colors.green,
color: Colors.grey,
)),
],
),
),
Container(
padding: const EdgeInsets.all(10),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text("Approver 2"),
CustomTextFieldUserWrapper(
isFocused: false,
isDesktop: widget.isDesktop,
child: SizedBox(
height: 40,
child: DropdownSearch<String>(
selectedItem:
selectedFirstApprovarType,
// enabled: !isViewMode,
popupProps: PopupProps.menu(
// showSearchBox: true,
fit: FlexFit
.loose, // Allows flexible height
constraints: BoxConstraints(
maxHeight: 250),
),
items: [
"Approve",
"Notification",
],
dropdownDecoratorProps:
DropDownDecoratorProps(
dropdownSearchDecoration:
InputDecoration(
border: InputBorder.none,
contentPadding:
EdgeInsets.symmetric(
horizontal: 1,
),
),
),
dropdownBuilder:
(context, selectedItem) =>
Align(
// Center-align selected item
alignment:
Alignment.centerLeft,
child: Text(
selectedItem ?? "Select",
style: TextStyle(
fontSize: 12,
color: Colors
.blueAccent),
),
),
onChanged:
(String? newValue) {
setState(() {
// Find the country_code based on selected country_name
selectedFirstApprovarType =
newValue;
// print("selectedUserType - $selectedUserType");
// if (selectedCountry!.isNotEmpty) {
// errorMessages.remove("country_code");
// }
});
},
),
),
),
Container(
height: 25,
width: 25,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.green,
width: 2),
),
child: Icon(
Icons.check_circle,
size: 20,
color: Colors.green,
// color: Colors.grey,
)),
],
),
),
Container(
padding: const EdgeInsets.all(10),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Text("Approver 3"),
CustomTextFieldUserWrapper(
isFocused: false,
isDesktop: widget.isDesktop,
child: SizedBox(
height: 40,
child: DropdownSearch<String>(
selectedItem:
selectedFirstApprovarType,
// enabled: !isViewMode,
popupProps: PopupProps.menu(
// showSearchBox: true,
fit: FlexFit
.loose, // Allows flexible height
constraints: BoxConstraints(
maxHeight: 250),
),
items: [
"Approve",
"Notification",
],
dropdownDecoratorProps:
DropDownDecoratorProps(
dropdownSearchDecoration:
InputDecoration(
border: InputBorder.none,
contentPadding:
EdgeInsets.symmetric(
horizontal: 1,
),
),
),
dropdownBuilder:
(context, selectedItem) =>
Align(
// Center-align selected item
alignment:
Alignment.centerLeft,
child: Text(
selectedItem ?? "Select",
style: TextStyle(
fontSize: 12,
color: Colors
.blueAccent),
),
),
onChanged:
(String? newValue) {
setState(() {
// Find the country_code based on selected country_name
selectedFirstApprovarType =
newValue;
// print("selectedUserType - $selectedUserType");
// if (selectedCountry!.isNotEmpty) {
// errorMessages.remove("country_code");
// }
});
},
),
),
),
Container(
height: 25,
width: 25,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: Colors.green,
width: 2),
),
child: Icon(
Icons.check_circle,
size: 20,
color: Colors.green,
// color: Colors.grey,
)),
],
),
),
]),
),
),
)
],
)),
), ),
], ],
), ),
), ),
), ),
),
),
], ],
); );
} }
} }

View File

@ -1 +0,0 @@
// TODO Implement this library.

View File

@ -5,7 +5,6 @@ Future<String?> getToken() async {
return prefs.getString("auth_token"); return prefs.getString("auth_token");
} }
Future<String?> getUserId() async { Future<String?> getUserId() async {
final prefs = await SharedPreferences.getInstance(); final prefs = await SharedPreferences.getInstance();
return prefs.getString('userId'); return prefs.getString('userId');