78 lines
2.1 KiB
Dart
78 lines
2.1 KiB
Dart
part of '../widgets.dart';
|
|
|
|
class CategoryCarousel extends StatelessWidget {
|
|
final List<Category> categories;
|
|
final void Function(Category) onSelect;
|
|
final void Function(Category) onUnselect;
|
|
|
|
const CategoryCarousel({
|
|
super.key,
|
|
required this.categories,
|
|
required this.onSelect,
|
|
required this.onUnselect,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final backgroundTheme = FlutterFlowTheme.of(context).primaryBackground;
|
|
|
|
bool isSelected = false;
|
|
Category? current = null;
|
|
|
|
return Container(
|
|
height: 120,
|
|
decoration: BoxDecoration(
|
|
color: backgroundTheme,
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
child: CarouselView(
|
|
itemExtent: 100,
|
|
onTap: (index) {
|
|
if (isSelected && current == categories[index]) {
|
|
onUnselect(categories[index]);
|
|
isSelected = false;
|
|
current = null;
|
|
} else {
|
|
onSelect(categories[index]);
|
|
isSelected = true;
|
|
current = categories[index];
|
|
}
|
|
},
|
|
children: categories.map((category) {
|
|
return GestureDetector(
|
|
onTap: () {},
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
padding: const EdgeInsets.all(8.0),
|
|
decoration: BoxDecoration(
|
|
color: category.color,
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: Icon(
|
|
Icons.folder,
|
|
color: Colors.white,
|
|
size: 40,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
category.title,
|
|
style: TextStyle(
|
|
color: category.color,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}).toList(),
|
|
),
|
|
);
|
|
}
|
|
}
|