app/lib/components/categories.dart
2022-05-15 14:57:40 +07:00

70 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:nekoya_flutter/components/_category.dart';
import '../utils/utils.dart';
class Categories extends StatelessWidget {
const Categories({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
height: 84,
child: ListView.separated(
scrollDirection: Axis.horizontal,
itemCount: demoCategories.length,
itemBuilder: (context, index) => CategoryCard(
icon: demoCategories[index].icon,
title: demoCategories[index].title,
press: () {},
),
separatorBuilder: (context, index) =>
const SizedBox(width: defaultPadding),
),
);
}
}
class CategoryCard extends StatelessWidget {
const CategoryCard({
Key? key,
required this.icon,
required this.title,
required this.press,
}) : super(key: key);
final String icon, title;
final VoidCallback press;
@override
Widget build(BuildContext context) {
return OutlinedButton(
onPressed: press,
style: OutlinedButton.styleFrom(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(defaultBorderRadius)),
),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: defaultPadding / 2, horizontal: defaultPadding / 4),
child: Column(
children: [
SvgPicture.asset(icon),
const SizedBox(height: defaultPadding / 2),
Text(
title,
style: TextStyle(
color: Colors.white,
backgroundColor: const Color(0xff212226),
),
)
],
),
),
);
}
}