chip_button_widget.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import "package:flutter/material.dart";
  2. import "package:photos/theme/ente_theme.dart";
  3. ///https://www.figma.com/file/SYtMyLBs5SAOkTbfMMzhqt/ente-Visual-Design?node-id=8119%3A59513&t=gQa1to5jY89Qk1k7-4
  4. class ChipButtonWidget extends StatelessWidget {
  5. final String? label;
  6. final IconData? leadingIcon;
  7. final VoidCallback? onTap;
  8. final bool noChips;
  9. const ChipButtonWidget(
  10. this.label, {
  11. this.leadingIcon,
  12. this.onTap,
  13. this.noChips = false,
  14. super.key,
  15. });
  16. @override
  17. Widget build(BuildContext context) {
  18. return GestureDetector(
  19. onTap: onTap?.call,
  20. child: Container(
  21. width: noChips ? double.infinity : null,
  22. decoration: BoxDecoration(
  23. color: getEnteColorScheme(context).fillFaint,
  24. borderRadius: const BorderRadius.all(Radius.circular(4)),
  25. ),
  26. child: Padding(
  27. padding: const EdgeInsets.all(8.0),
  28. child: Row(
  29. mainAxisSize: MainAxisSize.min,
  30. mainAxisAlignment: MainAxisAlignment.center,
  31. children: [
  32. leadingIcon != null
  33. ? Icon(
  34. leadingIcon,
  35. size: 16,
  36. )
  37. : const SizedBox.shrink(),
  38. if (label != null && leadingIcon != null)
  39. const SizedBox(width: 4),
  40. if (label != null)
  41. Padding(
  42. padding: const EdgeInsets.symmetric(horizontal: 4),
  43. child: Text(
  44. label!,
  45. style: getEnteTextTheme(context).miniBold,
  46. ),
  47. )
  48. ],
  49. ),
  50. ),
  51. ),
  52. );
  53. }
  54. }