diff --git a/lib/Screens/policy/policy.dart b/lib/Screens/policy/policy.dart index c2f8c40..8a7c873 100644 --- a/lib/Screens/policy/policy.dart +++ b/lib/Screens/policy/policy.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:math'; import 'package:flutter/material.dart'; import 'package:frontend/Screens/policy/policyCriteria.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_drawer.dart'; -class Policy extends StatefulWidget{ - - const Policy ({super.key}); +class Policy extends StatefulWidget { + const Policy({super.key}); @override _PolicyState createState() => _PolicyState(); } -class _PolicyState extends State{ - - late String policyType = "domestic"; +class _PolicyState extends State { + late String policyType = "domestic"; int? selectedServiceIndex = 1; - late String selectedService; + late String selectedService = "Train"; + + bool showClass = true; + bool showCost = true; @override Widget build(BuildContext context) { @@ -39,9 +41,11 @@ class _PolicyState extends State{ }); } - Widget buildPolicyLayout(bool isDesktop){ + Widget buildPolicyLayout(bool isDesktop) { 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, // color: Colors.grey, child: Column( @@ -52,11 +56,9 @@ class _PolicyState extends State{ child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Row( children: [ Expanded( - child: Container( // color: Colors.amber, // color: Color(0xFFF7F7FB), @@ -64,130 +66,140 @@ class _PolicyState extends State{ alignment: Alignment.center, child: Text( "Choose Policy Type", - style: TextStyle(fontSize: 20,), - ), - ), - - ), - ], - ), - - 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), - ), - ], + style: TextStyle( + fontSize: 18, ), - ), ), ), - Expanded( - + ], + ), + SizedBox( + height: 10, + ), + Container( + child: Row( + children: [ + Expanded( child: GestureDetector( - onTap: (){ setState(() { - policyType = "international"; - });}, - + onTap: () { + setState(() { + policyType = "domestic"; + }); + }, child: Container( padding: EdgeInsets.all(10), - // color: Color(0xFFEBEBF7), - color: policyType == "international" ? Colors.blueAccent.shade100 : Color(0xFFEBEBF7), - // color: Color(0xFFE3F2FD), - + color: policyType == "domestic" + ? Colors.blueAccent.shade100 + : Color(0xFFEBEBF7), + // color: Colors.blue.shade300, child: Column( children: [ Text( - "International", - style: TextStyle(color: policyType == "international" ? Colors.white :Colors.black87, fontSize: 18, fontWeight: FontWeight.bold), + "Domestic", + 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 ? - Expanded( - child: Row( - children: [ - - _buildPolicyCategoryList(isDesktop), - _buildPolicyCategory(isDesktop), - ], - ), - ) - - : Expanded( - child: Column( - children: [ - _buildPolicyCategoryList(isDesktop), - _buildPolicyCategory(isDesktop), - ], - ), - ) - + isDesktop + ? Expanded( + child: Row( + children: [ + _buildPolicyCategoryList(isDesktop), + _buildPolicyCategory(isDesktop), + ], + ), + ) + : Expanded( + child: Column( + children: [ + _buildPolicyCategoryList(isDesktop), + _buildPolicyCategory(isDesktop), + ], + ), + ) ], ), ); } - - Widget _buildPolicyCategoryList(bool isDesktop){ - return Container( + Widget _buildPolicyCategoryList(bool isDesktop) { + return Container( color: Colors.white, // color: Colors.blueGrey.shade200, width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null, - child: isDesktop ? Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - _buildPolicySubCategoryList(isDesktop) - - ], - ) + child: isDesktop + ? Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [_buildPolicySubCategoryList(isDesktop)], + ) : Container( - // color: Colors.amber, - child: Expanded( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - _buildPolicySubCategoryList(isDesktop) - ], - ), - ), - ), - + // color: Colors.amber, + child: Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [_buildPolicySubCategoryList(isDesktop)], + ), + ), + ), ); } Widget _buildPolicySubCategoryList(bool isDesktop) { List services = [ - "Flight", "Train", "Bus", "Taxi", "Forex","Accommodation", - "Insurance", "Visa", "Miscellaneous" + "Flight", + "Train", + "Bus", + "Taxi", + "Forex", + "Accommodation", + "Insurance", + "Visa", + "Miscellaneous" ]; return Expanded( @@ -195,64 +207,76 @@ class _PolicyState extends State{ scrollDirection: isDesktop ? Axis.vertical : Axis.horizontal, child: Flex( direction: isDesktop ? Axis.vertical : Axis.horizontal, - children: services.asMap().entries.map((entry) { - - int index = entry.key; - String service = entry.value; + int index = entry.key; + String service = entry.value; bool isSelected = selectedServiceIndex == index; return SizedBox( - width: 180, - height: isDesktop ? MediaQuery.of(context).size.height * 0.1 : 50, + width: isDesktop ? 180 : null, + 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( - onTap :(){ - print("Selected Services - $service - $index"); - setState(() { - selectedServiceIndex = index; - selectedService = service; - }); - }, - - child: Container( - margin: EdgeInsets.all(8), - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - // color: Colors.blue, - color: isSelected ? Colors.blueAccent.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), - ), - ), - ) - ); + if (selectedService == "Flight" || + selectedService == "Train") { + showClass = true; + showCost = true; + } else if (selectedService == "Accommodation") { + showClass = true; + showCost = false; + } else { + showClass = false; + showCost = false; + } + }); + }, + child: Container( + margin: EdgeInsets.all(8), + padding: isDesktop + ? EdgeInsets.all(8) + : EdgeInsets.only(top: 3, bottom: 3, left: 8, right: 8), + decoration: BoxDecoration( + // color: Colors.blue, + color: isSelected + ? Colors.blueAccent.shade100 + : 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(), - ), ), ); } - - Widget _buildPolicyCategory(bool isDesktop){ - return Expanded( + Widget _buildPolicyCategory(bool isDesktop) { + return Expanded( child: Container( - // color: Colors.brown.shade100, - color: Colors.white60, - - child: PolicyCriteria(isDesktop: isDesktop) - - - ), + // color: Colors.brown.shade100, + color: Colors.white60, + child: PolicyCriteria( + isDesktop: isDesktop, + isClass: showClass, + isCost: showCost, + selectedTab: selectedService)), ); } - - -} \ No newline at end of file +} diff --git a/lib/Screens/policy/policyCriteria.dart b/lib/Screens/policy/policyCriteria.dart index dfa6ae8..74481a1 100644 --- a/lib/Screens/policy/policyCriteria.dart +++ b/lib/Screens/policy/policyCriteria.dart @@ -1,157 +1,499 @@ +import 'package:dropdown_search/dropdown_search.dart'; import 'package:flutter/material.dart'; import '../../widgets/custom_text_field.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, required this.isDesktop}); + PolicyCriteria( + {super.key, + required this.isDesktop, + required this.selectedTab, + required this.isClass, + required this.isCost}); @override - _PolicyCriteriaState createState() => _PolicyCriteriaState(); - + _PolicyCriteriaState createState() => _PolicyCriteriaState(); } -class _PolicyCriteriaState extends State{ +class _PolicyCriteriaState extends State { + 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( mainAxisAlignment: MainAxisAlignment.start, children: [ - SizedBox(height: 15), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text("Selected Policy Criteria For Flight", - style: TextStyle( - fontSize: 16, - color:Colors.grey, - fontWeight: FontWeight.bold + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + "Selected Policy Criteria For ${widget.selectedTab} ", + style: TextStyle( + fontSize: 13, + color: Color(0xFF9E9DBD), + fontWeight: FontWeight.bold), ) - ,) - ],), - - - SizedBox(height: 15), + ], + ), + if (widget.isClass!) SizedBox(height: 15), Row( children: [ Expanded( child: Container( // 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( crossAxisAlignment: CrossAxisAlignment.start, children: [ - - Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Class", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200, color: Colors.black)), - SizedBox(height: 5), - CustomTextFieldUserWrapper( - isFocused: false, - isDesktop: widget.isDesktop, - child: SizedBox( - height: 40, - child: TextField( - style: TextStyle(fontSize: 12), - // controller: controllers["Fname"], - // enabled: !isViewMode, - onChanged: (value) { }, - decoration: InputDecoration( - labelText: "Class", - labelStyle: TextStyle(fontSize: 12, color: Colors.grey), - floatingLabelBehavior: FloatingLabelBehavior.never, - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric(vertical: 16), + if (widget.isClass!) + Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Class", + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w200, + color: Colors.black)), + SizedBox(height: 5), + CustomTextFieldUserWrapper( + isFocused: false, + isDesktop: widget.isDesktop, + child: SizedBox( + height: 40, + child: TextField( + style: TextStyle(fontSize: 12), + // controller: controllers["Fname"], + // enabled: !isViewMode, + onChanged: (value) {}, + decoration: InputDecoration( + labelText: "Class", + labelStyle: TextStyle( + fontSize: 12, color: Colors.grey), + floatingLabelBehavior: + FloatingLabelBehavior.never, + border: InputBorder.none, + contentPadding: + EdgeInsets.symmetric(vertical: 16), + ), ), ), ), - ), - - ], - ), - ], - ), - + ], + ), + ], + ), SizedBox(height: 10), - - Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text("Cost", style: TextStyle(fontSize: 15, fontWeight: FontWeight.w200, color: Colors.black)), - SizedBox(height: 5), - CustomTextFieldUserWrapper( - isFocused: false, - isDesktop: widget.isDesktop, - child: SizedBox( - height: 40, - child: TextField( - style: TextStyle(fontSize: 12), - // controller: controllers["Fname"], - // enabled: !isViewMode, - onChanged: (value) { }, - decoration: InputDecoration( - labelText: "Cost", - labelStyle: TextStyle(fontSize: 12, color: Colors.grey), - floatingLabelBehavior: FloatingLabelBehavior.never, - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric(vertical: 16), + if (widget.isCost!) + Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("Cost", + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w200, + color: Colors.black)), + SizedBox(height: 5), + CustomTextFieldUserWrapper( + isFocused: false, + isDesktop: widget.isDesktop, + child: SizedBox( + height: 40, + child: TextField( + style: TextStyle(fontSize: 12), + // controller: controllers["Fname"], + // enabled: !isViewMode, + onChanged: (value) {}, + decoration: InputDecoration( + 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( child: Container( - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFFEBEBF7), - - ), + border: null, + // border: Border.all( + // color: Color(0xFFEBEBF7), + // ), borderRadius: BorderRadius.circular(8), // 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( + 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( - children: [ - Expanded( - child: Container( - child: Text( - "policy Data 2" + // 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( + 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( + 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, + )), + ], + ), + ), + ]), + ), + ), + ) + ], + )), ), - ), + ], ), - ], + ), ), ), ), - ], ); } - -} \ No newline at end of file +} diff --git a/lib/Screens/services/apiService.dart b/lib/Screens/services/apiService.dart deleted file mode 100644 index b9f78bb..0000000 --- a/lib/Screens/services/apiService.dart +++ /dev/null @@ -1 +0,0 @@ -// TODO Implement this library. \ No newline at end of file diff --git a/lib/utils/auth_utils.dart b/lib/utils/auth_utils.dart index 5e35a51..8510d02 100644 --- a/lib/utils/auth_utils.dart +++ b/lib/utils/auth_utils.dart @@ -5,8 +5,7 @@ Future getToken() async { return prefs.getString("auth_token"); } - Future getUserId() async { final prefs = await SharedPreferences.getInstance(); return prefs.getString('userId'); -} \ No newline at end of file +}