notification_group.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import 'package:appflowy/workspace/presentation/notifications/notification_item.dart';
  2. import 'package:appflowy_backend/protobuf/flowy-user/reminder.pb.dart';
  3. import 'package:flowy_infra_ui/style_widget/text.dart';
  4. import 'package:flowy_infra_ui/widget/spacing.dart';
  5. import 'package:flutter/material.dart';
  6. class NotificationGroup extends StatelessWidget {
  7. const NotificationGroup({
  8. super.key,
  9. required this.reminders,
  10. required this.formattedDate,
  11. required this.isUpcoming,
  12. required this.onReadChanged,
  13. required this.onDelete,
  14. required this.onAction,
  15. });
  16. final List<ReminderPB> reminders;
  17. final String formattedDate;
  18. final bool isUpcoming;
  19. final Function(ReminderPB reminder, bool isRead)? onReadChanged;
  20. final Function(ReminderPB reminder)? onDelete;
  21. final Function(ReminderPB reminder)? onAction;
  22. @override
  23. Widget build(BuildContext context) {
  24. return Padding(
  25. padding: const EdgeInsets.only(bottom: 8),
  26. child: Column(
  27. crossAxisAlignment: CrossAxisAlignment.start,
  28. children: [
  29. Padding(
  30. padding: const EdgeInsets.only(left: 8),
  31. child: FlowyText(formattedDate),
  32. ),
  33. const VSpace(4),
  34. ...reminders
  35. .map(
  36. (reminder) => NotificationItem(
  37. reminderId: reminder.id,
  38. key: ValueKey(reminder.id),
  39. title: reminder.title,
  40. scheduled: reminder.scheduledAt,
  41. body: reminder.message,
  42. isRead: reminder.isRead,
  43. readOnly: isUpcoming,
  44. onReadChanged: (isRead) =>
  45. onReadChanged?.call(reminder, isRead),
  46. onDelete: () => onDelete?.call(reminder),
  47. onAction: () => onAction?.call(reminder),
  48. ),
  49. )
  50. .toList(),
  51. ],
  52. ),
  53. );
  54. }
  55. }