flutter-freaccess-hub/lib/shared/widgets/view/carousel_view.dart

60 lines
1.6 KiB
Dart

part of '../widgets.dart';
class CategoryCarousel<T> extends StatelessWidget {
final List<T?> categories;
final void Function(T) filter;
const CategoryCarousel({
super.key,
required this.categories,
required this.filter,
});
@override
Widget build(BuildContext context) {
final backgroundTheme = FlutterFlowTheme.of(context).primaryBackground;
return SizedBox(
height: 120,
child: CarouselView(
itemExtent: 100,
onTap: (index) => filter(categories[index] as T),
children: categories.map((category) {
category as Category?;
return ColoredBox(
color: backgroundTheme,
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(),
),
);
}
}