notification_widget.dart 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. Expanded(
  73. child: Column(
  74. crossAxisAlignment: CrossAxisAlignment.start,
  75. children: [
  76. Text(
  77. text,
  78. style: darkTextTheme.bodyBold,
  79. textAlign: TextAlign.left,
  80. ),
  81. subText != null
  82. ? Text(
  83. subText!,
  84. style: darkTextTheme.mini
  85. .copyWith(color: textMutedDark),
  86. )
  87. : const SizedBox.shrink(),
  88. ],
  89. ),
  90. ),
  91. const SizedBox(width: 12),
  92. IconButtonWidget(
  93. icon: actionIcon,
  94. iconButtonType: IconButtonType.rounded,
  95. iconColor: strokeBaseDark,
  96. defaultColor: fillFaintDark,
  97. pressedColor: fillMutedDark,
  98. onTap: onTap,
  99. )
  100. ],
  101. ),
  102. ),
  103. ),
  104. ),
  105. );
  106. }
  107. }