This commit is contained in:
hannathkadher
2024-10-29 18:41:59 +04:00
parent 0e6b83d9f5
commit 1558996891
9 changed files with 295 additions and 224 deletions

View File

@ -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: [],
);
}