From 43fcd3bfdbee2afa5429b9259aa71dcca28c8d96 Mon Sep 17 00:00:00 2001 From: FaizHashmiCS22 Date: Tue, 21 Mar 2023 11:35:40 +0300 Subject: [PATCH] Design Progress 3-20 --- lib/config/dependencies.dart | 7 + lib/main.dart | 10 +- lib/theme/app_theme.dart | 27 --- lib/theme/colors.dart | 73 ------- lib/view_models/dashboard_view_model.dart | 11 +- lib/views/dashboard/dashboard_page.dart | 206 ++---------------- .../dashboard/fragments/home_fragment.dart | 40 ++++ lib/views/dashboard/widgets/ad_widget.dart | 110 ++++++++++ .../widgets/appointment_slider_widget.dart | 89 ++++++++ .../dashboard/widgets/bottom_nav_bar.dart | 61 ++++++ .../dashboard/widgets/drawer_widget.dart | 196 +++++++++++++++++ .../dashboard/widgets/my_branches_widget.dart | 38 ++++ .../dashboard/widgets/view_all_widget.dart | 29 +++ pubspec.yaml | 2 +- 14 files changed, 597 insertions(+), 302 deletions(-) create mode 100644 lib/config/dependencies.dart delete mode 100644 lib/theme/app_theme.dart delete mode 100644 lib/theme/colors.dart create mode 100644 lib/views/dashboard/fragments/home_fragment.dart create mode 100644 lib/views/dashboard/widgets/ad_widget.dart create mode 100644 lib/views/dashboard/widgets/appointment_slider_widget.dart create mode 100644 lib/views/dashboard/widgets/bottom_nav_bar.dart create mode 100644 lib/views/dashboard/widgets/drawer_widget.dart create mode 100644 lib/views/dashboard/widgets/my_branches_widget.dart create mode 100644 lib/views/dashboard/widgets/view_all_widget.dart diff --git a/lib/config/dependencies.dart b/lib/config/dependencies.dart new file mode 100644 index 0000000..7fa12dd --- /dev/null +++ b/lib/config/dependencies.dart @@ -0,0 +1,7 @@ +import 'package:mc_common_app/config/dependencies.dart'; + +class LocalDependencies { + static void addDependencies() { + AppDependencies.addDependencies(); + } +} diff --git a/lib/main.dart b/lib/main.dart index 32e5a87..f97caa2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,16 +1,12 @@ -import 'package:car_customer_app/theme/app_theme.dart'; - -import 'package:car_customer_app/view_models/dashboard_view_model.dart'; - +import 'package:car_customer_app/config/dependencies.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mc_common_app/classes/app_state_cm.dart'; - +import 'package:mc_common_app/theme/app_theme.dart'; import 'package:mc_common_app/config/dependencies.dart'; import 'package:mc_common_app/config/routes.dart'; import 'package:mc_common_app/models/post_params_model.dart'; import 'package:mc_common_app/repositories/user_repo.dart'; -import 'package:mc_common_app/services/services.dart'; import 'package:mc_common_app/view_models/base_view_model.dart'; import 'package:mc_common_app/view_models/user_view_model.dart'; import 'package:sizer/sizer.dart'; @@ -21,7 +17,7 @@ import 'generated/codegen_loader.g.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - AppDependencies.addDependencies(); + LocalDependencies.addDependencies(); await EasyLocalization.ensureInitialized(); runApp( EasyLocalization( diff --git a/lib/theme/app_theme.dart b/lib/theme/app_theme.dart deleted file mode 100644 index 8d0252d..0000000 --- a/lib/theme/app_theme.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/material.dart'; - -import 'colors.dart'; - -class AppTheme { - static getTheme(isArabic) => ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. - primaryColor: primaryColor, - primaryTextTheme: const TextTheme( - titleLarge: TextStyle(color: Colors.white), - ), colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.orange).copyWith(background: Colors.white), - ); -} - -extension ExtendedRevoCheckTheme on TextTheme { - //add custom styles and colors here - //taken from https://medium.com/@crizantlai/flutter-how-to-extend-themedata-b5b987a95bb5 - TextStyle get price => const TextStyle(color: Colors.redAccent); -} diff --git a/lib/theme/colors.dart b/lib/theme/colors.dart deleted file mode 100644 index d65575d..0000000 --- a/lib/theme/colors.dart +++ /dev/null @@ -1,73 +0,0 @@ -import 'package:flutter/material.dart'; - -class MyColors { - static const Color darkPrimaryColor = Color(0xffF47F20); - static const Color primaryColor = Color(0xffF69521); - static const Color accentColor = Colors.blue; - static const Color lightTextColor = Color(0xff969696); - static const Color textColor = Color(0xff777777); - static const Color textFieldColor = Color(0xffF3F5F7); - static const Color darkIconColor = Color(0xff28323A); - static const Color darkTextColor = Color(0xff2B353E); - static const Color normalTextColor = Color(0xff5A5A5A); - static const Color gradiantStartColor = Color(0xff33c0a5); - static const Color gradiantEndColor = Color(0xff259db7); - static const Color textMixColor = Color(0xff2BB8A6); - static const Color backgroundColor = Color(0xffF8F8F8); - static const Color grey57Color = Color(0xff575757); - static const Color grey77Color = Color(0xff777777); - static const Color grey70Color = Color(0xff707070); - static const Color greyACColor = Color(0xffACACAC); - static const Color grey98Color = Color(0xff989898); - static const Color lightGreyEFColor = Color(0xffEFEFEF); - static const Color lightGreyEDColor = Color(0xffEDEDED); - static const Color lightGreyEAColor = Color(0xffEAEAEA); - static const Color darkWhiteColor = Color(0xffE0E0E0); - static const Color redColor = Color(0xffD02127); - static const Color yellowColor = Color(0xffF4E31C); - static const Color backgroundBlackColor = Color(0xff202529); - static const Color black = Color(0xff000000); - static const Color white = Color(0xffffffff); - static const Color green = Color(0xffffffff); - static const Color borderColor = Color(0xffE8E8E8); - - static Decoration gradient = BoxDecoration( - gradient: const LinearGradient(colors: [ - darkPrimaryColor, - primaryColor, - ]), - boxShadow: [ - BoxShadow( - color: primaryColor.withOpacity(0.5), - blurRadius: 20.0, - spreadRadius: 1.0, - ) - ], - ); - - static Decoration gradientButton = BoxDecoration( - gradient: const LinearGradient(colors: [ - darkPrimaryColor, - primaryColor, - ]), - borderRadius: BorderRadius.circular(6), - boxShadow: [ - BoxShadow( - color: primaryColor.withOpacity(0.2), - blurRadius: 4.0, - spreadRadius: 0.5, - ) - ], - ); -} - -const Color primaryColor = Colors.white; -const Color accentColor = Colors.blue; -const Color appBackgroundColor = Colors.white; -Color? accentColorDark = Colors.green[800]; -const Color borderColor = Colors.blueGrey; -Color? borderLightColor = Colors.blueGrey[50]; -const Color iconColor = Colors.blueGrey; -Color? headingColor = Colors.blueGrey[800]; -Color? txtColor = Colors.blueGrey[500]; - diff --git a/lib/view_models/dashboard_view_model.dart b/lib/view_models/dashboard_view_model.dart index 265cf92..2a45951 100644 --- a/lib/view_models/dashboard_view_model.dart +++ b/lib/view_models/dashboard_view_model.dart @@ -1,13 +1,13 @@ import 'dart:io'; import 'package:car_customer_app/generated/locale_keys.g.dart'; -import 'package:easy_localization/easy_localization.dart'; -import 'package:flutter/cupertino.dart'; import 'package:mc_common_app/classes/app_state_cm.dart'; import 'package:mc_common_app/models/user/image_response.dart'; import 'package:mc_common_app/repositories/user_repo.dart'; import 'package:mc_common_app/services/services.dart'; import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/view_models/base_view_model.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/cupertino.dart'; class DashboardVM extends BaseVM { final CommonServices commonServices; @@ -17,6 +17,13 @@ class DashboardVM extends BaseVM { String pickedImage = ""; + int selectedNavbarBarIndex = 2; + + void onNavbarTapped(int index) { + selectedNavbarBarIndex = index; + notifyListeners(); + } + void pickImageFromPhone(BuildContext context, int sourceFlag) async { final File? pickedImageFile = await commonServices.pickImageFromPhone(sourceFlag); if (pickedImageFile == null) { diff --git a/lib/views/dashboard/dashboard_page.dart b/lib/views/dashboard/dashboard_page.dart index 13b0b78..a1eb041 100644 --- a/lib/views/dashboard/dashboard_page.dart +++ b/lib/views/dashboard/dashboard_page.dart @@ -1,22 +1,8 @@ -import 'package:mc_common_app/classes/app_state_cm.dart'; -import 'package:mc_common_app/classes/consts.dart'; -import 'package:mc_common_app/config/routes.dart'; -import 'package:mc_common_app/extensions/int_extensions.dart'; -import 'package:mc_common_app/extensions/string_extensions.dart'; -import 'package:mc_common_app/extensions/widget_extensions.dart'; -import 'package:car_customer_app/generated/locale_keys.g.dart'; -import 'package:mc_common_app/models/user/image_response.dart'; -import 'package:car_customer_app/theme/colors.dart'; -import 'package:mc_common_app/utils/navigator.dart'; -import 'package:mc_common_app/utils/utils.dart'; import 'package:car_customer_app/view_models/dashboard_view_model.dart'; -import 'package:mc_common_app/widgets/app_bar.dart'; -import 'package:mc_common_app/widgets/show_fill_button.dart'; -import 'package:easy_localization/easy_localization.dart'; +import 'package:car_customer_app/views/dashboard/fragments/home_fragment.dart'; +import 'package:car_customer_app/views/dashboard/widgets/bottom_nav_bar.dart'; +import 'package:car_customer_app/views/dashboard/widgets/drawer_widget.dart'; import 'package:flutter/material.dart'; -import 'package:image_picker/image_picker.dart'; -import 'package:mc_common_app/extensions/string_extensions.dart'; -import 'package:mc_common_app/widgets/app_bar.dart'; import 'package:provider/provider.dart'; class DashboardPage extends StatefulWidget { @@ -38,184 +24,20 @@ class _DashboardPageState extends State { fetchUsername() async {} + List fragments = [ + const HomeFragment(), + const HomeFragment(), + const HomeFragment(), + const HomeFragment(), + ]; + @override Widget build(BuildContext context) { return Scaffold( - appBar: appBar(context, title: "Logo/Brand", isRemoveBackButton: true), - drawer: showDrawer(context), - body: Center( - child: LocaleKeys.dashboard.tr().toText( - height: 23 / 24, - fontSize: 24, - letterSpacing: -1.44, - ), - ), - ); - } - - Widget showDrawer(BuildContext context) { - return Drawer( - child: Column( - children: [ - Stack( - children: [ - Container( - width: double.infinity, - height: 200, - color: MyColors.darkPrimaryColor.withOpacity(0.01), - child: Image.network( - ApiConsts.baseUrlServices + AppStateCm().getUser.data!.userInfo!.userImageUrl.toString(), - ), - ), - Positioned( - top: 10, - right: 10, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Column( - children: [ - Container( - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.grey[200], - borderRadius: BorderRadius.circular(30), - ), - child: const Icon( - Icons.edit, - color: MyColors.darkPrimaryColor, - ).onPress(() { - _openImagePicker(); - // _handleURLButtonPress(context, ImageSourceType.camera); - }), - ), - 12.height, - Container( - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.grey[200], - borderRadius: BorderRadius.circular(30), - ), - child: const Icon( - Icons.delete, - color: Colors.red, - ).onPress(() async { - Utils.showLoading(context); - ImageResponse response = await dashboardVM.updateUserImage(""); - if (response.messageStatus == 1) { - Utils.showToast("Image is Deleted"); - setState(() { - AppStateCm().getUser.data!.userInfo!.userImageUrl = response.data; - }); - } - Utils.hideLoading(context); - }), - ), - ], - ), - ], - ), - ) - ], - ), - Container( - width: double.infinity, - color: MyColors.darkPrimaryColor.withOpacity(0.1), - padding: const EdgeInsets.all(20), - child: Row( - children: [ - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - "userName".toText( - isBold: true, - fontSize: 20, - letterSpacing: -1.44, - ), - AppStateCm().getUser.data!.userInfo!.roleName!.toText(fontSize: 10), - ], - ), - ), - ShowFillButton( - title: LocaleKeys.edit.tr(), - fontSize: 12, - maxHeight: 35, - maxWidth: 70, - onPressed: () { - navigateWithName(context, AppRoutes.editAccountPage); - }, - ), - ], - ), - ), - ListTile( - leading: const Icon( - Icons.notifications, - color: MyColors.darkPrimaryColor, - ), - title: LocaleKeys.notifications.tr().toText(fontSize: 12), - ), - ListTile( - leading: const Icon( - Icons.settings, - color: MyColors.darkPrimaryColor, - ), - title: LocaleKeys.general.tr().toText(fontSize: 12), - ), - ListTile( - leading: const Icon( - Icons.person, - color: MyColors.darkPrimaryColor, - ), - title: LocaleKeys.account.tr().toText(fontSize: 12), - ), - ListTile( - leading: Image.asset( - "assets/images/ic_world.png", - width: 20, - height: 20, - color: MyColors.darkPrimaryColor, - ), - title: LocaleKeys.english.tr().toText(fontSize: 12), - onTap: () { - if (EasyLocalization.of(context)?.currentLocale?.countryCode == "SA") { - context.setLocale(const Locale("en", "US")); - } else { - context.setLocale(const Locale('ar', 'SA')); - } - }, - ), - ListTile( - leading: const Icon( - Icons.logout, - color: MyColors.darkPrimaryColor, - ), - title: LocaleKeys.signOut.tr().toText(fontSize: 12), - onTap: () { - pop(context); - navigateReplaceWithName(context, AppRoutes.registerSelection); - }, - ), - ], - ), - ); - } - - void _openImagePicker() { - showDialog( - context: context, - builder: (context) => AlertDialog( - content: const Text("Choose image source"), - actions: [ - TextButton(child: const Text("Camera"), onPressed: () => dashboardVM.pickImageFromPhone(context, 0)), - TextButton(child: const Text("Gallery"), onPressed: () => dashboardVM.pickImageFromPhone(context, 1)), - ], - ), + appBar: const CustomAppBar(title: "Logo/Brand", isRemoveBackButton: true), + drawer: CustomDrawer(dashboardVM: dashboardVM), + bottomNavigationBar: const CustomBottomNavbar(), + body: fragments[dashboardVM.selectedNavbarBarIndex], ); } } diff --git a/lib/views/dashboard/fragments/home_fragment.dart b/lib/views/dashboard/fragments/home_fragment.dart new file mode 100644 index 0000000..360666c --- /dev/null +++ b/lib/views/dashboard/fragments/home_fragment.dart @@ -0,0 +1,40 @@ +import 'package:car_customer_app/extensions/int_extensions.dart'; +import 'package:car_customer_app/views/dashboard/widgets/ad_widget.dart'; +import 'package:car_customer_app/views/dashboard/widgets/appointment_slider_widget.dart'; +import 'package:car_customer_app/views/dashboard/widgets/my_branches_widget.dart'; +import 'package:car_customer_app/views/dashboard/widgets/view_all_widget.dart'; +import 'package:flutter/material.dart'; + +class HomeFragment extends StatelessWidget { + const HomeFragment({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return SizedBox( + width: double.infinity, + height: double.infinity, + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.only(top: 8, left: 21, right: 21, bottom: 21), + child: Column( + mainAxisSize: MainAxisSize.max, + children: [ + ViewAllWidget(title: "Upcoming Appointment".toUpperCase(), subTitle: "View All"), + const AppointmentSliderWidget(), + 20.height, + ViewAllWidget(title: "My Recent Service Providers".toUpperCase(), subTitle: "View All"), + const ServiceProviderWidget(), + 20.height, + ViewAllWidget(title: "My Active Ads".toUpperCase(), subTitle: "View All"), + // todo: we will replace this count with the sublist of ads + const AdWidget(count: 1), + 20.height, + ViewAllWidget(title: "My Recommended Ads".toUpperCase(), subTitle: "View All"), + const AdWidget(count: 2), + ], + ), + ), + ), + ); + } +} diff --git a/lib/views/dashboard/widgets/ad_widget.dart b/lib/views/dashboard/widgets/ad_widget.dart new file mode 100644 index 0000000..251bbcc --- /dev/null +++ b/lib/views/dashboard/widgets/ad_widget.dart @@ -0,0 +1,110 @@ +import 'package:car_customer_app/extensions/int_extensions.dart'; +import 'package:car_customer_app/extensions/string_extensions.dart'; +import 'package:car_customer_app/theme/colors.dart'; +import 'package:car_customer_app/widgets/extensions/extensions_widget.dart'; +import 'package:flutter/material.dart'; + +class AdWidget extends StatelessWidget { + final int count; + + const AdWidget({Key? key, required this.count}) : super(key: key); + + @override + Widget build(BuildContext context) { + return ListView.builder( + itemCount: count, + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.only(bottom: 15), + child: buildAdContainer(), + ); + }); + } + + Widget buildAdContainer() { + return Row( + children: [ + Image.asset( + "assets/images/bn_car.jpeg", + width: 80, + height: 80, + fit: BoxFit.cover, + ), + 12.width, + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + "Toyota Crolla".toText(fontSize: 16, isBold: true), + Row( + children: [ + "Model:".toText( + color: MyColors.lightTextColor, + ), + 2.width, + "2019".toText(), + ], + ), + Row( + children: [ + "Mileage:".toText( + color: MyColors.lightTextColor, + ), + 2.width, + "73,000 km".toText(), + ], + ), + ], + ), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + "Riyadh".toText( + color: MyColors.lightTextColor, + ), + "9 Hours Ago".toText( + color: MyColors.lightTextColor, + ), + ], + ), + ], + ), + 8.height, + Row( + children: [ + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + "30,000".toText(fontSize: 16, isBold: true), + 2.width, + "SAR:".toText( + color: MyColors.lightTextColor, + ), + ], + ), + ), + const Icon(Icons.arrow_forward) + ], + ), + ], + ), + ), + ], + ).toWhiteContainer(width: double.infinity, allPading: 12); + } +} diff --git a/lib/views/dashboard/widgets/appointment_slider_widget.dart b/lib/views/dashboard/widgets/appointment_slider_widget.dart new file mode 100644 index 0000000..fc21471 --- /dev/null +++ b/lib/views/dashboard/widgets/appointment_slider_widget.dart @@ -0,0 +1,89 @@ +import 'package:car_customer_app/extensions/int_extensions.dart'; +import 'package:car_customer_app/extensions/string_extensions.dart'; +import 'package:car_customer_app/theme/colors.dart'; +import 'package:car_customer_app/widgets/extensions/extensions_widget.dart'; +import 'package:flutter/material.dart'; + +class AppointmentSliderWidget extends StatelessWidget { + const AppointmentSliderWidget({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + "Olaya Brach".toText( + color: MyColors.lightTextColor, + isBold: true, + ), + "Abdullah Alhbas".toText( + isBold: true, + fontSize: 14, + ), + Row( + children: [ + "Appt. On:".toText( + color: MyColors.lightTextColor, + ), + 2.width, + "19-Mar-2023 11:48 AM".toText(), + ], + ), + ], + ), + ), + "1+ Requests".toText(fontSize: 10).toContainer( + borderRadius: 15, + backgroundColor: MyColors.lightGreyEAColor, + padding: const EdgeInsets.symmetric( + vertical: 6, + horizontal: 12, + ), + ), + ], + ), + 8.height, + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: Column( + children: [ + showServices("Maintenance"), + 2.height, + showServices("Accessories and Modification"), + ], + ), + ), + const Icon( + Icons.arrow_forward, + ), + ], + ), + ], + ).toWhiteContainer(width: double.infinity, allPading: 0); + } + + Widget showServices(String title) { + return Row( + children: [ + const Icon( + Icons.ac_unit, + color: MyColors.primaryColor, + size: 18, + ), + 8.width, + title.toText( + fontSize: 14, + isBold: true, + ), + ], + ); + } +} diff --git a/lib/views/dashboard/widgets/bottom_nav_bar.dart b/lib/views/dashboard/widgets/bottom_nav_bar.dart new file mode 100644 index 0000000..6c923b3 --- /dev/null +++ b/lib/views/dashboard/widgets/bottom_nav_bar.dart @@ -0,0 +1,61 @@ +import 'package:car_customer_app/classes/consts.dart'; +import 'package:car_customer_app/generated/locale_keys.g.dart'; +import 'package:car_customer_app/theme/colors.dart'; +import 'package:car_customer_app/view_models/dashboard_view_model.dart'; +import 'package:car_customer_app/widgets/extensions/extensions_widget.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class CustomBottomNavbar extends StatelessWidget { + const CustomBottomNavbar({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + final DashboardVM dashboardVM = context.watch(); + return BottomNavigationBar( + items: [ + BottomNavigationBarItem( + icon: SvgPicture.asset(MyAssets.providersIcon).paddingAll(5), + activeIcon: SvgPicture.asset(MyAssets.providersIcon, color: MyColors.darkIconColor).paddingAll(5), + label: LocaleKeys.providers.tr(), + ), + BottomNavigationBarItem( + icon: SvgPicture.asset(MyAssets.appointmentsIcon).paddingAll(5), + activeIcon: SvgPicture.asset(MyAssets.appointmentsIcon, color: MyColors.darkIconColor).paddingAll(5), + label: LocaleKeys.appointments.tr(), + ), + BottomNavigationBarItem( + icon: SvgPicture.asset( + MyAssets.homeIcon, + color: MyColors.lightIconColor, + ).paddingAll(5), + activeIcon: SvgPicture.asset(MyAssets.homeIcon, color: MyColors.darkIconColor).paddingAll(5), + label: LocaleKeys.home.tr(), + ), + BottomNavigationBarItem( + icon: SvgPicture.asset(MyAssets.announcementIcon).paddingAll(5), + activeIcon: SvgPicture.asset(MyAssets.announcementIcon, color: MyColors.darkIconColor).paddingAll(5), + label: LocaleKeys.ads.tr(), + ), + BottomNavigationBarItem( + icon: SvgPicture.asset(MyAssets.settingsIcon).paddingAll(5), + activeIcon: SvgPicture.asset(MyAssets.settingsIcon, color: MyColors.darkIconColor).paddingAll(5), + label: LocaleKeys.settings.tr(), + ), + ], + currentIndex: dashboardVM.selectedNavbarBarIndex, + type: BottomNavigationBarType.fixed, + selectedItemColor: MyColors.darkIconColor, + showSelectedLabels: true, + showUnselectedLabels: true, + unselectedItemColor: MyColors.lightTextColor, + unselectedFontSize: 11, + selectedFontSize: 11, + selectedLabelStyle: const TextStyle(fontFamily: "Poppins"), + unselectedLabelStyle: const TextStyle(fontFamily: "Poppins"), + onTap: (index) => dashboardVM.onNavbarTapped(index), + ); + } +} diff --git a/lib/views/dashboard/widgets/drawer_widget.dart b/lib/views/dashboard/widgets/drawer_widget.dart new file mode 100644 index 0000000..ad1b9e2 --- /dev/null +++ b/lib/views/dashboard/widgets/drawer_widget.dart @@ -0,0 +1,196 @@ +import 'package:car_customer_app/classes/app_state.dart'; +import 'package:car_customer_app/classes/consts.dart'; +import 'package:car_customer_app/config/routes.dart'; +import 'package:car_customer_app/extensions/int_extensions.dart'; +import 'package:car_customer_app/extensions/string_extensions.dart'; +import 'package:car_customer_app/extensions/widget_extensions.dart'; +import 'package:car_customer_app/generated/locale_keys.g.dart'; +import 'package:car_customer_app/models/user/image_response.dart'; +import 'package:car_customer_app/theme/colors.dart'; +import 'package:car_customer_app/utils/navigator.dart'; +import 'package:car_customer_app/utils/utils.dart'; +import 'package:car_customer_app/view_models/dashboard_view_model.dart'; +import 'package:car_customer_app/widgets/show_fill_button.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:image_picker/image_picker.dart'; + + + +class CustomDrawer extends StatefulWidget { + final DashboardVM dashboardVM; + const CustomDrawer({Key? key, required this.dashboardVM}) : super(key: key); + + @override + State createState() => _CustomDrawerState(); +} + +class _CustomDrawerState extends State { + + void _openImagePicker() { + showDialog( + context: context, + builder: (context) => AlertDialog( + content: const Text("Choose image source"), + actions: [ + TextButton(child: const Text("Camera"), onPressed: () => widget.dashboardVM.pickImageFromPhone(context, 0)), + TextButton(child: const Text("Gallery"), onPressed: () => widget.dashboardVM.pickImageFromPhone(context, 1)), + ], + ), + ); + } + + @override + Widget build(BuildContext context) { + return Drawer( + child: Column( + children: [ + Stack( + children: [ + Container( + width: double.infinity, + height: 200, + color: MyColors.darkPrimaryColor.withOpacity(0.01), + child: Image.network( + ApiConsts.baseUrlServices + AppState().getUser.data!.userInfo!.userImageUrl.toString(), + ), + ), + Positioned( + top: 10, + right: 10, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Column( + children: [ + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(30), + ), + child: const Icon( + Icons.edit, + color: MyColors.darkPrimaryColor, + ).onPress(() { + _openImagePicker(); + // _handleURLButtonPress(context, ImageSourceType.camera); + }), + ), + 12.height, + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(30), + ), + child: const Icon( + Icons.delete, + color: Colors.red, + ).onPress(() async { + Utils.showLoading(context); + ImageResponse response = await widget.dashboardVM.updateUserImage(""); + if (response.messageStatus == 1) { + Utils.showToast("Image is Deleted"); + setState(() { + AppState().getUser.data!.userInfo!.userImageUrl = response.data; + }); + } + Utils.hideLoading(context); + }), + ), + ], + ), + ], + ), + ) + ], + ), + Container( + width: double.infinity, + color: MyColors.darkPrimaryColor.withOpacity(0.1), + padding: const EdgeInsets.all(20), + child: Row( + children: [ + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + "userName".toText( + isBold: true, + fontSize: 20, + letterSpacing: -1.44, + ), + AppState().getUser.data!.userInfo!.roleName!.toText(fontSize: 10), + ], + ), + ), + ShowFillButton( + title: LocaleKeys.edit.tr(), + fontSize: 12, + maxHeight: 35, + maxWidth: 70, + onPressed: () { + navigateWithName(context, AppRoutes.editAccountPage); + }, + ), + ], + ), + ), + ListTile( + leading: const Icon( + Icons.notifications, + color: MyColors.darkPrimaryColor, + ), + title: LocaleKeys.notifications.tr().toText(fontSize: 12), + ), + ListTile( + leading: const Icon( + Icons.settings, + color: MyColors.darkPrimaryColor, + ), + title: LocaleKeys.general.tr().toText(fontSize: 12), + ), + ListTile( + leading: const Icon( + Icons.person, + color: MyColors.darkPrimaryColor, + ), + title: LocaleKeys.account.tr().toText(fontSize: 12), + ), + ListTile( + leading: Image.asset( + "assets/images/ic_world.png", + width: 20, + height: 20, + color: MyColors.darkPrimaryColor, + ), + title: LocaleKeys.english.tr().toText(fontSize: 12), + onTap: () { + if (EasyLocalization.of(context)?.currentLocale?.countryCode == "SA") { + context.setLocale(const Locale("en", "US")); + } else { + context.setLocale(const Locale('ar', 'SA')); + } + }, + ), + ListTile( + leading: const Icon( + Icons.logout, + color: MyColors.darkPrimaryColor, + ), + title: LocaleKeys.signOut.tr().toText(fontSize: 12), + onTap: () { + pop(context); + navigateReplaceWithName(context, AppRoutes.registerSelection); + }, + ), + ], + ), + ); + } +} diff --git a/lib/views/dashboard/widgets/my_branches_widget.dart b/lib/views/dashboard/widgets/my_branches_widget.dart new file mode 100644 index 0000000..1ebf152 --- /dev/null +++ b/lib/views/dashboard/widgets/my_branches_widget.dart @@ -0,0 +1,38 @@ +import 'package:car_customer_app/extensions/int_extensions.dart'; +import 'package:car_customer_app/extensions/string_extensions.dart'; +import 'package:car_customer_app/widgets/extensions/extensions_widget.dart'; +import 'package:flutter/material.dart'; + +class ServiceProviderWidget extends StatelessWidget { + const ServiceProviderWidget({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return SizedBox( + width: double.infinity, + height: 150, + child: ListView.builder( + itemCount: 9, + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemBuilder: (BuildContext context, int index) { + return SizedBox( + width: 90, + child: Column( + children: [ + Image.asset( + "assets/images/bn_car.jpeg", + width: 80, + height: 80, + fit: BoxFit.cover, + ).toCircle(borderRadius: 100), + 8.height, + "Olaya Branch".toText(fontSize: 14, isBold: true, textAlign: TextAlign.center), + ], + ), + ); + }, + ), + ); + } +} diff --git a/lib/views/dashboard/widgets/view_all_widget.dart b/lib/views/dashboard/widgets/view_all_widget.dart new file mode 100644 index 0000000..c70ae95 --- /dev/null +++ b/lib/views/dashboard/widgets/view_all_widget.dart @@ -0,0 +1,29 @@ +import 'package:car_customer_app/extensions/string_extensions.dart'; +import 'package:car_customer_app/theme/colors.dart'; +import 'package:flutter/cupertino.dart'; + +class ViewAllWidget extends StatelessWidget { + final String title; + final String subTitle; + + const ViewAllWidget({Key? key, required this.title, required this.subTitle}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: const EdgeInsets.only(bottom: 10), + child: Row( + children: [ + Expanded(child: title.toText(isBold: true, fontSize: 18)), + subTitle.toText( + fontSize: 11, + isBold: true, + color: MyColors.primaryColor, + textDecoration: TextDecoration.underline, + ) + ], + ), + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 76117b4..340fa59 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,7 +37,7 @@ dependencies: flutter_password_strength: ^0.1.6 mc_common_app: - path: C:\Users\mirza.shafique\AndroidStudioProjects\motor concept\mc_common_app + path: D:/Development/car_common_app dev_dependencies: flutter_test: