import 'package:flutter/material.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/models/appointments_models/service_schedule_model.dart'; import 'package:mc_common_app/models/general_models/widgets_models.dart'; import 'package:mc_common_app/theme/colors.dart'; class BuildTimeSlots extends StatelessWidget { final List timeSlots; final Function(int) onPressed; const BuildTimeSlots({Key? key, required this.timeSlots, required this.onPressed}) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( height: 37, width: double.infinity, child: ListView.builder( physics: const BouncingScrollPhysics(), itemCount: timeSlots.length, scrollDirection: Axis.horizontal, shrinkWrap: true, itemBuilder: (BuildContext context, int index) { return InkWell( onTap: () { if (!timeSlots[index].allowAppointment) { return; } onPressed(index); }, child: Container( alignment: Alignment.center, margin: const EdgeInsets.only(right: 8), // width: 50, padding: const EdgeInsets.symmetric(horizontal: 9), decoration: BoxDecoration( color: timeSlots[index].allowAppointment ? (timeSlots[index].isSelected ? MyColors.darkIconColor : null) : null, border: Border.all( color: timeSlots[index].allowAppointment ? (timeSlots[index].isSelected ? MyColors.darkIconColor : MyColors.primaryColor) : Colors.grey, ), ), child: timeSlots[index].slot.toText( fontSize: 12, color: timeSlots[index].isSelected ? MyColors.white : null, ), ), ); }), ); } } class BuildDateSlotsForAppointment extends StatelessWidget { final List customDateSlots; final Function(int) onPressed; const BuildDateSlotsForAppointment({Key? key, required this.customDateSlots, required this.onPressed}) : super(key: key); @override Widget build(BuildContext context) { return SizedBox( height: 37, width: double.infinity, child: ListView.builder( physics: const BouncingScrollPhysics(), itemCount: customDateSlots.length, scrollDirection: Axis.horizontal, shrinkWrap: true, itemBuilder: (BuildContext context, int index) { return InkWell( onTap: () { onPressed(index); }, child: Container( alignment: Alignment.center, margin: const EdgeInsets.only(right: 8), // width: 50, padding: const EdgeInsets.symmetric(horizontal: 9), decoration: BoxDecoration( color: customDateSlots[index].date!.isSelected ? MyColors.darkIconColor : null, border: Border.all( color: customDateSlots[index].date!.isSelected ? MyColors.darkIconColor : MyColors.primaryColor, ), ), child: customDateSlots[index].date!.date.toText( fontSize: 12, color: customDateSlots[index].date!.isSelected ? MyColors.white : null, ), ), ); }), ); } }