From 3b038f7b428f2c659a16690e7f8160ac44e0d594 Mon Sep 17 00:00:00 2001 From: VINISTAN Date: Thu, 9 Jan 2025 13:36:31 +0530 Subject: [PATCH] Marriage card Implemented --- lib/config/my_router.dart | 13 +- .../competitiveness.dart | 0 .../Country_Profile/country_profile.dart | 142 ++++++++ .../UAE_Numbers/Social/marriages.dart | 266 ++++++++++++++ .../{ => UAE_Numbers}/uae_numbers.dart | 36 +- .../country_profile.dart | 31 -- .../tab_routes/home_route.dart | 10 +- .../drawer_routes/custom_drawer_routes.dart | 329 +++++++++++++++--- pubspec.lock | 4 +- pubspec.yaml | 2 +- 10 files changed, 723 insertions(+), 110 deletions(-) rename lib/presentation/Screens/Bottom Navigation Pages/{ => Competitiveness}/competitiveness.dart (100%) create mode 100644 lib/presentation/Screens/Bottom Navigation Pages/Country_Profile/country_profile.dart create mode 100644 lib/presentation/Screens/Bottom Navigation Pages/UAE_Numbers/Social/marriages.dart rename lib/presentation/Screens/Bottom Navigation Pages/{ => UAE_Numbers}/uae_numbers.dart (91%) delete mode 100644 lib/presentation/Screens/Bottom Navigation Pages/country_profile.dart diff --git a/lib/config/my_router.dart b/lib/config/my_router.dart index 1e6d9a68..40b75655 100644 --- a/lib/config/my_router.dart +++ b/lib/config/my_router.dart @@ -294,9 +294,10 @@ import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/competitiveness.dart'; -import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/country_profile.dart'; -import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/uae_numbers.dart'; +import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/Competitiveness/competitiveness.dart'; +import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/Country_Profile/country_profile.dart'; +import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/UAE_Numbers/Social/marriages.dart'; +import 'package:uae_stat/presentation/Screens/Bottom%20Navigation%20Pages/UAE_Numbers/uae_numbers.dart'; import 'package:uae_stat/presentation/Screens/auth_verification/registration.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/Drawer%20Items/user_guide/getting_started.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; @@ -426,5 +427,11 @@ final GoRouter router = GoRouter( builder: (context, state) => CountryProfile(), ), + + // UAE NUMBER Routes + GoRoute( + path: '/marriages', + builder: (context, state) => Marriages(), + ), ], ); diff --git a/lib/presentation/Screens/Bottom Navigation Pages/competitiveness.dart b/lib/presentation/Screens/Bottom Navigation Pages/Competitiveness/competitiveness.dart similarity index 100% rename from lib/presentation/Screens/Bottom Navigation Pages/competitiveness.dart rename to lib/presentation/Screens/Bottom Navigation Pages/Competitiveness/competitiveness.dart diff --git a/lib/presentation/Screens/Bottom Navigation Pages/Country_Profile/country_profile.dart b/lib/presentation/Screens/Bottom Navigation Pages/Country_Profile/country_profile.dart new file mode 100644 index 00000000..58a1c5ae --- /dev/null +++ b/lib/presentation/Screens/Bottom Navigation Pages/Country_Profile/country_profile.dart @@ -0,0 +1,142 @@ +import 'package:flutter/material.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; +import 'package:fl_chart/fl_chart.dart'; + +class CountryProfile extends StatelessWidget { + const CountryProfile({super.key}); + + @override + Widget build(BuildContext context) { + double myheight = MediaQuery.of(context).size.height; + double mywidth = MediaQuery.of(context).size.width; + return BaseScaffold( + title: Center( + child: SizedBox( + height: myheight / 5, + width: mywidth / 3, + child: Image(image: AssetImage('assets/logos/uae_stat.png')))), + body: CountryProfileWidget(), + ); + } +} +class CountryProfileWidget extends StatelessWidget { + const CountryProfileWidget({super.key}); + + @override + Widget build(BuildContext context) { + return HorizontalBarChart(); + } +} + + + + + +class HorizontalBarChart extends StatelessWidget { + final List xAxisData = ['2019', '2020', '2021', '2022', '2023']; + final List yAxisData = [2, 4, 1, 5, 3]; + + + @override + Widget build(BuildContext context) { + double myheight = MediaQuery.of(context).size.height; + return Scaffold( + appBar: AppBar(title: Text('Horizontal Bar Chart')), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: + Container( + height: myheight/4, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black12, + blurRadius: 8, + offset: Offset(0, 4), + ), + ], + ), + child: + Padding( + padding: const EdgeInsets.only(top: 16,left: 8.0,right: 8.0,bottom: 8.0), + child: BarChart( + BarChartData( + alignment: BarChartAlignment.spaceAround, + maxY: 8, + barTouchData: BarTouchData(enabled: false), + titlesData: FlTitlesData( + leftTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + interval: 2, + getTitlesWidget: (value, meta) { + return Padding( + padding: const EdgeInsets.only(right: 8.0), + child: Text('${value.toInt()}K'), + ); + }, + reservedSize: 60, + ), + ), + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, meta) { + return Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text(xAxisData[value.toInt()]), + ); + }, + reservedSize: 40, + ), + ), + topTitles: AxisTitles( + sideTitles: SideTitles(showTitles: false), // Hides top titles + ), + rightTitles: AxisTitles( + sideTitles: SideTitles(showTitles: false), // Hides right titles + ), + ), + gridData: FlGridData(show: false), + borderData: FlBorderData(show: false), + barGroups: List.generate( + xAxisData.length, + (index) => BarChartGroupData( + x: index, + barRods: [ + BarChartRodData( + toY: yAxisData[index], + color: Colors.blueAccent, + //colors: [Colors.blueAccent], + borderRadius: BorderRadius.circular(4), + width: 20, + ), + ], + ), + ), + ), + ), + ), + ), + ), + ); + } +} + +void main() { + runApp(MaterialApp(home: HorizontalBarChart())); +} + + +// void main() { +// runApp(MaterialApp(home: HorizontalBarChart())); +// } + + + + + + + diff --git a/lib/presentation/Screens/Bottom Navigation Pages/UAE_Numbers/Social/marriages.dart b/lib/presentation/Screens/Bottom Navigation Pages/UAE_Numbers/Social/marriages.dart new file mode 100644 index 00000000..0caad6ea --- /dev/null +++ b/lib/presentation/Screens/Bottom Navigation Pages/UAE_Numbers/Social/marriages.dart @@ -0,0 +1,266 @@ +import 'package:flutter/material.dart'; +import 'package:uae_stat/presentation/components/constant/constant.dart'; +import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; +import 'package:fl_chart/fl_chart.dart'; + + +class Marriages extends StatelessWidget { + const Marriages({super.key}); + + @override + Widget build(BuildContext context) { + double myheight = MediaQuery.of(context).size.height; + double mywidth = MediaQuery.of(context).size.width; + final List xAxisData = ['2019', '2020', '2021', '2022', '2023']; + final List yAxisData = [2, 4, 1, 5, 3]; + return BaseScaffold( + //appbarActions: IconButton(onPressed: (){}, icon: Icon(Icons.arrow_back_ios_new)), + appbarColor: Color(0xFFC6BEB2), + title: Text("UAE Numbers",style: TextStyle(color: Colors.white,fontWeight: FontWeight.bold),), + showBackButton: true, + body: SingleChildScrollView( + child: Column( + children : [ + Container( + height: myheight/4.5, + width: double.infinity, + color: Color(0xFFC6BEB2), + child: Padding(padding: EdgeInsets.only(left: 30,right: 30,top: 20,bottom: 10),child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text("SOCIAL",style: TextStyle(color: Colors.white,fontSize: 30),), + Container(width: mywidth/5,child: Divider(thickness: 10,color: Colors.white,)), + Text("Marriages",style: TextStyle(color: Colors.white,fontSize: 20),), + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + IconButton(onPressed: (){}, icon: Icon(Icons.bookmark_add_outlined,color: Colors.white,size: 40,)), + IconButton(onPressed: (){}, icon: Icon(Icons.share,color: Colors.white,size: 30,)), + ],), + ], + ),) + ), + SingleChildScrollView(child: Container( + height: myheight, + color: Color(0xFFC6BEB2), + child: Padding( + padding: const EdgeInsets.only(top: 0.0,left: 10,right: 10,bottom: 20), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container(height: myheight/3.5,width: mywidth/2.5, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(10)) + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'assets/icons/indicator/social/marriage.png', + height: myheight / 10, // This ensures the image fits within the container's height + width: myheight / 10, // You can adjust the size as needed + ), + Text("Total",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 26),), + Text("2022",style: TextStyle(fontSize: 15,color: Colors.grey),), + Text("16759",style: TextStyle(fontSize: 26,fontWeight: FontWeight.bold,color: socialColor),), + ], + ), + ), + Container(height: myheight/3.5,width: mywidth/2.5, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(10)) + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'assets/icons/indicator/social/marriage.png', + height: myheight / 10, // This ensures the image fits within the container's height + width: myheight / 10, // You can adjust the size as needed + ), + Text("Average",style: TextStyle(fontWeight: FontWeight.bold,fontSize: 26),), + Text("(2021 - 2022)",style: TextStyle(fontSize: 15,color: Colors.grey),), + Text("15987",style: TextStyle(fontSize: 26,fontWeight: FontWeight.bold,color: socialColor),), + ], + ), + ), + ], + ), + SizedBox(height: myheight/20,), + Container( + height: myheight/2, + width: mywidth/1.2, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(10)) + ), + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + children: [ + SizedBox(height: myheight/30,), + Center(child: Text("Total Marriages by Marriage Type",style: TextStyle(fontSize: 16,fontWeight: FontWeight.bold),), + ), + SizedBox(height: myheight/30,), + Container( + height: myheight/4, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(12), + boxShadow: [ + BoxShadow( + color: Colors.black12, + blurRadius: 8, + offset: Offset(0, 4), + ), + ], + ), + child: + Padding( + padding: const EdgeInsets.only(top: 16,left: 8.0,right: 8.0,bottom: 8.0), + child: BarChart( + BarChartData( + alignment: BarChartAlignment.spaceAround, + maxY: 8, + barTouchData: BarTouchData(enabled: false), + titlesData: FlTitlesData( + leftTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + interval: 2, + getTitlesWidget: (value, meta) { + return Padding( + padding: const EdgeInsets.only(right: 8.0), + child: Text('${value.toInt()}K'), + ); + }, + reservedSize: 60, + ), + ), + bottomTitles: AxisTitles( + sideTitles: SideTitles( + showTitles: true, + getTitlesWidget: (value, meta) { + return Padding( + padding: const EdgeInsets.only(top: 8.0), + child: Text(xAxisData[value.toInt()]), + ); + }, + reservedSize: 40, + ), + ), + topTitles: AxisTitles( + sideTitles: SideTitles(showTitles: false), // Hides top titles + ), + rightTitles: AxisTitles( + sideTitles: SideTitles(showTitles: false), // Hides right titles + ), + ), + gridData: FlGridData(show: false), + borderData: FlBorderData(show: false), + barGroups: List.generate( + xAxisData.length, + (index) => BarChartGroupData( + x: index, + barRods: [ + BarChartRodData( + toY: yAxisData[index], + color: Colors.blueAccent, + //colors: [Colors.blueAccent], + borderRadius: BorderRadius.circular(4), + width: 20, + ), + ], + ), + ), + ), + ), + ), + ), + // Container( + // decoration: BoxDecoration( + // color: Colors.white, + // borderRadius: BorderRadius.circular(12), + // boxShadow: [ + // BoxShadow( + // color: Colors.black12, + // blurRadius: 8, + // offset: Offset(0, 4), + // ), + // ], + // ), + // child: + // BarChart( + // BarChartData( + // alignment: BarChartAlignment.spaceAround, + // maxY: 20, + // barTouchData: BarTouchData(enabled: false), + // titlesData: FlTitlesData( + // leftTitles: AxisTitles( + // sideTitles: SideTitles( + // showTitles: true, + // getTitlesWidget: (value, meta) { + // return Padding( + // padding: const EdgeInsets.only(right: 8.0), + // child: Text('${value.toInt()}K'), + // ); + // }, + // reservedSize: 40, + // ), + // ), + // bottomTitles: AxisTitles( + // sideTitles: SideTitles( + // showTitles: true, + // getTitlesWidget: (value, meta) { + // return Padding( + // padding: const EdgeInsets.only(top: 8.0), + // child: Text(xAxisData[value.toInt()]), + // ); + // }, + // reservedSize: 40, + // ), + // ), + // ), + // gridData: FlGridData(show: false), + // borderData: FlBorderData(show: false), + // barGroups: List.generate( + // xAxisData.length, + // (index) => BarChartGroupData( + // x: index, + // barRods: [ + // BarChartRodData( + // toY: yAxisData[index], + // color: Colors.blueAccent, + // //colors: [Colors.blueAccent], + // borderRadius: BorderRadius.circular(4), + // width: 20, + // ), + // ], + // ), + // ), + // ), + // ), + // ), + + ], + ), + ), + ) + ], + ), + ), + + + ),) + ] + ), + ), mycenterTitle: false, + + ); + } +} + diff --git a/lib/presentation/Screens/Bottom Navigation Pages/uae_numbers.dart b/lib/presentation/Screens/Bottom Navigation Pages/UAE_Numbers/uae_numbers.dart similarity index 91% rename from lib/presentation/Screens/Bottom Navigation Pages/uae_numbers.dart rename to lib/presentation/Screens/Bottom Navigation Pages/UAE_Numbers/uae_numbers.dart index b1899ffa..5cb1bbb5 100644 --- a/lib/presentation/Screens/Bottom Navigation Pages/uae_numbers.dart +++ b/lib/presentation/Screens/Bottom Navigation Pages/UAE_Numbers/uae_numbers.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart'; import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; import 'package:uae_stat/presentation/components/constant/constant.dart'; @@ -16,7 +17,7 @@ class UaeNumbers extends StatelessWidget { body: //EconomicDashboard(), //EconomyExpandTile() - uaenumberWidget()); + uaenumberWidget(),); } } @@ -83,8 +84,10 @@ class uaenumberWidget extends StatelessWidget { ]), buildCategoryTitle('Vital Statistics',socialColor), buildCardRow([ - buildCard(context,'Marriages', '96%', '2023',socialColor,socialColor,mywidth/2.5), - buildCard(context,'Divorces', '1.2K', '2024',socialColor,socialColor,mywidth/2.5), + InkWell(onTap : (){ + context.go('/marriages'); + },child: buildCard(context,'Marriages', '96%', '2023',socialColor,socialColor,mywidth/2.5)), + InkWell(onTap : (){},child: buildCard(context,'Divorces', '1.2K', '2024',socialColor,socialColor,mywidth/2.5)), ]), buildCategoryTitle('Education',socialColor), buildCardRow([ @@ -265,21 +268,22 @@ class _CustomExpandableTileState extends State { duration: Duration(milliseconds: 300), curve: Curves.easeInOut, width: double.infinity, - height: isExpanded ? myheight : 0, child: isExpanded - ? SingleChildScrollView( - child: Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(20)) - ), + ? IntrinsicHeight( + child: IntrinsicWidth( + child: Container( + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(20)) + ), - padding: const EdgeInsets.all(10), - child: Column( - children: widget.children, - ), - ), - ) + padding: const EdgeInsets.all(10), + child: Column( + children: widget.children, + ), + ), + ), + ) : null, ), ), diff --git a/lib/presentation/Screens/Bottom Navigation Pages/country_profile.dart b/lib/presentation/Screens/Bottom Navigation Pages/country_profile.dart deleted file mode 100644 index 8d3f1081..00000000 --- a/lib/presentation/Screens/Bottom Navigation Pages/country_profile.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:uae_stat/presentation/routes/drawer_routes/custom_drawer_routes.dart'; - -class CountryProfile extends StatelessWidget { - const CountryProfile({super.key}); - - @override - Widget build(BuildContext context) { - double myheight = MediaQuery.of(context).size.height; - double mywidth = MediaQuery.of(context).size.width; - return BaseScaffold( - title: Center( - child: SizedBox( - height: myheight / 5, - width: mywidth / 3, - child: Image(image: AssetImage('assets/logos/uae_stat.png')))), - body: CountryProfileWidget() - ); - } -} -class CountryProfileWidget extends StatelessWidget { - const CountryProfileWidget({super.key}); - - @override - Widget build(BuildContext context) { - return Center(child: Text("COuntry Profile"),); - } -} - - - diff --git a/lib/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart b/lib/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart index cc4702c4..491dc171 100644 --- a/lib/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart +++ b/lib/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart @@ -177,11 +177,11 @@ class _MyHomePageState extends State { double myheight = MediaQuery.of(context).size.height; double mywidth = MediaQuery.of(context).size.width; return BaseScaffold( - title: Center( - child: SizedBox( - height: myheight / 5, - width: mywidth / 3, - child: Image(image: AssetImage('assets/logos/uae_stat.png')))), + mycenterTitle: true, + title: SizedBox( + height: myheight / 5, + width: mywidth / 3, + child: Image(image: AssetImage('assets/logos/uae_stat.png'))), body: EconomyStats(), ); } diff --git a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart index de8715ed..5b2a903e 100644 --- a/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart +++ b/lib/presentation/routes/drawer_routes/custom_drawer_routes.dart @@ -1,20 +1,215 @@ +// import 'package:flutter/material.dart'; +// import 'package:go_router/go_router.dart'; +// +// class BaseScaffold extends StatelessWidget { +// final Widget body; +// final Widget title; +// final Widget? appbarActions; +// final List? actions; +// final Color? appbarColor,mytitleColor; +// +// const BaseScaffold({ +// Key? key, +// required this.body, +// required this.title, +// this.actions, +// this.appbarColor, +// this.mytitleColor, +// this.appbarActions +// }) : super(key: key); +// // final Widget body; +// // +// // const BaseScaffold({required this.body}); +// +// @override +// Widget build(BuildContext context) { +// // Get the current route to highlight the active item +// String currentRoute = GoRouterState.of(context).matchedLocation; +// double myheight = MediaQuery.of(context).size.height; +// double mywidth = MediaQuery.of(context).size.width; +// return Scaffold( +// appBar: AppBar(title: title,backgroundColor: appbarColor, actions: [ +// IconButton(onPressed: () {}, icon: Icon(Icons.toggle_off_outlined)), +// ], +// leading: appbarActions, +// +// ), +// +// drawer: Drawer( +// child: ListView( +// children: [ +// DrawerHeader( +// //decoration: BoxDecoration(color: Colors.blue), +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.stretch, +// children: [ +// Row( +// children: [ +// SizedBox( +// width: mywidth / 8, +// child: Image( +// image: AssetImage('assets/logos/fcsc.png'))), +// ], +// ), +// Divider(), +// InkWell( +// onTap: () => context.go('/editProfile'), +// child: Row( +// children: [ +// SizedBox( +// width: mywidth / 8, +// child: Image( +// image: AssetImage( +// 'assets/edit_profile/profile.png'))), +// SizedBox( +// width: mywidth / 20, +// ), +// Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Text('Mohammad'), +// Text('Mohammad@fcsc.com') +// ], +// ) +// ], +// ), +// ) +// ], +// ), +// ), +// ListTile( +// leading: SizedBox( +// height: myheight / 15, +// width: mywidth / 15, +// child: Image( +// image: AssetImage('assets/icons/drawer/message.png'))), +// title: Text('Feedback'), +// onTap: () => context.go('/feedback'), +// ), +// ListTile( +// leading: SizedBox( +// height: myheight / 15, +// width: mywidth / 15, +// child: Image( +// image: AssetImage('assets/icons/drawer/manageuser.png'))), +// title: Text('Manage User'), +// onTap: () => context.go('/manageuser'), +// ), +// +// ListTile( +// leading: SizedBox( +// height: myheight / 15, +// width: mywidth / 15, +// child: Image( +// image: AssetImage('assets/icons/drawer/book.png'))), +// title: Text('User Guide'), +// onTap: () => context.go('/user-guide'), +// ), +// ], +// ), +// ), +// bottomNavigationBar: BottomNavigationBar( +// currentIndex: _getSelectedIndex(currentRoute), +// onTap: (index) => _onItemTapped(context, index), +// type: BottomNavigationBarType.fixed, +// items: [ +// BottomNavigationBarItem( +// icon: SizedBox( +// height: myheight / 15, +// width: mywidth / 15, +// child: Image( +// image: AssetImage('assets/icons/bottom_bar/home.png'))), +// label: 'Home', +// ), +// BottomNavigationBarItem( +// icon: SizedBox( +// height: myheight / 15, +// width: mywidth / 15, +// child: Image( +// image: AssetImage('assets/icons/bottom_bar/uae_map.png'))), +// label: 'UAE Numbers', +// ), +// BottomNavigationBarItem( +// icon: SizedBox( +// height: myheight / 15, +// width: mywidth / 15, +// child: Image( +// image: +// AssetImage('assets/icons/bottom_bar/ranking.png'))), +// label: 'Competitiveness'), +// BottomNavigationBarItem( +// icon: SizedBox( +// height: myheight / 15, +// width: mywidth / 15, +// child: Image( +// image: AssetImage('assets/icons/bottom_bar/globe.png'))), +// label: 'Country Profile'), +// ], +// selectedItemColor: Colors.black, +// unselectedItemColor: Colors.grey, +// showUnselectedLabels: true, +// ), +// body: body, +// ); +// } +// +// //Map the current route to the selected index +// int _getSelectedIndex(String route) { +// switch (route) { +// case '/': +// return 0; +// case '/uaenumbers': +// return 1; +// case '/competitiveness': +// return 2; +// case '/countryprofile': +// return 3; +// default: +// return 0; +// } +// } +// +// //Handle navigation when an item is tapped +// void _onItemTapped(BuildContext context, int index) { +// switch (index) { +// case 0: +// context.go('/'); +// break; +// case 1: +// context.go('/uaenumbers'); +// break; +// case 2: +// context.go('/competitiveness'); +// break; +// case 3: +// context.go('/countryprofile'); +// break; +// } +// } +// } + + + import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; class BaseScaffold extends StatelessWidget { final Widget body; final Widget title; + final bool? mycenterTitle; + final bool showBackButton; final List? actions; + final Color? appbarColor, mytitleColor; const BaseScaffold({ Key? key, required this.body, required this.title, this.actions, + this.appbarColor, + this.mytitleColor, + this.showBackButton = false, this.mycenterTitle = false, // Default is to show the drawer icon }) : super(key: key); - // final Widget body; - // - // const BaseScaffold({required this.body}); @override Widget build(BuildContext context) { @@ -23,76 +218,105 @@ class BaseScaffold extends StatelessWidget { double myheight = MediaQuery.of(context).size.height; double mywidth = MediaQuery.of(context).size.width; return Scaffold( - appBar: AppBar(title: title, actions: [ - IconButton(onPressed: () {}, icon: Icon(Icons.toggle_off_outlined)), - ]), + appBar: AppBar( + centerTitle: mycenterTitle, + title: title, + backgroundColor: appbarColor, + leading: + + Stack( + children: [ + + // Show the back button if showBackButton is true, otherwise show the drawer menu + if (showBackButton) + Positioned( + left: 20, + child: IconButton( + color: Colors.white, + icon: Icon(Icons.arrow_back_ios_new), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + // Show the drawer icon in all cases + Positioned( + right: 10, + child: Builder( + builder: (BuildContext context) { + return IconButton( + color: showBackButton ? Colors.white : Colors.black, + icon: Icon(Icons.menu), + onPressed: () { + // Open the drawer using the Scaffold context + Scaffold.of(context).openDrawer(); + }, + ); + }, + ), + ), + ], + ), + + actions: actions, + ), drawer: Drawer( child: ListView( children: [ DrawerHeader( - //decoration: BoxDecoration(color: Colors.blue), + child: Container( child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - SizedBox( - width: mywidth / 8, - child: Image( - image: AssetImage('assets/logos/fcsc.png'))), - ], - ), + SizedBox( + width: mywidth/5, + height: myheight/15, + child: Image.asset('assets/logos/fcsc.png')), Divider(), - InkWell( - onTap: () => context.go('/editProfile'), + SizedBox( + height: myheight/15, child: Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, // Ensures the row only takes up as much space as its children need children: [ - SizedBox( - width: mywidth / 8, - child: Image( - image: AssetImage( - 'assets/edit_profile/profile.png'))), - SizedBox( - width: mywidth / 20, + // The profile image with fixed size + Image.asset( + 'assets/edit_profile/profile.png', + height: myheight / 10, // This ensures the image fits within the container's height + width: myheight / 10, // You can adjust the size as needed + ), + + // Wrapping the Column in Flexible to ensure no overflow + Flexible( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Mohammad'), + Text('Mohammad@fcsc.com'), + ], + ), ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text('Mohammad'), - Text('Mohammad@fcsc.com') - ], - ) ], ), - ) + ), ], - ), + + ),), + ), + SizedBox(height: myheight/60,), ListTile( - leading: SizedBox( - height: myheight / 15, - width: mywidth / 15, - child: Image( - image: AssetImage('assets/icons/drawer/message.png'))), + leading: Icon(Icons.feedback), title: Text('Feedback'), onTap: () => context.go('/feedback'), ), ListTile( - leading: SizedBox( - height: myheight / 15, - width: mywidth / 15, - child: Image( - image: AssetImage('assets/icons/drawer/manageuser.png'))), + leading: Icon(Icons.people), title: Text('Manage User'), onTap: () => context.go('/manageuser'), ), - ListTile( - leading: SizedBox( - height: myheight / 15, - width: mywidth / 15, - child: Image( - image: AssetImage('assets/icons/drawer/book.png'))), + leading: Icon(Icons.book), title: Text('User Guide'), onTap: () => context.go('/user-guide'), ), @@ -126,7 +350,7 @@ class BaseScaffold extends StatelessWidget { width: mywidth / 15, child: Image( image: - AssetImage('assets/icons/bottom_bar/ranking.png'))), + AssetImage('assets/icons/bottom_bar/ranking.png'))), label: 'Competitiveness'), BottomNavigationBarItem( icon: SizedBox( @@ -143,7 +367,6 @@ class BaseScaffold extends StatelessWidget { body: body, ); } - //Map the current route to the selected index int _getSelectedIndex(String route) { switch (route) { @@ -178,3 +401,5 @@ class BaseScaffold extends StatelessWidget { } } } + + diff --git a/pubspec.lock b/pubspec.lock index cc69ece0..566653a8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -385,10 +385,10 @@ packages: dependency: "direct main" description: name: fl_chart - sha256: "74959b99b92b9eebeed1a4049426fd67c4abc3c5a0f4d12e2877097d6a11ae08" + sha256: "10ddaf334fe84d59333a12d153043e366f243e0bdfff2df0313e1e249f5bf926" url: "https://pub.dev" source: hosted - version: "0.69.2" + version: "0.70.1" flutter: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index a223630d..ab6ae569 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,7 +20,7 @@ dependencies: injectable: ^2.3.2 riverpod_annotation: ^2.3.3 cupertino_icons: ^1.0.6 - fl_chart: ^0.69.0 + fl_chart: ^0.70.1 marquee: ^2.2.3 # dynamic_layouts: # git: