Fixed Bugs

pull/3/head
FaizHashmi 2 months ago
parent 306604e686
commit fcb4d8650c

@ -3,6 +3,7 @@
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />

@ -134,7 +134,7 @@ Future<void> main() async {
paymentService: injector.get<PaymentService>(),
paymentRepo: injector.get<PaymentsRepo>(),
),
),
),
ChangeNotifierProvider<ShippingManagementVM>(
create: (_) => ShippingManagementVM(
shippingRepo: injector.get<ShippingRepo>(),

@ -60,9 +60,7 @@ class _BranchDetailPageState extends State<BranchDetailPage> {
bool validation(BuildContext context) {
bool isValid = false;
for (var element in context
.read<ServiceVM>()
.allProviderDealersList) {
for (var element in context.read<ServiceVM>().allProviderDealersList) {
if (element.isBranchUser ?? false) {
isValid = true;
}
@ -102,7 +100,7 @@ class _BranchDetailPageState extends State<BranchDetailPage> {
Widget buildFooterActionWidget(BuildContext context) {
Widget actionWidget = const SizedBox();
if (AppState().userType == UserType.providerDealer && widget.branchData.branchStatus == BranchStatusEnum.approvedOrActive) {
if ((AppState().userType == UserType.providerDealer || AppState().userType == UserType.providerIndividual) && widget.branchData.branchStatus == BranchStatusEnum.approvedOrActive) {
actionWidget = ShowFillButton(
title: LocaleKeys.assignDealerUser.tr(),
maxWidth: double.infinity,
@ -174,47 +172,45 @@ class _BranchDetailPageState extends State<BranchDetailPage> {
8.width,
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
isArabic ? serviceVM.categories[pIndex].categoryNameN.toString().toText(fontSize: 16):
serviceVM.categories[pIndex].categoryName.toString().toText(fontSize: 16),
],
),
8.height,
Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: ListView.builder(
itemBuilder: (context, index) {
return Container(
child: (EasyLocalization
.of(context)
?.currentLocale
?.countryCode == "SA"
isArabic
? serviceVM.categories[pIndex].categoryNameN.toString().toText(fontSize: 14, maxLines: 2)
: serviceVM.categories[pIndex].categoryName.toString().toText(fontSize: 14, maxLines: 2),
],
),
8.height,
Row(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Expanded(
child: ListView.builder(
itemBuilder: (context, index) {
return Container(
child: (EasyLocalization.of(context)?.currentLocale?.countryCode == "SA"
? serviceVM.categories[pIndex].services![index].serviceDescriptionN.toString()
: serviceVM.categories[pIndex].services![index].serviceDescription.toString())
.toText(
fontSize: 12,
color: MyColors.lightTextColor,
),
);
},
itemCount: serviceVM.categories[pIndex].services?.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
padding: EdgeInsets.zero,
),
),
],
).withArrow(isArrowEnabled: true)
.toText(
fontSize: 12,
color: MyColors.lightTextColor,
),
);
},
itemCount: serviceVM.categories[pIndex].services?.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
padding: EdgeInsets.zero,
),
),
],
)),
).withArrow(isArrowEnabled: true)
],
)),
],
).toWhiteContainer(width: double.infinity, allPading: 12);
}
@ -289,29 +285,27 @@ class _BranchDetailPageState extends State<BranchDetailPage> {
8.width,
Expanded(
child: LocaleKeys.setorEditBranchSchedule.tr().toText(
isUnderLine: true,
fontSize: 12,
color: Colors.white,
decorationColor: MyColors.white,
),
isUnderLine: true,
fontSize: 12,
color: Colors.white,
decorationColor: MyColors.white,
),
),
],
)
.withArrow(
isArrowEnabled: true,
color: Colors.white,
arrowWidth: 16.16,
arrowHeight: 11.75,
)
isArrowEnabled: true,
color: Colors.white,
arrowWidth: 16.16,
arrowHeight: 11.75,
)
.margin(right: 5),
).onPress(() {
if (widget.branchData.branchStatus == BranchStatusEnum.pending || widget.branchData.branchStatus == BranchStatusEnum.rejected) {
Utils.showToast(LocaleKeys.waitForBranchVerification.tr());
return;
}
context
.read<ScheduleVM>()
.currentSelectedBranchName = widget.branchData.branchName.toString();
context.read<ScheduleVM>().currentSelectedBranchName = widget.branchData.branchName.toString();
navigateWithName(context, AppRoutes.schedulesList, arguments: widget.branchData.id.toString());
}),
10.height,
@ -373,39 +367,38 @@ class _BranchDetailPageState extends State<BranchDetailPage> {
const Center(
child: CircularProgressIndicator(),
),
] else
...[
ListView.separated(
itemBuilder: (context, pIndex) {
return buildServiceTileWidget(pIndex, serviceVM).onPress(() {
serviceVM.categories[pIndex].branchId = widget.branchData.id.toString();
serviceVM.categories[pIndex].branchName = widget.branchData.branchName.toString();
// CategoryData categoryData = serviceVM.categories[pIndex];
serviceVM.applyFilterOnBranchServices(serviceStatusEnum: ServiceStatusEnum.approvedOrActive);
] else ...[
ListView.separated(
itemBuilder: (context, pIndex) {
return buildServiceTileWidget(pIndex, serviceVM).onPress(() {
serviceVM.categories[pIndex].branchId = widget.branchData.id.toString();
serviceVM.categories[pIndex].branchName = widget.branchData.branchName.toString();
// CategoryData categoryData = serviceVM.categories[pIndex];
serviceVM.applyFilterOnBranchServices(serviceStatusEnum: ServiceStatusEnum.approvedOrActive);
CategoryData categoryData = CategoryData(
id: serviceVM.categories[pIndex].id,
branchId: serviceVM.categories[pIndex].branchId,
branchName: serviceVM.categories[pIndex].branchName,
categoryName: serviceVM.categories[pIndex].categoryName,
categoryNameN: serviceVM.categories[pIndex].categoryNameN,
serviceCategoryIconUrl: serviceVM.categories[pIndex].serviceCategoryIconUrl,
serviceCategoryImageUrl: serviceVM.categories[pIndex].serviceCategoryImageUrl,
services: [],
);
CategoryData categoryData = CategoryData(
id: serviceVM.categories[pIndex].id,
branchId: serviceVM.categories[pIndex].branchId,
branchName: serviceVM.categories[pIndex].branchName,
categoryName: serviceVM.categories[pIndex].categoryName,
categoryNameN: serviceVM.categories[pIndex].categoryNameN,
serviceCategoryIconUrl: serviceVM.categories[pIndex].serviceCategoryIconUrl,
serviceCategoryImageUrl: serviceVM.categories[pIndex].serviceCategoryImageUrl,
services: [],
);
navigateWithName(context, AppRoutes.servicesList, arguments: categoryData);
});
},
itemCount: serviceVM.categories.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
padding: const EdgeInsets.all(20),
separatorBuilder: (BuildContext context, int index) {
return 12.height;
},
),
],
navigateWithName(context, AppRoutes.servicesList, arguments: categoryData);
});
},
itemCount: serviceVM.categories.length,
physics: const NeverScrollableScrollPhysics(),
shrinkWrap: true,
padding: const EdgeInsets.all(20),
separatorBuilder: (BuildContext context, int index) {
return 12.height;
},
),
],
12.height,
],
),

@ -91,7 +91,8 @@ class BranchListPage extends StatelessWidget {
return const Center(child: CircularProgressIndicator());
} else {
List<BranchDetailModel> branches = [];
if (serviceVM.branches!.data != null) {
// Safe null check - don't use ! operator on serviceVM.branches
if (serviceVM.branches?.data?.serviceProviderBranch != null) {
if (serviceVM.selectedBranchStatus == 3) {
// 3 means active branch
branches = serviceVM.branches!.data!.serviceProviderBranch!.where((element) => element.statusId == 3).toList();

@ -137,6 +137,9 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
if (status) {
isServiceActive = value;
// Navigate back and pass the new service status
// Utils.showToast(LocaleKeys.serviceStatusUpdated.tr());
Navigator.pop(context, value ? ServiceStatusEnum.approvedOrActive : ServiceStatusEnum.deactivated);
}
setState(() {});
},

@ -301,15 +301,24 @@ class _ServicesListPageState extends State<ServicesListPage> {
height: 16,
),
).onPress(() async {
navigateWithName(context, AppRoutes.createServices3,
arguments: CreateBranchModel(
branchId: categoryData.branchId ?? '',
branchName: categoryData.branchName ?? '',
categoryId: categoryData.id.toString(),
categoryName: categoryData.categoryName,
serviceProviderService: filteredServices[index],
isForEdit: true,
));
final ServiceStatusEnum? newStatus = await Navigator.pushNamed(
context,
AppRoutes.createServices3,
arguments: CreateBranchModel(
branchId: categoryData.branchId ?? '',
branchName: categoryData.branchName ?? '',
categoryId: categoryData.id.toString(),
categoryName: categoryData.categoryName,
serviceProviderService: filteredServices[index],
isForEdit: true,
),
) as ServiceStatusEnum?;
// If status was updated, switch to that filter and refresh
if (newStatus != null) {
selectedService = newStatus;
await _onRefresh(newStatus);
}
}),
]
],

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:developer';
import 'package:car_provider_app/views/branch_management/branch/branch_list_page.dart';
import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/app_state.dart';
import 'package:mc_common_app/utils/enums.dart';
import 'package:mc_common_app/view_models/dashboard_view_model_provider.dart';
import 'package:mc_common_app/views/common_fragments/requests_fragment.dart';
@ -29,24 +30,43 @@ class _DashboardViewState extends State<DashboardView> {
log("widget.dashboardRouteEnum: ${widget.dashboardRouteEnum}");
super.initState();
dashboardVMProvider = Provider.of<DashboardVMProvider>(context, listen: false);
// Ensure selected index is valid for individual providers (no Requests tab)
if (AppState().userType != UserType.providerDealer) {
// For individuals, max index is 3 (Ads), so if selected is 4, set to Home (2)
if (dashboardVMProvider.selectedNavbarBarIndex >= 4) {
dashboardVMProvider.selectedNavbarBarIndex = 2; // Home
}
}
scheduleMicrotask(() => dashboardVMProvider.onRefresh(context, dashboardRouteEnum: widget.dashboardRouteEnum));
}
@override
Widget build(BuildContext context) {
// Build fragments list conditionally based on user type
// Individual providers should not have access to Requests
List<Widget> fragments = [
const BranchListPage(),
const BranchAppointmentFragment(),
const HomeFragment(),
const AdsFragment(),
const MyRequestsFragment(),
const BranchListPage(), // 0
const BranchAppointmentFragment(), // 1
const HomeFragment(), // 2
const AdsFragment(), // 3
// Only Dealerships can access Special Requests
if (AppState().userType == UserType.providerDealer)
const MyRequestsFragment(), // 4 (only for dealerships)
];
// Ensure the selected index is valid for the current fragments list
int validIndex = context.watch<DashboardVMProvider>().selectedNavbarBarIndex;
if (validIndex >= fragments.length) {
validIndex = fragments.length - 1; // Default to last valid fragment
}
return PopScope(
canPop: false,
child: Scaffold(
key: _scaffoldKey,
body: fragments[context.watch<DashboardVMProvider>().selectedNavbarBarIndex],
body: fragments[validIndex],
bottomNavigationBar: CustomBottomNavbar(
onSelected: (index) {
dashboardVMProvider.onNavbarTapped(index);

@ -37,7 +37,8 @@ class BranchAppointmentFragment extends StatelessWidget {
return const Center(child: CircularProgressIndicator());
} else {
List<BranchDetailModel> branches = [];
if (serviceVM.branches!.data != null) {
// Safe null check - don't use ! operator
if (serviceVM.branches?.data?.serviceProviderBranch != null) {
branches = serviceVM.branches!.data!.serviceProviderBranch!.where((element) => 3 == element.statusId).toList();
}
return RefreshIndicator(

Loading…
Cancel
Save