Added Reservable Code and AdStatus
parent
bb4e3d3c3a
commit
521ff9ca38
@ -0,0 +1,199 @@
|
||||
import 'package:carousel_slider/carousel_slider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:mc_common_app/classes/consts.dart';
|
||||
import 'package:mc_common_app/config/routes.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/navigator.dart';
|
||||
import 'package:mc_common_app/widgets/extensions/extensions_widget.dart';
|
||||
|
||||
class CustomerAppointmentSliderWidget extends StatelessWidget {
|
||||
final List<AppointmentListModel> myUpComingAppointments;
|
||||
|
||||
const CustomerAppointmentSliderWidget({Key? key, required this.myUpComingAppointments}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (myUpComingAppointments.isEmpty) {
|
||||
return InkWell(
|
||||
child: Container(
|
||||
height: 86,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
height: 24,
|
||||
width: 24,
|
||||
decoration: BoxDecoration(shape: BoxShape.circle, color: MyColors.darkTextColor),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: MyColors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10),
|
||||
"Add New Appointment".toText(
|
||||
fontSize: 15,
|
||||
isBold: true,
|
||||
color: MyColors.lightTextColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
).toWhiteContainer(width: double.infinity, margin: EdgeInsets.symmetric(horizontal: 21, vertical: 10));
|
||||
}
|
||||
return CarouselSlider.builder(
|
||||
options: CarouselOptions(
|
||||
height: 140,
|
||||
viewportFraction: 1.0,
|
||||
enlargeCenterPage: false,
|
||||
enableInfiniteScroll: false,
|
||||
),
|
||||
itemCount: myUpComingAppointments.length,
|
||||
itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) => BuildAppointmentContainerForCustomer(
|
||||
isForHome: true,
|
||||
appointmentListModel: myUpComingAppointments[itemIndex],
|
||||
onTapped: () => navigateWithName(context, AppRoutes.appointmentDetailView, arguments: myUpComingAppointments[itemIndex]),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class BuildAppointmentContainerForCustomer extends StatelessWidget {
|
||||
final bool? isForHome;
|
||||
final AppointmentListModel? appointmentListModel;
|
||||
final Function() onTapped;
|
||||
|
||||
const BuildAppointmentContainerForCustomer({Key? key, this.isForHome = false, required this.onTapped, required this.appointmentListModel}) : super(key: key);
|
||||
|
||||
Widget showServices(String title, String icon, {bool isMoreText = false}) {
|
||||
return Row(
|
||||
children: [
|
||||
if (icon != "") ...[
|
||||
SvgPicture.asset(icon),
|
||||
8.width,
|
||||
],
|
||||
Flexible(
|
||||
child: title.toText(
|
||||
fontSize: 12,
|
||||
isBold: true,
|
||||
color: isMoreText ? MyColors.primaryColor : MyColors.black,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> buildServicesFromAppointment({required AppointmentListModel appointmentListModel}) {
|
||||
if (appointmentListModel.serviceAppointmentItems == null || appointmentListModel.serviceAppointmentItems!.isEmpty) {
|
||||
return [SizedBox()];
|
||||
}
|
||||
|
||||
if (appointmentListModel.serviceAppointmentItems!.length == 1) {
|
||||
return [
|
||||
showServices(
|
||||
appointmentListModel.serviceAppointmentItems![0].serviceItemName!,
|
||||
MyAssets.modificationsIcon,
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
List<Widget> servicesList = List.generate(
|
||||
2,
|
||||
(index) => showServices(
|
||||
appointmentListModel.serviceAppointmentItems![index].serviceItemName!,
|
||||
MyAssets.modificationsIcon,
|
||||
),
|
||||
);
|
||||
|
||||
if (appointmentListModel.serviceAppointmentItems!.length > 1) {
|
||||
servicesList.add(
|
||||
showServices(
|
||||
"+ ${appointmentListModel.serviceAppointmentItems!.length - 1} More",
|
||||
"",
|
||||
isMoreText: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
return servicesList;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 10, left: 21, right: 21),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
isForHome != null && isForHome!
|
||||
? Image.asset(
|
||||
MyAssets.bnCar,
|
||||
width: 56,
|
||||
height: 56,
|
||||
fit: BoxFit.fill,
|
||||
).toCircle(borderRadius: 100)
|
||||
: Image.asset(
|
||||
MyAssets.bnCar,
|
||||
width: 80,
|
||||
height: 85,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
8.width,
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
(appointmentListModel!.providerName ?? "").toText(color: MyColors.black, isBold: true, fontSize: 16),
|
||||
Row(
|
||||
children: [
|
||||
MyAssets.miniClock.buildSvg(height: 12),
|
||||
2.width,
|
||||
"${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime()}".toText(
|
||||
color: MyColors.lightTextColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
],
|
||||
),
|
||||
9.height,
|
||||
isForHome != null && isForHome!
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
"Appointment Details".toText(
|
||||
color: MyColors.primaryColor,
|
||||
isUnderLine: true,
|
||||
isBold: true,
|
||||
fontSize: 14,
|
||||
),
|
||||
const Icon(Icons.arrow_forward),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: buildServicesFromAppointment(appointmentListModel: appointmentListModel!),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.arrow_forward,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
).onPress(onTapped).toWhiteContainer(width: double.infinity, allPading: 12),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue