mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-03-11 06:41:44 +00:00
subspace model added
This commit is contained in:
@ -1,13 +1,16 @@
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class SubSpaceModel {
|
||||
class RoomModel {
|
||||
final String? id;
|
||||
final String? name;
|
||||
final SpaceType type;
|
||||
List<DeviceModel>? devices;
|
||||
|
||||
SubSpaceModel({
|
||||
RoomModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.type,
|
||||
required this.devices,
|
||||
});
|
||||
|
||||
@ -15,20 +18,22 @@ class SubSpaceModel {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'type': type,
|
||||
'devices': devices,
|
||||
};
|
||||
}
|
||||
|
||||
factory SubSpaceModel.fromJson(Map<String, dynamic> json) {
|
||||
factory RoomModel.fromJson(Map<String, dynamic> json) {
|
||||
List<DeviceModel> devices = [];
|
||||
if (json['devices'] != null) {
|
||||
for (var device in json['devices']) {
|
||||
devices.add(DeviceModel.fromJson(device));
|
||||
}
|
||||
}
|
||||
return SubSpaceModel(
|
||||
return RoomModel(
|
||||
id: json['uuid'],
|
||||
name: json['name'],
|
||||
type: spaceTypesMap[json['type']]!,
|
||||
devices: [],
|
||||
);
|
||||
}
|
||||
|
||||
35
lib/features/devices/model/subspace_model.dart
Normal file
35
lib/features/devices/model/subspace_model.dart
Normal file
@ -0,0 +1,35 @@
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
|
||||
class SubSpaceModel {
|
||||
final String? id;
|
||||
final String? name;
|
||||
List<DeviceModel>? devices;
|
||||
|
||||
SubSpaceModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.devices,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'devices': devices,
|
||||
};
|
||||
}
|
||||
|
||||
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 SubSpaceModel(
|
||||
id: json['uuid'],
|
||||
name: json['name'],
|
||||
devices: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user