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.
322 lines
13 KiB
Dart
322 lines
13 KiB
Dart
import 'package:car_customer_app/view_models/appointments_view_model.dart';
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/classes/consts.dart';
|
|
import 'package:mc_common_app/extensions/int_extensions.dart';
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
import 'package:mc_common_app/generated/locale_keys.g.dart';
|
|
import 'package:mc_common_app/models/service_schedule_model.dart';
|
|
import 'package:mc_common_app/models/services/item_model.dart';
|
|
import 'package:mc_common_app/theme/colors.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 ReviewAppointment extends StatelessWidget {
|
|
const ReviewAppointment({Key? key}) : super(key: key);
|
|
|
|
Widget buildBranchInfoCard({required BuildContext context}) {
|
|
AppointmentsVM appointmentsVM = context.read<AppointmentsVM>();
|
|
return Padding(
|
|
padding: const EdgeInsets.only(
|
|
bottom: 10,
|
|
left: 21,
|
|
right: 21,
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Image.asset(
|
|
MyAssets.bnCar,
|
|
width: 80,
|
|
height: 60,
|
|
fit: BoxFit.cover,
|
|
),
|
|
12.width,
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
(appointmentsVM.selectedBranchModel!.branchName ?? "").toText(fontSize: 16, isBold: true),
|
|
Row(
|
|
children: [
|
|
LocaleKeys.location.tr().toText(color: MyColors.lightTextColor, fontSize: 12),
|
|
2.width,
|
|
": ${appointmentsVM.selectedBranchModel!.branchDescription ?? ""}".toText(fontSize: 12),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
children: [
|
|
"4.9".toText(
|
|
isUnderLine: true,
|
|
isBold: true,
|
|
fontSize: 12,
|
|
),
|
|
2.width,
|
|
MyAssets.starIcon.buildSvg(width: 12),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
).onPress(() {}).toWhiteContainer(width: double.infinity, allPading: 12));
|
|
}
|
|
|
|
Widget buildServicesInfoCard({required BuildContext context}) {
|
|
AppointmentsVM appointmentsVM = context.read<AppointmentsVM>();
|
|
return ListView.builder(
|
|
shrinkWrap: true,
|
|
itemCount: appointmentsVM.serviceAppointmentScheduleList.length,
|
|
itemBuilder: (BuildContext context, int scheduleIndex) {
|
|
ServiceAppointmentScheduleModel scheduleData = appointmentsVM.serviceAppointmentScheduleList[scheduleIndex];
|
|
return Column(
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: "Schedule: ${scheduleIndex + 1}".toText(fontSize: 20, isBold: true),
|
|
),
|
|
],
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
ListView.separated(
|
|
physics: NeverScrollableScrollPhysics(),
|
|
shrinkWrap: true,
|
|
itemCount: appointmentsVM.servicesInSchedule.length,
|
|
itemBuilder: (BuildContext context, int serviceIndex) {
|
|
DropValue selectedService = appointmentsVM.servicesInSchedule[serviceIndex];
|
|
String selectedTimeSlot = "";
|
|
if (scheduleData.selectedCustomTimeDateSlotModel!.availableSlots != null) {
|
|
selectedTimeSlot = scheduleData.selectedCustomTimeDateSlotModel!.availableSlots!.firstWhere((element) => element.isSelected).slot;
|
|
}
|
|
return Column(
|
|
children: [
|
|
// Row(
|
|
// children: [
|
|
// Expanded(
|
|
// child: selectedService.value.toText(fontSize: 14, isBold: true),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
if (true) ...[
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
"Service Location: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
(appointmentsVM.isHomeTapped ? "Home" : "Workshop").toText(fontSize: 12, isBold: true).expand(),
|
|
],
|
|
),
|
|
5.height,
|
|
Column(
|
|
children: List.generate(scheduleData.serviceItemList!.length, (itemIndex) {
|
|
ItemData itemData = scheduleData.serviceItemList![itemIndex];
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
"${itemData.name}: ${itemData.price} SAR".toText(fontSize: 13, color: MyColors.lightTextColor, isBold: true),
|
|
],
|
|
);
|
|
}),
|
|
),
|
|
],
|
|
5.height,
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
"Time & Location".toText(fontSize: 14, isBold: true),
|
|
3.height,
|
|
Row(children: [
|
|
"Date & Time: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
"${scheduleData.selectedCustomTimeDateSlotModel!.date!.date} at ${selectedTimeSlot}".toText(fontSize: 12, isBold: true),
|
|
]),
|
|
Row(children: [
|
|
"Location: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
"PM58+F97, Al Olaya, Riyadh 12333".toText(fontSize: 12, isBold: true),
|
|
]),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
);
|
|
},
|
|
separatorBuilder: (BuildContext context, int index) => Divider(thickness: 2),
|
|
).paddingOnly(bottom: 10),
|
|
],
|
|
),
|
|
],
|
|
).toWhiteContainer(width: double.infinity, allPading: 12, margin: const EdgeInsets.symmetric(horizontal: 21, vertical: 0));
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget buildTimeAndLocationInfoCard() {
|
|
return SizedBox(
|
|
width: double.infinity,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
"Time & Location".toText(fontSize: 16, isBold: true),
|
|
3.height,
|
|
Row(children: [
|
|
"Date & Time: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
"2nd Feb, 2023 at 09:30 AM".toText(fontSize: 12, isBold: true),
|
|
]),
|
|
Row(children: [
|
|
"Location: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
"PM58+F97, Al Olaya, Riyadh 12333".toText(fontSize: 12, isBold: true),
|
|
]),
|
|
],
|
|
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.only(left: 21, right: 21, top: 10)),
|
|
);
|
|
}
|
|
|
|
Widget buildChargesBreakDown({required BuildContext context}) {
|
|
AppointmentsVM appointmentsVM = context.read<AppointmentsVM>();
|
|
List<ItemData> allSelectedItems = [];
|
|
double totalServicePrice = 0.0;
|
|
appointmentsVM.serviceAppointmentScheduleList.forEach((schedule) {
|
|
schedule.serviceItemList!.forEach((item) {
|
|
allSelectedItems.add(item);
|
|
totalServicePrice = totalServicePrice + double.parse(item.price!);
|
|
});
|
|
});
|
|
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
"Services".toText(fontSize: 16, isBold: true),
|
|
Column(
|
|
children: List.generate(
|
|
allSelectedItems.length,
|
|
(index) => Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
"${allSelectedItems[index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
"${allSelectedItems[index].price} SAR".toText(fontSize: 12, isBold: true),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
"${totalServicePrice.toString()} SAR".toText(fontSize: 16, isBold: true),
|
|
],
|
|
),
|
|
10.height,
|
|
Divider(thickness: 0.7),
|
|
if (appointmentsVM.isHomeTapped) ...[
|
|
"Home Location".toText(fontSize: 16, isBold: true),
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
"10km ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true),
|
|
"5 x 10".toText(fontSize: 12, isBold: true),
|
|
],
|
|
),
|
|
8.height,
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
"50 SAR".toText(fontSize: 16, isBold: true),
|
|
],
|
|
),
|
|
10.height,
|
|
Divider(thickness: 0.7),
|
|
],
|
|
10.height,
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
"Total Amount ".toText(fontSize: 16, isBold: true),
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: [
|
|
totalServicePrice.toString().toText(fontSize: 29, isBold: true),
|
|
2.width,
|
|
"SAR".toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
10.height,
|
|
],
|
|
).toWhiteContainer(width: double.infinity, allPading: 12, margin: EdgeInsets.only(left: 21, right: 21, top: 10, bottom: 21));
|
|
}
|
|
|
|
Widget buildNextButtonFooter({required BuildContext context}) {
|
|
AppointmentsVM appointmentsVM = context.read<AppointmentsVM>();
|
|
return Container(
|
|
height: 90,
|
|
color: MyColors.white,
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Divider(thickness: 0.7, height: 3),
|
|
10.height,
|
|
SizedBox(
|
|
width: double.infinity,
|
|
child: ShowFillButton(
|
|
maxHeight: 55,
|
|
backgroundColor: MyColors.darkPrimaryColor,
|
|
title: "Book Appointment",
|
|
onPressed: () {
|
|
// appointmentsVM.onBookAppointmentPressed();
|
|
},
|
|
).paddingOnly(bottom: 12, left: 21, right: 21),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: CustomAppBar(
|
|
title: "Review Appointment",
|
|
isRemoveBackButton: false,
|
|
isDrawerEnabled: false,
|
|
actions: [MyAssets.searchIcon.buildSvg().paddingOnly(right: 21)],
|
|
onBackButtonTapped: () => Navigator.pop(context),
|
|
),
|
|
body: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
ListView(
|
|
children: [
|
|
buildBranchInfoCard(context: context),
|
|
buildServicesInfoCard(context: context),
|
|
// buildTimeAndLocationInfoCard(),
|
|
buildChargesBreakDown(context: context),
|
|
],
|
|
).expand(),
|
|
buildNextButtonFooter(context: context),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|