You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
car_provider_app/lib/views/settings/services/create_services_page2.dart

235 lines
11 KiB
Dart

// import 'package:car_provider_app/common/widget/checkbox_with_title_desc.dart';
// import 'package:mc_common_app/view_models/service_view_model.dart';
// import 'package:easy_localization/easy_localization.dart';
//
// import 'package:flutter/material.dart';
//
// import 'package:car_provider_app/generated/locale_keys.g.dart';
//
// import 'package:car_provider_app/view_models/branch_view_model.dart';
// import 'package:mc_common_app/classes/app_state.dart';
// import 'package:mc_common_app/extensions/int_extensions.dart';
// import 'package:mc_common_app/extensions/string_extensions.dart';
// import 'package:mc_common_app/models/m_response.dart';
// import 'package:mc_common_app/models/model/branch2.dart';
// 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/widgets/button/show_fill_button.dart';
// import 'package:mc_common_app/widgets/common_widgets/app_bar.dart';
// import 'package:mc_common_app/widgets/dropdown/dropdow_field.dart';
// import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
// import 'package:mc_common_app/widgets/txt_field.dart';
//
// import 'package:provider/provider.dart';
//
// class CreateServicesPage2 extends StatelessWidget {
// ServiceProviderBranch? serviceProviderBranch;
//
// CreateServicesPage2(this.serviceProviderBranch, {Key? key}) : super(key: key);
// bool isAppointmentAvailable = false;
// bool isHomeAppointmentAvailable = false;
// int serviceRage = 0;
// int chargersPerKm = 0;
//
// @override
// Widget build(BuildContext context) {
// ServiceVM branchVM = context.read<ServiceVM>();
//
// // if (serviceProviderBranch != null) {
// // branchVM.categoryDropList.clear();
// // branchVM.serviceId = -1;
// // branchVM.fetchBranchCategory(EasyLocalization.of(context)?.currentLocale?.countryCode ?? "SA");
// // }
// // print(AppState().getUser.data!.accessToken);
//
// return Scaffold(
// appBar: CustomAppBar(title: LocaleKeys.defineServices.tr()),
// body: SizedBox(
// width: double.infinity,
// height: double.infinity,
// child: Consumer<ServiceVM>(
// builder: (context, model, _) {
// return Column(
// children: [
// Expanded(
// child: SingleChildScrollView(
// child: Padding(
// padding: const EdgeInsets.all(20.0),
// child: Column(
// children: [
// Text(
// serviceProviderBranch!.branchName ?? "N/A",
// style: const TextStyle(
// fontSize: 12,
// fontWeight: FontWeight.bold,
// ),
// ).toContainer(
// padding: const EdgeInsets.only(left: 8, right: 8, bottom: 12, top: 12),
// backgroundColor: MyColors.textFieldColor,
// borderRadius: 0,
// width: double.infinity,
// ),
// 12.height,
// (model.category != null)
// ? DropdownField(
// (DropValue value) {
// model.categoryId = value.id;
// model.services = null;
// model.serviceId = -1;
// isAppointmentAvailable = false;
// isHomeAppointmentAvailable = false;
// model.fetchServicesByCategoryId();
//
// // model.setState(ViewState.idle);
// },
// list: model.categoryDropList,
// hint: LocaleKeys.selectServiceCategory.tr(),
// )
// : const CircularProgressIndicator(),
// 12.height,
// (model.services != null)
// ? DropdownField(
// (DropValue value) {
// model.serviceId = value.id;
// isAppointmentAvailable = false;
// isHomeAppointmentAvailable = false;
// model.setState(ViewState.idle);
// },
// list: model.servicesDropList,
// hint: LocaleKeys.defineServices.tr(),
// )
// : model.categoryId == -1
// ? Container()
// : const CircularProgressIndicator(),
// 20.height,
// if (model.serviceId != -1)
// Column(
// children: [
// CheckBoxWithTitleDescription(
// isSelected: isAppointmentAvailable,
// title: 'Available for appointment',
// description: 'This option will allow customer to book appointment for these services',
// onSelection: (bool v) {
// isAppointmentAvailable = v;
// model.setState(ViewState.idle);
// },
// ),
// 20.height,
// CheckBoxWithTitleDescription(
// isSelected: isHomeAppointmentAvailable,
// title: 'Allow home services',
// description: 'This option will allow customer to book appointment at their desired location',
// onSelection: (bool v) {
// isHomeAppointmentAvailable = v;
// model.setState(ViewState.idle);
// },
// ),
// 20.height,
// if (isHomeAppointmentAvailable)
// Column(
// children: [
// TxtField(
// hint: "Home Services Range",
// keyboardType: TextInputType.number,
// postfixWidget: Row(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// "KM".toText(color: MyColors.lightTextColor),
// ],
// ),
// onChanged: (v) {
// if (v.isNotEmpty) {
// serviceRage = int.parse(v);
// } else {
// serviceRage = 0;
// }
// },
// ),
// 12.height,
// TxtField(
// hint: "Charges per Kilometer",
// keyboardType: TextInputType.number,
// onChanged: (v) {
// if (v.isNotEmpty) {
// chargersPerKm = int.parse(v);
// } else {
// chargersPerKm = 0;
// }
// },
// ),
// ],
// ),
// ],
// ),
// ],
// ),
// ),
// ),
// ),
// if (model.serviceId != -1)
// ShowFillButton(
// title: LocaleKeys.save.tr(),
// maxWidth: double.infinity,
// margin: const EdgeInsets.all(20),
// onPressed: () {
// createService(context, model);
// },
// ),
// ],
// );
// },
// ),
// ),
// );
// }
//
// bool checkServicesSelection(BranchVM model) {
// bool isServiceSelected = false;
// try {
// for (var element in model.services!.data!) {
// if (element.isSelected ?? false) isServiceSelected = true;
// }
// } catch (e) {
// isServiceSelected = false;
// }
//
// return isServiceSelected;
// }
//
// createService(BuildContext context, BranchVM model) async {
// List<Map<String, dynamic>> map = [];
// model.services!.data?.forEach((element) {
// if (model.serviceId == element.id) {
// element.isSelected = true;
// } else {
// element.isSelected = false;
// }
// });
//
// for (int i = 0; i < model.services!.data!.length; i++) {
// if (model.services!.data![i].isSelected ?? false) {
// var postParams = {
// // "id": services!.data![i].id,
// "providerBranchID": model.branchId,
// "serviceID": model.services!.data![i].id,
// "isAllowAppointment": isAppointmentAvailable,
// "isActive": true,
// "customerLocationRange": serviceRage,
// "rangePricePerKm": chargersPerKm
// };
// map.add(postParams);
// }
// }
// // print(map);
// Utils.showLoading(context);
// MResponse mResponse = await model.createService(map);
// model.getBranchAndServices();
// Utils.hideLoading(context);
// Utils.showToast(mResponse.message ?? "");
// }
// }