Implemented tab to run setting

This commit is contained in:
Abdullah Alassaf
2024-10-28 16:45:59 +03:00
parent 20fdfdde87
commit 3d56f33ec3
18 changed files with 734 additions and 718 deletions

View File

@ -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;
}