mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 01:27:55 +00:00
finished get scene details
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class SceneDetailsModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String status;
|
||||
final String type;
|
||||
final List<Action> actions;
|
||||
|
||||
SceneDetailsModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.type,
|
||||
required this.actions,
|
||||
});
|
||||
|
||||
factory SceneDetailsModel.fromRawJson(String str) =>
|
||||
SceneDetailsModel.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory SceneDetailsModel.fromJson(Map<String, dynamic> json) =>
|
||||
SceneDetailsModel(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
status: json["status"],
|
||||
type: json["type"],
|
||||
actions:
|
||||
List<Action>.from(json["actions"].map((x) => Action.fromJson(x))),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"status": status,
|
||||
"type": type,
|
||||
"actions": List<dynamic>.from(actions.map((x) => x.toJson())),
|
||||
};
|
||||
}
|
||||
|
||||
class Action {
|
||||
final String actionExecutor;
|
||||
final String entityId;
|
||||
final ExecutorProperty executorProperty;
|
||||
|
||||
Action({
|
||||
required this.actionExecutor,
|
||||
required this.entityId,
|
||||
required this.executorProperty,
|
||||
});
|
||||
|
||||
factory Action.fromRawJson(String str) => Action.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory Action.fromJson(Map<String, dynamic> json) => Action(
|
||||
actionExecutor: json["actionExecutor"],
|
||||
entityId: json["entityId"],
|
||||
executorProperty: ExecutorProperty.fromJson(json["executorProperty"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"actionExecutor": actionExecutor,
|
||||
"entityId": entityId,
|
||||
"executorProperty": executorProperty.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class ExecutorProperty {
|
||||
final String functionCode;
|
||||
final dynamic functionValue;
|
||||
|
||||
ExecutorProperty({
|
||||
required this.functionCode,
|
||||
required this.functionValue,
|
||||
});
|
||||
|
||||
factory ExecutorProperty.fromRawJson(String str) =>
|
||||
ExecutorProperty.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory ExecutorProperty.fromJson(Map<String, dynamic> json) =>
|
||||
ExecutorProperty(
|
||||
functionCode: json["functionCode"],
|
||||
functionValue: json["functionValue"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"functionCode": functionCode,
|
||||
"functionValue": functionValue,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/// helper class for scene settings push route
|
||||
class SceneSettingsRouteArguments {
|
||||
final String sceneId;
|
||||
final String sceneName;
|
||||
final String sceneType;
|
||||
|
||||
SceneSettingsRouteArguments({
|
||||
required this.sceneId,
|
||||
required this.sceneName,
|
||||
required this.sceneType,
|
||||
});
|
||||
}
|
||||
@@ -11,6 +11,8 @@ class SceneStaticFunction {
|
||||
final String deviceId;
|
||||
final String operationName;
|
||||
final String uniqueCustomId;
|
||||
final dynamic functionValue;
|
||||
final String? deviceIcon;
|
||||
|
||||
SceneStaticFunction({
|
||||
required this.icon,
|
||||
@@ -19,6 +21,8 @@ class SceneStaticFunction {
|
||||
required this.operationalValues,
|
||||
required this.deviceId,
|
||||
required this.operationName,
|
||||
required this.functionValue,
|
||||
this.deviceIcon,
|
||||
}) : uniqueCustomId = const Uuid().v4();
|
||||
|
||||
SceneStaticFunction copyWith({
|
||||
@@ -28,6 +32,8 @@ class SceneStaticFunction {
|
||||
List<SceneOperationalValue>? operationalValues,
|
||||
String? deviceId,
|
||||
String? operationName,
|
||||
dynamic functionValue,
|
||||
String? deviceIcon,
|
||||
}) {
|
||||
return SceneStaticFunction(
|
||||
icon: icon ?? this.icon,
|
||||
@@ -36,6 +42,8 @@ class SceneStaticFunction {
|
||||
operationalValues: operationalValues ?? this.operationalValues,
|
||||
deviceId: deviceId ?? this.deviceId,
|
||||
operationName: operationName ?? this.operationName,
|
||||
functionValue: functionValue ?? this.functionValue,
|
||||
deviceIcon: deviceIcon ?? this.deviceIcon,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -46,7 +54,9 @@ class SceneStaticFunction {
|
||||
'code': code,
|
||||
'operationalValues': operationalValues.map((x) => x.toMap()).toList(),
|
||||
'deviceId': deviceId,
|
||||
'operationName': operationName
|
||||
'operationName': operationName,
|
||||
'functionValue': functionValue,
|
||||
'deviceIcon': deviceIcon
|
||||
};
|
||||
}
|
||||
|
||||
@@ -60,6 +70,8 @@ class SceneStaticFunction {
|
||||
),
|
||||
deviceId: map['deviceId'] ?? '',
|
||||
operationName: map['operationName'] ?? '',
|
||||
functionValue: map['functionValue'] ?? '',
|
||||
deviceIcon: map['deviceIcon'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -70,7 +82,7 @@ class SceneStaticFunction {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SceneStaticFunction(icon: $icon, name: $deviceName, code: $code, operationalValues: $operationalValues, deviceId: $deviceId, operationName: $operationName)';
|
||||
return 'SceneStaticFunction(icon: $icon, name: $deviceName, code: $code, operationalValues: $operationalValues, deviceId: $deviceId, operationName: $operationName, functionValue: $functionValue, deviceIcon: $deviceIcon)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -82,6 +94,8 @@ class SceneStaticFunction {
|
||||
other.deviceName == deviceName &&
|
||||
other.code == code &&
|
||||
other.operationName == operationName &&
|
||||
other.functionValue == functionValue &&
|
||||
other.deviceIcon == deviceIcon &&
|
||||
listEquals(other.operationalValues, operationalValues) &&
|
||||
other.deviceId == deviceId;
|
||||
}
|
||||
@@ -93,6 +107,8 @@ class SceneStaticFunction {
|
||||
code.hashCode ^
|
||||
deviceId.hashCode ^
|
||||
operationName.hashCode ^
|
||||
functionValue.hashCode ^
|
||||
deviceIcon.hashCode ^
|
||||
operationalValues.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,24 +1,24 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class SceneModel {
|
||||
class ScenesModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final Status status;
|
||||
final Type type;
|
||||
|
||||
SceneModel({
|
||||
ScenesModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
factory SceneModel.fromRawJson(String str) =>
|
||||
SceneModel.fromJson(json.decode(str));
|
||||
factory ScenesModel.fromRawJson(String str) =>
|
||||
ScenesModel.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory SceneModel.fromJson(Map<String, dynamic> json) => SceneModel(
|
||||
factory ScenesModel.fromJson(Map<String, dynamic> json) => ScenesModel(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
status: statusValues.map[json["status"]]!,
|
||||
Reference in New Issue
Block a user