diff --git a/lib/domain/models/floor.dart b/lib/domain/models/floor.dart new file mode 100644 index 0000000..655b3f0 --- /dev/null +++ b/lib/domain/models/floor.dart @@ -0,0 +1,51 @@ +class Floor { + const Floor({required this.id, required this.name}); + + final int id; + final String name; + + factory Floor.fromJson(Map json) => Floor( + id: json['id'] as int, + name: json['name'] as String, + ); +} + +class Room { + const Room({ + required this.id, + required this.name, + required this.floorId, + required this.x, + required this.y, + required this.width, + required this.height, + }); + + final int id; + final String name; + final int floorId; + final double x; // offset from floor origin, meters + final double y; + final double width; // meters + final double height; // meters + + factory Room.fromJson(Map json) => Room( + id: json['id'] as int, + name: json['name'] as String, + floorId: json['floor_id'] as int, + x: ((json['x'] as num?) ?? 0).toDouble(), + y: (json['y'] as num? ?? 0).toDouble(), + width: (json['width'] as num).toDouble(), + height: (json['height'] as num).toDouble(), + ); + + Map toJson() => { + 'id': id, + 'name': name, + 'floor_id': floorId, + 'x': x, + 'y': y, + 'width': width, + 'height': height, + }; +} diff --git a/lib/domain/models/tag.dart b/lib/domain/models/tag.dart index 6e436c4..c950d7f 100644 --- a/lib/domain/models/tag.dart +++ b/lib/domain/models/tag.dart @@ -47,8 +47,15 @@ class Tag { // Live position snapshot pushed from localiserd over Phoenix channel. class TagPosition { - const TagPosition({required this.tagId, required this.position}); + const TagPosition({ + required this.tagId, + required this.name, + required this.color, + this.roomId, + }); final String tagId; - final Position position; + final String name; + final String color; // hex color for chip rendering + final int? roomId; }