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';
@ -6,19 +7,20 @@ import 'package:responsive_builder/responsive_builder.dart';
import '../../routes/custom_appBar.dart'; 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
_PolicyState createState() => _PolicyState(); _PolicyState createState() => _PolicyState();
} }
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) {
@ -39,9 +41,11 @@ 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,130 +66,140 @@ 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(height: 10,),
Row (
children: [
Expanded(
child: GestureDetector(
onTap: (){ setState(() {
policyType = "domestic";
});},
child: Container(
padding: EdgeInsets.all(10),
color: policyType == "domestic" ? Colors.blueAccent.shade100 : Color(0xFFEBEBF7),
// color: Colors.blue.shade300,
child: Column(
children: [
Text(
"Domestic",
style: TextStyle(color: policyType == "domestic" ? Colors.white :Colors.black87, fontSize: 18,fontWeight: FontWeight.bold),
),
],
), ),
), ),
), ),
), ),
Expanded( ],
),
SizedBox(
height: 10,
),
Container(
child: Row(
children: [
Expanded(
child: GestureDetector( child: GestureDetector(
onTap: (){ setState(() { onTap: () {
policyType = "international"; setState(() {
});}, policyType = "domestic";
});
},
child: Container( child: Container(
padding: EdgeInsets.all(10), padding: EdgeInsets.all(10),
// color: Color(0xFFEBEBF7), color: policyType == "domestic"
color: policyType == "international" ? Colors.blueAccent.shade100 : Color(0xFFEBEBF7), ? Colors.blueAccent.shade100
// color: Color(0xFFE3F2FD), : Color(0xFFEBEBF7),
// color: Colors.blue.shade300,
child: Column( child: Column(
children: [ children: [
Text( Text(
"International", "Domestic",
style: TextStyle(color: policyType == "international" ? Colors.white :Colors.black87, fontSize: 18, fontWeight: FontWeight.bold), style: TextStyle(
color: policyType == "domestic"
? Colors.white
: Colors.black87,
fontSize: 15,
fontWeight: FontWeight.bold),
), ),
], ],
), ),
), ),
) ),
),
Expanded(
child: GestureDetector(
onTap: () {
setState(() {
policyType = "international";
});
},
child: Container(
padding: EdgeInsets.all(10),
// color: Color(0xFFEBEBF7),
color: policyType == "international"
? Colors.blueAccent.shade100
: Color(0xFFEBEBF7),
// color: Color(0xFFE3F2FD),
), child: Column(
children: [
], Text(
"International",
style: TextStyle(
color: policyType == "international"
? Colors.white
: Colors.black87,
fontSize: 15,
fontWeight: FontWeight.bold),
),
],
),
),
)),
],
),
), ),
], ],
), ),
), ),
isDesktop
isDesktop ? ? Expanded(
Expanded( child: Row(
child: Row( children: [
children: [ _buildPolicyCategoryList(isDesktop),
_buildPolicyCategory(isDesktop),
_buildPolicyCategoryList(isDesktop), ],
_buildPolicyCategory(isDesktop), ),
], )
), : Expanded(
) child: Column(
children: [
: Expanded( _buildPolicyCategoryList(isDesktop),
child: Column( _buildPolicyCategory(isDesktop),
children: [ ],
_buildPolicyCategoryList(isDesktop), ),
_buildPolicyCategory(isDesktop), )
],
),
)
], ],
), ),
); );
} }
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
mainAxisAlignment: MainAxisAlignment.start, ? Column(
children: [ mainAxisAlignment: MainAxisAlignment.start,
_buildPolicySubCategoryList(isDesktop) children: [_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(
onTap: () {
print("Selected Services - $service - $index");
setState(() {
selectedServiceIndex = index;
selectedService = service;
child:GestureDetector( if (selectedService == "Flight" ||
onTap :(){ selectedService == "Train") {
print("Selected Services - $service - $index"); showClass = true;
setState(() { showCost = true;
selectedServiceIndex = index; } else if (selectedService == "Accommodation") {
selectedService = service; showClass = true;
}); showCost = false;
}, } else {
showClass = false;
child: Container( showCost = false;
margin: EdgeInsets.all(8), }
padding: EdgeInsets.all(8), });
decoration: BoxDecoration( },
// color: Colors.blue, child: Container(
color: isSelected ? Colors.blueAccent.shade100 : Color(0xFFEBEBF7), margin: EdgeInsets.all(8),
borderRadius: BorderRadius.circular(8), padding: isDesktop
), ? EdgeInsets.all(8)
alignment: Alignment.center, : EdgeInsets.only(top: 3, bottom: 3, left: 8, right: 8),
child: Text( decoration: BoxDecoration(
service, // color: Colors.blue,
style: TextStyle(color: isSelected ? Colors.white : Colors.black87, color: isSelected
fontSize: 13, ? Colors.blueAccent.shade100
fontWeight: isSelected ? FontWeight.bold :FontWeight.w100), : Colors.grey.shade100,
), // : Color(0xFFEBEBF7),
), borderRadius: BorderRadius.circular(8),
) ),
); alignment: Alignment.center,
child: Text(
service,
style: TextStyle(
color: isSelected ? Colors.white : Colors.black87,
fontSize: 13,
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,157 +1,499 @@
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;
String selectedTab;
bool isClass = true;
bool isCost = true;
bool isDesktop; PolicyCriteria(
{super.key,
PolicyCriteria({super.key, required this.isDesktop}); 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;
Widget build(BuildContext context){ // 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) {
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(
style: TextStyle( "Selected Policy Criteria For ${widget.selectedTab} ",
fontSize: 16, style: TextStyle(
color:Colors.grey, fontSize: 13,
fontWeight: FontWeight.bold color: Color(0xFF9E9DBD),
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",
SizedBox(height: 5), style: TextStyle(
CustomTextFieldUserWrapper( fontSize: 12,
isFocused: false, fontWeight: FontWeight.w200,
isDesktop: widget.isDesktop, color: Colors.black)),
child: SizedBox( SizedBox(height: 5),
height: 40, CustomTextFieldUserWrapper(
child: TextField( isFocused: false,
style: TextStyle(fontSize: 12), isDesktop: widget.isDesktop,
// controller: controllers["Fname"], child: SizedBox(
// enabled: !isViewMode, height: 40,
onChanged: (value) { }, child: TextField(
decoration: InputDecoration( style: TextStyle(fontSize: 12),
labelText: "Class", // controller: controllers["Fname"],
labelStyle: TextStyle(fontSize: 12, color: Colors.grey), // enabled: !isViewMode,
floatingLabelBehavior: FloatingLabelBehavior.never, onChanged: (value) {},
border: InputBorder.none, decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 16), labelText: "Class",
labelStyle: TextStyle(
fontSize: 12, color: Colors.grey),
floatingLabelBehavior:
FloatingLabelBehavior.never,
border: InputBorder.none,
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",
SizedBox(height: 5), style: TextStyle(
CustomTextFieldUserWrapper( fontSize: 12,
isFocused: false, fontWeight: FontWeight.w200,
isDesktop: widget.isDesktop, color: Colors.black)),
child: SizedBox( SizedBox(height: 5),
height: 40, CustomTextFieldUserWrapper(
child: TextField( isFocused: false,
style: TextStyle(fontSize: 12), isDesktop: widget.isDesktop,
// controller: controllers["Fname"], child: SizedBox(
// enabled: !isViewMode, height: 40,
onChanged: (value) { }, child: TextField(
decoration: InputDecoration( style: TextStyle(fontSize: 12),
labelText: "Cost", // controller: controllers["Fname"],
labelStyle: TextStyle(fontSize: 12, color: Colors.grey), // enabled: !isViewMode,
floatingLabelBehavior: FloatingLabelBehavior.never, onChanged: (value) {},
border: InputBorder.none, decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(vertical: 16), labelText: "Cost",
labelStyle: TextStyle(
fontSize: 12, color: Colors.grey),
floatingLabelBehavior:
FloatingLabelBehavior.never,
border: InputBorder.none,
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(
scrollDirection: Axis.horizontal,
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
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(
selectedItem ?? "Select",
style: TextStyle(
fontSize: 12,
color: Colors
.blueAccent),
),
),
onChanged:
(String? newValue) {
setState(() {
// Find the country_code based on selected country_name
selectedFirstApprovarType =
newValue;
child: Row( // print("selectedUserType - $selectedUserType");
children: [
Expanded( // if (selectedCountry!.isNotEmpty) {
child: Container( // errorMessages.remove("country_code");
child: Text( // }
"policy Data 2" });
},
),
),
),
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,8 +5,7 @@ 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');
} }