ente/lib/ui/components/buttons/chip_button_widget.dart

57 lines
1.7 KiB
Dart
Raw Normal View History

2023-03-10 08:36:50 +00:00
import "package:flutter/material.dart";
import "package:photos/theme/ente_theme.dart";
///https://www.figma.com/file/SYtMyLBs5SAOkTbfMMzhqt/ente-Visual-Design?node-id=8119%3A59513&t=gQa1to5jY89Qk1k7-4
2023-03-10 08:36:50 +00:00
class ChipButtonWidget extends StatelessWidget {
2023-03-10 12:33:43 +00:00
final String? label;
2023-03-10 08:36:50 +00:00
final IconData? leadingIcon;
2023-03-10 10:19:29 +00:00
final VoidCallback? onTap;
final bool noChips;
2023-03-10 08:36:50 +00:00
const ChipButtonWidget(
this.label, {
this.leadingIcon,
2023-03-10 10:19:29 +00:00
this.onTap,
this.noChips = false,
2023-03-10 08:36:50 +00:00
super.key,
});
@override
Widget build(BuildContext context) {
2023-03-10 10:19:29 +00:00
return GestureDetector(
onTap: onTap?.call,
2023-03-10 12:33:43 +00:00
child: Container(
width: noChips ? double.infinity : null,
2023-03-10 12:33:43 +00:00
decoration: BoxDecoration(
color: getEnteColorScheme(context).fillFaint,
borderRadius: const BorderRadius.all(Radius.circular(4)),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
leadingIcon != null
? Icon(
leadingIcon,
2023-06-13 14:43:52 +00:00
size: 16,
2023-03-10 12:33:43 +00:00
)
: const SizedBox.shrink(),
2023-03-20 05:35:25 +00:00
if (label != null && leadingIcon != null)
const SizedBox(width: 4),
if (label != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 4),
child: Text(
label!,
2023-06-13 14:43:52 +00:00
style: getEnteTextTheme(context).miniBold,
2023-03-20 05:35:25 +00:00
),
2023-08-19 11:39:56 +00:00
),
2023-03-10 12:33:43 +00:00
],
),
2023-03-10 10:19:29 +00:00
),
2023-03-10 08:36:50 +00:00
),
);
}
}