selection_action_button_widget.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import "package:flutter/material.dart";
  2. import "package:photos/theme/ente_theme.dart";
  3. class SelectionActionButton extends StatefulWidget {
  4. final String labelText;
  5. final IconData icon;
  6. final VoidCallback? onTap;
  7. const SelectionActionButton({
  8. required this.labelText,
  9. required this.icon,
  10. required this.onTap,
  11. super.key,
  12. });
  13. @override
  14. State<SelectionActionButton> createState() => _SelectionActionButtonState();
  15. }
  16. class _SelectionActionButtonState extends State<SelectionActionButton> {
  17. Color? backgroundColor;
  18. @override
  19. Widget build(BuildContext context) {
  20. final colorScheme = getEnteColorScheme(context);
  21. return GestureDetector(
  22. onTap: widget.onTap,
  23. onTapDown: (details) {
  24. setState(() {
  25. backgroundColor = colorScheme.fillFaintPressed;
  26. });
  27. },
  28. onTapUp: (details) {
  29. setState(() {
  30. backgroundColor = null;
  31. });
  32. },
  33. onTapCancel: () {
  34. setState(() {
  35. backgroundColor = null;
  36. });
  37. },
  38. child: Container(
  39. decoration: BoxDecoration(
  40. borderRadius: BorderRadius.circular(8),
  41. color: backgroundColor,
  42. ),
  43. child: Padding(
  44. padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
  45. child: SizedBox(
  46. width: 64,
  47. child: Column(
  48. mainAxisAlignment: MainAxisAlignment.center,
  49. mainAxisSize: MainAxisSize.min,
  50. children: [
  51. Icon(
  52. widget.icon,
  53. size: 24,
  54. color: getEnteColorScheme(context).textMuted,
  55. ),
  56. const SizedBox(height: 4),
  57. Text(
  58. widget.labelText,
  59. textAlign: TextAlign.center,
  60. style: getEnteTextTheme(context).miniMuted,
  61. ),
  62. ],
  63. ),
  64. ),
  65. ),
  66. ),
  67. );
  68. }
  69. }