diff --git a/lib/Screens/approvals/approval_list.dart b/lib/Screens/approvals/approval_list.dart index a27bb64..53936aa 100644 --- a/lib/Screens/approvals/approval_list.dart +++ b/lib/Screens/approvals/approval_list.dart @@ -307,13 +307,25 @@ class _ApprovalListState extends State { return Scaffold( backgroundColor: Colors.white, - appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: Row( - children: [ - if (isDesktop) CustomDrawer(isDesktop: true), - Expanded(child: buildGroupListLayout(isDesktop)) - ], + // appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), + // drawer: isDesktop ? null : CustomDrawer(isDesktop: false), + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + 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: buildGroupListLayout(isDesktop)) + ], + ), ), ); }); @@ -321,11 +333,14 @@ class _ApprovalListState extends State { Widget buildGroupListLayout(bool isDesktop) { return Container( - decoration: BoxDecoration( - // color: Colors.amber, - // color: bodyColor, - color: Color(0xFFE1F5FE), - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // // color: Colors.amber, + // // color: bodyColor, + // color: Color(0xFFE1F5FE), + // border: Border.all( + // // color: Color(0xFFF7F7FB), + // color: Colors.white, + // width: 3.5)), child: buildTableLayout(isDesktop), ); } @@ -341,25 +356,26 @@ class _ApprovalListState extends State { } return Container( - margin: isDesktop - ? EdgeInsets.all(10.0) - : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), - padding: const EdgeInsets.all(10), + // margin: isDesktop + // ? EdgeInsets.all(10.0) + // : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), + // padding: const EdgeInsets.all(10), height: isDesktop ? MediaQuery.of(context).size.height * 0.98 : MediaQuery.of(context).size.height, - decoration: BoxDecoration( - border: isDesktop - ? Border.all( - width: 2, - color: Color(0xFFF7F7FB), - ) - : null, - color: Colors.white, - // color: Color(0xFFF7F7FB), - - // color: Colors.amber, - ), + // decoration: BoxDecoration( + // border: isDesktop + // ? Border.all( + // width: 2, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // ) + // : null, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // // color: Colors.amber, + // ), child: Padding( padding: const EdgeInsets.all(1.0), child: Container( @@ -368,7 +384,10 @@ class _ApprovalListState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - SizedBox(height: 2), + // Divider( + // thickness: 0.2, // how "thick" the line is + // color: Colors.grey, // optional + // ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -382,16 +401,6 @@ class _ApprovalListState extends State { color: Color(0xFF212121))), ], ), - ], - ), - SizedBox(height: 2), - Divider( - thickness: 0.2, // how "thick" the line is - color: Colors.grey, // optional - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ Container( width: MediaQuery.of(context).size.width * 0.2, // or use Flexible diff --git a/lib/Screens/authentication/login/login_widget.dart b/lib/Screens/authentication/login/login_widget.dart index 7475d5c..36d5904 100644 --- a/lib/Screens/authentication/login/login_widget.dart +++ b/lib/Screens/authentication/login/login_widget.dart @@ -178,7 +178,7 @@ class _LoginWidgetState extends State { ), const SizedBox(height: 2), const Text( - "Welcome To Travel Spends", + "Welcome To TravelSpends", style: TextStyle( fontSize: 11, fontFamily: "Nunito", diff --git a/lib/Screens/dashboard/home_page.dart b/lib/Screens/dashboard/home_page.dart index aaae909..669978b 100644 --- a/lib/Screens/dashboard/home_page.dart +++ b/lib/Screens/dashboard/home_page.dart @@ -9,27 +9,19 @@ class HomePage extends StatelessWidget { @override Widget build(BuildContext context) { - - return ResponsiveBuilder( - builder: (context, sizingInfo) { + return ResponsiveBuilder(builder: (context, sizingInfo) { bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; return Scaffold( - appBar: isDesktop ? null : const CustomAppBar(title:'Home'), + appBar: isDesktop ? null : const CustomAppBar(), drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: - Row( + body: Row( children: [ - if(isDesktop) - CustomDrawer(isDesktop: true), + if (isDesktop) CustomDrawer(isDesktop: true), const Expanded(child: Center(child: Text("Home Page Content"))), ], ), ); - - - }); - - + }); } } diff --git a/lib/Screens/group/group.dart b/lib/Screens/group/group.dart index b25578f..16e06ce 100644 --- a/lib/Screens/group/group.dart +++ b/lib/Screens/group/group.dart @@ -324,13 +324,23 @@ class _groupState extends State { return Scaffold( backgroundColor: Colors.white, - appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: Row( - children: [ - if (isDesktop) CustomDrawer(isDesktop: true), - Expanded(child: buildData(isDesktop, context)) - ], + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + 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)) + ], + ), ), ); }); @@ -339,17 +349,20 @@ class _groupState extends State { Widget buildData(bool isDesktop, context) { return Container( // margin: const EdgeInsets.only(left: 10.0, right: 15.0, top: 10.0, bottom: 10.0), - decoration: BoxDecoration( - // color: Colors.amber, - // color: bodyColor, - color: Color(0xFFE1F5FE), - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // // color: Colors.amber, + // // color: bodyColor, + // color: Color(0xFFE1F5FE), + // border: Border.all( + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // width: 3.5)), child: Column( children: [ Expanded( child: Container( // color: bodyColor, - color: Color(0xFFE1F5FE), + // color: Color(0xFFE1F5FE), child: buildOrganizationLayout(isDesktop), ), ), @@ -373,25 +386,26 @@ class _groupState extends State { Widget buildOrganizationLayout(isDesktop) { return Container( - margin: isDesktop - ? EdgeInsets.all(10.0) - : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), + // margin: isDesktop + // ? EdgeInsets.all(10.0) + // : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), height: isDesktop ? MediaQuery.of(context).size.height * 0.98 : MediaQuery.of(context).size.height, - decoration: BoxDecoration( - border: isDesktop - ? Border.all( - width: 2, - color: Color(0xFFF7F7FB), - ) - : null, - color: Colors.white, - - // color: Color(0xFFF7F7FB), - - // color: Colors.amber, - ), + // decoration: BoxDecoration( + // border: isDesktop + // ? Border.all( + // width: 2, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // ) + // : null, + // color: Colors.white, + // + // // color: Color(0xFFF7F7FB), + // + // // color: Colors.amber, + // ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/Screens/group/groupList.dart b/lib/Screens/group/groupList.dart index eafe21a..11c1721 100644 --- a/lib/Screens/group/groupList.dart +++ b/lib/Screens/group/groupList.dart @@ -132,13 +132,23 @@ class _GroupListState extends State { return Scaffold( backgroundColor: Colors.white, - appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: Row( - children: [ - if (isDesktop) CustomDrawer(isDesktop: true), - Expanded(child: buildGroupListLayout(isDesktop)) - ], + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + 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: buildGroupListLayout(isDesktop)) + ], + ), ), ); }); @@ -146,11 +156,14 @@ class _GroupListState extends State { Widget buildGroupListLayout(bool isDesktop) { return Container( - decoration: BoxDecoration( - // color: Colors.amber, - // color: bodyColor, - color: Color(0xFFE1F5FE), - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // // color: Colors.amber, + // // color: bodyColor, + // color: Color(0xFFE1F5FE), + // border: Border.all( + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // width: 3.5)), child: buildGroupData(isDesktop), ); } @@ -163,25 +176,26 @@ class _GroupListState extends State { Widget buildGroupData(isDesktop) { return Container( - margin: isDesktop - ? EdgeInsets.all(10.0) - : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), - padding: const EdgeInsets.all(10), + // margin: isDesktop + // ? EdgeInsets.all(10.0) + // : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), + // padding: const EdgeInsets.all(10), height: isDesktop ? MediaQuery.of(context).size.height * 0.98 : MediaQuery.of(context).size.height, - decoration: BoxDecoration( - border: isDesktop - ? Border.all( - width: 2, - color: Color(0xFFF7F7FB), - ) - : null, - color: Colors.white, - // color: Color(0xFFF7F7FB), - - // color: Colors.amber, - ), + // decoration: BoxDecoration( + // border: isDesktop + // ? Border.all( + // width: 2, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // ) + // : null, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // // color: Colors.amber, + // ), child: Column( children: [ Row( diff --git a/lib/Screens/itnerary_list/taxi_list.dart b/lib/Screens/itnerary_list/taxi_list.dart index bde897b..77cb482 100644 --- a/lib/Screens/itnerary_list/taxi_list.dart +++ b/lib/Screens/itnerary_list/taxi_list.dart @@ -184,7 +184,7 @@ class TaxiListWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ Text( - "${getRequestForTaxiClass(item["car_type"]!.toString())} For ${item["no_of_passengers"]!} Passernger", + "${getRequestForTaxiClass(item["car_type"]!.toString())} For ${item["no_of_passengers"]!} Passenger", style: TextStyle( fontSize: 14, fontWeight: FontWeight.w800, diff --git a/lib/Screens/organization/orgSetup.dart b/lib/Screens/organization/orgSetup.dart index 970566d..a2d2935 100644 --- a/lib/Screens/organization/orgSetup.dart +++ b/lib/Screens/organization/orgSetup.dart @@ -331,13 +331,23 @@ class _OrgSetUpState extends State { return Scaffold( backgroundColor: Colors.white, - appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: Row( - children: [ - if (isDesktop) CustomDrawer(isDesktop: true), - Expanded(child: buildOrganizationLayout(isDesktop)) - ], + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + 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: buildOrganizationLayout(isDesktop)) + ], + ), ), ); }); @@ -345,10 +355,13 @@ class _OrgSetUpState extends State { Widget buildOrganizationLayout(isDesktop) { return Container( - decoration: BoxDecoration( - // color: Colors.amber, - color: bodyColor, - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // // color: Colors.amber, + // color: bodyColor, + // border: Border.all( + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // width: 3.5)), child: Column( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -401,24 +414,25 @@ class _OrgSetUpState extends State { } return Container( - margin: isDesktop - ? EdgeInsets.all(10.0) - : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), + // margin: isDesktop + // ? EdgeInsets.all(10.0) + // : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), height: isDesktop ? MediaQuery.of(context).size.height * 0.98 : MediaQuery.of(context).size.height, - decoration: BoxDecoration( - border: isDesktop - ? Border.all( - width: 2, - color: Color(0xFFF7F7FB), - ) - : null, - color: Colors.white, - // color: Color(0xFFF7F7FB), - - // color: Colors.amber, - ), + // decoration: BoxDecoration( + // border: isDesktop + // ? Border.all( + // width: 2, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // ) + // : null, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // // color: Colors.amber, + // ), child: SingleChildScrollView( scrollDirection: Axis.vertical, child: Column( diff --git a/lib/Screens/organization/org_List.dart b/lib/Screens/organization/org_List.dart index 7a12ec2..4f439cb 100644 --- a/lib/Screens/organization/org_List.dart +++ b/lib/Screens/organization/org_List.dart @@ -59,11 +59,13 @@ class _OrganizationListState extends State { return Scaffold( backgroundColor: Colors.white, - appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), + // appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), + // drawer: isDesktop ? null : CustomDrawer(isDesktop: false), + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), body: Row( children: [ - if (isDesktop) CustomDrawer(isDesktop: true), + // if (isDesktop) CustomDrawer(isDesktop: true), Expanded(child: buildGroupListLayout(isDesktop)) ], ), diff --git a/lib/Screens/plans/create_plans.dart b/lib/Screens/plans/create_plans.dart index 4a64ccf..05868c3 100644 --- a/lib/Screens/plans/create_plans.dart +++ b/lib/Screens/plans/create_plans.dart @@ -67,13 +67,25 @@ class _CreatePlansState extends State { return Scaffold( backgroundColor: Colors.white, - body: Row( - children: [ - if (isDesktop) CustomDrawer(isDesktop: true), - Expanded( - child: - buildUserTable(isDesktop, context, bodyColor, layoutColor)), - ], + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + 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: buildUserTable( + isDesktop, context, bodyColor, layoutColor)), + ], + ), ), ); }); @@ -99,11 +111,15 @@ class _CreatePlansState extends State { return Container( // margin: const EdgeInsets.only(left: 10.0, right: 15.0, top: 10.0, bottom: 10.0), - decoration: BoxDecoration( - // color: Colors.amber, - // color: bodyColor, - color: Color(0xFFE1F5FE), - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // // color: Colors.amber, + // // color: bodyColor, + // color: Color(0xFFE1F5FE), + // border: Border.all( + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // width: 3.5)), child: Column( children: [ // Container( @@ -133,26 +149,27 @@ class _CreatePlansState extends State { // ), Expanded( child: Container( - margin: isDesktop - ? EdgeInsets.all(10.0) - : EdgeInsets.only( - left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), - padding: const EdgeInsets.all(10), + // margin: isDesktop + // ? EdgeInsets.all(10.0) + // : EdgeInsets.only( + // left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), + // padding: const EdgeInsets.all(10), height: isDesktop ? MediaQuery.of(context).size.height * 0.98 : MediaQuery.of(context).size.height, - decoration: BoxDecoration( - border: isDesktop - ? Border.all( - width: 2, - color: Color(0xFFF7F7FB), - ) - : null, - color: Colors.white, - // color: Color(0xFFF7F7FB), - - // color: Colors.amber, - ), + // decoration: BoxDecoration( + // border: isDesktop + // ? Border.all( + // width: 2, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // ) + // : null, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // // color: Colors.amber, + // ), // color: bodyColor, child: SingleChildScrollView( diff --git a/lib/Screens/plans/list_plans.dart b/lib/Screens/plans/list_plans.dart index 21d8424..189f551 100644 --- a/lib/Screens/plans/list_plans.dart +++ b/lib/Screens/plans/list_plans.dart @@ -233,13 +233,25 @@ class _ListPlansState extends State { return Scaffold( backgroundColor: Colors.white, - appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: Row( - children: [ - if (isDesktop) CustomDrawer(isDesktop: true), - Expanded(child: buildGroupListLayout(isDesktop)) - ], + // appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), + // drawer: isDesktop ? null : CustomDrawer(isDesktop: false), + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + 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: buildGroupListLayout(isDesktop)) + ], + ), ), ); }); @@ -247,11 +259,14 @@ class _ListPlansState extends State { Widget buildGroupListLayout(bool isDesktop) { return Container( - decoration: BoxDecoration( - // color: Colors.amber, - // color: bodyColor, - color: Color(0xFFE1F5FE), - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // // color: Colors.amber, + // // color: bodyColor, + // color: Color(0xFFE1F5FE), + // border: Border.all( + // // color: Color(0xFFF7F7FB), + // color: Colors.white, + // width: 3.5)), child: buildTableLayout(isDesktop), ); } @@ -278,7 +293,8 @@ class _ListPlansState extends State { border: isDesktop ? Border.all( width: 2, - color: Color(0xFFF7F7FB), + color: Colors.white, + // color: Color(0xFFF7F7FB), ) : null, color: Colors.white, @@ -294,7 +310,10 @@ class _ListPlansState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - SizedBox(height: 2), + // Divider( + // thickness: 0.2, // how "thick" the line is + // color: Colors.grey, // optional + // ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -308,16 +327,8 @@ class _ListPlansState extends State { color: Color(0xFF212121))), ], ), - ], - ), - SizedBox(height: 2), - Divider( - thickness: 0.2, // how "thick" the line is - color: Colors.grey, // optional - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + + Spacer(), Container( width: MediaQuery.of(context).size.width * 0.2, // or use Flexible @@ -573,30 +584,33 @@ class _ListPlansState extends State { height: 25, alignment: Alignment.center, decoration: BoxDecoration( - color: plan.statusValue == - "Partially Approved" - ? Colors.yellow.shade100 - : plan.statusValue == "Approved" - ? Colors.green.shade100 - : plan.statusValue == "Completed" - ? Colors.green.shade500 - : plan.statusValue == "Rejected" - ? Colors.red.shade100 - : Colors.grey.shade100, + color: getStatusColor(plan.statusValue), + // color: plan.statusValue == + // "Partially Approved" + // ? Colors.yellow.shade100 + // : plan.statusValue == "Approved" + // ? Colors.green.shade100 + // : plan.statusValue == "Completed" + // ? Colors.green.shade500 + // : plan.statusValue == "Rejected" + // ? Colors.red.shade100 + // : Colors.grey.shade100, borderRadius: BorderRadius.circular(10), ), child: Text( plan.statusValue, textAlign: TextAlign.center, style: TextStyle( - color: (plan.statusValue == - "Partially Approved" || - plan.statusValue == "Approved" || - plan.statusValue == "Rejected") - ? Colors.black - : plan.statusValue == "Completed" - ? Colors.white - : Colors.grey, + color: + getStatusTextColor(plan.statusValue), + // color: (plan.statusValue == + // "Partially Approved" || + // plan.statusValue == "Approved" || + // plan.statusValue == "Rejected") + // ? Colors.black + // : plan.statusValue == "Completed" + // ? Colors.white + // : Colors.grey, fontSize: 12, fontWeight: FontWeight.w400, ), @@ -667,4 +681,24 @@ class _ListPlansState extends State { ), ); } + + // Helper functions for colors + Color getStatusColor(String status) { + if (status == "Partially Approved") return Colors.yellow.shade100; + if (status == "Approved") return Colors.green.shade100; + if (status == "Completed") return Colors.green.shade500; + if (status == "Rejected") return Colors.red.shade100; + return Colors.grey.shade100; + } + + Color getStatusTextColor(String status) { + if (status == "Partially Approved" || + status == "Approved" || + status == "Rejected") { + return Colors.black; + } else if (status == "Completed") { + return Colors.white; + } + return Colors.grey; + } } diff --git a/lib/Screens/policy/policy.dart b/lib/Screens/policy/policy.dart index 31e6506..898805d 100644 --- a/lib/Screens/policy/policy.dart +++ b/lib/Screens/policy/policy.dart @@ -380,26 +380,36 @@ class _PolicyState extends State { return Scaffold( backgroundColor: Colors.white, - appBar: isDesktop ? null : const CustomAppBar(title: 'Policy'), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: Column( - children: [ - Expanded( - child: Row( - children: [ - if (isDesktop) CustomDrawer(isDesktop: true), + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + vertical: MediaQuery.of(context).size.height * + 0, // 5% of screen height as vertical padding + ) + : EdgeInsets.all(8), + child: Column( + children: [ + Expanded( + child: Row( + children: [ + // if (isDesktop) CustomDrawer(isDesktop: true), - Expanded(child: buildData(isDesktop, context)), - // Expanded( - // child: Container( - // color: bodyColor, - // child: buildPolicyLayout(isDesktop), - // ), - // ), - ], + Expanded(child: buildData(isDesktop, context)), + // Expanded( + // child: Container( + // color: bodyColor, + // child: buildPolicyLayout(isDesktop), + // ), + // ), + ], + ), ), - ), - ], + ], + ), ), // Row( @@ -440,16 +450,20 @@ class _PolicyState extends State { Widget buildData(bool isDesktop, context) { return Container( // margin: const EdgeInsets.only(left: 10.0, right: 15.0, top: 10.0, bottom: 10.0), - decoration: BoxDecoration( - color: Color(0xFFE1F5FE), - // color: bodyColor, - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // color: Color(0xFFE1F5FE), + // // color: bodyColor, + // border: Border.all( + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // width: 3.5)), child: Column( children: [ Expanded( child: Container( // color: bodyColor, - color: Color(0xFFE1F5FE), + // color: Color(0xFFE1F5FE), child: buildPolicyLayout(isDesktop), ), ), @@ -473,24 +487,25 @@ class _PolicyState extends State { Widget buildPolicyLayout(bool isDesktop) { return Container( - margin: isDesktop - ? EdgeInsets.all(10.0) - : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), + // margin: isDesktop + // ? EdgeInsets.all(10.0) + // : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), height: isDesktop ? MediaQuery.of(context).size.height * 0.98 : MediaQuery.of(context).size.height, - decoration: BoxDecoration( - border: isDesktop - ? Border.all( - width: 2, - color: Color(0xFFF7F7FB), - ) - : null, - color: Colors.white, - // color: Color(0xFFF7F7FB), - - // color: Colors.amber, - ), + // decoration: BoxDecoration( + // border: isDesktop + // ? Border.all( + // width: 2, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // ) + // : null, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // // color: Colors.amber, + // ), child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ diff --git a/lib/Screens/policy/policy_list.dart b/lib/Screens/policy/policy_list.dart index de615bc..11e995d 100644 --- a/lib/Screens/policy/policy_list.dart +++ b/lib/Screens/policy/policy_list.dart @@ -139,14 +139,24 @@ class _PolicyListState extends State { bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; return Scaffold( - backgroundColor: Colors.white, - appBar: isDesktop ? null : const CustomAppBar(title: 'Home'), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: Row( - children: [ - if (isDesktop) CustomDrawer(isDesktop: true), - Expanded(child: buildGroupList(isDesktop)) - ], + backgroundColor: Colors.white54, + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + 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: buildGroupList(isDesktop)) + ], + ), ), ); }); @@ -154,36 +164,40 @@ class _PolicyListState extends State { Widget buildGroupList(bool isDesktop) { return Container( - decoration: BoxDecoration( - // color: Colors.amber, - color: Color(0xFFE1F5FE), - // color: bodyColor, - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // // color: Colors.amber, + // color: Color(0xFFE1F5FE), + // // color: bodyColor, + // border: Border.all( + // // color: Color(0xFFF7F7FB), + // color: Colors.white, + // width: 3.5)), child: buildGroupListLayout(isDesktop), ); } Widget buildGroupListLayout(bool isDesktop) { return Container( - margin: isDesktop - ? EdgeInsets.all(10.0) - : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), - padding: const EdgeInsets.all(10), + // margin: isDesktop + // ? EdgeInsets.all(10.0) + // : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), + // padding: const EdgeInsets.all(10), height: isDesktop ? MediaQuery.of(context).size.height * 0.98 : MediaQuery.of(context).size.height, - decoration: BoxDecoration( - border: isDesktop - ? Border.all( - width: 2, - color: Color(0xFFF7F7FB), - ) - : null, - color: Colors.white, - // color: Color(0xFFF7F7FB), - - // color: Colors.amber, - ), + // decoration: BoxDecoration( + // border: isDesktop + // ? Border.all( + // width: 2, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // ) + // : null, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // // color: Colors.amber, + // ), child: Column( children: [ Row( diff --git a/lib/Screens/userManagement/create_user/create_user.dart b/lib/Screens/userManagement/create_user/create_user.dart index b6ee9db..60ee24b 100644 --- a/lib/Screens/userManagement/create_user/create_user.dart +++ b/lib/Screens/userManagement/create_user/create_user.dart @@ -663,14 +663,23 @@ class _CreateUserFormState extends State { bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; return Scaffold( - appBar: isDesktop ? null : const CustomAppBar(title: 'Create User '), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: Container( - // color: bodyColor, - color: Colors.white, + backgroundColor: Colors.white, + // appBar: isDesktop ? null : const CustomAppBar(title: 'Create User '), + // drawer: isDesktop ? null : CustomDrawer(isDesktop: false), + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + 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), + // if (isDesktop) CustomDrawer(isDesktop: true), // const Expanded(child: Center(child: Text("User Details Content"))), // Expanded( // child: _buildUserDetails(isDesktop), @@ -687,35 +696,39 @@ class _CreateUserFormState extends State { Widget buildData(bool isDesktop, context) { return Container( // margin: const EdgeInsets.only(left: 10.0, right: 15.0, top: 10.0, bottom: 10.0), - decoration: BoxDecoration( - // color: Colors.amber, - // color: bodyColor, - color: Color(0xFFE1F5FE), - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // // color: Colors.amber, + // // color: bodyColor, + // color: Color(0xFFE1F5FE), + // border: Border.all( + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // width: 3.5)), child: Column( children: [ Expanded( child: Container( - margin: isDesktop - ? EdgeInsets.all(10.0) - : EdgeInsets.only( - left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), - padding: const EdgeInsets.all(10), + // margin: isDesktop + // ? EdgeInsets.all(10.0) + // : EdgeInsets.only( + // left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), + // padding: const EdgeInsets.all(10), height: isDesktop ? MediaQuery.of(context).size.height * 0.98 : MediaQuery.of(context).size.height, - decoration: BoxDecoration( - border: isDesktop - ? Border.all( - width: 2, - color: Color(0xFFF7F7FB), - ) - : null, - color: Colors.white, - // color: Color(0xFFF7F7FB), - - // color: Colors.amber, - ), + // decoration: BoxDecoration( + // border: isDesktop + // ? Border.all( + // width: 2, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // ) + // : null, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // // color: Colors.amber, + // ), // color: bodyColor, child: SingleChildScrollView( child: Padding( diff --git a/lib/Screens/userManagement/user_List.dart b/lib/Screens/userManagement/user_List.dart index b799e76..2518942 100644 --- a/lib/Screens/userManagement/user_List.dart +++ b/lib/Screens/userManagement/user_List.dart @@ -245,13 +245,23 @@ class _UserListScreenState extends State { bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; return Scaffold( - appBar: isDesktop ? null : const CustomAppBar(title: 'User Management'), - drawer: isDesktop ? null : CustomDrawer(isDesktop: false), - body: Container( - color: Colors.white, + backgroundColor: Colors.white, + // appBar: isDesktop ? null : const CustomAppBar(title: 'User Management'), + // drawer: isDesktop ? null : CustomDrawer(isDesktop: false), + appBar: const CustomAppBar(), + drawer: CustomDrawer(isDesktop: false), + body: Padding( + padding: isDesktop + ? EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width * + 0.1, // 30% of screen width as horizontal padding + 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), + // if (isDesktop) CustomDrawer(isDesktop: true), // const Expanded(child: Center(child: Text("User Page Content"))), Expanded(child: buildGroupList(isDesktop)), ], @@ -263,36 +273,40 @@ class _UserListScreenState extends State { Widget buildGroupList(bool isDesktop) { return Container( - decoration: BoxDecoration( - // color: Colors.amber, - // color: bodyColor, - color: Color(0xFFE1F5FE), - border: Border.all(color: Color(0xFFF7F7FB), width: 3.5)), + // decoration: BoxDecoration( + // // color: Colors.amber, + // // color: bodyColor, + // color: Color(0xFFE1F5FE), + // border: Border.all( + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // width: 3.5)), child: buildUserTable(isDesktop), ); } Widget buildUserTable(bool isDesktop) { return Container( - margin: isDesktop - ? EdgeInsets.all(10.0) - : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), + // margin: isDesktop + // ? EdgeInsets.all(10.0) + // : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), // padding: const EdgeInsets.all(10), height: isDesktop ? MediaQuery.of(context).size.height * 0.98 : MediaQuery.of(context).size.height, - decoration: BoxDecoration( - border: isDesktop - ? Border.all( - width: 2, - color: Color(0xFFF7F7FB), - ) - : null, - color: Colors.white, - // color: Color(0xFFF7F7FB), - - // color: Colors.amber, - ), + // decoration: BoxDecoration( + // border: isDesktop + // ? Border.all( + // width: 2, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // ) + // : null, + // color: Colors.white, + // // color: Color(0xFFF7F7FB), + // + // // color: Colors.amber, + // ), child: Padding( padding: const EdgeInsets.all(10.0), child: Container( @@ -301,7 +315,10 @@ class _UserListScreenState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - SizedBox(height: 2), + // Divider( + // thickness: 0.2, // how "thick" the line is + // color: Colors.grey, // optional + // ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -315,18 +332,9 @@ class _UserListScreenState extends State { color: Color(0xFF212121))), ], ), - ], - ), - SizedBox(height: 2), - Divider( - thickness: 0.2, // how "thick" the line is - color: Colors.grey, // optional - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ + Spacer(), Container( - width: MediaQuery.of(context).size.width * 0.2, + width: MediaQuery.of(context).size.width * 0.3, // or use Flexible child: TextField( onChanged: (query) {}, @@ -406,445 +414,689 @@ class _UserListScreenState extends State { future: futureUsers, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { - return Center(child: CircularProgressIndicator()); - } else if (snapshot.hasError) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError || + !snapshot.hasData || + snapshot.data!.isEmpty) { return Center( child: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.error_outline, - color: Colors.redAccent, - size: 60, - ), + children: const [ + Icon(Icons.error_outline, + color: Colors.redAccent, size: 60), SizedBox(height: 16), - Text( - "Oops!", - style: TextStyle( - fontSize: 22, - fontWeight: FontWeight.bold, - color: Colors.redAccent, - ), - ), + Text("Oops!", + style: TextStyle( + fontSize: 22, + fontWeight: FontWeight.bold, + color: Colors.redAccent)), SizedBox(height: 8), - Text( - "No User Available", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ), + Text("No Plans Available For This User", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.bold, + color: Colors.grey)), SizedBox(height: 20), - Text( - " Please Create NewUser", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 16, - color: Colors.grey[700], - ), - ), + Text("Please Create Plan", + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 16, color: Colors.grey)), SizedBox(height: 20), - // ElevatedButton.icon( - // onPressed: () { - // // Optional: retry logic or navigation - // }, - // icon: Icon(Icons.refresh), - // label: Text("Try Again"), - // style: ElevatedButton.styleFrom( - // backgroundColor: Colors.blueAccent, - // ), - // ), ], ), ), ); - } else if (!snapshot.hasData || snapshot.data!.isEmpty) { - return Center(child: Text("No users found")); } List users = snapshot.data!; - Color borderColor = Color(0xFF9E9DBD); + // users.sort((a, b) => + // int.parse(b.planId).compareTo(int.parse(a.planId))); - return Expanded( - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: SizedBox( - width: MediaQuery.of(context).size.width * 1.5, - child: SingleChildScrollView( - scrollDirection: Axis - .horizontal, // Inner wrapper for vertical scrolling + Widget table = LayoutBuilder( + builder: (context, constraints) { + double minWidth = + isDesktop ? constraints.maxWidth : 1300; - child: ConstrainedBox( - constraints: BoxConstraints( - minWidth: - MediaQuery.of(context).size.width * - 0.8), - // constraints: BoxConstraints(minWidth: 1300), - // width: MediaQuery.of(context).size.width , - - child: Container( - // color: Colors.grey, - // color: Colors.amber, - child: DataTable( - columnSpacing: - 20.0, // Adjust spacing between columns - dividerThickness: 0.5, - dataRowMinHeight: - 60.0, // Minimum row height - dataRowMaxHeight: 100.0, - border: TableBorder( - horizontalInside: BorderSide( - width: 0.5, - color: Colors.grey.shade200), - ), - columns: const [ - DataColumn( - label: Text( - 'User Details', + return ConstrainedBox( + constraints: BoxConstraints(minWidth: minWidth), + child: DataTable( + dividerThickness: 0.5, + columnSpacing: isDesktop ? 24.0 : 16.0, + border: TableBorder( + horizontalInside: BorderSide( + width: 0.5, color: Colors.grey.shade200), + ), + columns: const [ + DataColumn( + label: Text('UserName', + style: TextStyle( + // color: Color(0xFF9E9DBD), + color: Color(0xFF9E9DBD), + fontSize: 14, + fontFamily: "Archivo", + fontWeight: FontWeight.w500))), + DataColumn( + label: Text('Email Id', style: TextStyle( color: Color(0xFF9E9DBD), - fontSize: 15, - fontWeight: FontWeight.bold), - )), - DataColumn( - label: Text( - 'Role', + fontFamily: "Archivo", + fontWeight: FontWeight.bold))), + DataColumn( + label: Text('Role', style: TextStyle( color: Color(0xFF9E9DBD), - fontSize: 15, - fontWeight: FontWeight.bold), - )), - DataColumn( - label: Text( - 'Level', + fontFamily: "Archivo", + fontWeight: FontWeight.bold))), + DataColumn( + label: Text('Status', style: TextStyle( color: Color(0xFF9E9DBD), - fontSize: 15, - fontWeight: FontWeight.bold), - )), - DataColumn( - label: Text( - 'Status', + fontFamily: "Archivo", + fontWeight: FontWeight.bold))), + DataColumn( + label: Text('Actions', style: TextStyle( color: Color(0xFF9E9DBD), - fontSize: 15, - fontWeight: FontWeight.bold), - )), - DataColumn( - label: Text( - 'Actions', + fontFamily: "Archivo", + fontWeight: FontWeight.bold))), + ], + rows: users.map((user) { + String userId = + user['user_id'].toString(); // Get user ID + bool isSelected = selectedUserId == userId; + + return DataRow(cells: [ + DataCell(Text( + "${user['first_name'] ?? ''} ${user['last_name'] ?? ''}", + style: TextStyle( + fontSize: 13, + fontFamily: "Archivo", + ))), + DataCell(Text(user['email'] ?? '', + style: TextStyle( + fontSize: 13, + fontFamily: "Archivo", + ))), + DataCell(Text(user['role_id'] ?? 'N/A', + style: TextStyle( + fontSize: 13, + fontFamily: "Archivo", + ), + softWrap: true, + overflow: TextOverflow.ellipsis)), + DataCell(GestureDetector( + onTap: () { + handleToggleUserStatus(user['user_id'], + user['is_active'], user); + }, + child: Text( + user['is_active'] == "1" + ? "Active" + : "Inactive", style: TextStyle( - color: Color(0xFF9E9DBD), - fontSize: 15, - fontWeight: FontWeight.bold), - )), - ], - - rows: users.map((user) { - String userId = user['user_id'] - .toString(); // Get user ID - bool isSelected = - selectedUserId == userId; - - return DataRow(cells: [ - // DataCell(Text(user['user_id'].toString())), - DataCell(Row( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Align( - alignment: Alignment.center, - child: GestureDetector( - onTap: () { - setState(() { - selectedUserId = - userId; // Store clicked user ID - }); - }, - child: Container( - width: 15, // Adjust size - height: 15, - decoration: BoxDecoration( - // Background color - shape: BoxShape.rectangle, - border: Border.all( - color: isSelected - ? Colors.blueAccent - : Color(0xFF9E9DBD), - // color: Color(0xFF9E9DBD), - // color: Color.fromRGBO(128, 128, 128, 0.6), - width: isSelected - ? 2 - : 1), // Grey outline - ), - ), - ), - ), - SizedBox( - width: 50, - ), - Align( - alignment: Alignment.center, - child: Container( - decoration: BoxDecoration( - shape: BoxShape.circle, - border: Border.all( - color: - Color(0xFF9E9DBD), - width: - 1), // Grey outline - ), - child: Padding( - padding: - const EdgeInsets.all( - 2.0), - child: Container( - width: 40, // Adjust size - height: 40, - decoration: BoxDecoration( - color: Colors - .amber, // Inner circle background - shape: BoxShape.circle, - ), - child: Column( - mainAxisAlignment: - MainAxisAlignment - .center, - crossAxisAlignment: - CrossAxisAlignment - .center, - children: [ - Text( - (user['first_name'] != - null && - user['first_name']! - .isNotEmpty) - ? user['first_name']![ - 0] - .toUpperCase() - : "?", - style: TextStyle( - fontSize: 18, - fontWeight: - FontWeight - .bold, - color: - Colors.white, - ), - ), - ], - ), - ), - )), - ), - SizedBox( - width: 20, - ), - Column( - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - Text( - "${user['first_name'] ?? ''} ${user['last_name'] ?? ''}", - style: TextStyle( - color: - Colors.blueAccent, - fontSize: 16), - ), - ], - ), - SizedBox(height: 5), - Row( - children: [ - Icon(Icons.mail_outline, - size: 15, - color: - Color(0xFF9E9EBE)), - SizedBox( - width: 10, - ), - Text(user['email'] ?? '') - ], - ), - SizedBox(height: 5), - Row( - children: [ - Icon( - Icons - .account_tree_outlined, - size: 15, - color: - Color(0xFF9E9EBE)), - SizedBox( - width: 10, - ), - Text( - user['user_type'] ?? '') - ], - ), - ], - ), - ], - )), - - DataCell(Text( - user['role_id'] ?? 'N/A', - style: TextStyle( - color: user['is_active'] == "1" - ? Colors.black - : Colors.grey, - fontWeight: FontWeight.bold), - )), - DataCell(Text( - user['level_id'] ?? 'N/A', - style: TextStyle( - color: user['is_active'] == "1" - ? Colors.black - : Colors.grey, - fontWeight: FontWeight.bold), - )), - DataCell(GestureDetector( - onTap: () { - handleToggleUserStatus( - user['user_id'], - user['is_active'], - user); - }, - child: Text( - user['is_active'] == "1" - ? "Active" - : "Inactive", - style: TextStyle( - color: - user['is_active'] == "1" - ? Colors.lightGreen - : Colors.grey, - fontWeight: FontWeight.bold), - ))), - - DataCell( - Row( - children: [ - MouseRegion( - cursor: user['is_active'] == "0" - ? SystemMouseCursors - .forbidden - : SystemMouseCursors.click, - child: IconButton( - icon: Icon( - Icons.remove_red_eye, - size: 18, - color: - user['is_active'] == - "0" - ? Colors.grey - : Color( - 0xFF475569)), - onPressed: - user['is_active'] == "0" - ? null - : () { - context.go( - "/CreateUserDetails", - extra: { - "selectedUser": - user, - "isViewMode": - true - }, - ); - }, - ), - ), - - MouseRegion( - cursor: user['is_active'] == "0" - ? SystemMouseCursors - .forbidden - : SystemMouseCursors.click, - child: GestureDetector( - onTap: - user['is_active'] == "0" - ? null - : () { - context.go( - "/CreateUserDetails", - extra: { - "selectedUser": - user, - "isViewMode": - false - }, - ); - }, - child: Image.asset( - 'assets/images/IconsImg/edit.png', - width: 20, - height: 15), - ), - ), - - // MouseRegion( - // cursor: user['is_active'] == "0" - // ? SystemMouseCursors - // .forbidden - // : SystemMouseCursors.click, - // child: IconButton( - // icon: Icon(Icons.edit, - // color: - // user['is_active'] == - // "0" - // ? Colors.grey - // : Colors.green), - // onPressed: - // user['is_active'] == "0" - // ? null - // : () { - // print( - // "USER: $user"); - // - // // final userJson = jsonEncode( - // // user); // Convert user map to string - // // final encodedUser = - // // Uri.encodeComponent( - // // userJson); - // - // context.go( - // "/CreateUserDetails", - // extra: { - // "selectedUser": - // user, - // "isViewMode": - // false - // }, - // ); - // }, - // ), - // ), - ], + color: user['is_active'] == "1" + ? Colors.green + : Colors.grey, + fontWeight: FontWeight.w400), + ))), + DataCell( + Row( + children: [ + MouseRegion( + cursor: user['is_active'] == "0" + ? SystemMouseCursors.forbidden + : SystemMouseCursors.click, + child: IconButton( + icon: Icon(Icons.remove_red_eye, + size: 18, + color: user['is_active'] == "0" + ? Colors.grey + : Color(0xFF475569)), + onPressed: user['is_active'] == "0" + ? null + : () { + context.go( + "/CreateUserDetails", + extra: { + "selectedUser": user, + "isViewMode": true + }, + ); + }, ), ), - ]); - }).toList(), + + MouseRegion( + cursor: user['is_active'] == "0" + ? SystemMouseCursors.forbidden + : SystemMouseCursors.click, + child: GestureDetector( + onTap: user['is_active'] == "0" + ? null + : () { + context.go( + "/CreateUserDetails", + extra: { + "selectedUser": user, + "isViewMode": false + }, + ); + }, + child: Image.asset( + 'assets/images/IconsImg/edit.png', + width: 20, + height: 15), + ), + ), + + // MouseRegion( + // cursor: user['is_active'] == "0" + // ? SystemMouseCursors + // .forbidden + // : SystemMouseCursors.click, + // child: IconButton( + // icon: Icon(Icons.edit, + // color: + // user['is_active'] == + // "0" + // ? Colors.grey + // : Colors.green), + // onPressed: + // user['is_active'] == "0" + // ? null + // : () { + // print( + // "USER: $user"); + // + // // final userJson = jsonEncode( + // // user); // Convert user map to string + // // final encodedUser = + // // Uri.encodeComponent( + // // userJson); + // + // context.go( + // "/CreateUserDetails", + // extra: { + // "selectedUser": + // user, + // "isViewMode": + // false + // }, + // ); + // }, + // ), + // ), + ], + ), ), + ]); + }).toList(), + ), + ); + }, + ); + + return Expanded( + child: isDesktop + ? table + : SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: table, ), ), - ), - ), - ), ); }, - ), + ) + + // FutureBuilder>( + // future: futureUsers, + // builder: (context, snapshot) { + // if (snapshot.connectionState == ConnectionState.waiting) { + // return Center(child: CircularProgressIndicator()); + // } else if (snapshot.hasError) { + // return Center( + // child: Padding( + // padding: const EdgeInsets.all(16.0), + // child: Column( + // mainAxisSize: MainAxisSize.min, + // children: [ + // Icon( + // Icons.error_outline, + // color: Colors.redAccent, + // size: 60, + // ), + // SizedBox(height: 16), + // Text( + // "Oops!", + // style: TextStyle( + // fontSize: 22, + // fontWeight: FontWeight.bold, + // color: Colors.redAccent, + // ), + // ), + // SizedBox(height: 8), + // Text( + // "No User Available", + // textAlign: TextAlign.center, + // style: TextStyle( + // fontSize: 20, + // fontWeight: FontWeight.bold, + // color: Colors.grey, + // ), + // ), + // SizedBox(height: 20), + // Text( + // " Please Create NewUser", + // textAlign: TextAlign.center, + // style: TextStyle( + // fontSize: 16, + // color: Colors.grey[700], + // ), + // ), + // SizedBox(height: 20), + // // ElevatedButton.icon( + // // onPressed: () { + // // // Optional: retry logic or navigation + // // }, + // // icon: Icon(Icons.refresh), + // // label: Text("Try Again"), + // // style: ElevatedButton.styleFrom( + // // backgroundColor: Colors.blueAccent, + // // ), + // // ), + // ], + // ), + // ), + // ); + // } else if (!snapshot.hasData || snapshot.data!.isEmpty) { + // return Center(child: Text("No users found")); + // } + // + // List users = snapshot.data!; + // Color borderColor = Color(0xFF9E9DBD); + // + // return Expanded( + // child: SingleChildScrollView( + // scrollDirection: Axis.vertical, + // child: SizedBox( + // width: MediaQuery.of(context).size.width * 1.5, + // child: SingleChildScrollView( + // scrollDirection: Axis + // .horizontal, // Inner wrapper for vertical scrolling + // + // child: ConstrainedBox( + // constraints: BoxConstraints( + // minWidth: + // MediaQuery.of(context).size.width * + // 0.8), + // // constraints: BoxConstraints(minWidth: 1300), + // // width: MediaQuery.of(context).size.width , + // + // child: Container( + // // color: Colors.grey, + // // color: Colors.amber, + // child: DataTable( + // columnSpacing: + // 20.0, // Adjust spacing between columns + // dividerThickness: 0.5, + // dataRowMinHeight: + // 60.0, // Minimum row height + // dataRowMaxHeight: 100.0, + // border: TableBorder( + // horizontalInside: BorderSide( + // width: 0.5, + // color: Colors.grey.shade200), + // ), + // columns: const [ + // DataColumn( + // label: Text( + // 'User Details', + // style: TextStyle( + // color: Color(0xFF9E9DBD), + // fontSize: 15, + // fontWeight: FontWeight.bold), + // )), + // DataColumn( + // label: Text( + // 'Role', + // style: TextStyle( + // color: Color(0xFF9E9DBD), + // fontSize: 15, + // fontWeight: FontWeight.bold), + // )), + // DataColumn( + // label: Text( + // 'Level', + // style: TextStyle( + // color: Color(0xFF9E9DBD), + // fontSize: 15, + // fontWeight: FontWeight.bold), + // )), + // DataColumn( + // label: Text( + // 'Status', + // style: TextStyle( + // color: Color(0xFF9E9DBD), + // fontSize: 15, + // fontWeight: FontWeight.bold), + // )), + // DataColumn( + // label: Text( + // 'Actions', + // style: TextStyle( + // color: Color(0xFF9E9DBD), + // fontSize: 15, + // fontWeight: FontWeight.bold), + // )), + // ], + // + // rows: users.map((user) { + // String userId = user['user_id'] + // .toString(); // Get user ID + // bool isSelected = + // selectedUserId == userId; + // + // return DataRow(cells: [ + // // DataCell(Text(user['user_id'].toString())), + // DataCell(Row( + // mainAxisAlignment: + // MainAxisAlignment.start, + // crossAxisAlignment: + // CrossAxisAlignment.start, + // children: [ + // Align( + // alignment: Alignment.center, + // child: GestureDetector( + // onTap: () { + // setState(() { + // selectedUserId = + // userId; // Store clicked user ID + // }); + // }, + // child: Container( + // width: 15, // Adjust size + // height: 15, + // decoration: BoxDecoration( + // // Background color + // shape: BoxShape.rectangle, + // border: Border.all( + // color: isSelected + // ? Colors.blueAccent + // : Color(0xFF9E9DBD), + // // color: Color(0xFF9E9DBD), + // // color: Color.fromRGBO(128, 128, 128, 0.6), + // width: isSelected + // ? 2 + // : 1), // Grey outline + // ), + // ), + // ), + // ), + // SizedBox( + // width: 50, + // ), + // Align( + // alignment: Alignment.center, + // child: Container( + // decoration: BoxDecoration( + // shape: BoxShape.circle, + // border: Border.all( + // color: + // Color(0xFF9E9DBD), + // width: + // 1), // Grey outline + // ), + // child: Padding( + // padding: + // const EdgeInsets.all( + // 2.0), + // child: Container( + // width: 40, // Adjust size + // height: 40, + // decoration: BoxDecoration( + // color: Colors + // .amber, // Inner circle background + // shape: BoxShape.circle, + // ), + // child: Column( + // mainAxisAlignment: + // MainAxisAlignment + // .center, + // crossAxisAlignment: + // CrossAxisAlignment + // .center, + // children: [ + // Text( + // (user['first_name'] != + // null && + // user['first_name']! + // .isNotEmpty) + // ? user['first_name']![ + // 0] + // .toUpperCase() + // : "?", + // style: TextStyle( + // fontSize: 18, + // fontWeight: + // FontWeight + // .bold, + // color: + // Colors.white, + // ), + // ), + // ], + // ), + // ), + // )), + // ), + // SizedBox( + // width: 20, + // ), + // Column( + // mainAxisAlignment: + // MainAxisAlignment.center, + // crossAxisAlignment: + // CrossAxisAlignment.start, + // children: [ + // Row( + // children: [ + // Text( + // "${user['first_name'] ?? ''} ${user['last_name'] ?? ''}", + // style: TextStyle( + // color: + // Colors.blueAccent, + // fontSize: 16), + // ), + // ], + // ), + // SizedBox(height: 5), + // Row( + // children: [ + // Icon(Icons.mail_outline, + // size: 15, + // color: + // Color(0xFF9E9EBE)), + // SizedBox( + // width: 10, + // ), + // Text(user['email'] ?? '') + // ], + // ), + // SizedBox(height: 5), + // Row( + // children: [ + // Icon( + // Icons + // .account_tree_outlined, + // size: 15, + // color: + // Color(0xFF9E9EBE)), + // SizedBox( + // width: 10, + // ), + // Text( + // user['user_type'] ?? '') + // ], + // ), + // ], + // ), + // ], + // )), + // + // DataCell(Text( + // user['role_id'] ?? 'N/A', + // style: TextStyle( + // color: user['is_active'] == "1" + // ? Colors.black + // : Colors.grey, + // fontWeight: FontWeight.bold), + // )), + // DataCell(Text( + // user['level_id'] ?? 'N/A', + // style: TextStyle( + // color: user['is_active'] == "1" + // ? Colors.black + // : Colors.grey, + // fontWeight: FontWeight.bold), + // )), + // DataCell(GestureDetector( + // onTap: () { + // handleToggleUserStatus( + // user['user_id'], + // user['is_active'], + // user); + // }, + // child: Text( + // user['is_active'] == "1" + // ? "Active" + // : "Inactive", + // style: TextStyle( + // color: + // user['is_active'] == "1" + // ? Colors.lightGreen + // : Colors.grey, + // fontWeight: FontWeight.bold), + // ))), + // + // DataCell( + // Row( + // children: [ + // MouseRegion( + // cursor: user['is_active'] == "0" + // ? SystemMouseCursors + // .forbidden + // : SystemMouseCursors.click, + // child: IconButton( + // icon: Icon( + // Icons.remove_red_eye, + // size: 18, + // color: + // user['is_active'] == + // "0" + // ? Colors.grey + // : Color( + // 0xFF475569)), + // onPressed: + // user['is_active'] == "0" + // ? null + // : () { + // context.go( + // "/CreateUserDetails", + // extra: { + // "selectedUser": + // user, + // "isViewMode": + // true + // }, + // ); + // }, + // ), + // ), + // + // MouseRegion( + // cursor: user['is_active'] == "0" + // ? SystemMouseCursors + // .forbidden + // : SystemMouseCursors.click, + // child: GestureDetector( + // onTap: + // user['is_active'] == "0" + // ? null + // : () { + // context.go( + // "/CreateUserDetails", + // extra: { + // "selectedUser": + // user, + // "isViewMode": + // false + // }, + // ); + // }, + // child: Image.asset( + // 'assets/images/IconsImg/edit.png', + // width: 20, + // height: 15), + // ), + // ), + // + // // MouseRegion( + // // cursor: user['is_active'] == "0" + // // ? SystemMouseCursors + // // .forbidden + // // : SystemMouseCursors.click, + // // child: IconButton( + // // icon: Icon(Icons.edit, + // // color: + // // user['is_active'] == + // // "0" + // // ? Colors.grey + // // : Colors.green), + // // onPressed: + // // user['is_active'] == "0" + // // ? null + // // : () { + // // print( + // // "USER: $user"); + // // + // // // final userJson = jsonEncode( + // // // user); // Convert user map to string + // // // final encodedUser = + // // // Uri.encodeComponent( + // // // userJson); + // // + // // context.go( + // // "/CreateUserDetails", + // // extra: { + // // "selectedUser": + // // user, + // // "isViewMode": + // // false + // // }, + // // ); + // // }, + // // ), + // // ), + // ], + // ), + // ), + // ]); + // }).toList(), + // ), + // ), + // ), + // ), + // ), + // ), + // ); + // }, + // ), + // ]), )), ); diff --git a/lib/routes/custom_appBar.dart b/lib/routes/custom_appBar.dart index 952c024..7347402 100644 --- a/lib/routes/custom_appBar.dart +++ b/lib/routes/custom_appBar.dart @@ -1,34 +1,361 @@ +import 'dart:convert'; import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:shared_preferences/shared_preferences.dart'; // don't forget +import '../services/apiService.dart'; -class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { - final String title; - final List? actions; // Optional actions (icons, buttons) +class CustomAppBar extends StatefulWidget implements PreferredSizeWidget { + final String? logoUrl; + final String? username; + final List? actions; final bool showBackButton; const CustomAppBar({ super.key, - required this.title, + this.logoUrl, + this.username, this.actions, - this.showBackButton = false, // Default: No back button + this.showBackButton = false, }); + @override + Size get preferredSize => const Size.fromHeight(kToolbarHeight); + + @override + _CustomAppBarState createState() => _CustomAppBarState(); +} + +class _CustomAppBarState extends State { + final ApiService apiService = ApiService(); + + String? token; + Map? userData; + Map? fetchedUserData; + Map userDetails = {}; + + Map? selectedOrg; + Color? layoutColor; + Color? bodyColor; + + Color _myTravelRequestColor = Color(0xFF475569); // Default color + Color _myApprovalsColor = Color(0xFF475569); // Default color + + void initState() { + super.initState(); + // initializeData(); + WidgetsBinding.instance.addPostFrameCallback((_) { + initializeData(); + getOrganizationData(); + }); + } + + Future initializeData() async { + print("initializeDatainitializeData"); + token = await getToken(); + fetchedUserData = await getUserData(); + + if (token == null || fetchedUserData == null) { + print("Token or USerId missing"); + return; + } + + setState(() { + userData = fetchedUserData; + }); + } + + Future getToken() async { + final prefs = await SharedPreferences.getInstance(); + return prefs.getString("auth_token"); + } + + Future?> getUserData() async { + final prefs = await SharedPreferences.getInstance(); + final String? userDataString = prefs.getString('user_data'); + + if (userDataString != null) { + try { + userDetails = jsonDecode(userDataString); + + return { + "user_id": userDetails["user_id"].toString(), + "name": "${userDetails["first_name"]} ${userDetails["last_name"]}", + "email": userDetails["email"] ?? "", + "role": userDetails["role"] ?? "", + }; + } catch (e) { + print("Error decoding user data: $e"); + return null; + } + } + return null; + } + + Future getOrganizationData() async { + try { + print("getUpdatedServices"); + + final result = await apiService.fetchOrganization(); + + final prefs = await SharedPreferences.getInstance(); + print("UUPdatedServices - $result"); + + setState(() { + selectedOrg = result; + + layoutColor = selectedOrg?['layout_color'] != null + ? Color(int.parse(selectedOrg!['layout_color'])) + : Colors.white; + + bodyColor = selectedOrg?['color'] != null + ? Color(int.parse( + selectedOrg!['color'].toString().replaceFirst('0x', ''), + radix: 16)) + : Colors.blue; + + String? rawLogoPath = selectedOrg?['logo']; + if (rawLogoPath != null && rawLogoPath.contains('/assets')) { + const baseUrl = "https://apitest.tripapprovaltool.com"; + final assetPath = rawLogoPath.split('/assets').last; + selectedOrg!['logo'] = "$baseUrl/assets$assetPath"; + } + }); + + // Save to SharedPreferences + await prefs.setString('layout_color', selectedOrg?['layout_color']); + await prefs.setString('body_color', selectedOrg?['color']); + await prefs.setString('body_color', selectedOrg?['plan_action']); + + print( + "Layout Color- ${selectedOrg?['layout_color']} - $layoutColor ---------- bodyColor - $bodyColor"); + } catch (e) { + print("Error : $e"); + } + } + @override Widget build(BuildContext context) { return AppBar( - title: Text(title, style: const TextStyle(fontWeight: FontWeight.bold)), - centerTitle: true, - backgroundColor: Colors.blueAccent, // Customize color - elevation: 4, // Shadow effect - leading: showBackButton - ? IconButton( - icon: const Icon(Icons.arrow_back), - onPressed: () => Navigator.pop(context), // Back navigation - ) - : null, - actions: actions, + backgroundColor: Colors.white, + surfaceTintColor: Colors.white, + // elevation: 3, + automaticallyImplyLeading: false, + // leading: showBackButton + // ? IconButton( + // icon: const Icon(Icons.arrow_back, color: Colors.black87), + // onPressed: () => Navigator.pop(context), + // ) + // : null, + titleSpacing: 0, + title: Row( + children: [ + Padding( + padding: const EdgeInsets.all(10), + child: selectedOrg?['logo'] != null + ? ClipRect( + child: Image.network( + selectedOrg!['logo'], + width: 100, + height: 50, + fit: BoxFit.contain, + errorBuilder: (context, error, stackTrace) { + return const CircleAvatar( + radius: 20, + backgroundColor: Colors.redAccent, + child: Icon(Icons.error, size: 10), + ); + }, + ), + ) + : const CircleAvatar( + radius: 20, + backgroundColor: Colors.white, + child: Icon( + Icons.add_a_photo, + size: 10, + color: Colors.grey, + ), + ), + ), + const SizedBox(width: 8), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + child: Row( + children: [ + GestureDetector( + onTap: () { + print("ONTAP Custom"); + print("ONTAP Custom- $userDetails "); + context.go( + "/CreateUserDetails", + extra: { + "selectedUser": userDetails, + "isEditProfile": true, + "isViewMode": true + }, + ); + }, + child: Text( + userData?["name"] ?? "N/A", + style: TextStyle( + fontSize: 13, + fontWeight: FontWeight.w600, + fontFamily: "Archivo", + // color: Color(0xFF12B24B), + color: layoutColor, + ), + ), + ), + ], + ), + ), + ], + ), + ), + ], + ), + actions: [ + Row( + children: [ + MouseRegion( + cursor: SystemMouseCursors.click, + onEnter: (_) { + setState(() { + _myTravelRequestColor = Colors.blue; // Change color on hover + }); + }, + onExit: (_) { + setState(() { + _myTravelRequestColor = + Color(0xFF475569); // Revert color when hover ends + }); + }, + child: GestureDetector( + onTap: () { + context.go('/listPlan'); + }, + child: Text( + "My Travel Request", + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + // color: Color(0xFF475569), + color: _myTravelRequestColor, + fontFamily: "Archivo"), + )), + ), + const SizedBox(width: 25), + MouseRegion( + cursor: SystemMouseCursors.click, + onEnter: (_) { + setState(() { + _myApprovalsColor = Colors.blue; // Change color on hover + }); + }, + onExit: (_) { + setState(() { + _myApprovalsColor = + Color(0xFF475569); // Revert color when hover ends + }); + }, + child: GestureDetector( + onTap: () { + context.go('/ApprovalList'); + }, + child: Text( + "My Approvals", + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: _myApprovalsColor, + // color: Color(0xFF475569), + fontFamily: "Archivo"), + )), + ), + const SizedBox(width: 15), + if (userData?["role"] != "User") + Builder( + builder: (context) => PopupMenuButton( + color: Colors.white, + icon: const Icon(Icons.settings, color: Colors.black87), + offset: const Offset(0, 50), // 👈 shift it 50 pixels down + onSelected: (String value) { + switch (value) { + case '/OrganizationSetup': + context.go('/OrganizationSetup'); + break; + case '/listUser': + context.go('/listUser'); + break; + case '/group': + context.go('/group'); + break; + case '/PolicyList': + context.go('/PolicyList'); + case '/CreateUserDetails': + context.go( + "/CreateUserDetails", + extra: { + "selectedUser": userDetails, + "isEditProfile": true, + "isViewMode": true + }, + ); + case '/logout': + context.go('/'); + break; + } + }, + + itemBuilder: (BuildContext context) => + menuItems.map(buildMenuItem).toList(), + ), + ), + const SizedBox(width: 8), + ], + ), + ], + bottom: PreferredSize( + preferredSize: Size.fromHeight(1), + child: Container( + height: 1, + color: Colors.grey.shade200, // Set the color of the bottom border + ), + ), ); } @override - Size get preferredSize => const Size.fromHeight(56); // Standard AppBar height + Size get preferredSize => const Size.fromHeight(kToolbarHeight); +} + +final List> menuItems = [ + { + 'value': '/OrganizationSetup', + 'icon': Icons.business, + 'label': 'Organization' + }, + {'value': '/listUser', 'icon': Icons.manage_accounts, 'label': 'Users'}, + {'value': '/group', 'icon': Icons.group, 'label': 'Group'}, + {'value': '/PolicyList', 'icon': Icons.policy, 'label': 'Policy'}, + { + 'value': '/CreateUserDetails', + 'icon': Icons.account_circle, + 'label': 'My Profile' + }, + {'value': '/logout', 'icon': Icons.login_outlined, 'label': 'Logout'}, +]; + +PopupMenuItem buildMenuItem(Map item) { + return PopupMenuItem( + value: item['value'], + child: ListTile( + leading: Icon(item['icon'], size: 18), + title: Text(item['label'], style: const TextStyle(fontSize: 13)), + ), + ); } diff --git a/lib/routes/custom_drawer.dart b/lib/routes/custom_drawer.dart index 3d38cee..31188f3 100644 --- a/lib/routes/custom_drawer.dart +++ b/lib/routes/custom_drawer.dart @@ -357,18 +357,21 @@ class _CustomDrawerState extends State { ), ); - if (widget.isDesktop) { - // Sidebar for Desktop (always visible)** - return Container( - width: 250, // Fixed width for sidebar - color: Colors.grey.shade50, - child: drawerContent, - ); - } else { - // Drawer for Mobile & Tablet** - return Drawer( - child: ListView(padding: EdgeInsets.zero, children: [drawerContent])); - } + return Drawer( + child: ListView(padding: EdgeInsets.zero, children: [drawerContent])); + + // if (widget.isDesktop) { + // // Sidebar for Desktop (always visible)** + // return Container( + // width: 250, // Fixed width for sidebar + // color: Colors.grey.shade50, + // child: drawerContent, + // ); + // } else { + // // Drawer for Mobile & Tablet** + // return Drawer( + // child: ListView(padding: EdgeInsets.zero, children: [drawerContent])) ; + // } } /// **Reusable Drawer Item**