mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
Implemented tab to run setting
This commit is contained in:
@ -4,12 +4,16 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
class CreateSceneModel {
|
||||
String unitUuid;
|
||||
String iconId;
|
||||
bool showInDevice;
|
||||
String sceneName;
|
||||
String decisionExpr;
|
||||
List<CreateSceneAction> actions;
|
||||
|
||||
CreateSceneModel({
|
||||
required this.unitUuid,
|
||||
required this.iconId,
|
||||
required this.showInDevice,
|
||||
required this.sceneName,
|
||||
required this.decisionExpr,
|
||||
required this.actions,
|
||||
@ -17,12 +21,16 @@ class CreateSceneModel {
|
||||
|
||||
CreateSceneModel copyWith({
|
||||
String? unitUuid,
|
||||
String? iconId,
|
||||
bool? showInDevice,
|
||||
String? sceneName,
|
||||
String? decisionExpr,
|
||||
List<CreateSceneAction>? actions,
|
||||
}) {
|
||||
return CreateSceneModel(
|
||||
unitUuid: unitUuid ?? this.unitUuid,
|
||||
iconId: iconId ?? this.iconId,
|
||||
showInDevice: showInDevice ?? this.showInDevice,
|
||||
sceneName: sceneName ?? this.sceneName,
|
||||
decisionExpr: decisionExpr ?? this.decisionExpr,
|
||||
actions: actions ?? this.actions,
|
||||
@ -32,6 +40,8 @@ class CreateSceneModel {
|
||||
Map<String, dynamic> toMap([String? sceneId]) {
|
||||
return {
|
||||
if (sceneId == null) 'unitUuid': unitUuid,
|
||||
if (iconId.isNotEmpty) 'iconUuid': iconId,
|
||||
'showInHomePage': showInDevice,
|
||||
'sceneName': sceneName,
|
||||
'decisionExpr': decisionExpr,
|
||||
'actions': actions.map((x) => x.toMap()).toList(),
|
||||
@ -41,17 +51,18 @@ class CreateSceneModel {
|
||||
factory CreateSceneModel.fromMap(Map<String, dynamic> map) {
|
||||
return CreateSceneModel(
|
||||
unitUuid: map['unitUuid'] ?? '',
|
||||
iconId: map['iconUuid'] ?? '',
|
||||
showInDevice: map['showInHomePage'] ?? false,
|
||||
sceneName: map['sceneName'] ?? '',
|
||||
decisionExpr: map['decisionExpr'] ?? '',
|
||||
actions: List<CreateSceneAction>.from(
|
||||
map['actions']?.map((x) => CreateSceneAction.fromMap(x))),
|
||||
actions:
|
||||
List<CreateSceneAction>.from(map['actions']?.map((x) => CreateSceneAction.fromMap(x))),
|
||||
);
|
||||
}
|
||||
|
||||
String toJson([String? sceneId]) => json.encode(toMap(sceneId));
|
||||
|
||||
factory CreateSceneModel.fromJson(String source) =>
|
||||
CreateSceneModel.fromMap(json.decode(source));
|
||||
factory CreateSceneModel.fromJson(String source) => CreateSceneModel.fromMap(json.decode(source));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -64,6 +75,8 @@ class CreateSceneModel {
|
||||
|
||||
return other is CreateSceneModel &&
|
||||
other.unitUuid == unitUuid &&
|
||||
other.iconId == iconId &&
|
||||
other.showInDevice == showInDevice &&
|
||||
other.sceneName == sceneName &&
|
||||
other.decisionExpr == decisionExpr &&
|
||||
listEquals(other.actions, actions);
|
||||
@ -71,10 +84,7 @@ class CreateSceneModel {
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return unitUuid.hashCode ^
|
||||
sceneName.hashCode ^
|
||||
decisionExpr.hashCode ^
|
||||
actions.hashCode;
|
||||
return unitUuid.hashCode ^ sceneName.hashCode ^ decisionExpr.hashCode ^ actions.hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,8 +130,7 @@ class CreateSceneAction {
|
||||
return CreateSceneAction(
|
||||
entityId: map['entityId'] ?? '',
|
||||
actionExecutor: map['actionExecutor'] ?? '',
|
||||
executorProperty:
|
||||
CreateSceneExecutorProperty.fromMap(map['executorProperty']),
|
||||
executorProperty: CreateSceneExecutorProperty.fromMap(map['executorProperty']),
|
||||
);
|
||||
}
|
||||
|
||||
@ -145,8 +154,7 @@ class CreateSceneAction {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
entityId.hashCode ^ actionExecutor.hashCode ^ executorProperty.hashCode;
|
||||
int get hashCode => entityId.hashCode ^ actionExecutor.hashCode ^ executorProperty.hashCode;
|
||||
}
|
||||
|
||||
class CreateSceneExecutorProperty {
|
||||
@ -210,6 +218,5 @@ class CreateSceneExecutorProperty {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
functionCode.hashCode ^ functionValue.hashCode ^ delaySeconds.hashCode;
|
||||
int get hashCode => functionCode.hashCode ^ functionValue.hashCode ^ delaySeconds.hashCode;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ class SceneDetailsModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String status;
|
||||
final String? icon;
|
||||
final bool? showInDevice;
|
||||
final String type;
|
||||
final List<Action> actions;
|
||||
final List<Condition>? conditions;
|
||||
@ -16,48 +18,44 @@ class SceneDetailsModel {
|
||||
required this.status,
|
||||
required this.type,
|
||||
required this.actions,
|
||||
this.icon,
|
||||
this.showInDevice,
|
||||
this.conditions,
|
||||
this.decisionExpr,
|
||||
this.effectiveTime,
|
||||
});
|
||||
|
||||
factory SceneDetailsModel.fromRawJson(String str) =>
|
||||
SceneDetailsModel.fromJson(json.decode(str));
|
||||
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: (json["actions"] as List)
|
||||
.map((x) => Action.fromJson(x))
|
||||
.where((x) => x != null)
|
||||
.toList()
|
||||
.cast<Action>(),
|
||||
conditions: json["conditions"] != null
|
||||
? (json["conditions"] as List)
|
||||
.map((x) => Condition.fromJson(x))
|
||||
.toList()
|
||||
: null,
|
||||
decisionExpr: json["decisionExpr"],
|
||||
effectiveTime: json["effectiveTime"] != null
|
||||
? EffectiveTime.fromJson(json["effectiveTime"])
|
||||
: null,
|
||||
);
|
||||
factory SceneDetailsModel.fromJson(Map<String, dynamic> json) => SceneDetailsModel(
|
||||
id: json["id"],
|
||||
name: json["name"],
|
||||
status: json["status"],
|
||||
type: json["type"],
|
||||
actions: (json["actions"] as List)
|
||||
.map((x) => Action.fromJson(x))
|
||||
.where((x) => x != null)
|
||||
.toList()
|
||||
.cast<Action>(),
|
||||
conditions: json["conditions"] != null
|
||||
? (json["conditions"] as List).map((x) => Condition.fromJson(x)).toList()
|
||||
: null,
|
||||
decisionExpr: json["decisionExpr"],
|
||||
effectiveTime:
|
||||
json["effectiveTime"] != null ? EffectiveTime.fromJson(json["effectiveTime"]) : null,
|
||||
icon: json["iconUuid"] != null ? json["iconUuid"] ?? '' : '',
|
||||
showInDevice: json['showInHome'] != null ? json['showInHome'] ?? false : false);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
"name": name,
|
||||
"status": status,
|
||||
"type": type,
|
||||
|
||||
"actions": List<dynamic>.from(actions.map((x) => x.toJson())),
|
||||
"conditions": conditions != null
|
||||
? List<dynamic>.from(conditions!.map((x) => x.toJson()))
|
||||
: null,
|
||||
"conditions":
|
||||
conditions != null ? List<dynamic>.from(conditions!.map((x) => x.toJson())) : null,
|
||||
"decisionExpr": decisionExpr,
|
||||
"effectiveTime": effectiveTime?.toJson(),
|
||||
};
|
||||
@ -90,7 +88,7 @@ class Action {
|
||||
);
|
||||
}
|
||||
if (json["executorProperty"] == null) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
return Action(
|
||||
@ -118,8 +116,7 @@ class ExecutorProperty {
|
||||
this.delaySeconds,
|
||||
});
|
||||
|
||||
factory ExecutorProperty.fromJson(Map<String, dynamic> json) =>
|
||||
ExecutorProperty(
|
||||
factory ExecutorProperty.fromJson(Map<String, dynamic> json) => ExecutorProperty(
|
||||
functionCode: json["functionCode"] ?? '',
|
||||
functionValue: json["functionValue"] ?? '',
|
||||
delaySeconds: json["delaySeconds"] ?? 0,
|
||||
@ -145,8 +142,7 @@ class Condition {
|
||||
required this.expr,
|
||||
});
|
||||
|
||||
factory Condition.fromRawJson(String str) =>
|
||||
Condition.fromJson(json.decode(str));
|
||||
factory Condition.fromRawJson(String str) => Condition.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
@ -204,8 +200,7 @@ class EffectiveTime {
|
||||
required this.loops,
|
||||
});
|
||||
|
||||
factory EffectiveTime.fromRawJson(String str) =>
|
||||
EffectiveTime.fromJson(json.decode(str));
|
||||
factory EffectiveTime.fromRawJson(String str) => EffectiveTime.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
|
@ -1,29 +1,31 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
class ScenesModel {
|
||||
final String id;
|
||||
final String name;
|
||||
final String status;
|
||||
final String type;
|
||||
final String icon;
|
||||
|
||||
ScenesModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.type,
|
||||
});
|
||||
ScenesModel(
|
||||
{required this.id,
|
||||
required this.name,
|
||||
required this.status,
|
||||
required this.type,
|
||||
required this.icon});
|
||||
|
||||
factory ScenesModel.fromRawJson(String str) =>
|
||||
ScenesModel.fromJson(json.decode(str));
|
||||
factory ScenesModel.fromRawJson(String str) => ScenesModel.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
Uint8List get iconInBytes => base64Decode(icon);
|
||||
|
||||
factory ScenesModel.fromJson(Map<String, dynamic> json) => ScenesModel(
|
||||
id: json["id"],
|
||||
name: json["name"] ?? '',
|
||||
status: json["status"] ?? '',
|
||||
type: json["type"] ?? '',
|
||||
);
|
||||
id: json["id"],
|
||||
name: json["name"] ?? '',
|
||||
status: json["status"] ?? '',
|
||||
type: json["type"] ?? '',
|
||||
icon: json["icon"] ?? '');
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"id": id,
|
||||
|
Reference in New Issue
Block a user