taafee-mobile/lib/features/card/presentation_layer/widgets/appointment_details.dart
MhdZiadHirati 441516a472 ui fixes
2023-10-25 12:41:12 +03:00

182 lines
6.9 KiB
Dart

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:taafee_mobile/common/widgets/button.dart';
import 'package:taafee_mobile/common/widgets/toast.dart';
import 'package:taafee_mobile/core/routing/routing_manager.dart';
import 'package:taafee_mobile/features/card/data_layer/model/appointment.dart';
import '../../../../common/const/const.dart';
import '../../../../common/widgets/text.dart';
import '../../../home/business_logic_layer/home_controller.dart';
class AppointmentDetails extends StatelessWidget {
AppointmentDetails({
super.key,
required this.appointment,
});
final Appointment appointment;
final HomeController homeController = Get.find<HomeController>();
@override
Widget build(BuildContext context) {
return SizedBox(
width: 320,
height: 280,
child: Column(
children: [
const SizedBox(
height: 16,
),
RegularTextWidget(
'you_have_an_appointment_on'.tr,
fontSize: 15,
),
const SizedBox(
height: 20,
),
Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: AppColors.secondaryColor.withOpacity(0.7),
),
child: Column(
children: [
BoldTextWidget(
DateFormat.EEEE().format(appointment.dateTime).tr,
fontSize: 15,
color: Colors.white,
),
const SizedBox(
height: 16,
),
Row(
children: [
const Icon(
Icons.calendar_month,
color: Colors.white,
),
RegularTextWidget(
' ${appointment.dateTime.day} / ${appointment.dateTime.month}',
fontSize: 15,
color: Colors.white,
),
],
),
const SizedBox(
height: 8,
),
Row(
children: [
const Icon(
Icons.schedule,
color: Colors.white,
),
if (!homeController.isArabic.value)
RegularTextWidget(
' ${appointment.dateTime.hour % 12} : ${appointment.dateTime.minute >= 10 ? appointment.dateTime.minute : '0${appointment.dateTime.minute}'} ${(appointment.dateTime.hour <= 12) ? 'am'.tr : 'pm'.tr}',
color: Colors.white,
fontSize: 15,
),
if (homeController.isArabic.value)
RegularTextWidget(
' ${appointment.dateTime.minute >= 10 ? appointment.dateTime.minute : '0${appointment.dateTime.minute}'} : ${appointment.dateTime.hour % 12} ${(appointment.dateTime.hour <= 12) ? 'am'.tr : 'pm'.tr}',
color: Colors.white,
fontSize: 15,
),
],
),
const SizedBox(
height: 8,
),
],
),
).paddingSymmetric(horizontal: 16),
const SizedBox(
height: 16,
),
Obx(() {
return ButtonWidget(
isLoading: homeController.appointmentCancelingState.loading,
width: 125,
onTap: () async {
bool cancel = false;
await showDialog(
context: context,
builder: (context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20)),
contentPadding: EdgeInsets.zero,
actionsPadding: EdgeInsets.zero,
title: BoldTextWidget(
'appointment_canceling'.tr,
fontSize: 18,
textAlign: TextAlign.center,
),
content: SizedBox(
height: 280,
width: 320,
child: Column(
children: [
const SizedBox(
height: 72,
),
RegularTextWidget(
'are_you_sure_?'.tr,
fontSize: 16,
textAlign: TextAlign.center,
),
const SizedBox(
height: 64,
),
SizedBox(
width: 300,
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
ButtonWidget(
width: 100,
onTap: () {
cancel = true;
RoutingManager.back();
},
color: AppColors.redColor,
title: 'yes'.tr),
ButtonWidget(
width: 100,
color: AppColors.secondaryColor
.withOpacity(0.7),
onTap: () {
cancel = false;
RoutingManager.back();
},
title: 'no'.tr),
],
),
)
],
),
),
);
});
if (cancel) {
homeController.cancelAppointment(onSuccess: () {
Toast.showToast('appointment_canceled_successfully'.tr);
RoutingManager.back();
});
}
},
hideTextOnLoading: true,
title: 'cancel_appointment'.tr,
color: AppColors.redColor,
);
}),
],
),
);
}
}