mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 06:07:56 +00:00
built 3 gang switch View
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||
|
||||
class ACModel extends DeviceModel {
|
||||
late double temperature;
|
||||
@@ -23,6 +24,7 @@ class ACModel extends DeviceModel {
|
||||
required super.status,
|
||||
required super.image,
|
||||
required super.timer,
|
||||
required super.functions,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -40,6 +42,12 @@ class ACModel extends DeviceModel {
|
||||
}
|
||||
|
||||
factory ACModel.fromJson(Map<String, dynamic> json) {
|
||||
List<FunctionModel> func = [];
|
||||
if (json['functions'] != null) {
|
||||
json['functions'].forEach((v) {
|
||||
func.add(FunctionModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
return ACModel(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
@@ -52,6 +60,7 @@ class ACModel extends DeviceModel {
|
||||
timer: json['timer'],
|
||||
coolTo: json['coolTo'],
|
||||
bounds: Bounds.fromJson(json['bounds']),
|
||||
functions: func,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||
|
||||
class CurtainModel extends DeviceModel {
|
||||
late int openPercentage;
|
||||
@@ -11,6 +12,7 @@ class CurtainModel extends DeviceModel {
|
||||
required super.status,
|
||||
required super.image,
|
||||
required super.timer,
|
||||
required super.functions,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -26,6 +28,12 @@ class CurtainModel extends DeviceModel {
|
||||
}
|
||||
|
||||
factory CurtainModel.fromJson(Map<String, dynamic> json) {
|
||||
List<FunctionModel> func = [];
|
||||
if (json['functions'] != null) {
|
||||
json['functions'].forEach((v) {
|
||||
func.add(FunctionModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
return CurtainModel(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
@@ -34,6 +42,7 @@ class CurtainModel extends DeviceModel {
|
||||
timer: json['timer'],
|
||||
type: json['type'],
|
||||
image: json['image'],
|
||||
functions: func,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
class DeviceControlModel {
|
||||
String? deviceId;
|
||||
String? code;
|
||||
bool? value;
|
||||
|
||||
DeviceControlModel({
|
||||
required this.deviceId,
|
||||
required this.code,
|
||||
required this.value,
|
||||
});
|
||||
|
||||
factory DeviceControlModel.fromJson(Map<String, dynamic> json) {
|
||||
return DeviceControlModel(
|
||||
deviceId: json['deviceId'],
|
||||
code: json['code'],
|
||||
value: json['value'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'deviceId': deviceId,
|
||||
'code': code,
|
||||
'value': value,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,19 @@
|
||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
abstract class DeviceModel {
|
||||
final String? id;
|
||||
class DeviceModel {
|
||||
final int? id;
|
||||
final String? name;
|
||||
final DeviceType? type;
|
||||
bool? status;
|
||||
final String? image;
|
||||
final double? timer;
|
||||
|
||||
late final String icon;
|
||||
bool isSelected = false;
|
||||
|
||||
late List<FunctionModel> functions;
|
||||
|
||||
DeviceModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
@@ -19,6 +21,7 @@ abstract class DeviceModel {
|
||||
required this.status,
|
||||
required this.image,
|
||||
required this.timer,
|
||||
required this.functions,
|
||||
}) {
|
||||
switch (type) {
|
||||
case DeviceType.AC:
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//{
|
||||
// "code": "switch_1",
|
||||
// "desc": "switch 1",
|
||||
// "name": "switch 1",
|
||||
// "type": "Boolean",
|
||||
// "values": "{}"
|
||||
// }
|
||||
class FunctionModel {
|
||||
String? code;
|
||||
String? desc;
|
||||
String? name;
|
||||
String? type;
|
||||
String? values;
|
||||
|
||||
FunctionModel({
|
||||
required this.code,
|
||||
required this.desc,
|
||||
required this.name,
|
||||
required this.type,
|
||||
required this.values,
|
||||
});
|
||||
|
||||
factory FunctionModel.fromJson(Map<String, dynamic> json) {
|
||||
return FunctionModel(
|
||||
code: json['code'],
|
||||
desc: json['desc'],
|
||||
name: json['name'],
|
||||
type: json['type'],
|
||||
values: json['values'],
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'code': code,
|
||||
'desc': desc,
|
||||
'name': name,
|
||||
'type': type,
|
||||
'values': values,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:syncrow_app/features/devices/model/device_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||
|
||||
class LightModel extends DeviceModel {
|
||||
late double brightness;
|
||||
@@ -19,6 +20,7 @@ class LightModel extends DeviceModel {
|
||||
required super.status,
|
||||
required super.image,
|
||||
required super.timer,
|
||||
required super.functions,
|
||||
});
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -37,6 +39,12 @@ class LightModel extends DeviceModel {
|
||||
}
|
||||
|
||||
factory LightModel.fromJson(Map<String, dynamic> json) {
|
||||
List<FunctionModel> func = [];
|
||||
if (json['functions'] != null) {
|
||||
json['functions'].forEach((v) {
|
||||
func.add(FunctionModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
return LightModel(
|
||||
id: json['id'],
|
||||
name: json['name'],
|
||||
@@ -48,6 +56,7 @@ class LightModel extends DeviceModel {
|
||||
type: json['type'],
|
||||
image: json['image'],
|
||||
recentColors: json['recentColors'],
|
||||
functions: func,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user