feat: add Floor/Room models aligned with API
This commit is contained in:
@@ -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,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -47,8 +47,15 @@ class Tag {
|
|||||||
|
|
||||||
// Live position snapshot pushed from localiserd over Phoenix channel.
|
// Live position snapshot pushed from localiserd over Phoenix channel.
|
||||||
class TagPosition {
|
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 String tagId;
|
||||||
final Position position;
|
final String name;
|
||||||
|
final String color; // hex color for chip rendering
|
||||||
|
final int? roomId;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user