Added Ads Filters and Appointments Filter

aamir_dev
Faiz Hashmi 2 years ago
parent 0b953bbe7d
commit 71030bf0fa

@ -25,6 +25,7 @@ import 'package:mc_common_app/views/setting_options/setting_options_invite_frien
import 'package:mc_common_app/views/setting_options/setting_options_language.dart'; import 'package:mc_common_app/views/setting_options/setting_options_language.dart';
import 'package:mc_common_app/views/chat/chat_view.dart'; import 'package:mc_common_app/views/chat/chat_view.dart';
import 'package:mc_common_app/views/branches/branches_filter_view.dart'; import 'package:mc_common_app/views/branches/branches_filter_view.dart';
import 'package:mc_common_app/views/appointments/appointments_filter_view.dart';
class CustomerAppRoutes { class CustomerAppRoutes {
static final Map<String, WidgetBuilder> routes = { static final Map<String, WidgetBuilder> routes = {
@ -43,6 +44,7 @@ class CustomerAppRoutes {
AppRoutes.paymentMethodsView: (context) => PaymentMethodsView(paymentType: ModalRoute.of(context)!.settings.arguments as PaymentTypes), AppRoutes.paymentMethodsView: (context) => PaymentMethodsView(paymentType: ModalRoute.of(context)!.settings.arguments as PaymentTypes),
AppRoutes.branchDetailPage: (context) => BranchDetailPage(branchDetailModel: ModalRoute.of(context)!.settings.arguments as BranchDetailModel), AppRoutes.branchDetailPage: (context) => BranchDetailPage(branchDetailModel: ModalRoute.of(context)!.settings.arguments as BranchDetailModel),
AppRoutes.branchSearchFilterPage: (context) => BranchesFilterView(), AppRoutes.branchSearchFilterPage: (context) => BranchesFilterView(),
AppRoutes.appoinmentSearchFilterPage: (context) => AppointmentsFilterView(),
AppRoutes.providerProfilePage: (context) => ProviderProfilePage(providerId: ModalRoute.of(context)!.settings.arguments as int), AppRoutes.providerProfilePage: (context) => ProviderProfilePage(providerId: ModalRoute.of(context)!.settings.arguments as int),
AppRoutes.offersListPage: (context) => OfferListPage(offerListPageArguments: ModalRoute.of(context)!.settings.arguments as OfferListPageArguments), AppRoutes.offersListPage: (context) => OfferListPage(offerListPageArguments: ModalRoute.of(context)!.settings.arguments as OfferListPageArguments),
AppRoutes.createRequestPage: (context) => CreateRequestPage(), AppRoutes.createRequestPage: (context) => CreateRequestPage(),

@ -62,7 +62,7 @@ Future<void> main() async {
), ),
ChangeNotifierProvider<AppointmentsVM>( ChangeNotifierProvider<AppointmentsVM>(
create: (_) => AppointmentsVM( create: (_) => AppointmentsVM(
scheduleRepo: injector.get<AppointmentRepo>(), appointmentRepo: injector.get<AppointmentRepo>(),
commonServices: injector.get<CommonAppServices>(), commonServices: injector.get<CommonAppServices>(),
commonRepo: injector.get<CommonRepo>(), commonRepo: injector.get<CommonRepo>(),
branchRepo: injector.get<BranchRepo>(), branchRepo: injector.get<BranchRepo>(),

@ -1,4 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:developer';
import 'package:car_customer_app/views/dashboard/fragments/ads_fragment.dart'; import 'package:car_customer_app/views/dashboard/fragments/ads_fragment.dart';
import 'package:car_customer_app/views/dashboard/fragments/appointments_fragment.dart'; import 'package:car_customer_app/views/dashboard/fragments/appointments_fragment.dart';
@ -57,8 +58,9 @@ class _DashboardPageState extends State<DashboardPage> {
if (appointmentsVM.myAppointments.isEmpty) { if (appointmentsVM.myAppointments.isEmpty) {
await appointmentsVM.getMyAppointments(); await appointmentsVM.getMyAppointments();
} }
if (appointmentsVM.nearbyBranches.isEmpty) { if (appointmentsVM.nearbyBranches.isEmpty) {
await appointmentsVM.getAllNearBranches(isFromRefresh: true); await appointmentsVM.applyFilterOnBranches(index: 0); // to get all branches!
} }
if (adVM.myAds.isEmpty) { if (adVM.myAds.isEmpty) {
@ -99,7 +101,7 @@ class _DashboardPageState extends State<DashboardPage> {
String getPageTitle(int index) { String getPageTitle(int index) {
if (index == 0) { if (index == 0) {
return "Select Branch"; return "Branches";
} }
if (index == 1) { if (index == 1) {
return "Appointments"; return "Appointments";
@ -120,54 +122,56 @@ class _DashboardPageState extends State<DashboardPage> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
DashboardVmCustomer dashboardVM = context.read<DashboardVmCustomer>(); DashboardVmCustomer dashboardVM = context.read<DashboardVmCustomer>();
bool isHomePage = dashboardVM.selectedNavbarBarIndex == 2; bool isHomePage = dashboardVM.selectedNavbarBarIndex == 2;
return Scaffold( return WillPopScope(
appBar: CustomAppBar( onWillPop: () async => Future.value(false),
backgroundColor: null, child: Scaffold(
leadingWidth: 100, appBar: CustomAppBar(
title: getPageTitle(dashboardVM.selectedNavbarBarIndex), backgroundColor: null,
profileImageUrl: MyAssets.bnCar, leadingWidth: 100,
isRemoveBackButton: true, title: getPageTitle(dashboardVM.selectedNavbarBarIndex),
isDrawerEnabled: isHomePage ? true : false, profileImageUrl: MyAssets.bnCar,
onTap: () { isRemoveBackButton: true,
if (isHomePage) { isDrawerEnabled: isHomePage ? true : false,
navigateWithName(context, AppRoutes.settingOptionsLanguages); onTap: () {
} if (isHomePage) {
}, navigateWithName(context, AppRoutes.settingOptionsLanguages);
actions: [ }
(isHomePage },
? Row( actions: [
children: [ (isHomePage
"${AppState().currentAppType}".toText(color: MyColors.darkTextColor).onPress( ? Row(
() { children: [
print("userId: ${AppState().getUser.data!.userInfo!.userId}"); "${AppState().currentAppType}".toText(color: MyColors.darkTextColor).onPress(
print("customerId: ${AppState().getUser.data!.userInfo!.customerId}"); () {
// context.read<ChatVM>().buildHubConnection(); print("userId: ${AppState().getUser.data!.userInfo!.userId}");
}, print("customerId: ${AppState().getUser.data!.userInfo!.customerId}");
), // context.read<ChatVM>().buildHubConnection();
10.width, },
MyAssets.notificationsBellIcon.buildSvg().onPress(() {}), ),
15.width, 10.width,
Icon(Icons.message, color: MyColors.darkTextColor).onPress( MyAssets.notificationsBellIcon.buildSvg().onPress(() {}),
() { 15.width,
_onRefresh(); Icon(Icons.message, color: MyColors.darkTextColor)
}, ],
), )
], : InkWell(
) onTap: () async {
: InkWell( if (dashboardVM.selectedNavbarBarIndex == 0) {
onTap: () async { navigateWithName(context, AppRoutes.branchSearchFilterPage);
if (dashboardVM.selectedNavbarBarIndex == 3) { }
await context.read<AdVM>().populateDataForAdFilter(); if (dashboardVM.selectedNavbarBarIndex == 1) {
navigateWithName(context, AppRoutes.adsFilterView); navigateWithName(context, AppRoutes.appoinmentSearchFilterPage);
} }
if (dashboardVM.selectedNavbarBarIndex == 0) { if (dashboardVM.selectedNavbarBarIndex == 3) {
navigateWithName(context, AppRoutes.branchSearchFilterPage); await context.read<AdVM>().populateDataForAdFilter();
} navigateWithName(context, AppRoutes.adsFilterView);
}, }
child: Consumer( },
builder: (BuildContext context, AppointmentsVM appointmentsVM, Widget? child) { child: Consumer2<AppointmentsVM, AdVM>(
return appointmentsVM.branchFiltersCounter > 0 builder: (BuildContext context, AppointmentsVM appointmentsVM, AdVM adVM, Widget? child) {
? Padding( if (dashboardVM.selectedNavbarBarIndex == 0) {
if (appointmentsVM.branchFiltersCounter > 0) {
return Padding(
padding: const EdgeInsets.only(top: 20), padding: const EdgeInsets.only(top: 20),
child: Badge( child: Badge(
largeSize: 15, largeSize: 15,
@ -176,16 +180,56 @@ class _DashboardPageState extends State<DashboardPage> {
label: Text('${appointmentsVM.branchFiltersCounter}'), label: Text('${appointmentsVM.branchFiltersCounter}'),
child: MyAssets.searchIcon.buildSvg(), child: MyAssets.searchIcon.buildSvg(),
), ),
) );
: MyAssets.searchIcon.buildSvg(); } else {
}, return MyAssets.searchIcon.buildSvg();
), }
)) }
.paddingOnly(right: 21)
], if (dashboardVM.selectedNavbarBarIndex == 1) {
if (appointmentsVM.appointmentFiltersCounter > 0) {
return Padding(
padding: const EdgeInsets.only(top: 20),
child: Badge(
largeSize: 15,
smallSize: 20,
backgroundColor: MyColors.darkPrimaryColor,
label: Text('${appointmentsVM.appointmentFiltersCounter}'),
child: MyAssets.searchIcon.buildSvg(),
),
);
} else {
return MyAssets.searchIcon.buildSvg();
}
}
if (dashboardVM.selectedNavbarBarIndex == 3) {
if (adVM.adsFiltersCounter > 0) {
return Padding(
padding: const EdgeInsets.only(top: 20),
child: Badge(
largeSize: 15,
smallSize: 20,
backgroundColor: MyColors.darkPrimaryColor,
label: Text('${adVM.adsFiltersCounter}'),
child: MyAssets.searchIcon.buildSvg(),
),
);
} else {
return MyAssets.searchIcon.buildSvg();
}
}
return MyAssets.searchIcon.buildSvg();
},
),
))
.paddingOnly(right: 21)
],
),
bottomNavigationBar: CustomBottomNavbar(),
body: fragments[context.watch<DashboardVmCustomer>().selectedNavbarBarIndex],
), ),
bottomNavigationBar: CustomBottomNavbar(),
body: fragments[context.watch<DashboardVmCustomer>().selectedNavbarBarIndex],
); );
} }
} }

Loading…
Cancel
Save