conversation.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import 'package:flutter/foundation.dart';
  2. enum ConversationItemType { userBubble, aiCard }
  3. enum AiVerdictStatus { ok, warn, neutral }
  4. @immutable
  5. final class ConversationItem {
  6. const ConversationItem({
  7. required this.id,
  8. required this.type,
  9. required this.timestamp,
  10. this.text,
  11. this.aiLabel,
  12. this.aiSubLabel,
  13. this.fields = const [],
  14. this.verdict,
  15. this.verdictStatus = AiVerdictStatus.neutral,
  16. this.actions = const [],
  17. });
  18. final String id;
  19. final ConversationItemType type;
  20. final DateTime timestamp;
  21. final String? text;
  22. final String? aiLabel;
  23. final String? aiSubLabel;
  24. final List<AiField> fields;
  25. final String? verdict;
  26. final AiVerdictStatus verdictStatus;
  27. final List<AiAction> actions;
  28. ConversationItem copyWith({
  29. String? id,
  30. ConversationItemType? type,
  31. DateTime? timestamp,
  32. String? text,
  33. String? aiLabel,
  34. String? aiSubLabel,
  35. List<AiField>? fields,
  36. String? verdict,
  37. AiVerdictStatus? verdictStatus,
  38. List<AiAction>? actions,
  39. }) {
  40. return ConversationItem(
  41. id: id ?? this.id,
  42. type: type ?? this.type,
  43. timestamp: timestamp ?? this.timestamp,
  44. text: text ?? this.text,
  45. aiLabel: aiLabel ?? this.aiLabel,
  46. aiSubLabel: aiSubLabel ?? this.aiSubLabel,
  47. fields: fields ?? this.fields,
  48. verdict: verdict ?? this.verdict,
  49. verdictStatus: verdictStatus ?? this.verdictStatus,
  50. actions: actions ?? this.actions,
  51. );
  52. }
  53. }
  54. @immutable
  55. final class AiField {
  56. const AiField({
  57. required this.key,
  58. required this.value,
  59. this.highlight = false,
  60. });
  61. final String key;
  62. final String value;
  63. final bool highlight;
  64. }
  65. @immutable
  66. final class AiAction {
  67. const AiAction({required this.label, this.isPrimary = false, this.onTap});
  68. final String label;
  69. final bool isPrimary;
  70. final VoidCallback? onTap;
  71. }