mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 11:54:55 +00:00
models
This commit is contained in:
@ -1,16 +1,13 @@
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class RoomModel {
|
||||
class SubSpaceModel {
|
||||
final String? id;
|
||||
final String? name;
|
||||
final SpaceType type;
|
||||
List<DeviceModel>? devices;
|
||||
|
||||
RoomModel({
|
||||
SubSpaceModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.type,
|
||||
required this.devices,
|
||||
});
|
||||
|
||||
@ -18,22 +15,20 @@ class RoomModel {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'type': type,
|
||||
'devices': devices,
|
||||
};
|
||||
}
|
||||
|
||||
factory RoomModel.fromJson(Map<String, dynamic> json) {
|
||||
factory SubSpaceModel.fromJson(Map<String, dynamic> json) {
|
||||
List<DeviceModel> devices = [];
|
||||
if (json['devices'] != null) {
|
||||
for (var device in json['devices']) {
|
||||
devices.add(DeviceModel.fromJson(device));
|
||||
}
|
||||
}
|
||||
return RoomModel(
|
||||
return SubSpaceModel(
|
||||
id: json['uuid'],
|
||||
name: json['name'],
|
||||
type: spaceTypesMap[json['type']]!,
|
||||
devices: [],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user