|
|
|
@ -1,5 +1,7 @@
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'dart:developer';
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
import 'package:car_provider_app/main.dart';
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
|
|
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
|
|
import 'package:mc_common_app/models/general_models/generic_resp_model.dart';
|
|
|
|
import 'package:mc_common_app/utils/navigator.dart';
|
|
|
|
import 'package:mc_common_app/utils/navigator.dart';
|
|
|
|
@ -38,6 +40,7 @@ class CreateServicesPage3 extends StatefulWidget {
|
|
|
|
class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
bool isAppointmentAvailable = false;
|
|
|
|
bool isAppointmentAvailable = false;
|
|
|
|
bool isHomeAppointmentAvailable = false;
|
|
|
|
bool isHomeAppointmentAvailable = false;
|
|
|
|
|
|
|
|
ServiceStatusEnum serviceStatusEnum = ServiceStatusEnum.pending;
|
|
|
|
int serviceRage = 0;
|
|
|
|
int serviceRage = 0;
|
|
|
|
String chargersPerKm = "";
|
|
|
|
String chargersPerKm = "";
|
|
|
|
int? categoryId = -1;
|
|
|
|
int? categoryId = -1;
|
|
|
|
@ -45,6 +48,9 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
DropValue? category;
|
|
|
|
DropValue? category;
|
|
|
|
DropValue? service;
|
|
|
|
DropValue? service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool isEditDisabled = false;
|
|
|
|
|
|
|
|
bool isServiceActive = true;
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
super.initState();
|
|
|
|
@ -57,6 +63,9 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
service = serviceVM.servicesDropList.firstWhere((element) => element.id == widget.branchModel!.serviceProviderService!.serviceId);
|
|
|
|
service = serviceVM.servicesDropList.firstWhere((element) => element.id == widget.branchModel!.serviceProviderService!.serviceId);
|
|
|
|
isAppointmentAvailable = widget.branchModel?.serviceProviderService?.isAllowAppointment ?? false;
|
|
|
|
isAppointmentAvailable = widget.branchModel?.serviceProviderService?.isAllowAppointment ?? false;
|
|
|
|
serviceRage = widget.branchModel?.serviceProviderService?.customerLocationRange ?? 0;
|
|
|
|
serviceRage = widget.branchModel?.serviceProviderService?.customerLocationRange ?? 0;
|
|
|
|
|
|
|
|
serviceStatusEnum = widget.branchModel?.serviceProviderService?.serviceStatusEnum ?? ServiceStatusEnum.pending;
|
|
|
|
|
|
|
|
isServiceActive = widget.branchModel?.serviceProviderService?.isActive ?? true;
|
|
|
|
|
|
|
|
isEditDisabled = serviceStatusEnum == ServiceStatusEnum.blocked;
|
|
|
|
if (serviceRage > 0) {
|
|
|
|
if (serviceRage > 0) {
|
|
|
|
isHomeAppointmentAvailable = true;
|
|
|
|
isHomeAppointmentAvailable = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -101,7 +110,43 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
list: model.categoryDropList,
|
|
|
|
list: model.categoryDropList,
|
|
|
|
hint: category != null ? category!.value : LocaleKeys.selectServiceCategory.tr(),
|
|
|
|
hint: category != null ? category!.value : LocaleKeys.selectServiceCategory.tr(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
12.height,
|
|
|
|
if (widget.branchModel!.isForEdit) ...[
|
|
|
|
|
|
|
|
22.height,
|
|
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 18),
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
LocaleKeys.active.tr().toText(fontSize: 16),
|
|
|
|
|
|
|
|
8.width,
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
width: 50,
|
|
|
|
|
|
|
|
height: 30,
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: isServiceActive ? MyColors.darkPrimaryColor : MyColors.white,
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(25.0),
|
|
|
|
|
|
|
|
border: Border.all(color: MyColors.lightTextColor, width: 1),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
child: Transform.scale(
|
|
|
|
|
|
|
|
scale: 0.8,
|
|
|
|
|
|
|
|
child: CupertinoSwitch(
|
|
|
|
|
|
|
|
activeColor: MyColors.darkPrimaryColor,
|
|
|
|
|
|
|
|
trackColor: MyColors.white,
|
|
|
|
|
|
|
|
thumbColor: MyColors.greyACColor,
|
|
|
|
|
|
|
|
value: isServiceActive,
|
|
|
|
|
|
|
|
onChanged: (value) {
|
|
|
|
|
|
|
|
if (isEditDisabled) return;
|
|
|
|
|
|
|
|
isServiceActive = value;
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
] else ...[
|
|
|
|
|
|
|
|
12.height,
|
|
|
|
|
|
|
|
],
|
|
|
|
(model.state == ViewState.idle)
|
|
|
|
(model.state == ViewState.idle)
|
|
|
|
? categoryId != -1 && model.servicesDropList.isNotEmpty
|
|
|
|
? categoryId != -1 && model.servicesDropList.isNotEmpty
|
|
|
|
? DropdownField(
|
|
|
|
? DropdownField(
|
|
|
|
@ -128,6 +173,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
20.height,
|
|
|
|
20.height,
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
|
|
|
|
isDisabled: isEditDisabled,
|
|
|
|
isSelected: isAppointmentAvailable,
|
|
|
|
isSelected: isAppointmentAvailable,
|
|
|
|
title: LocaleKeys.availableforAppointment.tr(),
|
|
|
|
title: LocaleKeys.availableforAppointment.tr(),
|
|
|
|
description: LocaleKeys.bookAppointmentForServices.tr(),
|
|
|
|
description: LocaleKeys.bookAppointmentForServices.tr(),
|
|
|
|
@ -142,6 +188,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
20.height,
|
|
|
|
20.height,
|
|
|
|
if (isAppointmentAvailable)
|
|
|
|
if (isAppointmentAvailable)
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
CheckBoxWithTitleDescription(
|
|
|
|
|
|
|
|
isDisabled: isEditDisabled,
|
|
|
|
isSelected: isHomeAppointmentAvailable,
|
|
|
|
isSelected: isHomeAppointmentAvailable,
|
|
|
|
title: LocaleKeys.allowingHomeService.tr(),
|
|
|
|
title: LocaleKeys.allowingHomeService.tr(),
|
|
|
|
description: LocaleKeys.bookAppointmentAtLocation.tr(),
|
|
|
|
description: LocaleKeys.bookAppointmentAtLocation.tr(),
|
|
|
|
@ -209,20 +256,24 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
if (serviceId != -1)
|
|
|
|
if (serviceId != -1)
|
|
|
|
ShowFillButton(
|
|
|
|
if (isEditDisabled) ...[
|
|
|
|
title: LocaleKeys.save.tr(),
|
|
|
|
Utils.buildStatusContainer(LocaleKeys.blockedByAdmin.tr()),
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
] else ...[
|
|
|
|
margin: const EdgeInsets.all(20),
|
|
|
|
ShowFillButton(
|
|
|
|
onPressed: () {
|
|
|
|
title: LocaleKeys.save.tr(),
|
|
|
|
if (widget.branchModel!.serviceProviderService != null) {
|
|
|
|
maxWidth: double.infinity,
|
|
|
|
updateService(context, model);
|
|
|
|
margin: const EdgeInsets.all(20),
|
|
|
|
} else {
|
|
|
|
onPressed: () {
|
|
|
|
if (model.services != null) {
|
|
|
|
if (widget.branchModel!.serviceProviderService != null) {
|
|
|
|
createService(context, model);
|
|
|
|
updateService(context, model);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (model.services != null) {
|
|
|
|
|
|
|
|
createService(context, model);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -231,7 +282,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
createService(BuildContext context, ServiceVM model) async {
|
|
|
|
createService(BuildContext context, ServiceVM serviceVM) async {
|
|
|
|
if (isHomeAppointmentAvailable) {
|
|
|
|
if (isHomeAppointmentAvailable) {
|
|
|
|
if (serviceRage == 0 || chargersPerKm.isEmpty || double.parse(chargersPerKm) < 1) {
|
|
|
|
if (serviceRage == 0 || chargersPerKm.isEmpty || double.parse(chargersPerKm) < 1) {
|
|
|
|
Utils.showToast(LocaleKeys.chargesAndServiceRangeGreaterThanZero.tr());
|
|
|
|
Utils.showToast(LocaleKeys.chargesAndServiceRangeGreaterThanZero.tr());
|
|
|
|
@ -239,7 +290,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Map<String, dynamic>> map = [];
|
|
|
|
List<Map<String, dynamic>> map = [];
|
|
|
|
model.services!.data?.forEach((element) {
|
|
|
|
serviceVM.services!.data?.forEach((element) {
|
|
|
|
if (serviceId == element.id) {
|
|
|
|
if (serviceId == element.id) {
|
|
|
|
element.isSelected = true;
|
|
|
|
element.isSelected = true;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -247,12 +298,12 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < model.services!.data!.length; i++) {
|
|
|
|
for (int i = 0; i < serviceVM.services!.data!.length; i++) {
|
|
|
|
if (model.services!.data![i].isSelected ?? false) {
|
|
|
|
if (serviceVM.services!.data![i].isSelected ?? false) {
|
|
|
|
var postParams = {
|
|
|
|
var postParams = {
|
|
|
|
// "id": services!.data![i].id,
|
|
|
|
// "id": services!.data![i].id,
|
|
|
|
"providerBranchID": widget.branchModel!.branchId,
|
|
|
|
"providerBranchID": widget.branchModel!.branchId,
|
|
|
|
"serviceID": model.services!.data![i].id,
|
|
|
|
"serviceID": serviceVM.services!.data![i].id,
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
"isActive": true,
|
|
|
|
"isActive": true,
|
|
|
|
"customerLocationRange": serviceRage,
|
|
|
|
"customerLocationRange": serviceRage,
|
|
|
|
@ -263,8 +314,8 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// print(map);
|
|
|
|
// print(map);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
GenericRespModel mResponse = await model.createService(map);
|
|
|
|
GenericRespModel mResponse = await serviceVM.createService(map);
|
|
|
|
await model.getBranchAndServices();
|
|
|
|
await serviceVM.getBranchAndServices();
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.showToast(mResponse.message ?? "");
|
|
|
|
Utils.showToast(mResponse.message ?? "");
|
|
|
|
if (mResponse.messageStatus == 1) {
|
|
|
|
if (mResponse.messageStatus == 1) {
|
|
|
|
@ -287,7 +338,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"id": widget.branchModel!.serviceProviderService!.serviceProviderServiceId.toString(),
|
|
|
|
"id": widget.branchModel!.serviceProviderService!.serviceProviderServiceId.toString(),
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
"isActive": true,
|
|
|
|
"isActive": isServiceActive,
|
|
|
|
"customerLocationRange": serviceRage,
|
|
|
|
"customerLocationRange": serviceRage,
|
|
|
|
"rangePricePerKm": chargersPerKm.isEmpty ? "0.0" : chargersPerKm,
|
|
|
|
"rangePricePerKm": chargersPerKm.isEmpty ? "0.0" : chargersPerKm,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -297,7 +348,7 @@ class _CreateServicesPage3State extends State<CreateServicesPage3> {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"id": widget.branchModel!.serviceProviderService!.serviceProviderServiceId.toString(),
|
|
|
|
"id": widget.branchModel!.serviceProviderService!.serviceProviderServiceId.toString(),
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
"isAllowAppointment": isAppointmentAvailable,
|
|
|
|
"isActive": true,
|
|
|
|
"isActive": isServiceActive,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|