feat: add Floor/Room models aligned with API

This commit is contained in:
2026-05-12 16:35:28 +02:00
parent 9f21beb39b
commit aedd8ad00c
2 changed files with 60 additions and 2 deletions
+51
View File
@@ -0,0 +1,51 @@
class Floor {
const Floor({required this.id, required this.name});
final int id;
final String name;
factory Floor.fromJson(Map<String, dynamic> 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<String, dynamic> 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<String, dynamic> toJson() => {
'id': id,
'name': name,
'floor_id': floorId,
'x': x,
'y': y,
'width': width,
'height': height,
};
}
+9 -2
View File
@@ -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;
}