|
|
|
@ -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,7 +122,9 @@ 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(
|
|
|
|
|
|
|
|
onWillPop: () async => Future.value(false),
|
|
|
|
|
|
|
|
child: Scaffold(
|
|
|
|
appBar: CustomAppBar(
|
|
|
|
appBar: CustomAppBar(
|
|
|
|
backgroundColor: null,
|
|
|
|
backgroundColor: null,
|
|
|
|
leadingWidth: 100,
|
|
|
|
leadingWidth: 100,
|
|
|
|
@ -147,27 +151,27 @@ class _DashboardPageState extends State<DashboardPage> {
|
|
|
|
10.width,
|
|
|
|
10.width,
|
|
|
|
MyAssets.notificationsBellIcon.buildSvg().onPress(() {}),
|
|
|
|
MyAssets.notificationsBellIcon.buildSvg().onPress(() {}),
|
|
|
|
15.width,
|
|
|
|
15.width,
|
|
|
|
Icon(Icons.message, color: MyColors.darkTextColor).onPress(
|
|
|
|
Icon(Icons.message, color: MyColors.darkTextColor)
|
|
|
|
() {
|
|
|
|
|
|
|
|
_onRefresh();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
: InkWell(
|
|
|
|
: InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
onTap: () async {
|
|
|
|
|
|
|
|
if (dashboardVM.selectedNavbarBarIndex == 0) {
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.branchSearchFilterPage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dashboardVM.selectedNavbarBarIndex == 1) {
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.appoinmentSearchFilterPage);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (dashboardVM.selectedNavbarBarIndex == 3) {
|
|
|
|
if (dashboardVM.selectedNavbarBarIndex == 3) {
|
|
|
|
await context.read<AdVM>().populateDataForAdFilter();
|
|
|
|
await context.read<AdVM>().populateDataForAdFilter();
|
|
|
|
navigateWithName(context, AppRoutes.adsFilterView);
|
|
|
|
navigateWithName(context, AppRoutes.adsFilterView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dashboardVM.selectedNavbarBarIndex == 0) {
|
|
|
|
|
|
|
|
navigateWithName(context, AppRoutes.branchSearchFilterPage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: Consumer(
|
|
|
|
child: Consumer2<AppointmentsVM, AdVM>(
|
|
|
|
builder: (BuildContext context, AppointmentsVM appointmentsVM, Widget? child) {
|
|
|
|
builder: (BuildContext context, AppointmentsVM appointmentsVM, AdVM adVM, Widget? child) {
|
|
|
|
return appointmentsVM.branchFiltersCounter > 0
|
|
|
|
if (dashboardVM.selectedNavbarBarIndex == 0) {
|
|
|
|
? Padding(
|
|
|
|
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,8 +180,47 @@ 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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
))
|
|
|
|
))
|
|
|
|
@ -186,6 +229,7 @@ class _DashboardPageState extends State<DashboardPage> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
bottomNavigationBar: CustomBottomNavbar(),
|
|
|
|
bottomNavigationBar: CustomBottomNavbar(),
|
|
|
|
body: fragments[context.watch<DashboardVmCustomer>().selectedNavbarBarIndex],
|
|
|
|
body: fragments[context.watch<DashboardVmCustomer>().selectedNavbarBarIndex],
|
|
|
|
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|