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.
48 lines
1.7 KiB
Dart
48 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mc_common_app/extensions/string_extensions.dart';
|
|
import 'package:mc_common_app/models/widgets_models.dart';
|
|
import 'package:mc_common_app/theme/colors.dart';
|
|
|
|
class BuildTimeSlots extends StatelessWidget {
|
|
final List<TimeSlotModel> 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: () {
|
|
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].isSelected ? MyColors.darkIconColor : null,
|
|
border: Border.all(
|
|
color: timeSlots[index].isSelected ? MyColors.darkIconColor : MyColors.primaryColor,
|
|
),
|
|
),
|
|
child: timeSlots[index].slot.toText(
|
|
fontSize: 12,
|
|
color: timeSlots[index].isSelected ? MyColors.white : null,
|
|
),
|
|
),
|
|
);
|
|
}),
|
|
);
|
|
}
|
|
}
|