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_provider_app/config/provider_routes.dart';
|
|
import 'package:car_provider_app/views/appoinments/widget/appointment_detail_list_widget.dart';
|
|
import 'package:car_provider_app/views/appoinments/widget/sheets.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/classes/app_state.dart';
|
|
import 'package:mc_common_app/config/dependencies.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/appointments_models/appointment_list_model.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/view_models/appointments_view_model.dart';
|
|
import 'package:mc_common_app/widgets/bottom_sheet.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/extensions/extensions_widget.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../dashboard/widget/appointment_slider_widget.dart';
|
|
|
|
class UpdateAppointmentPage extends StatelessWidget {
|
|
late AppointmentListModel appointmentListModel;
|
|
|
|
UpdateAppointmentPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: const CustomAppBar(
|
|
title: "Update Appointment",
|
|
),
|
|
body: SizedBox(
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
child: Consumer(builder: (BuildContext context,
|
|
AppointmentsVM appointmentsVM, Widget? child) {
|
|
appointmentListModel = appointmentsVM
|
|
.myFilteredAppointments2[
|
|
appointmentsVM.selectedAppointmentIndex]
|
|
.customerAppointmentList![
|
|
appointmentsVM.selectedAppointmentSubIndex];
|
|
if (appointmentsVM.state == ViewState.busy) {
|
|
return const Center(child: CircularProgressIndicator());
|
|
} else {
|
|
return Column(
|
|
children: [
|
|
Expanded(
|
|
child: ListView(
|
|
padding: const EdgeInsets.all(21),
|
|
children: [
|
|
AppointmentSliderWidget(
|
|
appointmentListModel: appointmentListModel,
|
|
isNeedTotalPayment: true,
|
|
isNeedToShowItems: true,
|
|
isNeedToShowToMoreText: false,
|
|
onTap: () {},
|
|
),
|
|
21.height,
|
|
ShowFillButton(
|
|
title: "+ Add New Service",
|
|
txtColor: MyColors.darkPrimaryColor,
|
|
isFilled: false,
|
|
onPressed: () {
|
|
navigateWithName(
|
|
context,
|
|
ProviderAppRoutes.addServiceInAppointment,
|
|
arguments: appointmentListModel,
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.cancelled)
|
|
"Appointment is Canceled".toText(),
|
|
if (appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.booked)
|
|
Column(
|
|
children: [
|
|
showPayNowButton(context, appointmentsVM),
|
|
21.height,
|
|
showCancelButton(context, appointmentsVM),
|
|
],
|
|
).paddingAll(21),
|
|
|
|
if (appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.confirmed &&
|
|
appointmentListModel.appointmentPaymentStatusEnum ==
|
|
AppointmentPaymentStatusEnum.defaultStatus)
|
|
Column(
|
|
children: [
|
|
showArrivedutton(context, appointmentsVM),
|
|
],
|
|
).paddingAll(21),
|
|
|
|
if (appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.arrived &&
|
|
appointmentListModel.appointmentPaymentStatusEnum ==
|
|
AppointmentPaymentStatusEnum.defaultStatus)
|
|
Column(
|
|
children: [
|
|
showPayNowButton(context, appointmentsVM),
|
|
21.height,
|
|
showPayLaterButton(context, appointmentsVM),
|
|
],
|
|
).paddingAll(21),
|
|
|
|
if ((appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.arrived ||
|
|
appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.workStarted) &&
|
|
appointmentListModel.appointmentPaymentStatusEnum ==
|
|
AppointmentPaymentStatusEnum.payNow)
|
|
"Waiting for the payment from the customer".toText(),
|
|
|
|
if (appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.arrived &&
|
|
(appointmentListModel.appointmentPaymentStatusEnum ==
|
|
AppointmentPaymentStatusEnum.paid ||
|
|
appointmentListModel.appointmentPaymentStatusEnum ==
|
|
AppointmentPaymentStatusEnum.payLater))
|
|
Column(
|
|
children: [
|
|
showWorkStartButton(context, appointmentsVM),
|
|
],
|
|
).paddingAll(21),
|
|
|
|
if (appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.workStarted &&
|
|
appointmentListModel.appointmentPaymentStatusEnum ==
|
|
AppointmentPaymentStatusEnum.payPartial)
|
|
Column(
|
|
children: [
|
|
showPayLaterButton(context, appointmentsVM),
|
|
21.height,
|
|
showPayNowButton(context, appointmentsVM),
|
|
],
|
|
).paddingAll(21),
|
|
// "Show Pay Now".toText(),
|
|
|
|
if (appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.workStarted &&
|
|
appointmentListModel.appointmentPaymentStatusEnum ==
|
|
AppointmentPaymentStatusEnum.paid)
|
|
Column(
|
|
children: [
|
|
showCompleteButton(context, appointmentsVM),
|
|
],
|
|
).paddingAll(21),
|
|
// "Show Complete Button".toText(),
|
|
if (appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.workStarted &&
|
|
appointmentListModel.appointmentPaymentStatusEnum ==
|
|
AppointmentPaymentStatusEnum.payLater)
|
|
showPayNowButton(context, appointmentsVM),
|
|
|
|
if (appointmentListModel.appointmentStatusEnum ==
|
|
AppointmentStatusEnum.visitCompleted)
|
|
"Appointment is completed".toText().paddingAll(21),
|
|
|
|
// Padding(
|
|
// padding: const EdgeInsets.all(21.0),
|
|
// child: Column(
|
|
// children: [
|
|
// ShowFillButton(
|
|
// title: "Confirm Arrive",
|
|
// maxWidth: double.infinity,
|
|
// onPressed: () {
|
|
// showMyBottomSheet(
|
|
// context,
|
|
// child: ShowCollectPaymentSheet(
|
|
// onClickYes: () {},
|
|
// onClickNo: () {},
|
|
// ),
|
|
// );
|
|
// },
|
|
// ),
|
|
// 12.height,
|
|
// ShowFillButton(
|
|
// title: "Cancel Appointment",
|
|
// maxWidth: double.infinity,
|
|
// isFilled: false,
|
|
// txtColor: MyColors.redColor,
|
|
// borderColor: MyColors.redColor,
|
|
// onPressed: () {
|
|
// showMyBottomSheet(context,
|
|
// child: CancelAppointmentReasonSheet(
|
|
// onCancelClick: (String reason) {},
|
|
// ));
|
|
// },
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
],
|
|
);
|
|
}
|
|
})),
|
|
);
|
|
}
|
|
|
|
Widget showWorkStartButton(
|
|
BuildContext context, AppointmentsVM appointmentsVM) {
|
|
return ShowFillButton(
|
|
title: "Work Start",
|
|
maxWidth: double.infinity,
|
|
onPressed: () async {
|
|
Utils.showLoading(context);
|
|
await appointmentsVM.updateAppointmentStatus({
|
|
"appointmentID": appointmentListModel.id.toString(),
|
|
"appointmentStatusID": 7
|
|
});
|
|
Utils.hideLoading(context);
|
|
// showMyBottomSheet(
|
|
// context,
|
|
// child: ShowCollectPaymentSheet(
|
|
// onClickYes: () {},
|
|
// onClickNo: () {},
|
|
// ),
|
|
// );
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget showPayNowButton(BuildContext context, AppointmentsVM appointmentsVM) {
|
|
return ShowFillButton(
|
|
title: "Pay Now",
|
|
maxWidth: double.infinity,
|
|
onPressed: () async {
|
|
Utils.showLoading(context);
|
|
await appointmentsVM.updateAppointmentPaymentStatus({
|
|
"appointmentID": appointmentListModel.id.toString(),
|
|
"appointmentServicePaymentStatusID": 2
|
|
});
|
|
Utils.hideLoading(context);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget showArrivedutton(BuildContext context, AppointmentsVM appointmentsVM) {
|
|
return ShowFillButton(
|
|
title: "Arrived",
|
|
maxWidth: double.infinity,
|
|
onPressed: () async {
|
|
Utils.showLoading(context);
|
|
await appointmentsVM.updateAppointmentStatus({
|
|
"appointmentID": appointmentListModel.id.toString(),
|
|
"appointmentStatusID": 3
|
|
});
|
|
Utils.hideLoading(context);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget showPayLaterButton(
|
|
BuildContext context, AppointmentsVM appointmentsVM) {
|
|
return ShowFillButton(
|
|
title: "Pay Later",
|
|
maxWidth: double.infinity,
|
|
onPressed: () async {
|
|
Utils.showLoading(context);
|
|
await appointmentsVM.updateAppointmentPaymentStatus({
|
|
"appointmentID": appointmentListModel.id.toString(),
|
|
"appointmentServicePaymentStatusID": 4
|
|
});
|
|
Utils.hideLoading(context);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget showCompleteButton(
|
|
BuildContext context, AppointmentsVM appointmentsVM) {
|
|
return ShowFillButton(
|
|
title: "Complete",
|
|
maxWidth: double.infinity,
|
|
onPressed: () async {
|
|
Utils.showLoading(context);
|
|
await appointmentsVM.updateAppointmentStatus({
|
|
"appointmentID": appointmentListModel.id.toString(),
|
|
"appointmentStatusID": 8
|
|
});
|
|
Utils.hideLoading(context);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget showCancelButton(BuildContext context, AppointmentsVM appointmentsVM) {
|
|
return ShowFillButton(
|
|
title: "Cancel",
|
|
maxWidth: double.infinity,
|
|
isFilled: false,
|
|
txtColor: MyColors.redColor,
|
|
borderColor: MyColors.redColor,
|
|
onPressed: () {
|
|
showMyBottomSheet(
|
|
context,
|
|
child: ShowCollectPaymentSheet(
|
|
onClickYes: () {},
|
|
onClickNo: () {},
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Future<void> _updateAppointment(BuildContext context, int branchId) async {
|
|
await context.read<AppointmentsVM>().getProviderMyAppointments({
|
|
"ServiceProviderID": injector
|
|
.get<AppState>()
|
|
.getUser
|
|
.data
|
|
?.userInfo
|
|
?.providerId
|
|
.toString() ??
|
|
"0",
|
|
"ProviderBranchID": branchId.toString(),
|
|
}, isNeedToRebuild: true);
|
|
}
|
|
}
|