notification_widget.dart 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import 'package:flutter/material.dart';
  2. import 'package:photos/ente_theme_data.dart';
  3. import 'package:photos/theme/colors.dart';
  4. import 'package:photos/theme/text_style.dart';
  5. import 'package:photos/ui/components/icon_button_widget.dart';
  6. // CreateNotificationType enum
  7. enum NotificationType {
  8. warning,
  9. banner,
  10. }
  11. class NotificationWidget extends StatelessWidget {
  12. final IconData startIcon;
  13. final IconData actionIcon;
  14. final String text;
  15. final String? subText;
  16. final GestureTapCallback onTap;
  17. final NotificationType type;
  18. const NotificationWidget({
  19. Key? key,
  20. required this.startIcon,
  21. required this.actionIcon,
  22. required this.text,
  23. required this.onTap,
  24. this.subText,
  25. this.type = NotificationType.warning,
  26. }) : super(key: key);
  27. @override
  28. Widget build(BuildContext context) {
  29. Color backgroundColor = Colors.white;
  30. switch (type) {
  31. case NotificationType.warning:
  32. backgroundColor = warning500;
  33. break;
  34. case NotificationType.banner:
  35. backgroundColor = backgroundElevated2Dark;
  36. break;
  37. }
  38. return Center(
  39. child: GestureDetector(
  40. onTap: onTap,
  41. child: Container(
  42. decoration: BoxDecoration(
  43. borderRadius: const BorderRadius.all(
  44. Radius.circular(8),
  45. ),
  46. boxShadow: Theme.of(context).colorScheme.enteTheme.shadowMenu,
  47. color: backgroundColor,
  48. ),
  49. child: Padding(
  50. padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
  51. child: Row(
  52. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  53. children: [
  54. Icon(
  55. startIcon,
  56. size: 36,
  57. color: Colors.white,
  58. ),
  59. const SizedBox(width: 12),
  60. Column(
  61. crossAxisAlignment: CrossAxisAlignment.start,
  62. children: [
  63. Text(
  64. text,
  65. style: darkTextTheme.bodyBold,
  66. textAlign: TextAlign.left,
  67. ),
  68. subText != null
  69. ? Text(
  70. subText!,
  71. style: darkTextTheme.mini
  72. .copyWith(color: textMutedDark),
  73. )
  74. : const SizedBox.shrink(),
  75. ],
  76. ),
  77. const SizedBox(width: 12),
  78. IconButtonWidget(
  79. icon: actionIcon,
  80. iconButtonType: IconButtonType.rounded,
  81. iconColor: strokeBaseDark,
  82. defaultColor: fillFaintDark,
  83. pressedColor: fillMutedDark,
  84. onTap: onTap,
  85. )
  86. ],
  87. ),
  88. ),
  89. ),
  90. ),
  91. );
  92. }
  93. }