import 'package:mc_common_app/view_models/ad_view_model.dart'; import 'package:flutter/material.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/advertisment_models/vehicle_details_models.dart'; import 'package:mc_common_app/theme/colors.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/time_slots.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 BottomSheetListContent extends StatefulWidget { final AdVM adVM; const BottomSheetListContent({Key? key, required this.adVM}) : super(key: key); @override State createState() => _BottomSheetListContentState(); } class _BottomSheetListContentState extends State { bool checkBoxValue = false; @override Widget build(BuildContext context) { return SizedBox( height: MediaQuery.of(context).size.height * 0.85, child: Column( children: [ Container( margin: const EdgeInsets.all(8), height: 8, width: 60, decoration: const BoxDecoration(color: MyColors.lightTextColor, borderRadius: BorderRadius.all(Radius.circular(20))), ), 12.height, Row( mainAxisAlignment: MainAxisAlignment.start, children: [ "Damage Part List".toText(fontSize: 24, isBold: true), ], ), 8.height, TxtField( value: "", errorValue: "", hint: "Search Part", onChanged: (value) {}, ), 8.height, Expanded( child: ListView.builder( shrinkWrap: true, itemCount: widget.adVM.vehicleDamageParts.length, itemBuilder: (BuildContext context, int index) { VehiclePartModel vehiclePart = widget.adVM.vehicleDamageParts[index]; return Column( children: [ // CheckboxListTile( // value: false, // visualDensity: VisualDensity.compact, // contentPadding: EdgeInsets.zero, // controlAffinity: ListTileControlAffinity.leading, // title: "Rear Break Light".toText( // fontSize: 16, // isBold: true, // ), // onChanged: (value) {}, // ), InkWell( onTap: () { if (vehiclePart.isSelected!) { return; } widget.adVM.vehicleDamageParts[index].isChecked = !(widget.adVM.vehicleDamageParts[index].isChecked!); setState(() {}); }, child: Row( children: [ SizedBox( height: 40.0, width: 30.0, child: Transform.scale( scale: 1.3, child: Checkbox( value: vehiclePart.isSelected! ? true : vehiclePart.isChecked, activeColor: vehiclePart.isSelected! ? MyColors.lightTextColor : MyColors.primaryColor, onChanged: (value) {}, ), ), ), const SizedBox(width: 20), vehiclePart.partName.toString().toText( fontSize: 16, isBold: true, color: vehiclePart.isSelected! ? MyColors.lightTextColor : MyColors.black, ) ], ), ), const Divider(thickness: 1), ], ); }, ), ), SizedBox( width: double.infinity, child: ShowFillButton( title: "Add Damage Part", onPressed: () { for (var value in widget.adVM.vehicleDamageParts) { if (value.isChecked! && !value.isSelected!) { widget.adVM.addNewDamagePartCard( damageCard: VehicleDamageCard( partImageErrorValue: "", partImages: null, partSelectedId: SelectionModel(selectedOption: value.partName!, selectedId: value.id!, errorValue: ""), ), ); value.isChecked = false; value.isSelected = true; } } Navigator.pop(context); }, ).paddingOnly(bottom: 10), ), ], ), ).horPaddingMain(); } } class BottomSheetServiceContent extends StatelessWidget { const BottomSheetServiceContent({Key? key}) : super(key: key); bool isButtonTappable(AdVM adVM) { bool status = (adVM.vehicleAdsSpecialServicesId.selectedId != -1) && (adVM.vehicleAdsSpecialServicesId.selectedOption != ""); if (status) { return true; } return false; } @override Widget build(BuildContext context) { return Consumer( builder: (BuildContext context, AdVM adVM, Widget? child) { return SizedBox( height: MediaQuery.of(context).size.height * 0.85, child: Column( children: [ Container( margin: const EdgeInsets.all(8), height: 8, width: 60, decoration: const BoxDecoration(color: MyColors.lightTextColor, borderRadius: BorderRadius.all(Radius.circular(20))), ), 12.height, Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ "Add Special Service".toText(fontSize: 24, isBold: true), 8.height, Builder(builder: (context) { List vehicleAdsSpecialServices = []; for (var element in adVM.vehicleAdsSpecialServices) { if (!element.isSelected!) { vehicleAdsSpecialServices.add(DropValue(element.id?.toInt() ?? 0, element.name ?? "", element.price == null ? "" : element.price!.toInt().toString())); } } return DropdownField( (DropValue value) => adVM.updateVehicleAdsSpecialServicesId(SelectionModel(selectedId: value.id, selectedOption: value.value, itemPrice: value.subValue)), list: vehicleAdsSpecialServices, hint: "Select Service", dropdownValue: adVM.vehicleAdsSpecialServicesId.selectedId != -1 ? DropValue(adVM.vehicleAdsSpecialServicesId.selectedId, adVM.vehicleAdsSpecialServicesId.selectedOption, "") : null, ); }), 8.height, TxtField( errorValue: adVM.adStartDateError, hint: 'Date', value: adVM.adSpecialServiceDate, isNeedClickAll: true, postfixData: Icons.calendar_month_rounded, postFixDataColor: MyColors.lightTextColor, onTap: () async { final formattedDate = await Utils.pickDateFromDatePicker(context); adVM.updateAdSpecialServiceDate(formattedDate); }, ), 22.height, "Available slots".toText(fontSize: 15, isBold: true), 8.height, const BuildTimeSlots(), 22.height, "Service Amount".toText(fontSize: 16, isBold: true, color: MyColors.lightTextColor), if (adVM.vehicleAdsSpecialServicesId.selectedId != -1) ...[ adVM.vehicleAdsSpecialServicesId.itemPrice.toText(fontSize: 20, isBold: true), "SAR".toText(fontSize: 10, isBold: true, color: MyColors.lightTextColor), ], // 5.height, // Divider(thickness: 1.2), // 5.height, // DottedRectContainer( // onTap: () => null, // text: "Add Service", // icon: MyAssets.attachmentIcon.buildSvg(), // ), ], ), ), SizedBox( width: double.infinity, child: ShowFillButton( backgroundColor: !isButtonTappable(adVM) ? MyColors.lightTextColor : MyColors.primaryColor, title: "Add Service", onPressed: () { if (!isButtonTappable(adVM)) { return; } Navigator.pop(context); adVM.addNewSpecialServiceCard( specialServiceCard: SpecialServiceCard( serviceDate: "", serviceDateError: "", serviceSelectedId: adVM.vehicleAdsSpecialServicesId, serviceTimeError: "", serviceTime: "", ), ); // for (var value in widget.adVM.vehicleDamageParts) { // if (value.isChecked! && !value.isSelected!) { // widget.adVM.addNewDamagePartCard( // damageCard: VehicleDamageCard( // partImageErrorValue: "", // partImages: null, // partSelectedId: SelectionModel(selectedOption: value.partName!, selectedId: value.id!, errorValue: ""), // ), // ); // value.isChecked = false; // value.isSelected = true; // } // } }, ).paddingOnly(bottom: 10), ), ], ).horPaddingMain(), ); }, ); } }