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_view.dart

212 lines
9.8 KiB
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/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:provider/provider.dart';
//
// class CreateServicesPage extends StatelessWidget {
// ServiceProviderBranch? serviceProviderBranch;
//
// CreateServicesPage(this.serviceProviderBranch, {Key? key}) : super(key: key);
//
// @override
// Widget build(BuildContext context) {
// ServiceVM branchVM = context.read<ServiceVM>();
// branchVM.getBranchAndServices();
// branchVM.fetchBranches();
// if (serviceProviderBranch != null) {
// // branchVM.branchId = serviceProviderBranch!.id ?? -1;
// // branchVM.branchValue = DropValue(branchVM.branchId, serviceProviderBranch!.branchName ?? "", "");
// // print("llll1 ${branchVM.branchId} ${serviceProviderBranch!.branchName} ${branchVM.branchValue!.value}");
// if (branchVM.branchId != 1) branchVM.fetchBranchCategory(EasyLocalization.of(context)?.currentLocale?.countryCode ?? "SA");
// }
//
// 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(12.0),
// child: Column(
// children: [
// model.branch != null
// ? (model.branchValue != null && model.branchId != -1)
// ? Text(
// model.branchValue!.value ?? "",
// 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,
// )
// : DropdownField(
// (DropValue value) {
// // countryCode = value.subValue;
// // countryId = value.id;
// // fetchCites();
// model.branchId = value.id;
// model.fetchBranchCategory(EasyLocalization.of(context)?.currentLocale?.countryCode ?? "SA");
// model.setState(ViewState.idle);
// },
// list: model.countryDropListForService,
// hint: LocaleKeys.selectBranch.tr(),
// dropdownValue: model.branchValue,
// )
// : const CircularProgressIndicator(),
// 12.height,
// (model.category != null)
// ? DropdownField((DropValue value) {
// // countryCode = value.subValue;
// // countryId = value.id;
// // fetchCites();
// model.categoryId = value.id;
// model.fetchServicesByCategoryId();
// model.setState(ViewState.idle);
// }, list: model.categoryDropList, hint: LocaleKeys.selectServiceCategory.tr())
// : model.branchId == -1
// ? Container()
// : const CircularProgressIndicator(),
// 12.height,
// if ((model.categoryId != -1))
// model.services == null
// ? const CircularProgressIndicator()
// : ListView.separated(
// itemBuilder: (context, index) {
// return Padding(
// padding: const EdgeInsets.all(8.0),
// child: Row(
// children: [
// Checkbox(
// value: model.services!.data![index].isSelected,
// onChanged: (v) {
// model.services!.data![index].isSelected = v;
// model.setState(ViewState.idle);
// },
// ),
// 12.width,
// ((EasyLocalization.of(context)?.currentLocale?.countryCode == "SA" ? model.services!.data![index].descriptionN : model.services!.data![index].description) ??
// "")
// .toText(fontSize: 12)
// ],
// ),
// );
// },
// separatorBuilder: (context, index) {
// return 1.height;
// },
// itemCount: model.services!.data!.length,
// physics: NeverScrollableScrollPhysics(),
// shrinkWrap: true,
// )
// ],
// ),
// ),
// ),
// ),
// if (checkServicesSelection(model))
// Padding(
// padding: const EdgeInsets.all(12.0),
// child: ShowFillButton(
// title: LocaleKeys.save.tr(),
// maxWidth: double.infinity,
// 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 = [];
// if (serviceProviderBranch != null && model.branchId != -1) {
// 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": true,
// "isActive": true
// };
// map.add(postParams);
// }
// }
// Utils.showLoading(context);
// MResponse mResponse = await model.createService(map);
// Utils.hideLoading(context);
//
// if (serviceProviderBranch != null) {
// Utils.showToast(mResponse.message ?? "");
// if (mResponse.messageStatus != 2) {
// pop(context);
// pop(context);
// model.getBranchAndServices();
// }
// }
// } else {
// 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": true,
// "isActive": true
// };
// map.add(postParams);
// }
// }
// Utils.showLoading(context);
// MResponse mResponse = await model.createService(map);
// model.getBranchAndServices();
// Utils.hideLoading(context);
// Utils.showToast(mResponse.message ?? "");
// }
// }
// }