import 'package:hive/hive.dart'; part 'room.g.dart'; /// Modèle simple de conversation/room @HiveType(typeId: 50) class Room extends HiveObject { @HiveField(0) final String id; @HiveField(1) final String title; @HiveField(2) final String type; // 'private' ou 'group' @HiveField(3) final DateTime createdAt; @HiveField(4) final String? lastMessage; @HiveField(5) final DateTime? lastMessageAt; @HiveField(6) final int unreadCount; Room({ required this.id, required this.title, required this.type, required this.createdAt, this.lastMessage, this.lastMessageAt, this.unreadCount = 0, }); // Simple factory depuis JSON factory Room.fromJson(Map json) { return Room( id: json['id'], title: json['title'] ?? 'Sans titre', type: json['type'] ?? 'private', createdAt: DateTime.parse(json['date_creation']), lastMessage: json['last_message'], lastMessageAt: json['last_message_at'] != null ? DateTime.parse(json['last_message_at']) : null, unreadCount: json['unread_count'] ?? 0, ); } // Simple conversion en JSON Map toJson() => { 'id': id, 'title': title, 'type': type, 'date_creation': createdAt.toIso8601String(), }; }