mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
finished get scene details
This commit is contained in:
@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||
import 'package:syncrow_app/features/scene/helper/scene_operations_data_helper.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
@ -10,13 +11,15 @@ import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
part 'create_scene_event.dart';
|
||||
part 'create_scene_state.dart';
|
||||
|
||||
class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState> {
|
||||
class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||
with SceneOperationsDataHelper {
|
||||
CreateSceneBloc() : super(CreateSceneInitial()) {
|
||||
on<CreateSceneWithTasksEvent>(_createSceneWithTasks);
|
||||
on<AddTaskEvent>(_onAddSceneTask);
|
||||
on<SelectedValueEvent>(_selectedValue);
|
||||
on<RemoveTaskEvent>(_removeTaskById);
|
||||
on<ClearTaskListEvent>(_clearTaskList);
|
||||
on<FetchSceneTasks>(_fetchSceneTasks);
|
||||
}
|
||||
|
||||
List<SceneStaticFunction> tasksList = [];
|
||||
@ -31,6 +34,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState> {
|
||||
icon: event.icon,
|
||||
code: event.deviceControlModel.code ?? '',
|
||||
deviceId: event.deviceId,
|
||||
functionValue: event.deviceControlModel.value,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
value: event.deviceControlModel.value,
|
||||
@ -84,4 +88,22 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState> {
|
||||
tasksList.clear();
|
||||
emit(AddSceneTask(tasksList: tasksList));
|
||||
}
|
||||
|
||||
FutureOr<void> _fetchSceneTasks(
|
||||
FetchSceneTasks event, Emitter<CreateSceneState> emit) async {
|
||||
emit(CreateSceneLoading());
|
||||
|
||||
try {
|
||||
final response = await SceneApi.getSceneDetails(event.sceneId);
|
||||
if (response.id.isNotEmpty) {
|
||||
tasksList = getTaskListFunctionsFromApi(
|
||||
actions: response.actions, deviceId: response.id);
|
||||
emit(AddSceneTask(tasksList: tasksList));
|
||||
} else {
|
||||
emit(const CreateSceneError(message: 'Something went wrong'));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(CreateSceneError(message: e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,3 +59,11 @@ class ClearTaskListEvent extends CreateSceneEvent {
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class FetchSceneTasks extends CreateSceneEvent {
|
||||
final String sceneId;
|
||||
const FetchSceneTasks({required this.sceneId});
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ import 'dart:async';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||
|
||||
part 'scene_state.dart';
|
||||
|
@ -12,7 +12,7 @@ class SceneInitial extends SceneState {}
|
||||
class SceneLoading extends SceneState {}
|
||||
|
||||
class SceneLoaded extends SceneState {
|
||||
final List<SceneModel> scenes;
|
||||
final List<ScenesModel> scenes;
|
||||
final String? loadingSceneId;
|
||||
|
||||
const SceneLoaded(this.scenes, {this.loadingSceneId});
|
||||
|
@ -3,6 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/utils/context_extension.dart';
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/ac_values.dart';
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
@ -14,31 +17,67 @@ mixin SceneOperationsDataHelper {
|
||||
switch (type) {
|
||||
case DeviceType.LightBulb:
|
||||
return lightBulbFunctions(
|
||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
||||
functions: functions,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
functionValue: null,
|
||||
);
|
||||
case DeviceType.CeilingSensor:
|
||||
return ceilingSensorFunctions(
|
||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
||||
functions: functions,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
functionValue: null,
|
||||
);
|
||||
case DeviceType.WallSensor:
|
||||
return wallSensorFunctions(
|
||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
||||
functions: functions,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
functionValue: null,
|
||||
);
|
||||
case DeviceType.AC:
|
||||
return acFunctions(
|
||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
||||
functions: functions,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
functionValue: null,
|
||||
);
|
||||
case DeviceType.DoorLock:
|
||||
return doorLockFunctions(
|
||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
||||
functions: functions,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
functionValue: null,
|
||||
);
|
||||
case DeviceType.Curtain:
|
||||
return curtainFunctions(
|
||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
||||
functions: functions,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
functionValue: null,
|
||||
);
|
||||
case DeviceType.ThreeGang:
|
||||
return threeGangFunctions(
|
||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
||||
functions: functions,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
functionValue: null,
|
||||
);
|
||||
case DeviceType.Gateway:
|
||||
return gatewayFunctions(
|
||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
||||
functions: functions,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
functionValue: null,
|
||||
);
|
||||
default:
|
||||
return lightBulbFunctions(
|
||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
||||
functions: functions,
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
functionValue: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,10 +105,12 @@ mixin SceneOperationsDataHelper {
|
||||
}
|
||||
|
||||
/// presence sensor
|
||||
List<SceneStaticFunction> ceilingSensorFunctions(
|
||||
{required List<FunctionModel> functions,
|
||||
List<SceneStaticFunction> ceilingSensorFunctions({
|
||||
required List<FunctionModel> functions,
|
||||
required String deviceId,
|
||||
required String deviceName}) {
|
||||
required String deviceName,
|
||||
required dynamic functionValue,
|
||||
}) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
@ -77,6 +118,7 @@ mixin SceneOperationsDataHelper {
|
||||
icon: Assets.assetsSensitivityFunction,
|
||||
operationName: 'Sensitivity',
|
||||
code: 'sensitivity',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
@ -132,25 +174,28 @@ mixin SceneOperationsDataHelper {
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
List<SceneStaticFunction> curtainFunctions(
|
||||
{required List<FunctionModel> functions,
|
||||
required String deviceId,
|
||||
required String deviceName}) {
|
||||
required String deviceName,
|
||||
required functionValue}) {
|
||||
return [];
|
||||
}
|
||||
|
||||
List<SceneStaticFunction> doorLockFunctions(
|
||||
{required List<FunctionModel> functions,
|
||||
List<SceneStaticFunction> doorLockFunctions({
|
||||
required List<FunctionModel> functions,
|
||||
required String deviceId,
|
||||
required String deviceName}) {
|
||||
required String deviceName,
|
||||
required functionValue,
|
||||
}) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsIconsDoorLock,
|
||||
operationName: 'Set Door lock Normal Open',
|
||||
functionValue: functionValue,
|
||||
code: 'normal_open_switch',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
@ -162,10 +207,12 @@ List<SceneStaticFunction> doorLockFunctions(
|
||||
];
|
||||
}
|
||||
|
||||
List<SceneStaticFunction> wallSensorFunctions(
|
||||
{required List<FunctionModel> functions,
|
||||
List<SceneStaticFunction> wallSensorFunctions({
|
||||
required List<FunctionModel> functions,
|
||||
required String deviceId,
|
||||
required String deviceName}) {
|
||||
required String deviceName,
|
||||
required functionValue,
|
||||
}) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
@ -173,6 +220,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
||||
icon: Assets.assetsFarDetection,
|
||||
operationName: 'Far Detection',
|
||||
code: 'far_detection',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
@ -230,6 +278,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
||||
icon: Assets.assetsMotionDetection,
|
||||
operationName: 'Motion Detection Sensitivity',
|
||||
code: 'motion_sensitivity_value',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
@ -264,6 +313,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
||||
icon: Assets.assetsMotionlessDetection,
|
||||
operationName: 'Motionless Detection Sensitivity',
|
||||
code: 'motionless_sensitivity',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
iconValue: '1',
|
||||
@ -303,6 +353,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
||||
icon: Assets.assetsIndicator,
|
||||
operationName: 'Indicator',
|
||||
code: 'indicator',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
@ -316,6 +367,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
||||
icon: Assets.assetsNobodyTime,
|
||||
operationName: 'Nobody Time',
|
||||
code: 'presence_time',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: '', value: 0),
|
||||
],
|
||||
@ -326,14 +378,17 @@ List<SceneStaticFunction> wallSensorFunctions(
|
||||
List<SceneStaticFunction> lightBulbFunctions(
|
||||
{required List<FunctionModel> functions,
|
||||
required String deviceId,
|
||||
required String deviceName}) {
|
||||
required String deviceName,
|
||||
required functionValue}) {
|
||||
return [];
|
||||
}
|
||||
|
||||
List<SceneStaticFunction> gatewayFunctions(
|
||||
{required List<FunctionModel> functions,
|
||||
List<SceneStaticFunction> gatewayFunctions({
|
||||
required List<FunctionModel> functions,
|
||||
required String deviceId,
|
||||
required String deviceName}) {
|
||||
required String deviceName,
|
||||
required functionValue,
|
||||
}) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
@ -341,6 +396,7 @@ List<SceneStaticFunction> gatewayFunctions(
|
||||
icon: Assets.assetsSwitchAlarmSound,
|
||||
operationName: 'Switch Alarm Sound',
|
||||
code: 'switch_alarm_sound',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
@ -354,6 +410,7 @@ List<SceneStaticFunction> gatewayFunctions(
|
||||
icon: Assets.assetsMasterState,
|
||||
operationName: 'Master State',
|
||||
code: 'master_state',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -373,6 +430,7 @@ List<SceneStaticFunction> gatewayFunctions(
|
||||
icon: Assets.assetsFactoryReset,
|
||||
operationName: 'Factory Reset',
|
||||
code: 'factory_reset',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSceneRefresh, description: "ON", value: true),
|
||||
@ -383,10 +441,12 @@ List<SceneStaticFunction> gatewayFunctions(
|
||||
];
|
||||
}
|
||||
|
||||
List<SceneStaticFunction> threeGangFunctions(
|
||||
{required List<FunctionModel> functions,
|
||||
List<SceneStaticFunction> threeGangFunctions({
|
||||
required List<FunctionModel> functions,
|
||||
required String deviceId,
|
||||
required String deviceName}) {
|
||||
required String deviceName,
|
||||
required functionValue,
|
||||
}) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
@ -394,6 +454,7 @@ List<SceneStaticFunction> threeGangFunctions(
|
||||
icon: Assets.assetsAcPower,
|
||||
operationName: 'Light 1 Switch',
|
||||
code: 'switch_1',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
@ -412,6 +473,7 @@ List<SceneStaticFunction> threeGangFunctions(
|
||||
icon: Assets.assetsAcPower,
|
||||
operationName: 'Light 2 Switch',
|
||||
code: 'switch_2',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
@ -430,6 +492,7 @@ List<SceneStaticFunction> threeGangFunctions(
|
||||
icon: Assets.assetsAcPower,
|
||||
operationName: 'Light 3 Switch',
|
||||
code: 'switch_3',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
@ -448,6 +511,7 @@ List<SceneStaticFunction> threeGangFunctions(
|
||||
icon: Assets.assetsLightCountdown,
|
||||
operationName: 'Light 1 CountDown',
|
||||
code: 'countdown_1',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: '', value: 0),
|
||||
],
|
||||
@ -457,7 +521,8 @@ List<SceneStaticFunction> threeGangFunctions(
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
operationName: 'Light 2 CountDown',
|
||||
code: 'countdown_1',
|
||||
code: 'countdown_2',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: '', value: 0),
|
||||
],
|
||||
@ -467,7 +532,8 @@ List<SceneStaticFunction> threeGangFunctions(
|
||||
deviceName: deviceName,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
operationName: 'Light 3 CountDown',
|
||||
code: 'countdown_1',
|
||||
code: 'countdown_3',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: '', value: 0),
|
||||
],
|
||||
@ -476,10 +542,12 @@ List<SceneStaticFunction> threeGangFunctions(
|
||||
}
|
||||
|
||||
/// smart ac thermostat
|
||||
List<SceneStaticFunction> acFunctions(
|
||||
{required List<FunctionModel> functions,
|
||||
List<SceneStaticFunction> acFunctions({
|
||||
required List<FunctionModel> functions,
|
||||
required String deviceId,
|
||||
required String deviceName}) {
|
||||
required String deviceName,
|
||||
required functionValue,
|
||||
}) {
|
||||
return [
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
@ -487,6 +555,7 @@ List<SceneStaticFunction> acFunctions(
|
||||
icon: Assets.assetsAcPower,
|
||||
operationName: 'Power',
|
||||
code: 'switch',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
@ -506,6 +575,7 @@ List<SceneStaticFunction> acFunctions(
|
||||
icon: Assets.assetsFreezing,
|
||||
operationName: 'Mode',
|
||||
code: 'mode',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcCooling,
|
||||
@ -530,6 +600,7 @@ List<SceneStaticFunction> acFunctions(
|
||||
icon: Assets.assetsTempreture,
|
||||
operationName: 'Set Temperature',
|
||||
code: 'temp_set',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsCelsiusDegrees,
|
||||
@ -544,6 +615,7 @@ List<SceneStaticFunction> acFunctions(
|
||||
icon: Assets.assetsFanSpeed,
|
||||
operationName: 'Fan Speed',
|
||||
code: 'level',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcFanLow,
|
||||
@ -573,6 +645,7 @@ List<SceneStaticFunction> acFunctions(
|
||||
icon: Assets.assetsChildLock,
|
||||
operationName: 'Child Lock',
|
||||
code: 'child_lock',
|
||||
functionValue: functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSceneChildLock,
|
||||
@ -588,3 +661,609 @@ List<SceneStaticFunction> acFunctions(
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
List<SceneStaticFunction> getTaskListFunctionsFromApi({
|
||||
required List<Action> actions,
|
||||
required String deviceId,
|
||||
}) {
|
||||
List<SceneStaticFunction> functions = [];
|
||||
|
||||
for (var action in actions) {
|
||||
ExecutorProperty executorProperty = action.executorProperty;
|
||||
|
||||
switch (executorProperty.functionCode) {
|
||||
case 'sensitivity':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Presence Sensor',
|
||||
deviceIcon: Assets.assetsIconsSensors,
|
||||
icon: Assets.assetsSensitivityFunction,
|
||||
operationName: 'Sensitivity',
|
||||
code: 'sensitivity',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 1,
|
||||
description: 1.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 2,
|
||||
description: 2.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 3,
|
||||
description: 3.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 4,
|
||||
description: 4.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 5,
|
||||
description: 5.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 6,
|
||||
description: 6.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 7,
|
||||
description: 7.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 8,
|
||||
description: 8.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 9,
|
||||
description: 9.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 10,
|
||||
description: 10.toString(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'normal_open_switch':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'WIFI LOCK PRO',
|
||||
deviceIcon: Assets.assetsIconsDoorLock,
|
||||
icon: Assets.assetsIconsDoorLock,
|
||||
operationName: 'Set Door lock Normal Open',
|
||||
functionValue: executorProperty.functionValue,
|
||||
code: 'normal_open_switch',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'far_detection':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Human Presence Sensor',
|
||||
deviceIcon: Assets.assetsIconsSensors,
|
||||
icon: Assets.assetsFarDetection,
|
||||
operationName: 'Far Detection',
|
||||
functionValue: executorProperty.functionValue,
|
||||
code: 'far_detection',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 75,
|
||||
description: '75cm',
|
||||
iconValue: '75',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 150,
|
||||
description: '150cm',
|
||||
iconValue: '150',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 225,
|
||||
description: '225cm',
|
||||
iconValue: '225',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 300,
|
||||
description: '300cm',
|
||||
iconValue: '300',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 375,
|
||||
description: '375cm',
|
||||
iconValue: '375',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 450,
|
||||
description: '450cm',
|
||||
iconValue: '450',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 525,
|
||||
description: '525cm',
|
||||
iconValue: '525',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 600,
|
||||
description: '600cm',
|
||||
iconValue: '600',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'motion_sensitivity_value':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Human Presence Sensor',
|
||||
deviceIcon: Assets.assetsIconsSensors,
|
||||
icon: Assets.assetsMotionDetection,
|
||||
operationName: 'Motion Detection Sensitivity',
|
||||
functionValue: executorProperty.functionValue,
|
||||
code: 'motion_sensitivity_value',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 1,
|
||||
description: 1.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 2,
|
||||
description: 2.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 3,
|
||||
description: 3.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 4,
|
||||
description: 4.toString(),
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSensitivityOperationIcon,
|
||||
value: 5,
|
||||
description: 5.toString(),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'motionless_sensitivity':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Human Presence Sensor',
|
||||
deviceIcon: Assets.assetsIconsSensors,
|
||||
icon: Assets.assetsMotionlessDetection,
|
||||
operationName: 'Motionless Detection Sensitivity',
|
||||
functionValue: executorProperty.functionValue,
|
||||
code: 'motion_sensitivity_value',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
iconValue: '1',
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 1,
|
||||
description: '1',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 2,
|
||||
description: '2',
|
||||
iconValue: '2',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 3,
|
||||
description: '3',
|
||||
iconValue: '3',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 4,
|
||||
description: '4',
|
||||
iconValue: '4',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFarDetectionFunction,
|
||||
value: 5,
|
||||
description: '5',
|
||||
iconValue: '5',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'indicator':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Human Presence Sensor',
|
||||
deviceIcon: Assets.assetsIconsSensors,
|
||||
icon: Assets.assetsIndicator,
|
||||
operationName: 'Indicator',
|
||||
functionValue: executorProperty.functionValue,
|
||||
code: 'indicator',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'presence_time':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Human Presence Sensor',
|
||||
deviceIcon: Assets.assetsIconsSensors,
|
||||
icon: Assets.assetsNobodyTime,
|
||||
operationName: 'Nobody Time',
|
||||
functionValue: executorProperty.functionValue,
|
||||
code: 'presence_time',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: '', value: 0),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'switch_alarm_sound':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Multi-Mode Gateway Z-W-B',
|
||||
deviceIcon: Assets.assetsIconsGateway,
|
||||
icon: Assets.assetsSwitchAlarmSound,
|
||||
operationName: 'Switch Alarm Sound',
|
||||
functionValue: executorProperty.functionValue,
|
||||
code: 'switch_alarm_sound',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "ON",
|
||||
value: true,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'master_state':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Multi-Mode Gateway Z-W-B',
|
||||
deviceIcon: Assets.assetsIconsGateway,
|
||||
icon: Assets.assetsMasterState,
|
||||
operationName: 'Master State',
|
||||
functionValue: executorProperty.functionValue,
|
||||
code: 'master_state',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "Alarm",
|
||||
value: 'alarm',
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "Normal",
|
||||
value: 'normal',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'factory_reset':
|
||||
functions.add(
|
||||
SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Multi-Mode Gateway Z-W-B',
|
||||
deviceIcon: Assets.assetsIconsGateway,
|
||||
icon: Assets.assetsFactoryReset,
|
||||
operationName: 'Reset Factory',
|
||||
functionValue: executorProperty.functionValue,
|
||||
code: 'factory_reset',
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSceneRefresh,
|
||||
description: "ON",
|
||||
value: true),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsResetOff,
|
||||
description: "OFF",
|
||||
value: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
break;
|
||||
case 'switch_1':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: '3 Gang Button Switch L-L',
|
||||
deviceIcon: Assets.assetsIcons3GangSwitch,
|
||||
icon: Assets.assetsAcPower,
|
||||
operationName: 'Light 1 Switch',
|
||||
code: 'switch_1',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "ON",
|
||||
value: true,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSceneRefresh,
|
||||
description: "Reverse Switch",
|
||||
value: null,
|
||||
),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'switch_2':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: '3 Gang Button Switch L-L',
|
||||
deviceIcon: Assets.assetsIcons3GangSwitch,
|
||||
icon: Assets.assetsAcPower,
|
||||
operationName: 'Light 2 Switch',
|
||||
code: 'switch_2',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSceneRefresh,
|
||||
description: "Reverse Switch",
|
||||
value: null,
|
||||
),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'switch_3':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: '3 Gang Button Switch L-L',
|
||||
deviceIcon: Assets.assetsIcons3GangSwitch,
|
||||
icon: Assets.assetsAcPower,
|
||||
operationName: 'Light 3 Switch',
|
||||
code: 'switch_3',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSceneRefresh,
|
||||
description: "Reverse Switch",
|
||||
value: null,
|
||||
),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'countdown_1':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: '3 Gang Button Switch L-L',
|
||||
deviceIcon: Assets.assetsIcons3GangSwitch,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
operationName: 'Light 1 CountDown',
|
||||
code: 'countdown_1',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: '', value: 0),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'countdown_2':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: '3 Gang Button Switch L-L',
|
||||
deviceIcon: Assets.assetsIcons3GangSwitch,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
operationName: 'Light 2 CountDown',
|
||||
code: 'countdown_2',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: '', value: 0),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'countdown_3':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: '3 Gang Button Switch L-L',
|
||||
deviceIcon: Assets.assetsIcons3GangSwitch,
|
||||
icon: Assets.assetsLightCountdown,
|
||||
operationName: 'Light 3 CountDown',
|
||||
code: 'countdown_3',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(icon: '', value: 0),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'switch':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Smart AC Thermostat - Grey - Model A',
|
||||
deviceIcon: Assets.assetsIconsAC,
|
||||
icon: Assets.assetsAcPower,
|
||||
operationName: 'Power',
|
||||
code: 'switch',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPower,
|
||||
description: "ON",
|
||||
value: true,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcPowerOFF,
|
||||
description: "OFF",
|
||||
value: false,
|
||||
),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'temp_set':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Smart AC Thermostat - Grey - Model A',
|
||||
deviceIcon: Assets.assetsIconsAC,
|
||||
icon: Assets.assetsTempreture,
|
||||
operationName: 'Set Temperature',
|
||||
code: 'temp_set',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsCelsiusDegrees,
|
||||
value: 0,
|
||||
description: 'COOL TO',
|
||||
),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'mode':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Smart AC Thermostat - Grey - Model A',
|
||||
deviceIcon: Assets.assetsIconsAC,
|
||||
icon: Assets.assetsFreezing,
|
||||
operationName: 'Mode',
|
||||
code: 'mode',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcCooling,
|
||||
description: AcValuesEnums.Cooling.name,
|
||||
value: TempModes.cold.name,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcHeating,
|
||||
description: AcValuesEnums.Heating.name,
|
||||
value: TempModes.hot.name,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsFanSpeed,
|
||||
description: AcValuesEnums.Ventilation.name,
|
||||
value: TempModes.wind.name,
|
||||
),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'level':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Smart AC Thermostat - Grey - Model A',
|
||||
deviceIcon: Assets.assetsIconsAC,
|
||||
icon: Assets.assetsFanSpeed,
|
||||
operationName: 'Fan Speed',
|
||||
code: 'level',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcFanLow,
|
||||
description: ValueACRange.LOW.name,
|
||||
value: FanSpeeds.low.name,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcFanMiddle,
|
||||
description: ValueACRange.MIDDLE.name,
|
||||
value: FanSpeeds.middle.name,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcFanHigh,
|
||||
description: ValueACRange.HIGH.name,
|
||||
value: FanSpeeds.high.name,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsAcFanAuto,
|
||||
description: ValueACRange.AUTO.name,
|
||||
value: FanSpeeds.auto.name,
|
||||
),
|
||||
],
|
||||
));
|
||||
break;
|
||||
case 'child_lock':
|
||||
functions.add(SceneStaticFunction(
|
||||
deviceId: deviceId,
|
||||
deviceName: 'Smart AC Thermostat - Grey - Model A',
|
||||
deviceIcon: Assets.assetsIconsAC,
|
||||
icon: Assets.assetsChildLock,
|
||||
operationName: 'Child Lock',
|
||||
code: 'child_lock',
|
||||
functionValue: executorProperty.functionValue,
|
||||
operationalValues: [
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSceneChildLock,
|
||||
description: 'Lock',
|
||||
value: true,
|
||||
),
|
||||
SceneOperationalValue(
|
||||
icon: Assets.assetsSceneChildUnlock,
|
||||
description: 'Unlock',
|
||||
value: false,
|
||||
),
|
||||
],
|
||||
));
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
return functions;
|
||||
}
|
||||
}
|
||||
|
94
lib/features/scene/model/scene_details_model.dart
Normal file
94
lib/features/scene/model/scene_details_model.dart
Normal file
@ -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,
|
||||
};
|
||||
}
|
12
lib/features/scene/model/scene_settings_route_arguments.dart
Normal file
12
lib/features/scene/model/scene_settings_route_arguments.dart
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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"]]!,
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_list_tile.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||
@ -40,9 +41,13 @@ class CreateSceneView extends StatelessWidget {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.sceneTasksRoute,
|
||||
arguments: CreateSceneEnum.tabToRun,
|
||||
arguments: SceneSettingsRouteArguments(
|
||||
sceneType: CreateSceneEnum.tabToRun.name,
|
||||
sceneId: '',
|
||||
sceneName: '',
|
||||
),
|
||||
);
|
||||
context.read<CreateSceneBloc>().add(ClearTaskListEvent());
|
||||
context.read<CreateSceneBloc>().add(const ClearTaskListEvent());
|
||||
},
|
||||
),
|
||||
DefaultContainer(
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/create_scene_save_button.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/if_then_containers/if_container.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/if_then_containers/then_container.dart';
|
||||
@ -14,8 +15,12 @@ class SceneTasksView extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final sceneSettings = ModalRoute.of(context)!.settings.arguments
|
||||
as SceneSettingsRouteArguments;
|
||||
return DefaultScaffold(
|
||||
title: StringsManager.createScene,
|
||||
title: sceneSettings.sceneName.isNotEmpty
|
||||
? sceneSettings.sceneName
|
||||
: StringsManager.createScene,
|
||||
padding: EdgeInsets.zero,
|
||||
actions: [
|
||||
SizedBox(
|
||||
@ -33,21 +38,21 @@ class SceneTasksView extends StatelessWidget {
|
||||
],
|
||||
child: Stack(
|
||||
children: [
|
||||
const SingleChildScrollView(
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
// IF
|
||||
IFDefaultContainer(),
|
||||
SizedBox(
|
||||
const IFDefaultContainer(),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
// THEN
|
||||
ThenDefaultContainer(),
|
||||
SizedBox(
|
||||
ThenDefaultContainer(sceneId: sceneSettings.sceneId),
|
||||
const SizedBox(
|
||||
height: 100,
|
||||
),
|
||||
],
|
||||
|
@ -22,14 +22,16 @@ class ThenAddedTasksContainer extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
String operationValue = '';
|
||||
if (taskList.code.contains('countdown')) {
|
||||
final duration = Duration(
|
||||
seconds:
|
||||
int.tryParse(taskList.operationalValues.first.value.toString()) ??
|
||||
0);
|
||||
final functionValue =
|
||||
taskList.functionValue ?? taskList.operationalValues.first.value;
|
||||
final duration =
|
||||
Duration(seconds: int.tryParse(functionValue.toString()) ?? 0);
|
||||
operationValue =
|
||||
"${duration.inHours}h ${duration.inMinutes.remainder(60)}m ";
|
||||
} else {
|
||||
operationValue = taskList.operationalValues.first.value.toString();
|
||||
final functionValue =
|
||||
taskList.functionValue ?? taskList.operationalValues.first.value;
|
||||
operationValue = functionValue.toString();
|
||||
}
|
||||
return DefaultContainer(
|
||||
padding: EdgeInsets.zero,
|
||||
|
@ -15,8 +15,11 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
class ThenDefaultContainer extends StatelessWidget {
|
||||
const ThenDefaultContainer({
|
||||
super.key,
|
||||
required this.sceneId,
|
||||
});
|
||||
|
||||
final String sceneId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultContainer(
|
||||
@ -47,7 +50,32 @@ class ThenDefaultContainer extends StatelessWidget {
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
const LightDivider(),
|
||||
BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
sceneId.isNotEmpty
|
||||
? BlocProvider(
|
||||
create: (context) =>
|
||||
CreateSceneBloc()..add(FetchSceneTasks(sceneId:sceneId)),
|
||||
child: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is AddSceneTask) {
|
||||
final taskLists = state.tasksList;
|
||||
if (taskLists.isNotEmpty) {
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemCount: taskLists.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ThenAddedTasksContainer(
|
||||
taskList: taskLists[index],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
return const SizedBox();
|
||||
}
|
||||
return const SizedBox();
|
||||
},
|
||||
))
|
||||
: BlocBuilder<CreateSceneBloc, CreateSceneState>(
|
||||
builder: (context, state) {
|
||||
if (state is AddSceneTask) {
|
||||
final taskLists = state.tasksList;
|
||||
|
@ -1,10 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:syncrow_app/features/scene/model/scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_item.dart';
|
||||
|
||||
class SceneGrid extends StatelessWidget {
|
||||
final List<SceneModel> scenes;
|
||||
final List<ScenesModel> scenes;
|
||||
final String? loadingSceneId;
|
||||
|
||||
const SceneGrid({
|
||||
|
@ -2,15 +2,18 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_bloc.dart';
|
||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_settings_route_arguments.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||
|
||||
import 'package:syncrow_app/generated/assets.dart';
|
||||
import 'package:syncrow_app/navigation/routing_constants.dart';
|
||||
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||
|
||||
class SceneItem extends StatelessWidget {
|
||||
final SceneModel scene;
|
||||
final ScenesModel scene;
|
||||
final bool isLoading;
|
||||
|
||||
const SceneItem({
|
||||
@ -22,6 +25,17 @@ class SceneItem extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DefaultContainer(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.sceneTasksRoute,
|
||||
arguments: SceneSettingsRouteArguments(
|
||||
sceneType: CreateSceneEnum.tabToRun.name,
|
||||
sceneId: scene.id,
|
||||
sceneName: scene.name,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
@ -1,5 +1,6 @@
|
||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scene_details_model.dart';
|
||||
import 'package:syncrow_app/features/scene/model/scenes_model.dart';
|
||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||
import 'package:syncrow_app/services/api/http_service.dart';
|
||||
|
||||
@ -23,15 +24,15 @@ class SceneApi {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<List<SceneModel>> getScenesByUnitId(String unitId) async {
|
||||
static Future<List<ScenesModel>> getScenesByUnitId(String unitId) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getUnitScenes.replaceAll('{unitUuid}', unitId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<SceneModel> scenes = [];
|
||||
List<ScenesModel> scenes = [];
|
||||
for (var scene in json) {
|
||||
scenes.add(SceneModel.fromJson(scene));
|
||||
scenes.add(ScenesModel.fromJson(scene));
|
||||
}
|
||||
return scenes;
|
||||
},
|
||||
@ -54,4 +55,23 @@ class SceneApi {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
//getScene
|
||||
|
||||
static Future<SceneDetailsModel> getSceneDetails(String sceneId) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getScene.replaceAll('{sceneId}', sceneId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => SceneDetailsModel.fromJson(json),
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
//deleteScene
|
||||
|
||||
//updateScene
|
||||
}
|
||||
|
Reference in New Issue
Block a user