notification_widget.dart 3.3 KB

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