mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 18:16:21 +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:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.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/create_scene_model.dart';
|
||||||
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
import 'package:syncrow_app/features/scene/model/scene_static_function.dart';
|
||||||
import 'package:syncrow_app/services/api/scene_api.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_event.dart';
|
||||||
part 'create_scene_state.dart';
|
part 'create_scene_state.dart';
|
||||||
|
|
||||||
class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState> {
|
class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState>
|
||||||
|
with SceneOperationsDataHelper {
|
||||||
CreateSceneBloc() : super(CreateSceneInitial()) {
|
CreateSceneBloc() : super(CreateSceneInitial()) {
|
||||||
on<CreateSceneWithTasksEvent>(_createSceneWithTasks);
|
on<CreateSceneWithTasksEvent>(_createSceneWithTasks);
|
||||||
on<AddTaskEvent>(_onAddSceneTask);
|
on<AddTaskEvent>(_onAddSceneTask);
|
||||||
on<SelectedValueEvent>(_selectedValue);
|
on<SelectedValueEvent>(_selectedValue);
|
||||||
on<RemoveTaskEvent>(_removeTaskById);
|
on<RemoveTaskEvent>(_removeTaskById);
|
||||||
on<ClearTaskListEvent>(_clearTaskList);
|
on<ClearTaskListEvent>(_clearTaskList);
|
||||||
|
on<FetchSceneTasks>(_fetchSceneTasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneStaticFunction> tasksList = [];
|
List<SceneStaticFunction> tasksList = [];
|
||||||
@ -31,6 +34,7 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState> {
|
|||||||
icon: event.icon,
|
icon: event.icon,
|
||||||
code: event.deviceControlModel.code ?? '',
|
code: event.deviceControlModel.code ?? '',
|
||||||
deviceId: event.deviceId,
|
deviceId: event.deviceId,
|
||||||
|
functionValue: event.deviceControlModel.value,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
value: event.deviceControlModel.value,
|
value: event.deviceControlModel.value,
|
||||||
@ -84,4 +88,22 @@ class CreateSceneBloc extends Bloc<CreateSceneEvent, CreateSceneState> {
|
|||||||
tasksList.clear();
|
tasksList.clear();
|
||||||
emit(AddSceneTask(tasksList: tasksList));
|
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
|
@override
|
||||||
List<Object> get props => [];
|
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:equatable/equatable.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.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/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';
|
import 'package:syncrow_app/services/api/scene_api.dart';
|
||||||
|
|
||||||
part 'scene_state.dart';
|
part 'scene_state.dart';
|
||||||
|
@ -12,7 +12,7 @@ class SceneInitial extends SceneState {}
|
|||||||
class SceneLoading extends SceneState {}
|
class SceneLoading extends SceneState {}
|
||||||
|
|
||||||
class SceneLoaded extends SceneState {
|
class SceneLoaded extends SceneState {
|
||||||
final List<SceneModel> scenes;
|
final List<ScenesModel> scenes;
|
||||||
final String? loadingSceneId;
|
final String? loadingSceneId;
|
||||||
|
|
||||||
const SceneLoaded(this.scenes, {this.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/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/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/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/features/scene/model/scene_static_function.dart';
|
||||||
import 'package:syncrow_app/utils/context_extension.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/devices/model/function_model.dart';
|
||||||
import 'package:syncrow_app/features/scene/enum/ac_values.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/features/scene/model/scene_static_function.dart';
|
||||||
import 'package:syncrow_app/generated/assets.dart';
|
import 'package:syncrow_app/generated/assets.dart';
|
||||||
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||||
@ -14,31 +17,67 @@ mixin SceneOperationsDataHelper {
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case DeviceType.LightBulb:
|
case DeviceType.LightBulb:
|
||||||
return lightBulbFunctions(
|
return lightBulbFunctions(
|
||||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
functions: functions,
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
functionValue: null,
|
||||||
|
);
|
||||||
case DeviceType.CeilingSensor:
|
case DeviceType.CeilingSensor:
|
||||||
return ceilingSensorFunctions(
|
return ceilingSensorFunctions(
|
||||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
functions: functions,
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
functionValue: null,
|
||||||
|
);
|
||||||
case DeviceType.WallSensor:
|
case DeviceType.WallSensor:
|
||||||
return wallSensorFunctions(
|
return wallSensorFunctions(
|
||||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
functions: functions,
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
functionValue: null,
|
||||||
|
);
|
||||||
case DeviceType.AC:
|
case DeviceType.AC:
|
||||||
return acFunctions(
|
return acFunctions(
|
||||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
functions: functions,
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
functionValue: null,
|
||||||
|
);
|
||||||
case DeviceType.DoorLock:
|
case DeviceType.DoorLock:
|
||||||
return doorLockFunctions(
|
return doorLockFunctions(
|
||||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
functions: functions,
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
functionValue: null,
|
||||||
|
);
|
||||||
case DeviceType.Curtain:
|
case DeviceType.Curtain:
|
||||||
return curtainFunctions(
|
return curtainFunctions(
|
||||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
functions: functions,
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
functionValue: null,
|
||||||
|
);
|
||||||
case DeviceType.ThreeGang:
|
case DeviceType.ThreeGang:
|
||||||
return threeGangFunctions(
|
return threeGangFunctions(
|
||||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
functions: functions,
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
functionValue: null,
|
||||||
|
);
|
||||||
case DeviceType.Gateway:
|
case DeviceType.Gateway:
|
||||||
return gatewayFunctions(
|
return gatewayFunctions(
|
||||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
functions: functions,
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
functionValue: null,
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
return lightBulbFunctions(
|
return lightBulbFunctions(
|
||||||
functions: functions, deviceId: deviceId, deviceName: deviceName);
|
functions: functions,
|
||||||
|
deviceId: deviceId,
|
||||||
|
deviceName: deviceName,
|
||||||
|
functionValue: null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,10 +105,12 @@ mixin SceneOperationsDataHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// presence sensor
|
/// presence sensor
|
||||||
List<SceneStaticFunction> ceilingSensorFunctions(
|
List<SceneStaticFunction> ceilingSensorFunctions({
|
||||||
{required List<FunctionModel> functions,
|
required List<FunctionModel> functions,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
required String deviceName}) {
|
required String deviceName,
|
||||||
|
required dynamic functionValue,
|
||||||
|
}) {
|
||||||
return [
|
return [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
@ -77,6 +118,7 @@ mixin SceneOperationsDataHelper {
|
|||||||
icon: Assets.assetsSensitivityFunction,
|
icon: Assets.assetsSensitivityFunction,
|
||||||
operationName: 'Sensitivity',
|
operationName: 'Sensitivity',
|
||||||
code: 'sensitivity',
|
code: 'sensitivity',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsSensitivityOperationIcon,
|
icon: Assets.assetsSensitivityOperationIcon,
|
||||||
@ -132,25 +174,28 @@ mixin SceneOperationsDataHelper {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
List<SceneStaticFunction> curtainFunctions(
|
List<SceneStaticFunction> curtainFunctions(
|
||||||
{required List<FunctionModel> functions,
|
{required List<FunctionModel> functions,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
required String deviceName}) {
|
required String deviceName,
|
||||||
|
required functionValue}) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneStaticFunction> doorLockFunctions(
|
List<SceneStaticFunction> doorLockFunctions({
|
||||||
{required List<FunctionModel> functions,
|
required List<FunctionModel> functions,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
required String deviceName}) {
|
required String deviceName,
|
||||||
|
required functionValue,
|
||||||
|
}) {
|
||||||
return [
|
return [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsIconsDoorLock,
|
icon: Assets.assetsIconsDoorLock,
|
||||||
operationName: 'Set Door lock Normal Open',
|
operationName: 'Set Door lock Normal Open',
|
||||||
|
functionValue: functionValue,
|
||||||
code: 'normal_open_switch',
|
code: 'normal_open_switch',
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
@ -162,10 +207,12 @@ List<SceneStaticFunction> doorLockFunctions(
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneStaticFunction> wallSensorFunctions(
|
List<SceneStaticFunction> wallSensorFunctions({
|
||||||
{required List<FunctionModel> functions,
|
required List<FunctionModel> functions,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
required String deviceName}) {
|
required String deviceName,
|
||||||
|
required functionValue,
|
||||||
|
}) {
|
||||||
return [
|
return [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
@ -173,6 +220,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
|||||||
icon: Assets.assetsFarDetection,
|
icon: Assets.assetsFarDetection,
|
||||||
operationName: 'Far Detection',
|
operationName: 'Far Detection',
|
||||||
code: 'far_detection',
|
code: 'far_detection',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsFarDetectionFunction,
|
icon: Assets.assetsFarDetectionFunction,
|
||||||
@ -230,6 +278,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
|||||||
icon: Assets.assetsMotionDetection,
|
icon: Assets.assetsMotionDetection,
|
||||||
operationName: 'Motion Detection Sensitivity',
|
operationName: 'Motion Detection Sensitivity',
|
||||||
code: 'motion_sensitivity_value',
|
code: 'motion_sensitivity_value',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsSensitivityOperationIcon,
|
icon: Assets.assetsSensitivityOperationIcon,
|
||||||
@ -264,6 +313,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
|||||||
icon: Assets.assetsMotionlessDetection,
|
icon: Assets.assetsMotionlessDetection,
|
||||||
operationName: 'Motionless Detection Sensitivity',
|
operationName: 'Motionless Detection Sensitivity',
|
||||||
code: 'motionless_sensitivity',
|
code: 'motionless_sensitivity',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
iconValue: '1',
|
iconValue: '1',
|
||||||
@ -303,6 +353,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
|||||||
icon: Assets.assetsIndicator,
|
icon: Assets.assetsIndicator,
|
||||||
operationName: 'Indicator',
|
operationName: 'Indicator',
|
||||||
code: 'indicator',
|
code: 'indicator',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
@ -316,6 +367,7 @@ List<SceneStaticFunction> wallSensorFunctions(
|
|||||||
icon: Assets.assetsNobodyTime,
|
icon: Assets.assetsNobodyTime,
|
||||||
operationName: 'Nobody Time',
|
operationName: 'Nobody Time',
|
||||||
code: 'presence_time',
|
code: 'presence_time',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(icon: '', value: 0),
|
SceneOperationalValue(icon: '', value: 0),
|
||||||
],
|
],
|
||||||
@ -326,14 +378,17 @@ List<SceneStaticFunction> wallSensorFunctions(
|
|||||||
List<SceneStaticFunction> lightBulbFunctions(
|
List<SceneStaticFunction> lightBulbFunctions(
|
||||||
{required List<FunctionModel> functions,
|
{required List<FunctionModel> functions,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
required String deviceName}) {
|
required String deviceName,
|
||||||
|
required functionValue}) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneStaticFunction> gatewayFunctions(
|
List<SceneStaticFunction> gatewayFunctions({
|
||||||
{required List<FunctionModel> functions,
|
required List<FunctionModel> functions,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
required String deviceName}) {
|
required String deviceName,
|
||||||
|
required functionValue,
|
||||||
|
}) {
|
||||||
return [
|
return [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
@ -341,6 +396,7 @@ List<SceneStaticFunction> gatewayFunctions(
|
|||||||
icon: Assets.assetsSwitchAlarmSound,
|
icon: Assets.assetsSwitchAlarmSound,
|
||||||
operationName: 'Switch Alarm Sound',
|
operationName: 'Switch Alarm Sound',
|
||||||
code: 'switch_alarm_sound',
|
code: 'switch_alarm_sound',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
@ -354,6 +410,7 @@ List<SceneStaticFunction> gatewayFunctions(
|
|||||||
icon: Assets.assetsMasterState,
|
icon: Assets.assetsMasterState,
|
||||||
operationName: 'Master State',
|
operationName: 'Master State',
|
||||||
code: 'master_state',
|
code: 'master_state',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
@ -373,6 +430,7 @@ List<SceneStaticFunction> gatewayFunctions(
|
|||||||
icon: Assets.assetsFactoryReset,
|
icon: Assets.assetsFactoryReset,
|
||||||
operationName: 'Factory Reset',
|
operationName: 'Factory Reset',
|
||||||
code: 'factory_reset',
|
code: 'factory_reset',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsSceneRefresh, description: "ON", value: true),
|
icon: Assets.assetsSceneRefresh, description: "ON", value: true),
|
||||||
@ -383,10 +441,12 @@ List<SceneStaticFunction> gatewayFunctions(
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SceneStaticFunction> threeGangFunctions(
|
List<SceneStaticFunction> threeGangFunctions({
|
||||||
{required List<FunctionModel> functions,
|
required List<FunctionModel> functions,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
required String deviceName}) {
|
required String deviceName,
|
||||||
|
required functionValue,
|
||||||
|
}) {
|
||||||
return [
|
return [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
@ -394,6 +454,7 @@ List<SceneStaticFunction> threeGangFunctions(
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
operationName: 'Light 1 Switch',
|
operationName: 'Light 1 Switch',
|
||||||
code: 'switch_1',
|
code: 'switch_1',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
@ -412,6 +473,7 @@ List<SceneStaticFunction> threeGangFunctions(
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
operationName: 'Light 2 Switch',
|
operationName: 'Light 2 Switch',
|
||||||
code: 'switch_2',
|
code: 'switch_2',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
@ -430,6 +492,7 @@ List<SceneStaticFunction> threeGangFunctions(
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
operationName: 'Light 3 Switch',
|
operationName: 'Light 3 Switch',
|
||||||
code: 'switch_3',
|
code: 'switch_3',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsAcPower, description: "ON", value: true),
|
icon: Assets.assetsAcPower, description: "ON", value: true),
|
||||||
@ -448,6 +511,7 @@ List<SceneStaticFunction> threeGangFunctions(
|
|||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
operationName: 'Light 1 CountDown',
|
operationName: 'Light 1 CountDown',
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(icon: '', value: 0),
|
SceneOperationalValue(icon: '', value: 0),
|
||||||
],
|
],
|
||||||
@ -457,7 +521,8 @@ List<SceneStaticFunction> threeGangFunctions(
|
|||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
operationName: 'Light 2 CountDown',
|
operationName: 'Light 2 CountDown',
|
||||||
code: 'countdown_1',
|
code: 'countdown_2',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(icon: '', value: 0),
|
SceneOperationalValue(icon: '', value: 0),
|
||||||
],
|
],
|
||||||
@ -467,7 +532,8 @@ List<SceneStaticFunction> threeGangFunctions(
|
|||||||
deviceName: deviceName,
|
deviceName: deviceName,
|
||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
operationName: 'Light 3 CountDown',
|
operationName: 'Light 3 CountDown',
|
||||||
code: 'countdown_1',
|
code: 'countdown_3',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(icon: '', value: 0),
|
SceneOperationalValue(icon: '', value: 0),
|
||||||
],
|
],
|
||||||
@ -476,10 +542,12 @@ List<SceneStaticFunction> threeGangFunctions(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// smart ac thermostat
|
/// smart ac thermostat
|
||||||
List<SceneStaticFunction> acFunctions(
|
List<SceneStaticFunction> acFunctions({
|
||||||
{required List<FunctionModel> functions,
|
required List<FunctionModel> functions,
|
||||||
required String deviceId,
|
required String deviceId,
|
||||||
required String deviceName}) {
|
required String deviceName,
|
||||||
|
required functionValue,
|
||||||
|
}) {
|
||||||
return [
|
return [
|
||||||
SceneStaticFunction(
|
SceneStaticFunction(
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
@ -487,6 +555,7 @@ List<SceneStaticFunction> acFunctions(
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
operationName: 'Power',
|
operationName: 'Power',
|
||||||
code: 'switch',
|
code: 'switch',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
@ -506,6 +575,7 @@ List<SceneStaticFunction> acFunctions(
|
|||||||
icon: Assets.assetsFreezing,
|
icon: Assets.assetsFreezing,
|
||||||
operationName: 'Mode',
|
operationName: 'Mode',
|
||||||
code: 'mode',
|
code: 'mode',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsAcCooling,
|
icon: Assets.assetsAcCooling,
|
||||||
@ -530,6 +600,7 @@ List<SceneStaticFunction> acFunctions(
|
|||||||
icon: Assets.assetsTempreture,
|
icon: Assets.assetsTempreture,
|
||||||
operationName: 'Set Temperature',
|
operationName: 'Set Temperature',
|
||||||
code: 'temp_set',
|
code: 'temp_set',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsCelsiusDegrees,
|
icon: Assets.assetsCelsiusDegrees,
|
||||||
@ -544,6 +615,7 @@ List<SceneStaticFunction> acFunctions(
|
|||||||
icon: Assets.assetsFanSpeed,
|
icon: Assets.assetsFanSpeed,
|
||||||
operationName: 'Fan Speed',
|
operationName: 'Fan Speed',
|
||||||
code: 'level',
|
code: 'level',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsAcFanLow,
|
icon: Assets.assetsAcFanLow,
|
||||||
@ -573,6 +645,7 @@ List<SceneStaticFunction> acFunctions(
|
|||||||
icon: Assets.assetsChildLock,
|
icon: Assets.assetsChildLock,
|
||||||
operationName: 'Child Lock',
|
operationName: 'Child Lock',
|
||||||
code: 'child_lock',
|
code: 'child_lock',
|
||||||
|
functionValue: functionValue,
|
||||||
operationalValues: [
|
operationalValues: [
|
||||||
SceneOperationalValue(
|
SceneOperationalValue(
|
||||||
icon: Assets.assetsSceneChildLock,
|
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 deviceId;
|
||||||
final String operationName;
|
final String operationName;
|
||||||
final String uniqueCustomId;
|
final String uniqueCustomId;
|
||||||
|
final dynamic functionValue;
|
||||||
|
final String? deviceIcon;
|
||||||
|
|
||||||
SceneStaticFunction({
|
SceneStaticFunction({
|
||||||
required this.icon,
|
required this.icon,
|
||||||
@ -19,6 +21,8 @@ class SceneStaticFunction {
|
|||||||
required this.operationalValues,
|
required this.operationalValues,
|
||||||
required this.deviceId,
|
required this.deviceId,
|
||||||
required this.operationName,
|
required this.operationName,
|
||||||
|
required this.functionValue,
|
||||||
|
this.deviceIcon,
|
||||||
}) : uniqueCustomId = const Uuid().v4();
|
}) : uniqueCustomId = const Uuid().v4();
|
||||||
|
|
||||||
SceneStaticFunction copyWith({
|
SceneStaticFunction copyWith({
|
||||||
@ -28,6 +32,8 @@ class SceneStaticFunction {
|
|||||||
List<SceneOperationalValue>? operationalValues,
|
List<SceneOperationalValue>? operationalValues,
|
||||||
String? deviceId,
|
String? deviceId,
|
||||||
String? operationName,
|
String? operationName,
|
||||||
|
dynamic functionValue,
|
||||||
|
String? deviceIcon,
|
||||||
}) {
|
}) {
|
||||||
return SceneStaticFunction(
|
return SceneStaticFunction(
|
||||||
icon: icon ?? this.icon,
|
icon: icon ?? this.icon,
|
||||||
@ -36,6 +42,8 @@ class SceneStaticFunction {
|
|||||||
operationalValues: operationalValues ?? this.operationalValues,
|
operationalValues: operationalValues ?? this.operationalValues,
|
||||||
deviceId: deviceId ?? this.deviceId,
|
deviceId: deviceId ?? this.deviceId,
|
||||||
operationName: operationName ?? this.operationName,
|
operationName: operationName ?? this.operationName,
|
||||||
|
functionValue: functionValue ?? this.functionValue,
|
||||||
|
deviceIcon: deviceIcon ?? this.deviceIcon,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +54,9 @@ class SceneStaticFunction {
|
|||||||
'code': code,
|
'code': code,
|
||||||
'operationalValues': operationalValues.map((x) => x.toMap()).toList(),
|
'operationalValues': operationalValues.map((x) => x.toMap()).toList(),
|
||||||
'deviceId': deviceId,
|
'deviceId': deviceId,
|
||||||
'operationName': operationName
|
'operationName': operationName,
|
||||||
|
'functionValue': functionValue,
|
||||||
|
'deviceIcon': deviceIcon
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +70,8 @@ class SceneStaticFunction {
|
|||||||
),
|
),
|
||||||
deviceId: map['deviceId'] ?? '',
|
deviceId: map['deviceId'] ?? '',
|
||||||
operationName: map['operationName'] ?? '',
|
operationName: map['operationName'] ?? '',
|
||||||
|
functionValue: map['functionValue'] ?? '',
|
||||||
|
deviceIcon: map['deviceIcon'] ?? '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +82,7 @@ class SceneStaticFunction {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
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
|
@override
|
||||||
@ -82,6 +94,8 @@ class SceneStaticFunction {
|
|||||||
other.deviceName == deviceName &&
|
other.deviceName == deviceName &&
|
||||||
other.code == code &&
|
other.code == code &&
|
||||||
other.operationName == operationName &&
|
other.operationName == operationName &&
|
||||||
|
other.functionValue == functionValue &&
|
||||||
|
other.deviceIcon == deviceIcon &&
|
||||||
listEquals(other.operationalValues, operationalValues) &&
|
listEquals(other.operationalValues, operationalValues) &&
|
||||||
other.deviceId == deviceId;
|
other.deviceId == deviceId;
|
||||||
}
|
}
|
||||||
@ -93,6 +107,8 @@ class SceneStaticFunction {
|
|||||||
code.hashCode ^
|
code.hashCode ^
|
||||||
deviceId.hashCode ^
|
deviceId.hashCode ^
|
||||||
operationName.hashCode ^
|
operationName.hashCode ^
|
||||||
|
functionValue.hashCode ^
|
||||||
|
deviceIcon.hashCode ^
|
||||||
operationalValues.hashCode;
|
operationalValues.hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
class SceneModel {
|
class ScenesModel {
|
||||||
final String id;
|
final String id;
|
||||||
final String name;
|
final String name;
|
||||||
final Status status;
|
final Status status;
|
||||||
final Type type;
|
final Type type;
|
||||||
|
|
||||||
SceneModel({
|
ScenesModel({
|
||||||
required this.id,
|
required this.id,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.status,
|
required this.status,
|
||||||
required this.type,
|
required this.type,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory SceneModel.fromRawJson(String str) =>
|
factory ScenesModel.fromRawJson(String str) =>
|
||||||
SceneModel.fromJson(json.decode(str));
|
ScenesModel.fromJson(json.decode(str));
|
||||||
|
|
||||||
String toRawJson() => json.encode(toJson());
|
String toRawJson() => json.encode(toJson());
|
||||||
|
|
||||||
factory SceneModel.fromJson(Map<String, dynamic> json) => SceneModel(
|
factory ScenesModel.fromJson(Map<String, dynamic> json) => ScenesModel(
|
||||||
id: json["id"],
|
id: json["id"],
|
||||||
name: json["name"],
|
name: json["name"],
|
||||||
status: statusValues.map[json["status"]]!,
|
status: statusValues.map[json["status"]]!,
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.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/bloc/create_scene/create_scene_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/enum/create_scene_enum.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/scene/widgets/scene_list_tile.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
import 'package:syncrow_app/features/shared_widgets/default_scaffold.dart';
|
||||||
@ -40,9 +41,13 @@ class CreateSceneView extends StatelessWidget {
|
|||||||
Navigator.pushNamed(
|
Navigator.pushNamed(
|
||||||
context,
|
context,
|
||||||
Routes.sceneTasksRoute,
|
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(
|
DefaultContainer(
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.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/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/if_container.dart';
|
||||||
import 'package:syncrow_app/features/scene/widgets/if_then_containers/then_container.dart';
|
import 'package:syncrow_app/features/scene/widgets/if_then_containers/then_container.dart';
|
||||||
@ -14,8 +15,12 @@ class SceneTasksView extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final sceneSettings = ModalRoute.of(context)!.settings.arguments
|
||||||
|
as SceneSettingsRouteArguments;
|
||||||
return DefaultScaffold(
|
return DefaultScaffold(
|
||||||
title: StringsManager.createScene,
|
title: sceneSettings.sceneName.isNotEmpty
|
||||||
|
? sceneSettings.sceneName
|
||||||
|
: StringsManager.createScene,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
actions: [
|
actions: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -33,21 +38,21 @@ class SceneTasksView extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
const SingleChildScrollView(
|
SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 24,
|
height: 24,
|
||||||
),
|
),
|
||||||
// IF
|
// IF
|
||||||
IFDefaultContainer(),
|
const IFDefaultContainer(),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 8,
|
height: 8,
|
||||||
),
|
),
|
||||||
// THEN
|
// THEN
|
||||||
ThenDefaultContainer(),
|
ThenDefaultContainer(sceneId: sceneSettings.sceneId),
|
||||||
SizedBox(
|
const SizedBox(
|
||||||
height: 100,
|
height: 100,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -22,14 +22,16 @@ class ThenAddedTasksContainer extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
String operationValue = '';
|
String operationValue = '';
|
||||||
if (taskList.code.contains('countdown')) {
|
if (taskList.code.contains('countdown')) {
|
||||||
final duration = Duration(
|
final functionValue =
|
||||||
seconds:
|
taskList.functionValue ?? taskList.operationalValues.first.value;
|
||||||
int.tryParse(taskList.operationalValues.first.value.toString()) ??
|
final duration =
|
||||||
0);
|
Duration(seconds: int.tryParse(functionValue.toString()) ?? 0);
|
||||||
operationValue =
|
operationValue =
|
||||||
"${duration.inHours}h ${duration.inMinutes.remainder(60)}m ";
|
"${duration.inHours}h ${duration.inMinutes.remainder(60)}m ";
|
||||||
} else {
|
} else {
|
||||||
operationValue = taskList.operationalValues.first.value.toString();
|
final functionValue =
|
||||||
|
taskList.functionValue ?? taskList.operationalValues.first.value;
|
||||||
|
operationValue = functionValue.toString();
|
||||||
}
|
}
|
||||||
return DefaultContainer(
|
return DefaultContainer(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
|
@ -15,8 +15,11 @@ import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
|||||||
class ThenDefaultContainer extends StatelessWidget {
|
class ThenDefaultContainer extends StatelessWidget {
|
||||||
const ThenDefaultContainer({
|
const ThenDefaultContainer({
|
||||||
super.key,
|
super.key,
|
||||||
|
required this.sceneId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final String sceneId;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DefaultContainer(
|
return DefaultContainer(
|
||||||
@ -47,7 +50,32 @@ class ThenDefaultContainer extends StatelessWidget {
|
|||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
),
|
),
|
||||||
const LightDivider(),
|
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) {
|
builder: (context, state) {
|
||||||
if (state is AddSceneTask) {
|
if (state is AddSceneTask) {
|
||||||
final taskLists = state.tasksList;
|
final taskLists = state.tasksList;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
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';
|
import 'package:syncrow_app/features/scene/widgets/scene_view_widget/scene_item.dart';
|
||||||
|
|
||||||
class SceneGrid extends StatelessWidget {
|
class SceneGrid extends StatelessWidget {
|
||||||
final List<SceneModel> scenes;
|
final List<ScenesModel> scenes;
|
||||||
final String? loadingSceneId;
|
final String? loadingSceneId;
|
||||||
|
|
||||||
const SceneGrid({
|
const SceneGrid({
|
||||||
|
@ -2,15 +2,18 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.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_bloc.dart';
|
||||||
import 'package:syncrow_app/features/scene/bloc/scene_bloc/scene_event.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/default_container.dart';
|
||||||
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
import 'package:syncrow_app/features/shared_widgets/text_widgets/body_medium.dart';
|
||||||
|
|
||||||
import 'package:syncrow_app/generated/assets.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';
|
import 'package:syncrow_app/utils/resource_manager/color_manager.dart';
|
||||||
|
|
||||||
class SceneItem extends StatelessWidget {
|
class SceneItem extends StatelessWidget {
|
||||||
final SceneModel scene;
|
final ScenesModel scene;
|
||||||
final bool isLoading;
|
final bool isLoading;
|
||||||
|
|
||||||
const SceneItem({
|
const SceneItem({
|
||||||
@ -22,6 +25,17 @@ class SceneItem extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return DefaultContainer(
|
return DefaultContainer(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pushNamed(
|
||||||
|
context,
|
||||||
|
Routes.sceneTasksRoute,
|
||||||
|
arguments: SceneSettingsRouteArguments(
|
||||||
|
sceneType: CreateSceneEnum.tabToRun.name,
|
||||||
|
sceneId: scene.id,
|
||||||
|
sceneName: scene.name,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:syncrow_app/features/scene/model/create_scene_model.dart';
|
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/api_links_endpoints.dart';
|
||||||
import 'package:syncrow_app/services/api/http_service.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 {
|
try {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.getUnitScenes.replaceAll('{unitUuid}', unitId),
|
path: ApiEndpoints.getUnitScenes.replaceAll('{unitUuid}', unitId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
List<SceneModel> scenes = [];
|
List<ScenesModel> scenes = [];
|
||||||
for (var scene in json) {
|
for (var scene in json) {
|
||||||
scenes.add(SceneModel.fromJson(scene));
|
scenes.add(ScenesModel.fromJson(scene));
|
||||||
}
|
}
|
||||||
return scenes;
|
return scenes;
|
||||||
},
|
},
|
||||||
@ -54,4 +55,23 @@ class SceneApi {
|
|||||||
rethrow;
|
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