|
|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:car_provider_app/config/provider_routes.dart';
|
|
|
|
|
import 'package:car_provider_app/views/branch_management/services/duplication/sheet/approved_branches_list_sheet.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
|
|
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
|
|
|
@ -15,12 +15,13 @@ import 'package:mc_common_app/theme/colors.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/enums.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/navigator.dart';
|
|
|
|
|
import 'package:mc_common_app/utils/utils.dart';
|
|
|
|
|
import 'package:mc_common_app/view_models/service_view_model.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/bottom_sheet.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
|
|
|
|
import 'package:mc_common_app/widgets/tab/role_type_tab.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class CreateBranchModel {
|
|
|
|
|
final String branchId;
|
|
|
|
|
@ -51,16 +52,34 @@ class _ServicesListPageState extends State<ServicesListPage> {
|
|
|
|
|
int selectedTab = 0;
|
|
|
|
|
ServiceStatusEnum selectedService = ServiceStatusEnum.approvedOrActive;
|
|
|
|
|
|
|
|
|
|
List<ServiceModel> filteredServices = [];
|
|
|
|
|
late CategoryData categoryData;
|
|
|
|
|
|
|
|
|
|
ViewState screenState = ViewState.busy;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final categoryData = ModalRoute.of(context)!.settings.arguments as CategoryData;
|
|
|
|
|
List<ServiceModel> services = [];
|
|
|
|
|
if (selectedService == ServiceStatusEnum.approvedOrActive) {
|
|
|
|
|
services = categoryData.services!.where((i) => i.serviceStatus == ServiceStatusEnum.approvedOrActive.index + 1).toList();
|
|
|
|
|
} else {
|
|
|
|
|
services = categoryData.services!.where((i) => i.serviceStatus != ServiceStatusEnum.approvedOrActive.index + 1).toList();
|
|
|
|
|
void initState() {
|
|
|
|
|
scheduleMicrotask(() async {
|
|
|
|
|
await _fetchServices();
|
|
|
|
|
});
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> _fetchServices() async {
|
|
|
|
|
categoryData.services = await context.read<ServiceVM>().fetchProviderServicesModelByCategoryIdAndBranchID(
|
|
|
|
|
branchID: categoryData.branchId.toString(),
|
|
|
|
|
categoryId: categoryData.id.toString(),
|
|
|
|
|
);
|
|
|
|
|
filteredServices = categoryData.services!.where((i) => i.serviceStatus == ServiceStatusEnum.approvedOrActive.index + 1).toList();
|
|
|
|
|
|
|
|
|
|
screenState = ViewState.idle;
|
|
|
|
|
setState(() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
categoryData = ModalRoute.of(context)!.settings.arguments as CategoryData;
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: CustomAppBar(
|
|
|
|
|
title: LocaleKeys.services.tr(),
|
|
|
|
|
@ -97,8 +116,10 @@ class _ServicesListPageState extends State<ServicesListPage> {
|
|
|
|
|
selectedTab = value.id;
|
|
|
|
|
if (selectedTab == 0) {
|
|
|
|
|
selectedService = ServiceStatusEnum.approvedOrActive;
|
|
|
|
|
filteredServices = categoryData.services!.where((i) => i.serviceStatus == ServiceStatusEnum.approvedOrActive.index + 1).toList();
|
|
|
|
|
} else {
|
|
|
|
|
selectedService = value.id.toServiceStatusEnum();
|
|
|
|
|
filteredServices = categoryData.services!.where((i) => i.serviceStatus != ServiceStatusEnum.approvedOrActive.index + 1).toList();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
@ -106,9 +127,30 @@ class _ServicesListPageState extends State<ServicesListPage> {
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: services.isEmpty
|
|
|
|
|
child: RefreshIndicator(
|
|
|
|
|
onRefresh: () async {
|
|
|
|
|
screenState = ViewState.busy;
|
|
|
|
|
setState(() {});
|
|
|
|
|
categoryData.services = await context.read<ServiceVM>().fetchProviderServicesModelByCategoryIdAndBranchID(
|
|
|
|
|
branchID: categoryData.branchId.toString(),
|
|
|
|
|
categoryId: categoryData.id.toString(),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (selectedService == ServiceStatusEnum.approvedOrActive) {
|
|
|
|
|
filteredServices = categoryData.services!.where((i) => i.serviceStatus == ServiceStatusEnum.approvedOrActive.index + 1).toList();
|
|
|
|
|
} else {
|
|
|
|
|
filteredServices = categoryData.services!.where((i) => i.serviceStatus != ServiceStatusEnum.approvedOrActive.index + 1).toList();
|
|
|
|
|
}
|
|
|
|
|
screenState = ViewState.idle;
|
|
|
|
|
setState(() {});
|
|
|
|
|
},
|
|
|
|
|
child: screenState == ViewState.busy
|
|
|
|
|
? const Center(
|
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
|
)
|
|
|
|
|
: filteredServices.isEmpty
|
|
|
|
|
? Center(
|
|
|
|
|
child: LocaleKeys.noItemsToShow.tr().toText(fontSize: 16, color: MyColors.lightTextColor),
|
|
|
|
|
child: LocaleKeys.noServicesAvailable.tr().toText(fontSize: 16, color: MyColors.lightTextColor),
|
|
|
|
|
)
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
@ -117,16 +159,16 @@ class _ServicesListPageState extends State<ServicesListPage> {
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
if (services[index].serviceStatus == 1) ...[
|
|
|
|
|
if (filteredServices[index].serviceStatus == 1) ...[
|
|
|
|
|
Utils.statusContainerChip(text: "Pending", chipColor: MyColors.adPendingStatusColor),
|
|
|
|
|
5.height,
|
|
|
|
|
],
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
child: (services[index].serviceDescription ?? "").toText(fontSize: 16),
|
|
|
|
|
child: (filteredServices[index].serviceDescription ?? "").toText(fontSize: 16),
|
|
|
|
|
),
|
|
|
|
|
if (services[index].serviceStatus != 1) ...[
|
|
|
|
|
if (filteredServices[index].serviceStatus != 1) ...[
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.all(4.0),
|
|
|
|
|
child: SvgPicture.asset(
|
|
|
|
|
@ -141,7 +183,7 @@ class _ServicesListPageState extends State<ServicesListPage> {
|
|
|
|
|
branchName: categoryData.branchName ?? '',
|
|
|
|
|
categoryId: categoryData.id.toString(),
|
|
|
|
|
categoryName: categoryData.categoryName,
|
|
|
|
|
serviceProviderService: services[index],
|
|
|
|
|
serviceProviderService: filteredServices[index],
|
|
|
|
|
isForEdit: true,
|
|
|
|
|
));
|
|
|
|
|
}),
|
|
|
|
|
@ -158,11 +200,13 @@ class _ServicesListPageState extends State<ServicesListPage> {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
showItem('${LocaleKeys.availableforAppointment.tr()}:', (services[index].isAllowAppointment ?? false) ? LocaleKeys.yes.tr() : LocaleKeys.no.tr(), valueColor: Colors.green),
|
|
|
|
|
showItem('${LocaleKeys.allowingHomeService.tr()}:', (services[index].isAllowAppointmentHome ?? false) ? LocaleKeys.yes.tr() : LocaleKeys.no.tr(), valueColor: Colors.green),
|
|
|
|
|
if ((services[index].isAllowAppointmentHome ?? false)) ...[
|
|
|
|
|
showItem('${LocaleKeys.homeServiceRange.tr()}:', services[index].customerLocationRange.toString()),
|
|
|
|
|
showItem('${LocaleKeys.chargesPerKM.tr()}:', services[index].rangePricePerKm.toString()),
|
|
|
|
|
showItem('${LocaleKeys.availableforAppointment.tr()}:', (filteredServices[index].isAllowAppointment ?? false) ? LocaleKeys.yes.tr() : LocaleKeys.no.tr(),
|
|
|
|
|
valueColor: Colors.green),
|
|
|
|
|
showItem('${LocaleKeys.allowingHomeService.tr()}:', (filteredServices[index].isAllowAppointmentHome ?? false) ? LocaleKeys.yes.tr() : LocaleKeys.no.tr(),
|
|
|
|
|
valueColor: Colors.green),
|
|
|
|
|
if ((filteredServices[index].isAllowAppointmentHome ?? false)) ...[
|
|
|
|
|
showItem('${LocaleKeys.homeServiceRange.tr()}:', filteredServices[index].customerLocationRange.toString()),
|
|
|
|
|
showItem('${LocaleKeys.chargesPerKM.tr()}:', filteredServices[index].rangePricePerKm.toString()),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -173,14 +217,15 @@ class _ServicesListPageState extends State<ServicesListPage> {
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
).toWhiteContainer(width: double.infinity, allPading: 12).onPress(
|
|
|
|
|
() => navigateWithName(context, AppRoutes.itemsList, arguments: services[index]),
|
|
|
|
|
() => navigateWithName(context, AppRoutes.itemsList, arguments: filteredServices[index]),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (context, index) {
|
|
|
|
|
return const SizedBox(height: 12);
|
|
|
|
|
},
|
|
|
|
|
padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20, top: 10),
|
|
|
|
|
itemCount: services.length,
|
|
|
|
|
itemCount: filteredServices.length,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
|