mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
finished ac devices
This commit is contained in:
@ -1,8 +1,5 @@
|
|||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
enum TempModes { hot, cold, wind }
|
|
||||||
|
|
||||||
enum FanSpeeds { auto, low, middle, high }
|
|
||||||
|
|
||||||
class AcStatusModel {
|
class AcStatusModel {
|
||||||
final String uuid;
|
final String uuid;
|
||||||
|
@ -3,9 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class BatchAcMode extends StatelessWidget {
|
class BatchAcMode extends StatelessWidget {
|
||||||
@ -27,15 +27,19 @@ class BatchAcMode extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
_buildIconContainer(context, TempModes.cold, Assets.freezing, value == TempModes.cold),
|
_buildIconContainer(context, TempModes.cold, Assets.freezing,
|
||||||
_buildIconContainer(context, TempModes.hot, Assets.acSun, value == TempModes.hot),
|
value == TempModes.cold),
|
||||||
_buildIconContainer(context, TempModes.wind, Assets.acAirConditioner, value == TempModes.wind),
|
_buildIconContainer(
|
||||||
|
context, TempModes.hot, Assets.acSun, value == TempModes.hot),
|
||||||
|
_buildIconContainer(context, TempModes.wind, Assets.acAirConditioner,
|
||||||
|
value == TempModes.wind),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIconContainer(BuildContext context, TempModes mode, String assetPath, bool isSelected) {
|
Widget _buildIconContainer(
|
||||||
|
BuildContext context, TempModes mode, String assetPath, bool isSelected) {
|
||||||
return Flexible(
|
return Flexible(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
@ -3,9 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class BatchFanSpeedControl extends StatelessWidget {
|
class BatchFanSpeedControl extends StatelessWidget {
|
||||||
@ -30,8 +30,10 @@ class BatchFanSpeedControl extends StatelessWidget {
|
|||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
_buildIconContainer(context, FanSpeeds.auto, Assets.acFanAuto, value == FanSpeeds.auto),
|
_buildIconContainer(context, FanSpeeds.auto, Assets.acFanAuto,
|
||||||
_buildIconContainer(context, FanSpeeds.low, Assets.acFanLow, value == FanSpeeds.low),
|
value == FanSpeeds.auto),
|
||||||
|
_buildIconContainer(context, FanSpeeds.low, Assets.acFanLow,
|
||||||
|
value == FanSpeeds.low),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
@ -39,8 +41,10 @@ class BatchFanSpeedControl extends StatelessWidget {
|
|||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
_buildIconContainer(context, FanSpeeds.middle, Assets.acFanMiddle, value == FanSpeeds.middle),
|
_buildIconContainer(context, FanSpeeds.middle, Assets.acFanMiddle,
|
||||||
_buildIconContainer(context, FanSpeeds.high, Assets.acFanHigh, value == FanSpeeds.high),
|
value == FanSpeeds.middle),
|
||||||
|
_buildIconContainer(context, FanSpeeds.high, Assets.acFanHigh,
|
||||||
|
value == FanSpeeds.high),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -48,7 +52,8 @@ class BatchFanSpeedControl extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIconContainer(BuildContext context, FanSpeeds speed, String assetPath, bool isSelected) {
|
Widget _buildIconContainer(BuildContext context, FanSpeeds speed,
|
||||||
|
String assetPath, bool isSelected) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<AcBloc>().add(
|
context.read<AcBloc>().add(
|
||||||
|
@ -3,9 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class AcMode extends StatelessWidget {
|
class AcMode extends StatelessWidget {
|
||||||
@ -27,15 +27,19 @@ class AcMode extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
_buildIconContainer(context, TempModes.cold, Assets.freezing, value == TempModes.cold),
|
_buildIconContainer(context, TempModes.cold, Assets.freezing,
|
||||||
_buildIconContainer(context, TempModes.hot, Assets.acSun, value == TempModes.hot),
|
value == TempModes.cold),
|
||||||
_buildIconContainer(context, TempModes.wind, Assets.acAirConditioner, value == TempModes.wind),
|
_buildIconContainer(
|
||||||
|
context, TempModes.hot, Assets.acSun, value == TempModes.hot),
|
||||||
|
_buildIconContainer(context, TempModes.wind, Assets.acAirConditioner,
|
||||||
|
value == TempModes.wind),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIconContainer(BuildContext context, TempModes mode, String assetPath, bool isSelected) {
|
Widget _buildIconContainer(
|
||||||
|
BuildContext context, TempModes mode, String assetPath, bool isSelected) {
|
||||||
return Flexible(
|
return Flexible(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
@ -3,9 +3,9 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/bloc/ac_event.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
import 'package:syncrow_web/pages/device_managment/shared/device_controls_container.dart';
|
||||||
import 'package:syncrow_web/utils/color_manager.dart';
|
import 'package:syncrow_web/utils/color_manager.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class FanSpeedControl extends StatelessWidget {
|
class FanSpeedControl extends StatelessWidget {
|
||||||
@ -29,8 +29,10 @@ class FanSpeedControl extends StatelessWidget {
|
|||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
_buildIconContainer(context, FanSpeeds.auto, Assets.acFanAuto, value == FanSpeeds.auto),
|
_buildIconContainer(context, FanSpeeds.auto, Assets.acFanAuto,
|
||||||
_buildIconContainer(context, FanSpeeds.low, Assets.acFanLow, value == FanSpeeds.low),
|
value == FanSpeeds.auto),
|
||||||
|
_buildIconContainer(context, FanSpeeds.low, Assets.acFanLow,
|
||||||
|
value == FanSpeeds.low),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
@ -38,8 +40,10 @@ class FanSpeedControl extends StatelessWidget {
|
|||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: [
|
children: [
|
||||||
_buildIconContainer(context, FanSpeeds.middle, Assets.acFanMiddle, value == FanSpeeds.middle),
|
_buildIconContainer(context, FanSpeeds.middle, Assets.acFanMiddle,
|
||||||
_buildIconContainer(context, FanSpeeds.high, Assets.acFanHigh, value == FanSpeeds.high),
|
value == FanSpeeds.middle),
|
||||||
|
_buildIconContainer(context, FanSpeeds.high, Assets.acFanHigh,
|
||||||
|
value == FanSpeeds.high),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@ -47,7 +51,8 @@ class FanSpeedControl extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIconContainer(BuildContext context, FanSpeeds speed, String assetPath, bool isSelected) {
|
Widget _buildIconContainer(BuildContext context, FanSpeeds speed,
|
||||||
|
String assetPath, bool isSelected) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context.read<AcBloc>().add(
|
context.read<AcBloc>().add(
|
||||||
|
@ -1,6 +1,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:flutter/material.dart';
|
|
||||||
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
|
|
||||||
part 'functions_bloc_event.dart';
|
part 'functions_bloc_event.dart';
|
||||||
@ -10,120 +11,32 @@ class FunctionBloc extends Bloc<FunctionBlocEvent, FunctionBlocState> {
|
|||||||
FunctionBloc() : super(const FunctionBlocState()) {
|
FunctionBloc() : super(const FunctionBlocState()) {
|
||||||
on<InitializeFunctions>(_onInitializeFunctions);
|
on<InitializeFunctions>(_onInitializeFunctions);
|
||||||
on<AddFunction>(_onAddFunction);
|
on<AddFunction>(_onAddFunction);
|
||||||
on<UpdateFunction>(_onUpdateFunctions);
|
on<SelectFunction>(_onSelectFunction);
|
||||||
on<UpdateFunctionValue>(_onUpdateFunctionValue);
|
|
||||||
on<UpdateFunctionCondition>(_onUpdateFunctionCondition);
|
|
||||||
on<RemoveFunction>(_onRemoveFunction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onAddFunction(AddFunction event, Emitter<FunctionBlocState> emit) {
|
void _onAddFunction(AddFunction event, Emitter<FunctionBlocState> emit) {
|
||||||
debugPrint('Adding function: ${event.functionData.function}');
|
final functions = List<DeviceFunctionData>.from(state.addedFunctions);
|
||||||
final functions = List<DeviceFunctionData>.from(state.functions);
|
|
||||||
|
|
||||||
// Find existing function data
|
|
||||||
final existingIndex = functions.indexWhere(
|
final existingIndex = functions.indexWhere(
|
||||||
(f) => f.function == event.functionData.function,
|
(f) => f.functionCode == event.functionData.functionCode,
|
||||||
);
|
);
|
||||||
|
|
||||||
// If function exists, preserve its value and condition
|
|
||||||
if (existingIndex != -1) {
|
if (existingIndex != -1) {
|
||||||
final existingData = functions[existingIndex];
|
final existingData = functions[existingIndex];
|
||||||
functions[existingIndex] = DeviceFunctionData(
|
functions[existingIndex] = DeviceFunctionData(
|
||||||
entityId: event.functionData.entityId,
|
entityId: event.functionData.entityId,
|
||||||
function: event.functionData.function,
|
functionCode: event.functionData.functionCode,
|
||||||
operationName: event.functionData.operationName,
|
operationName: event.functionData.operationName,
|
||||||
value: existingData.value, // Preserve the existing value
|
value: event.functionData.value ?? existingData.value,
|
||||||
condition: existingData.condition, // Preserve the existing condition
|
valueDescription: event.functionData.valueDescription ??
|
||||||
|
existingData.valueDescription,
|
||||||
|
condition: event.functionData.condition ?? existingData.condition,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
functions.add(event.functionData);
|
functions.add(event.functionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint('Functions after add: $functions');
|
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
functions: functions,
|
addedFunctions: functions,
|
||||||
selectedFunction: event.functionData.function,
|
selectedFunction: event.functionData.functionCode,
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onUpdateFunctions(
|
|
||||||
UpdateFunction event, Emitter<FunctionBlocState> emit) {
|
|
||||||
final functions = state.functions.map((data) {
|
|
||||||
return data.function == event.functionData.function
|
|
||||||
? event.functionData
|
|
||||||
: data;
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
emit(state.copyWith(functions: functions));
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onUpdateFunctionValue(
|
|
||||||
UpdateFunctionValue event,
|
|
||||||
Emitter<FunctionBlocState> emit,
|
|
||||||
) {
|
|
||||||
debugPrint('Updating function value: ${event.function} -> ${event.value}');
|
|
||||||
|
|
||||||
// Create a new list to ensure state immutability
|
|
||||||
final functions = List<DeviceFunctionData>.from(state.functions);
|
|
||||||
|
|
||||||
// Find the index of the function to update
|
|
||||||
final functionIndex = functions.indexWhere(
|
|
||||||
(data) => data.function == event.function,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (functionIndex != -1) {
|
|
||||||
// Update the existing function data while preserving other fields
|
|
||||||
final existingData = functions[functionIndex];
|
|
||||||
functions[functionIndex] = DeviceFunctionData(
|
|
||||||
entityId: existingData.entityId,
|
|
||||||
function: existingData.function,
|
|
||||||
operationName: existingData.operationName,
|
|
||||||
value: event.value,
|
|
||||||
condition: existingData.condition,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// If function doesn't exist, add it
|
|
||||||
functions.add(DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
function: event.function,
|
|
||||||
operationName: '',
|
|
||||||
value: event.value,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
debugPrint('Functions after update: $functions');
|
|
||||||
emit(state.copyWith(functions: functions));
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onUpdateFunctionCondition(
|
|
||||||
UpdateFunctionCondition event,
|
|
||||||
Emitter<FunctionBlocState> emit,
|
|
||||||
) {
|
|
||||||
final functions = state.functions.map((data) {
|
|
||||||
if (data.function == event.function) {
|
|
||||||
return DeviceFunctionData(
|
|
||||||
entityId: data.entityId,
|
|
||||||
function: data.function,
|
|
||||||
operationName: data.operationName,
|
|
||||||
value: data.value,
|
|
||||||
condition: event.condition,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
emit(state.copyWith(functions: functions));
|
|
||||||
}
|
|
||||||
|
|
||||||
void _onRemoveFunction(
|
|
||||||
RemoveFunction event, Emitter<FunctionBlocState> emit) {
|
|
||||||
final functions = state.functions
|
|
||||||
.where((data) => data.function != event.functionCode)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
|
||||||
functions: functions,
|
|
||||||
selectedFunction: functions.isEmpty ? null : state.selectedFunction,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,18 +44,25 @@ class FunctionBloc extends Bloc<FunctionBlocEvent, FunctionBlocState> {
|
|||||||
InitializeFunctions event,
|
InitializeFunctions event,
|
||||||
Emitter<FunctionBlocState> emit,
|
Emitter<FunctionBlocState> emit,
|
||||||
) {
|
) {
|
||||||
emit(state.copyWith(functions: event.functions));
|
emit(state.copyWith(addedFunctions: event.functions));
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceFunctionData? getFunction(String functionCode) {
|
DeviceFunctionData? getFunction(String functionCode) {
|
||||||
return state.functions.firstWhere(
|
return state.addedFunctions.firstWhere(
|
||||||
(data) => data.function == functionCode,
|
(data) => data.functionCode == functionCode,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
function: functionCode,
|
functionCode: functionCode,
|
||||||
operationName: '',
|
operationName: '',
|
||||||
value: null,
|
value: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FutureOr<void> _onSelectFunction(
|
||||||
|
SelectFunction event, Emitter<FunctionBlocState> emit) {
|
||||||
|
emit(state.copyWith(
|
||||||
|
selectedFunction: event.functionCode,
|
||||||
|
selectedOperationName: event.operationName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,48 +18,17 @@ class AddFunction extends FunctionBlocEvent {
|
|||||||
List<Object?> get props => [functionData];
|
List<Object?> get props => [functionData];
|
||||||
}
|
}
|
||||||
|
|
||||||
class UpdateFunction extends FunctionBlocEvent {
|
class SelectFunction extends FunctionBlocEvent {
|
||||||
final DeviceFunctionData functionData;
|
|
||||||
|
|
||||||
const UpdateFunction(this.functionData);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [functionData];
|
|
||||||
}
|
|
||||||
|
|
||||||
class UpdateFunctionValue extends FunctionBlocEvent {
|
|
||||||
final String function;
|
|
||||||
final dynamic value;
|
|
||||||
|
|
||||||
const UpdateFunctionValue({
|
|
||||||
required this.function,
|
|
||||||
required this.value,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [function, value];
|
|
||||||
}
|
|
||||||
|
|
||||||
class UpdateFunctionCondition extends FunctionBlocEvent {
|
|
||||||
final String function;
|
|
||||||
final String condition;
|
|
||||||
|
|
||||||
const UpdateFunctionCondition({
|
|
||||||
required this.function,
|
|
||||||
required this.condition,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [function, condition];
|
|
||||||
}
|
|
||||||
|
|
||||||
class RemoveFunction extends FunctionBlocEvent {
|
|
||||||
final String functionCode;
|
final String functionCode;
|
||||||
|
final String operationName;
|
||||||
|
|
||||||
const RemoveFunction(this.functionCode);
|
const SelectFunction({
|
||||||
|
required this.functionCode,
|
||||||
|
required this.operationName,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [functionCode];
|
List<Object?> get props => [functionCode, operationName];
|
||||||
}
|
}
|
||||||
|
|
||||||
class InitializeFunctions extends FunctionBlocEvent {
|
class InitializeFunctions extends FunctionBlocEvent {
|
||||||
|
@ -1,24 +1,29 @@
|
|||||||
part of 'functions_bloc_bloc.dart';
|
part of 'functions_bloc_bloc.dart';
|
||||||
|
|
||||||
class FunctionBlocState extends Equatable {
|
class FunctionBlocState extends Equatable {
|
||||||
final List<DeviceFunctionData> functions;
|
final List<DeviceFunctionData> addedFunctions;
|
||||||
final String? selectedFunction;
|
final String? selectedFunction;
|
||||||
|
final String? selectedOperationName;
|
||||||
const FunctionBlocState({
|
const FunctionBlocState({
|
||||||
this.functions = const [],
|
this.addedFunctions = const [],
|
||||||
this.selectedFunction,
|
this.selectedFunction,
|
||||||
|
this.selectedOperationName,
|
||||||
});
|
});
|
||||||
|
|
||||||
FunctionBlocState copyWith({
|
FunctionBlocState copyWith({
|
||||||
List<DeviceFunctionData>? functions,
|
List<DeviceFunctionData>? addedFunctions,
|
||||||
String? selectedFunction,
|
String? selectedFunction,
|
||||||
|
String? selectedOperationName,
|
||||||
}) {
|
}) {
|
||||||
return FunctionBlocState(
|
return FunctionBlocState(
|
||||||
functions: functions ?? this.functions,
|
addedFunctions: addedFunctions ?? this.addedFunctions,
|
||||||
selectedFunction: selectedFunction ?? this.selectedFunction,
|
selectedFunction: selectedFunction ?? this.selectedFunction,
|
||||||
|
selectedOperationName:
|
||||||
|
selectedOperationName ?? this.selectedOperationName,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [functions, selectedFunction];
|
List<Object?> get props =>
|
||||||
|
[addedFunctions, selectedFunction, selectedOperationName];
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/routine_model.dart';
|
import 'package:syncrow_web/pages/routiens/models/routine_model.dart';
|
||||||
import 'package:syncrow_web/services/routines_api.dart';
|
import 'package:syncrow_web/services/routines_api.dart';
|
||||||
@ -21,32 +22,33 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onAddToIfContainer(AddToIfContainer event, Emitter<RoutineState> emit) {
|
void _onAddToIfContainer(AddToIfContainer event, Emitter<RoutineState> emit) {
|
||||||
if (!_isDuplicate(state.ifItems, event.item)) {
|
// if (!_isDuplicate(state.ifItems, event.item)) {
|
||||||
final updatedIfItems = List<Map<String, dynamic>>.from(state.ifItems)
|
final updatedIfItems = List<Map<String, dynamic>>.from(state.ifItems)
|
||||||
..add(event.item);
|
..add(event.item);
|
||||||
emit(state.copyWith(ifItems: updatedIfItems));
|
emit(state.copyWith(ifItems: updatedIfItems));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onAddToThenContainer(
|
void _onAddToThenContainer(
|
||||||
AddToThenContainer event, Emitter<RoutineState> emit) {
|
AddToThenContainer event, Emitter<RoutineState> emit) {
|
||||||
if (!_isDuplicate(state.thenItems, event.item)) {
|
// if (!_isDuplicate(state.thenItems, event.item)) {
|
||||||
final updatedThenItems = List<Map<String, dynamic>>.from(state.thenItems)
|
final updatedThenItems = List<Map<String, dynamic>>.from(state.thenItems)
|
||||||
..add(event.item);
|
..add(event.item);
|
||||||
emit(state.copyWith(thenItems: updatedThenItems));
|
emit(state.copyWith(thenItems: updatedThenItems));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onAddFunction(AddFunctionToRoutine event, Emitter<RoutineState> emit) {
|
void _onAddFunction(AddFunctionToRoutine event, Emitter<RoutineState> emit) {
|
||||||
final functions = List<DeviceFunctionData>.from(state.selectedFunctions);
|
final functions = List<DeviceFunctionData>.from(state.selectedFunctions);
|
||||||
functions.add(event.function);
|
functions.add(event.function);
|
||||||
|
debugPrint("******" + functions.toString());
|
||||||
emit(state.copyWith(selectedFunctions: functions));
|
emit(state.copyWith(selectedFunctions: functions));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onRemoveFunction(RemoveFunction event, Emitter<RoutineState> emit) {
|
void _onRemoveFunction(RemoveFunction event, Emitter<RoutineState> emit) {
|
||||||
final functions = List<DeviceFunctionData>.from(state.selectedFunctions)
|
final functions = List<DeviceFunctionData>.from(state.selectedFunctions)
|
||||||
..removeWhere((f) =>
|
..removeWhere((f) =>
|
||||||
f.function == event.function.function &&
|
f.functionCode == event.function.functionCode &&
|
||||||
f.value == event.function.value);
|
f.value == event.function.value);
|
||||||
emit(state.copyWith(selectedFunctions: functions));
|
emit(state.copyWith(selectedFunctions: functions));
|
||||||
}
|
}
|
||||||
@ -55,12 +57,12 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
|||||||
emit(state.copyWith(selectedFunctions: []));
|
emit(state.copyWith(selectedFunctions: []));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isDuplicate(
|
// bool _isDuplicate(
|
||||||
List<Map<String, dynamic>> items, Map<String, dynamic> newItem) {
|
// List<Map<String, dynamic>> items, Map<String, dynamic> newItem) {
|
||||||
return items.any((item) =>
|
// return items.any((item) =>
|
||||||
item['imagePath'] == newItem['imagePath'] &&
|
// item['imagePath'] == newItem['imagePath'] &&
|
||||||
item['title'] == newItem['title']);
|
// item['title'] == newItem['title']);
|
||||||
}
|
// }
|
||||||
|
|
||||||
Future<void> _onLoadScenes(
|
Future<void> _onLoadScenes(
|
||||||
LoadScenes event, Emitter<RoutineState> emit) async {
|
LoadScenes event, Emitter<RoutineState> emit) async {
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
enum AcValuesEnums {
|
|
||||||
Cooling,
|
|
||||||
Heating,
|
|
||||||
Ventilation,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum TempModes { hot, cold, wind }
|
|
||||||
|
|
||||||
enum FanSpeeds { auto, low, middle, high }
|
|
@ -1,7 +1,9 @@
|
|||||||
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_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/ac/ac_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_function.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routiens/widgets/dialog_header.dart';
|
||||||
@ -13,42 +15,32 @@ import 'package:syncrow_web/pages/routiens/bloc/functions_bloc/functions_bloc_bl
|
|||||||
class ACHelper {
|
class ACHelper {
|
||||||
static Future<Map<String, dynamic>?> showACFunctionsDialog(
|
static Future<Map<String, dynamic>?> showACFunctionsDialog(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
List<DeviceFunction<dynamic>> functions,
|
List<DeviceFunction> functions,
|
||||||
|
AllDevicesModel? device,
|
||||||
|
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
) async {
|
) async {
|
||||||
List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
||||||
|
|
||||||
// Initialize the FunctionBloc with existing functions
|
|
||||||
final initialFunctions = acFunctions
|
|
||||||
.map((f) => DeviceFunctionData(
|
|
||||||
entityId: '',
|
|
||||||
function: f.code,
|
|
||||||
operationName: f.operationName,
|
|
||||||
value: null,
|
|
||||||
))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
return showDialog<Map<String, dynamic>?>(
|
return showDialog<Map<String, dynamic>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) =>
|
create: (_) => FunctionBloc()
|
||||||
FunctionBloc()..add(InitializeFunctions(initialFunctions)),
|
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
child: AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final selectedFunction = state.selectedFunction;
|
final selectedFunction = state.selectedFunction;
|
||||||
final selectedFunctionData = selectedFunction != null
|
final selectedOperationName = state.selectedOperationName;
|
||||||
? state.functions.firstWhere(
|
final selectedFunctionData = state.addedFunctions
|
||||||
(f) => f.function == selectedFunction,
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
function: selectedFunction,
|
functionCode: selectedFunction ?? '',
|
||||||
operationName: '',
|
operationName: '',
|
||||||
value: null,
|
value: null,
|
||||||
),
|
));
|
||||||
)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
width: selectedFunction != null ? 600 : 360,
|
width: selectedFunction != null ? 600 : 360,
|
||||||
@ -70,41 +62,27 @@ class ACHelper {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: selectedFunction != null ? 320 : 360,
|
width: selectedFunction != null ? 320 : 360,
|
||||||
child: _buildFunctionsList(
|
child: _buildFunctionsList(
|
||||||
context,
|
context: context,
|
||||||
acFunctions,
|
acFunctions: acFunctions,
|
||||||
(functionCode) =>
|
onFunctionSelected:
|
||||||
context.read<FunctionBloc>().add(
|
(functionCode, operationName) => context
|
||||||
AddFunction(
|
.read<FunctionBloc>()
|
||||||
functionData: DeviceFunctionData(
|
.add(SelectFunction(
|
||||||
entityId: '',
|
functionCode: functionCode,
|
||||||
function: functionCode,
|
operationName: operationName,
|
||||||
operationName: '',
|
)),
|
||||||
value: null,
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Value selector
|
// Value selector
|
||||||
if (selectedFunction != null)
|
if (selectedFunction != null)
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildValueSelector(
|
child: _buildValueSelector(
|
||||||
context,
|
context: context,
|
||||||
selectedFunction,
|
selectedFunction: selectedFunction,
|
||||||
selectedFunctionData,
|
selectedFunctionData: selectedFunctionData,
|
||||||
(value) => context.read<FunctionBloc>().add(
|
acFunctions: acFunctions,
|
||||||
UpdateFunctionValue(
|
device: device,
|
||||||
function: selectedFunction,
|
operationName: selectedOperationName ?? '',
|
||||||
value: value,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(condition) =>
|
|
||||||
context.read<FunctionBloc>().add(
|
|
||||||
UpdateFunctionCondition(
|
|
||||||
function: selectedFunction,
|
|
||||||
condition: condition,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
acFunctions,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -114,11 +92,10 @@ class ACHelper {
|
|||||||
onCancel: () {
|
onCancel: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
onConfirm: selectedFunction != null &&
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
selectedFunctionData?.value != null
|
|
||||||
? () {
|
? () {
|
||||||
/// add the functions to the routine bloc
|
/// add the functions to the routine bloc
|
||||||
for (var function in state.functions) {
|
for (var function in state.addedFunctions) {
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
AddFunctionToRoutine(
|
AddFunctionToRoutine(
|
||||||
function,
|
function,
|
||||||
@ -126,7 +103,9 @@ class ACHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Return the device data to be added to the container
|
// Return the device data to be added to the container
|
||||||
Navigator.pop(context);
|
Navigator.pop(context, {
|
||||||
|
'deviceId': functions.first.deviceId,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
isConfirmEnabled: selectedFunction != null,
|
isConfirmEnabled: selectedFunction != null,
|
||||||
@ -145,11 +124,11 @@ class ACHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Build functions list for AC functions dialog
|
/// Build functions list for AC functions dialog
|
||||||
static Widget _buildFunctionsList(
|
static Widget _buildFunctionsList({
|
||||||
BuildContext context,
|
required BuildContext context,
|
||||||
List<ACFunction> acFunctions,
|
required List<ACFunction> acFunctions,
|
||||||
Function(String) onFunctionSelected,
|
required Function(String, String) onFunctionSelected,
|
||||||
) {
|
}) {
|
||||||
return ListView.separated(
|
return ListView.separated(
|
||||||
shrinkWrap: false,
|
shrinkWrap: false,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
@ -182,29 +161,34 @@ class ACHelper {
|
|||||||
size: 16,
|
size: 16,
|
||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () => onFunctionSelected(function.code),
|
onTap: () => onFunctionSelected(
|
||||||
|
function.code,
|
||||||
|
function.operationName,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build value selector for AC functions dialog
|
/// Build value selector for AC functions dialog
|
||||||
static Widget _buildValueSelector(
|
static Widget _buildValueSelector({
|
||||||
BuildContext context,
|
required BuildContext context,
|
||||||
String selectedFunction,
|
required String selectedFunction,
|
||||||
DeviceFunctionData? selectedFunctionData,
|
required DeviceFunctionData? selectedFunctionData,
|
||||||
Function(dynamic) onValueChanged,
|
required List<ACFunction> acFunctions,
|
||||||
Function(String) onConditionChanged,
|
AllDevicesModel? device,
|
||||||
List<ACFunction> acFunctions,
|
required String operationName,
|
||||||
) {
|
}) {
|
||||||
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
|
if (selectedFunction == 'temp_set' || selectedFunction == 'temp_current') {
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 200;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context,
|
context: context,
|
||||||
initialValue,
|
initialValue: initialValue,
|
||||||
selectedFunctionData?.condition,
|
selectCode: selectedFunction,
|
||||||
onValueChanged,
|
currentCondition: selectedFunctionData?.condition,
|
||||||
onConditionChanged,
|
device: device,
|
||||||
|
operationName: operationName,
|
||||||
|
selectedFunctionData: selectedFunctionData,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,37 +197,43 @@ class ACHelper {
|
|||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
context,
|
context: context,
|
||||||
values,
|
values: values,
|
||||||
selectedFunctionData?.value,
|
selectedValue: selectedFunctionData?.value,
|
||||||
onValueChanged,
|
device: device,
|
||||||
|
operationName: operationName,
|
||||||
|
selectCode: selectedFunction,
|
||||||
|
selectedFunctionData: selectedFunctionData,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build temperature selector for AC functions dialog
|
/// Build temperature selector for AC functions dialog
|
||||||
static Widget _buildTemperatureSelector(
|
static Widget _buildTemperatureSelector({
|
||||||
BuildContext context,
|
required BuildContext context,
|
||||||
dynamic initialValue,
|
required dynamic initialValue,
|
||||||
String? currentCondition,
|
required String? currentCondition,
|
||||||
Function(dynamic) onValueChanged,
|
required String selectCode,
|
||||||
Function(String) onConditionChanged,
|
AllDevicesModel? device,
|
||||||
) {
|
required String operationName,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
}) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
_buildConditionToggle(
|
_buildConditionToggle(
|
||||||
context,
|
context,
|
||||||
currentCondition,
|
currentCondition,
|
||||||
onConditionChanged,
|
selectCode,
|
||||||
|
device,
|
||||||
|
operationName,
|
||||||
|
selectedFunctionData,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildTemperatureDisplay(context, initialValue),
|
_buildTemperatureDisplay(context, initialValue, device, operationName,
|
||||||
|
selectedFunctionData, selectCode),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildTemperatureSlider(
|
_buildTemperatureSlider(context, initialValue, device, operationName,
|
||||||
context,
|
selectedFunctionData, selectCode),
|
||||||
initialValue,
|
|
||||||
onValueChanged,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -252,13 +242,28 @@ class ACHelper {
|
|||||||
static Widget _buildConditionToggle(
|
static Widget _buildConditionToggle(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
String? currentCondition,
|
String? currentCondition,
|
||||||
Function(String) onConditionChanged,
|
String selectCode,
|
||||||
|
AllDevicesModel? device,
|
||||||
|
String operationName,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
// Function(String) onConditionChanged,
|
||||||
) {
|
) {
|
||||||
final conditions = ["<", "==", ">"];
|
final conditions = ["<", "==", ">"];
|
||||||
|
|
||||||
return ToggleButtons(
|
return ToggleButtons(
|
||||||
onPressed: (int index) {
|
onPressed: (int index) {
|
||||||
onConditionChanged(conditions[index]);
|
context.read<FunctionBloc>().add(
|
||||||
|
AddFunction(
|
||||||
|
functionData: DeviceFunctionData(
|
||||||
|
entityId: device?.uuid ?? '',
|
||||||
|
functionCode: selectCode,
|
||||||
|
operationName: operationName,
|
||||||
|
condition: conditions[index],
|
||||||
|
value: selectedFunctionData?.value,
|
||||||
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
selectedBorderColor: ColorsManager.primaryColorWithOpacity,
|
selectedBorderColor: ColorsManager.primaryColorWithOpacity,
|
||||||
@ -277,7 +282,12 @@ class ACHelper {
|
|||||||
|
|
||||||
/// Build temperature display for AC functions dialog
|
/// Build temperature display for AC functions dialog
|
||||||
static Widget _buildTemperatureDisplay(
|
static Widget _buildTemperatureDisplay(
|
||||||
BuildContext context, dynamic initialValue) {
|
BuildContext context,
|
||||||
|
dynamic initialValue,
|
||||||
|
AllDevicesModel? device,
|
||||||
|
String operationName,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
String selectCode) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -296,7 +306,10 @@ class ACHelper {
|
|||||||
static Widget _buildTemperatureSlider(
|
static Widget _buildTemperatureSlider(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
dynamic initialValue,
|
dynamic initialValue,
|
||||||
Function(dynamic) onValueChanged,
|
AllDevicesModel? device,
|
||||||
|
String operationName,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
String selectCode,
|
||||||
) {
|
) {
|
||||||
return Slider(
|
return Slider(
|
||||||
value: initialValue is int ? initialValue.toDouble() : 200.0,
|
value: initialValue is int ? initialValue.toDouble() : 200.0,
|
||||||
@ -305,17 +318,32 @@ class ACHelper {
|
|||||||
divisions: 14,
|
divisions: 14,
|
||||||
label: '${((initialValue ?? 200) / 10).toInt()}°C',
|
label: '${((initialValue ?? 200) / 10).toInt()}°C',
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
onValueChanged(value.toInt());
|
context.read<FunctionBloc>().add(
|
||||||
|
AddFunction(
|
||||||
|
functionData: DeviceFunctionData(
|
||||||
|
entityId: device?.uuid ?? '',
|
||||||
|
functionCode: selectCode,
|
||||||
|
operationName: operationName,
|
||||||
|
value: value,
|
||||||
|
condition: selectedFunctionData?.condition,
|
||||||
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Widget _buildOperationalValuesList(
|
static Widget _buildOperationalValuesList({
|
||||||
BuildContext context,
|
required BuildContext context,
|
||||||
List<dynamic> values,
|
required List<ACOperationalValue> values,
|
||||||
dynamic selectedValue,
|
required dynamic selectedValue,
|
||||||
Function(dynamic) onValueChanged,
|
AllDevicesModel? device,
|
||||||
) {
|
required String operationName,
|
||||||
|
required String selectCode,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
// required Function(dynamic) onValueChanged,
|
||||||
|
}) {
|
||||||
return ListView.builder(
|
return ListView.builder(
|
||||||
shrinkWrap: false,
|
shrinkWrap: false,
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
@ -349,7 +377,19 @@ class ACHelper {
|
|||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
onValueChanged(value.value);
|
context.read<FunctionBloc>().add(
|
||||||
|
AddFunction(
|
||||||
|
functionData: DeviceFunctionData(
|
||||||
|
entityId: device?.uuid ?? '',
|
||||||
|
functionCode: selectCode,
|
||||||
|
operationName: operationName,
|
||||||
|
value: value.value,
|
||||||
|
condition: selectedFunctionData?.condition,
|
||||||
|
valueDescription:
|
||||||
|
selectedFunctionData?.valueDescription,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/helper/ac_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/ac_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/helper/one_gang_switch_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/one_gang_switch_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/helper/three_gang_switch_helper.dart';
|
import 'package:syncrow_web/pages/routiens/helper/three_gang_switch_helper.dart';
|
||||||
@ -16,6 +18,7 @@ class DeviceDialogHelper {
|
|||||||
final result = await _getDialogForDeviceType(
|
final result = await _getDialogForDeviceType(
|
||||||
context,
|
context,
|
||||||
data['productType'],
|
data['productType'],
|
||||||
|
data,
|
||||||
functions,
|
functions,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -32,21 +35,30 @@ class DeviceDialogHelper {
|
|||||||
static Future<Map<String, dynamic>?> _getDialogForDeviceType(
|
static Future<Map<String, dynamic>?> _getDialogForDeviceType(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
String productType,
|
String productType,
|
||||||
|
Map<String, dynamic> data,
|
||||||
List<DeviceFunction> functions,
|
List<DeviceFunction> functions,
|
||||||
) async {
|
) async {
|
||||||
|
final routineBloc = context.read<RoutineBloc>();
|
||||||
|
final deviceSelectedFunctions = routineBloc.state.selectedFunctions
|
||||||
|
.where((f) => f.entityId == data['deviceId'])
|
||||||
|
.toList();
|
||||||
|
|
||||||
switch (productType) {
|
switch (productType) {
|
||||||
case 'AC':
|
case 'AC':
|
||||||
return ACHelper.showACFunctionsDialog(context, functions);
|
return ACHelper.showACFunctionsDialog(
|
||||||
|
context, functions, data['device'], deviceSelectedFunctions);
|
||||||
|
|
||||||
case '1G':
|
case '1G':
|
||||||
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
context, functions);
|
context, functions, data['device'], deviceSelectedFunctions);
|
||||||
case '2G':
|
case '2G':
|
||||||
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
context, functions);
|
context, functions);
|
||||||
case '3G':
|
case '3G':
|
||||||
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
context, functions);
|
context, functions);
|
||||||
break;
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/bloc/routine_bloc/routine_bloc.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_function.dart';
|
||||||
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/base_switch_function.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
import 'package:syncrow_web/pages/routiens/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
||||||
@ -11,59 +17,57 @@ import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
|||||||
class OneGangSwitchHelper {
|
class OneGangSwitchHelper {
|
||||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
List<DeviceFunction<dynamic>> functions,
|
List<DeviceFunction> functions,
|
||||||
|
AllDevicesModel? device,
|
||||||
|
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
) async {
|
) async {
|
||||||
List<DeviceFunction<dynamic>> switchFunctions = functions
|
List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
||||||
.where(
|
|
||||||
(f) => f is OneGangSwitchFunction || f is OneGangCountdownFunction)
|
|
||||||
.toList();
|
|
||||||
final selectedFunctionNotifier = ValueNotifier<String?>(null);
|
|
||||||
final selectedValueNotifier = ValueNotifier<dynamic>(null);
|
|
||||||
final selectedConditionNotifier = ValueNotifier<String?>("<");
|
|
||||||
final selectedConditionsNotifier =
|
|
||||||
ValueNotifier<List<bool>>([true, false, false]);
|
|
||||||
|
|
||||||
return showDialog<Map<String, dynamic>?>(
|
return showDialog<Map<String, dynamic>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return ValueListenableBuilder<String?>(
|
return BlocProvider(
|
||||||
valueListenable: selectedFunctionNotifier,
|
create: (_) => FunctionBloc()
|
||||||
builder: (context, selectedFunction, _) {
|
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
return AlertDialog(
|
child: AlertDialog(
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: EdgeInsets.zero,
|
||||||
content: Container(
|
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||||
width: selectedFunction != null ? 600 : 360,
|
builder: (context, state) {
|
||||||
height: 450,
|
final selectedFunction = state.selectedFunction;
|
||||||
decoration: BoxDecoration(
|
final selectedOperationName = state.selectedOperationName;
|
||||||
color: Colors.white,
|
final selectedFunctionData = state.addedFunctions
|
||||||
borderRadius: BorderRadius.circular(20),
|
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
),
|
orElse: () => DeviceFunctionData(
|
||||||
padding: const EdgeInsets.only(top: 20),
|
entityId: '',
|
||||||
child: Column(
|
functionCode: selectedFunction ?? '',
|
||||||
mainAxisSize: MainAxisSize.min,
|
operationName: '',
|
||||||
children: [
|
value: null,
|
||||||
const DialogHeader('1 Gang Light Switch Condition'),
|
));
|
||||||
Expanded(
|
return Container(
|
||||||
child: Row(
|
width: selectedFunction != null ? 600 : 360,
|
||||||
children: [
|
height: 450,
|
||||||
// Left side: Function list
|
decoration: BoxDecoration(
|
||||||
Expanded(
|
color: Colors.white,
|
||||||
child: ListView.separated(
|
borderRadius: BorderRadius.circular(20),
|
||||||
itemCount: switchFunctions.length,
|
),
|
||||||
separatorBuilder: (_, __) => const Divider(
|
padding: const EdgeInsets.only(top: 20),
|
||||||
color: ColorsManager.dividerColor,
|
child: Column(
|
||||||
),
|
mainAxisSize: MainAxisSize.min,
|
||||||
itemBuilder: (context, index) {
|
children: [
|
||||||
final function = switchFunctions[index];
|
const DialogHeader('1 Gang Light Switch Condition'),
|
||||||
return ValueListenableBuilder<String?>(
|
Expanded(
|
||||||
valueListenable: selectedFunctionNotifier,
|
child: Row(
|
||||||
builder: (context, selectedFunction, _) {
|
children: [
|
||||||
final isSelected =
|
// Left side: Function list
|
||||||
selectedFunction == function.code;
|
Expanded(
|
||||||
|
child: ListView.separated(
|
||||||
|
itemCount: acFunctions.length,
|
||||||
|
separatorBuilder: (_, __) => const Divider(
|
||||||
|
color: ColorsManager.dividerColor,
|
||||||
|
),
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final function = acFunctions[index];
|
||||||
return ListTile(
|
return ListTile(
|
||||||
tileColor: isSelected
|
|
||||||
? Colors.grey.shade100
|
|
||||||
: null,
|
|
||||||
leading: SvgPicture.asset(
|
leading: SvgPicture.asset(
|
||||||
function.icon,
|
function.icon,
|
||||||
width: 24,
|
width: 24,
|
||||||
@ -79,191 +83,413 @@ class OneGangSwitchHelper {
|
|||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
selectedFunctionNotifier.value =
|
context
|
||||||
function.code;
|
.read<FunctionBloc>()
|
||||||
selectedValueNotifier.value =
|
.add(SelectFunction(
|
||||||
function is OneGangCountdownFunction
|
functionCode: function.code,
|
||||||
? 0
|
operationName:
|
||||||
: null;
|
function.operationName,
|
||||||
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
),
|
||||||
},
|
),
|
||||||
),
|
// Right side: Value selector
|
||||||
|
if (selectedFunction != null)
|
||||||
|
Expanded(
|
||||||
|
child: _buildValueSelector(
|
||||||
|
context: context,
|
||||||
|
selectedFunction: selectedFunction,
|
||||||
|
selectedFunctionData: selectedFunctionData,
|
||||||
|
acFunctions: acFunctions,
|
||||||
|
device: device,
|
||||||
|
operationName: selectedOperationName ?? '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// ValueListenableBuilder<String?>(
|
||||||
|
// valueListenable: selectedFunctionNotifier,
|
||||||
|
// builder: (context, selectedFunction, _) {
|
||||||
|
// final selectedFn =
|
||||||
|
// switchFunctions.firstWhere(
|
||||||
|
// (f) => f.code == selectedFunction,
|
||||||
|
// );
|
||||||
|
// return Expanded(
|
||||||
|
// child: selectedFn
|
||||||
|
// is OneGangCountdownFunction
|
||||||
|
// ? _buildCountDownSelector(
|
||||||
|
// context,
|
||||||
|
// selectedValueNotifier,
|
||||||
|
// selectedConditionNotifier,
|
||||||
|
// selectedConditionsNotifier,
|
||||||
|
// )
|
||||||
|
// : _buildOperationalValuesList(
|
||||||
|
// context,
|
||||||
|
// selectedFn as BaseSwitchFunction,
|
||||||
|
// selectedValueNotifier,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
// Right side: Value selector
|
),
|
||||||
if (selectedFunction != null)
|
Container(
|
||||||
ValueListenableBuilder<String?>(
|
height: 1,
|
||||||
valueListenable: selectedFunctionNotifier,
|
width: double.infinity,
|
||||||
builder: (context, selectedFunction, _) {
|
color: ColorsManager.greyColor,
|
||||||
final selectedFn = switchFunctions.firstWhere(
|
),
|
||||||
(f) => f.code == selectedFunction,
|
DialogFooter(
|
||||||
);
|
onCancel: () {
|
||||||
return Expanded(
|
Navigator.pop(context);
|
||||||
child: selectedFn is OneGangCountdownFunction
|
},
|
||||||
? _buildCountDownSelector(
|
onConfirm: state.addedFunctions.isNotEmpty
|
||||||
context,
|
? () {
|
||||||
selectedValueNotifier,
|
/// add the functions to the routine bloc
|
||||||
selectedConditionNotifier,
|
for (var function in state.addedFunctions) {
|
||||||
selectedConditionsNotifier,
|
context.read<RoutineBloc>().add(
|
||||||
)
|
AddFunctionToRoutine(
|
||||||
: _buildOperationalValuesList(
|
function,
|
||||||
context,
|
),
|
||||||
selectedFn as BaseSwitchFunction,
|
);
|
||||||
selectedValueNotifier,
|
}
|
||||||
),
|
// Return the device data to be added to the container
|
||||||
);
|
Navigator.pop(context, {
|
||||||
},
|
'deviceId': functions.first.deviceId,
|
||||||
),
|
});
|
||||||
],
|
}
|
||||||
),
|
: null,
|
||||||
|
isConfirmEnabled: selectedFunction != null,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
Container(
|
);
|
||||||
height: 1,
|
},
|
||||||
width: double.infinity,
|
),
|
||||||
color: ColorsManager.greyColor,
|
));
|
||||||
),
|
},
|
||||||
DialogFooter(
|
);
|
||||||
onCancel: () => Navigator.pop(context),
|
}
|
||||||
onConfirm: selectedFunctionNotifier.value != null &&
|
|
||||||
selectedValueNotifier.value != null
|
static Widget _buildValueSelector({
|
||||||
? () {
|
required BuildContext context,
|
||||||
final selectedFn = switchFunctions.firstWhere(
|
required String selectedFunction,
|
||||||
(f) => f.code == selectedFunctionNotifier.value,
|
required DeviceFunctionData? selectedFunctionData,
|
||||||
);
|
required List<ACFunction> acFunctions,
|
||||||
final value = selectedValueNotifier.value;
|
AllDevicesModel? device,
|
||||||
final functionData = DeviceFunctionData(
|
required String operationName,
|
||||||
entityId: selectedFn.deviceId,
|
}) {
|
||||||
function: selectedFn.code,
|
if (selectedFunction == 'countdown_1') {
|
||||||
operationName: selectedFn.operationName,
|
final initialValue = selectedFunctionData?.value ?? 200;
|
||||||
value: value,
|
return _buildTemperatureSelector(
|
||||||
condition: selectedConditionNotifier.value,
|
context: context,
|
||||||
valueDescription:
|
initialValue: initialValue,
|
||||||
selectedFn is OneGangCountdownFunction
|
selectCode: selectedFunction,
|
||||||
? '${value} sec'
|
currentCondition: selectedFunctionData?.condition,
|
||||||
: ((selectedFn as BaseSwitchFunction)
|
device: device,
|
||||||
.getOperationalValues()
|
operationName: operationName,
|
||||||
.firstWhere((v) => v.value == value)
|
selectedFunctionData: selectedFunctionData,
|
||||||
.description),
|
);
|
||||||
);
|
}
|
||||||
Navigator.pop(
|
|
||||||
context, {selectedFn.code: functionData});
|
final selectedFn =
|
||||||
}
|
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
: null,
|
final values = selectedFn.getOperationalValues();
|
||||||
isConfirmEnabled: selectedFunctionNotifier.value != null,
|
|
||||||
),
|
return _buildOperationalValuesList(
|
||||||
],
|
context: context,
|
||||||
|
values: values,
|
||||||
|
selectedValue: selectedFunctionData?.value,
|
||||||
|
device: device,
|
||||||
|
operationName: operationName,
|
||||||
|
selectCode: selectedFunction,
|
||||||
|
selectedFunctionData: selectedFunctionData,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Widget _buildTemperatureSelector({
|
||||||
|
required BuildContext context,
|
||||||
|
required dynamic initialValue,
|
||||||
|
required String? currentCondition,
|
||||||
|
required String selectCode,
|
||||||
|
AllDevicesModel? device,
|
||||||
|
required String operationName,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
}) {
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
_buildConditionToggle(
|
||||||
|
context,
|
||||||
|
currentCondition,
|
||||||
|
selectCode,
|
||||||
|
device,
|
||||||
|
operationName,
|
||||||
|
selectedFunctionData,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildTemperatureDisplay(context, initialValue, device, operationName,
|
||||||
|
selectedFunctionData, selectCode),
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
_buildTemperatureSlider(context, initialValue, device, operationName,
|
||||||
|
selectedFunctionData, selectCode),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build condition toggle for AC functions dialog
|
||||||
|
static Widget _buildConditionToggle(
|
||||||
|
BuildContext context,
|
||||||
|
String? currentCondition,
|
||||||
|
String selectCode,
|
||||||
|
AllDevicesModel? device,
|
||||||
|
String operationName,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
// Function(String) onConditionChanged,
|
||||||
|
) {
|
||||||
|
final conditions = ["<", "==", ">"];
|
||||||
|
|
||||||
|
return ToggleButtons(
|
||||||
|
onPressed: (int index) {
|
||||||
|
context.read<FunctionBloc>().add(
|
||||||
|
AddFunction(
|
||||||
|
functionData: DeviceFunctionData(
|
||||||
|
entityId: device?.uuid ?? '',
|
||||||
|
functionCode: selectCode,
|
||||||
|
operationName: operationName,
|
||||||
|
condition: conditions[index],
|
||||||
|
value: selectedFunctionData?.value,
|
||||||
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
).then((value) {
|
|
||||||
selectedFunctionNotifier.dispose();
|
|
||||||
selectedValueNotifier.dispose();
|
|
||||||
selectedConditionNotifier.dispose();
|
|
||||||
selectedConditionsNotifier.dispose();
|
|
||||||
return value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static Widget _buildCountDownSelector(
|
|
||||||
BuildContext context,
|
|
||||||
ValueNotifier<dynamic> valueNotifier,
|
|
||||||
ValueNotifier<String?> conditionNotifier,
|
|
||||||
ValueNotifier<List<bool>> conditionsNotifier,
|
|
||||||
) {
|
|
||||||
return ValueListenableBuilder<dynamic>(
|
|
||||||
valueListenable: valueNotifier,
|
|
||||||
builder: (context, value, _) {
|
|
||||||
return Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
ValueListenableBuilder<List<bool>>(
|
|
||||||
valueListenable: conditionsNotifier,
|
|
||||||
builder: (context, selectedConditions, _) {
|
|
||||||
return ToggleButtons(
|
|
||||||
onPressed: (int index) {
|
|
||||||
final newConditions = List<bool>.filled(3, false);
|
|
||||||
newConditions[index] = true;
|
|
||||||
conditionsNotifier.value = newConditions;
|
|
||||||
conditionNotifier.value = index == 0
|
|
||||||
? "<"
|
|
||||||
: index == 1
|
|
||||||
? "=="
|
|
||||||
: ">";
|
|
||||||
},
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
||||||
selectedBorderColor: ColorsManager.primaryColorWithOpacity,
|
|
||||||
selectedColor: Colors.white,
|
|
||||||
fillColor: ColorsManager.primaryColorWithOpacity,
|
|
||||||
color: ColorsManager.primaryColorWithOpacity,
|
|
||||||
constraints: const BoxConstraints(
|
|
||||||
minHeight: 40.0,
|
|
||||||
minWidth: 40.0,
|
|
||||||
),
|
|
||||||
isSelected: selectedConditions,
|
|
||||||
children: const [Text("<"), Text("="), Text(">")],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Text(
|
|
||||||
'${value ?? 0} sec',
|
|
||||||
style: Theme.of(context).textTheme.headlineMedium,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20),
|
|
||||||
Slider(
|
|
||||||
value: (value ?? 0).toDouble(),
|
|
||||||
min: 0,
|
|
||||||
max: 300,
|
|
||||||
divisions: 300,
|
|
||||||
onChanged: (newValue) {
|
|
||||||
valueNotifier.value = newValue.toInt();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
selectedBorderColor: ColorsManager.primaryColorWithOpacity,
|
||||||
|
selectedColor: Colors.white,
|
||||||
|
fillColor: ColorsManager.primaryColorWithOpacity,
|
||||||
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
minHeight: 40.0,
|
||||||
|
minWidth: 40.0,
|
||||||
|
),
|
||||||
|
isSelected:
|
||||||
|
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Widget _buildOperationalValuesList(
|
/// Build temperature display for AC functions dialog
|
||||||
|
static Widget _buildTemperatureDisplay(
|
||||||
|
BuildContext context,
|
||||||
|
dynamic initialValue,
|
||||||
|
AllDevicesModel? device,
|
||||||
|
String operationName,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
String selectCode) {
|
||||||
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: ColorsManager.primaryColorWithOpacity.withOpacity(0.1),
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'${initialValue ?? 0} sec',
|
||||||
|
style: context.textTheme.headlineMedium!.copyWith(
|
||||||
|
color: ColorsManager.primaryColorWithOpacity,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Widget _buildTemperatureSlider(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
BaseSwitchFunction function,
|
dynamic initialValue,
|
||||||
ValueNotifier<dynamic> valueNotifier,
|
AllDevicesModel? device,
|
||||||
|
String operationName,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
String selectCode,
|
||||||
) {
|
) {
|
||||||
final values = function.getOperationalValues();
|
return Slider(
|
||||||
return ValueListenableBuilder<dynamic>(
|
value: (initialValue ?? 0).toDouble(),
|
||||||
valueListenable: valueNotifier,
|
min: 0,
|
||||||
builder: (context, selectedValue, _) {
|
max: 300,
|
||||||
return ListView.builder(
|
divisions: 300,
|
||||||
itemCount: values.length,
|
onChanged: (value) {
|
||||||
itemBuilder: (context, index) {
|
context.read<FunctionBloc>().add(
|
||||||
final value = values[index];
|
AddFunction(
|
||||||
return ListTile(
|
functionData: DeviceFunctionData(
|
||||||
leading: SvgPicture.asset(
|
entityId: device?.uuid ?? '',
|
||||||
value.icon,
|
functionCode: selectCode,
|
||||||
width: 24,
|
operationName: operationName,
|
||||||
height: 24,
|
value: value,
|
||||||
),
|
condition: selectedFunctionData?.condition,
|
||||||
title: Text(
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
value.description,
|
),
|
||||||
style: context.textTheme.bodyMedium,
|
|
||||||
),
|
|
||||||
trailing: Radio<dynamic>(
|
|
||||||
value: value.value,
|
|
||||||
groupValue: selectedValue,
|
|
||||||
onChanged: (newValue) {
|
|
||||||
valueNotifier.value = newValue;
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Widget _buildOperationalValuesList({
|
||||||
|
required BuildContext context,
|
||||||
|
required List<ACOperationalValue> values,
|
||||||
|
required dynamic selectedValue,
|
||||||
|
AllDevicesModel? device,
|
||||||
|
required String operationName,
|
||||||
|
required String selectCode,
|
||||||
|
DeviceFunctionData? selectedFunctionData,
|
||||||
|
// required Function(dynamic) onValueChanged,
|
||||||
|
}) {
|
||||||
|
return ListView.builder(
|
||||||
|
shrinkWrap: false,
|
||||||
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
|
itemCount: values.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final value = values[index];
|
||||||
|
final isSelected = selectedValue == value.value;
|
||||||
|
return ListTile(
|
||||||
|
leading: SvgPicture.asset(
|
||||||
|
value.icon,
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
placeholderBuilder: (BuildContext context) => Container(
|
||||||
|
width: 24,
|
||||||
|
height: 24,
|
||||||
|
color: Colors.transparent,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
value.description,
|
||||||
|
style: context.textTheme.bodyMedium,
|
||||||
|
),
|
||||||
|
trailing: Icon(
|
||||||
|
isSelected
|
||||||
|
? Icons.radio_button_checked
|
||||||
|
: Icons.radio_button_unchecked,
|
||||||
|
size: 24,
|
||||||
|
color: isSelected
|
||||||
|
? ColorsManager.primaryColorWithOpacity
|
||||||
|
: ColorsManager.textGray,
|
||||||
|
),
|
||||||
|
onTap: () {
|
||||||
|
if (!isSelected) {
|
||||||
|
context.read<FunctionBloc>().add(
|
||||||
|
AddFunction(
|
||||||
|
functionData: DeviceFunctionData(
|
||||||
|
entityId: device?.uuid ?? '',
|
||||||
|
functionCode: selectCode,
|
||||||
|
operationName: operationName,
|
||||||
|
value: value.value,
|
||||||
|
condition: selectedFunctionData?.condition,
|
||||||
|
valueDescription:
|
||||||
|
selectedFunctionData?.valueDescription,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static Widget _buildCountDownSelector(
|
||||||
|
// BuildContext context,
|
||||||
|
// ValueNotifier<dynamic> valueNotifier,
|
||||||
|
// ValueNotifier<String?> conditionNotifier,
|
||||||
|
// ValueNotifier<List<bool>> conditionsNotifier,
|
||||||
|
// ) {
|
||||||
|
// return ValueListenableBuilder<dynamic>(
|
||||||
|
// valueListenable: valueNotifier,
|
||||||
|
// builder: (context, value, _) {
|
||||||
|
// return Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
// children: [
|
||||||
|
// ValueListenableBuilder<List<bool>>(
|
||||||
|
// valueListenable: conditionsNotifier,
|
||||||
|
// builder: (context, selectedConditions, _) {
|
||||||
|
// return ToggleButtons(
|
||||||
|
// onPressed: (int index) {
|
||||||
|
// final newConditions = List<bool>.filled(3, false);
|
||||||
|
// newConditions[index] = true;
|
||||||
|
// conditionsNotifier.value = newConditions;
|
||||||
|
// conditionNotifier.value = index == 0
|
||||||
|
// ? "<"
|
||||||
|
// : index == 1
|
||||||
|
// ? "=="
|
||||||
|
// : ">";
|
||||||
|
// },
|
||||||
|
// borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||||
|
// selectedBorderColor: ColorsManager.primaryColorWithOpacity,
|
||||||
|
// selectedColor: Colors.white,
|
||||||
|
// fillColor: ColorsManager.primaryColorWithOpacity,
|
||||||
|
// color: ColorsManager.primaryColorWithOpacity,
|
||||||
|
// constraints: const BoxConstraints(
|
||||||
|
// minHeight: 40.0,
|
||||||
|
// minWidth: 40.0,
|
||||||
|
// ),
|
||||||
|
// isSelected: selectedConditions,
|
||||||
|
// children: const [Text("<"), Text("="), Text(">")],
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 20),
|
||||||
|
// Text(
|
||||||
|
// '${value ?? 0} sec',
|
||||||
|
// style: Theme.of(context).textTheme.headlineMedium,
|
||||||
|
// ),
|
||||||
|
// const SizedBox(height: 20),
|
||||||
|
// Slider(
|
||||||
|
// value: (value ?? 0).toDouble(),
|
||||||
|
// min: 0,
|
||||||
|
// max: 300,
|
||||||
|
// divisions: 300,
|
||||||
|
// onChanged: (newValue) {
|
||||||
|
// valueNotifier.value = newValue.toInt();
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static Widget _buildOperationalValuesList(
|
||||||
|
// BuildContext context,
|
||||||
|
// BaseSwitchFunction function,
|
||||||
|
// ValueNotifier<dynamic> valueNotifier,
|
||||||
|
// ) {
|
||||||
|
// final values = function.getOperationalValues();
|
||||||
|
// return ValueListenableBuilder<dynamic>(
|
||||||
|
// valueListenable: valueNotifier,
|
||||||
|
// builder: (context, selectedValue, _) {
|
||||||
|
// return ListView.builder(
|
||||||
|
// itemCount: values.length,
|
||||||
|
// itemBuilder: (context, index) {
|
||||||
|
// final value = values[index];
|
||||||
|
// return ListTile(
|
||||||
|
// leading: SvgPicture.asset(
|
||||||
|
// value.icon,
|
||||||
|
// width: 24,
|
||||||
|
// height: 24,
|
||||||
|
// ),
|
||||||
|
// title: Text(
|
||||||
|
// value.description,
|
||||||
|
// style: context.textTheme.bodyMedium,
|
||||||
|
// ),
|
||||||
|
// trailing: Radio<dynamic>(
|
||||||
|
// value: value.value,
|
||||||
|
// groupValue: selectedValue,
|
||||||
|
// onChanged: (newValue) {
|
||||||
|
// valueNotifier.value = newValue;
|
||||||
|
// },
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ class ThreeGangSwitchHelper {
|
|||||||
final value = selectedValueNotifier.value;
|
final value = selectedValueNotifier.value;
|
||||||
final functionData = DeviceFunctionData(
|
final functionData = DeviceFunctionData(
|
||||||
entityId: selectedFn.deviceId,
|
entityId: selectedFn.deviceId,
|
||||||
function: selectedFn.code,
|
functionCode: selectedFn.code,
|
||||||
operationName: selectedFn.operationName,
|
operationName: selectedFn.operationName,
|
||||||
value: value,
|
value: value,
|
||||||
condition: selectedConditionNotifier.value,
|
condition: selectedConditionNotifier.value,
|
||||||
|
@ -138,7 +138,7 @@ class TwoGangSwitchHelper {
|
|||||||
final value = selectedValueNotifier.value;
|
final value = selectedValueNotifier.value;
|
||||||
final functionData = DeviceFunctionData(
|
final functionData = DeviceFunctionData(
|
||||||
entityId: selectedFn.deviceId,
|
entityId: selectedFn.deviceId,
|
||||||
function: selectedFn.code,
|
functionCode: selectedFn.code,
|
||||||
operationName: selectedFn.operationName,
|
operationName: selectedFn.operationName,
|
||||||
value: value,
|
value: value,
|
||||||
condition: selectedConditionNotifier.value,
|
condition: selectedConditionNotifier.value,
|
||||||
|
@ -1,25 +1,17 @@
|
|||||||
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
import 'package:syncrow_web/pages/device_managment/ac/model/ac_model.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/ac/ac_operational_value.dart';
|
import 'package:syncrow_web/pages/routiens/models/ac/ac_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||||
|
import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
abstract class ACFunction extends DeviceFunction<AcStatusModel> {
|
abstract class ACFunction extends DeviceFunction<AcStatusModel> {
|
||||||
ACFunction({
|
ACFunction({
|
||||||
required String deviceId,
|
required super.deviceId,
|
||||||
required String deviceName,
|
required super.deviceName,
|
||||||
required String code,
|
required super.code,
|
||||||
required String operationName,
|
required super.operationName,
|
||||||
required String icon,
|
required super.icon,
|
||||||
}) : super(
|
});
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
code: code,
|
|
||||||
operationName: operationName,
|
|
||||||
icon: icon,
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue);
|
|
||||||
|
|
||||||
List<ACOperationalValue> getOperationalValues();
|
List<ACOperationalValue> getOperationalValues();
|
||||||
}
|
}
|
||||||
@ -32,11 +24,6 @@ class SwitchFunction extends ACFunction {
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
|
||||||
return currentStatus.copyWith(acSwitch: newValue as bool);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ACOperationalValue> getOperationalValues() => [
|
List<ACOperationalValue> getOperationalValues() => [
|
||||||
ACOperationalValue(
|
ACOperationalValue(
|
||||||
@ -60,27 +47,22 @@ class ModeFunction extends ACFunction {
|
|||||||
icon: Assets.assetsFreezing,
|
icon: Assets.assetsFreezing,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
|
||||||
return currentStatus.copyWith(modeString: (newValue as TempModes).toString().split('.').last);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ACOperationalValue> getOperationalValues() => [
|
List<ACOperationalValue> getOperationalValues() => [
|
||||||
ACOperationalValue(
|
ACOperationalValue(
|
||||||
icon: Assets.assetsAcCooling,
|
icon: Assets.assetsAcCooling,
|
||||||
description: "Cooling",
|
description: "Cooling",
|
||||||
value: TempModes.cold,
|
value: TempModes.cold.name,
|
||||||
),
|
),
|
||||||
ACOperationalValue(
|
ACOperationalValue(
|
||||||
icon: Assets.assetsAcHeating,
|
icon: Assets.assetsAcHeating,
|
||||||
description: "Heating",
|
description: "Heating",
|
||||||
value: TempModes.hot,
|
value: TempModes.hot.name,
|
||||||
),
|
),
|
||||||
ACOperationalValue(
|
ACOperationalValue(
|
||||||
icon: Assets.assetsFanSpeed,
|
icon: Assets.assetsFanSpeed,
|
||||||
description: "Ventilation",
|
description: "Ventilation",
|
||||||
value: TempModes.wind,
|
value: TempModes.wind.name,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -100,11 +82,6 @@ class TempSetFunction extends ACFunction {
|
|||||||
icon: Assets.assetsTempreture,
|
icon: Assets.assetsTempreture,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
|
||||||
return currentStatus.copyWith(tempSet: newValue as int);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ACOperationalValue> getOperationalValues() {
|
List<ACOperationalValue> getOperationalValues() {
|
||||||
List<ACOperationalValue> values = [];
|
List<ACOperationalValue> values = [];
|
||||||
@ -127,32 +104,27 @@ class LevelFunction extends ACFunction {
|
|||||||
icon: Assets.assetsFanSpeed,
|
icon: Assets.assetsFanSpeed,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
|
||||||
return currentStatus.copyWith(fanSpeedsString: (newValue as FanSpeeds).toString().split('.').last);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ACOperationalValue> getOperationalValues() => [
|
List<ACOperationalValue> getOperationalValues() => [
|
||||||
ACOperationalValue(
|
ACOperationalValue(
|
||||||
icon: Assets.assetsAcFanLow,
|
icon: Assets.assetsAcFanLow,
|
||||||
description: "LOW",
|
description: "LOW",
|
||||||
value: FanSpeeds.low,
|
value: FanSpeeds.low.name,
|
||||||
),
|
),
|
||||||
ACOperationalValue(
|
ACOperationalValue(
|
||||||
icon: Assets.assetsAcFanMiddle,
|
icon: Assets.assetsAcFanMiddle,
|
||||||
description: "MIDDLE",
|
description: "MIDDLE",
|
||||||
value: FanSpeeds.middle,
|
value: FanSpeeds.middle.name,
|
||||||
),
|
),
|
||||||
ACOperationalValue(
|
ACOperationalValue(
|
||||||
icon: Assets.assetsAcFanHigh,
|
icon: Assets.assetsAcFanHigh,
|
||||||
description: "HIGH",
|
description: "HIGH",
|
||||||
value: FanSpeeds.high,
|
value: FanSpeeds.high.name,
|
||||||
),
|
),
|
||||||
ACOperationalValue(
|
ACOperationalValue(
|
||||||
icon: Assets.assetsAcFanAuto,
|
icon: Assets.assetsAcFanAuto,
|
||||||
description: "AUTO",
|
description: "AUTO",
|
||||||
value: FanSpeeds.auto,
|
value: FanSpeeds.auto.name,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -165,11 +137,6 @@ class ChildLockFunction extends ACFunction {
|
|||||||
icon: Assets.assetsChildLock,
|
icon: Assets.assetsChildLock,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
AcStatusModel execute(AcStatusModel currentStatus, dynamic newValue) {
|
|
||||||
return currentStatus.copyWith(childLock: newValue as bool);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<ACOperationalValue> getOperationalValues() => [
|
List<ACOperationalValue> getOperationalValues() => [
|
||||||
ACOperationalValue(
|
ACOperationalValue(
|
||||||
@ -184,32 +151,3 @@ class ChildLockFunction extends ACFunction {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
final deviceId = 'AC001';
|
|
||||||
final deviceName = 'Living Room AC';
|
|
||||||
|
|
||||||
// Initial AC status
|
|
||||||
var acStatus = AcStatusModel(
|
|
||||||
uuid: deviceId,
|
|
||||||
acSwitch: false,
|
|
||||||
modeString: 'cold',
|
|
||||||
tempSet: 220,
|
|
||||||
currentTemp: 250,
|
|
||||||
fanSpeedsString: 'auto',
|
|
||||||
childLock: false,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Get all AC functions
|
|
||||||
final acFunctions = getACFunctions(deviceId, deviceName);
|
|
||||||
|
|
||||||
// Example: Turn on the AC
|
|
||||||
final switchFunction = acFunctions.firstWhere((f) => f is SwitchFunction) as SwitchFunction;
|
|
||||||
acStatus = switchFunction.execute(acStatus, true);
|
|
||||||
|
|
||||||
// Example: Change mode to heat
|
|
||||||
final modeFunction = acFunctions.firstWhere((f) => f is ModeFunction) as ModeFunction;
|
|
||||||
acStatus = modeFunction.execute(acStatus, TempModes.hot);
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
abstract class DeviceFunction<T> {
|
abstract class DeviceFunction<T> {
|
||||||
final String deviceId;
|
final String deviceId;
|
||||||
final String deviceName;
|
final String deviceName;
|
||||||
@ -12,34 +14,33 @@ abstract class DeviceFunction<T> {
|
|||||||
required this.operationName,
|
required this.operationName,
|
||||||
required this.icon,
|
required this.icon,
|
||||||
});
|
});
|
||||||
|
|
||||||
T execute(T currentStatus, dynamic newValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeviceFunctionData {
|
class DeviceFunctionData {
|
||||||
final String entityId;
|
final String entityId;
|
||||||
final String actionExecutor;
|
final String actionExecutor;
|
||||||
final String function;
|
final String functionCode;
|
||||||
final String operationName;
|
final String operationName;
|
||||||
final dynamic value;
|
final dynamic value;
|
||||||
final String? condition;
|
final String? condition;
|
||||||
final String? valueDescription;
|
final String? valueDescription;
|
||||||
|
final UniqueKey uniqueKey;
|
||||||
|
|
||||||
DeviceFunctionData({
|
DeviceFunctionData({
|
||||||
required this.entityId,
|
required this.entityId,
|
||||||
this.actionExecutor = 'function',
|
this.actionExecutor = 'device_issue',
|
||||||
required this.function,
|
required this.functionCode,
|
||||||
required this.operationName,
|
required this.operationName,
|
||||||
required this.value,
|
required this.value,
|
||||||
this.condition,
|
this.condition,
|
||||||
this.valueDescription,
|
this.valueDescription,
|
||||||
});
|
}) : uniqueKey = UniqueKey();
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
return {
|
||||||
'entityId': entityId,
|
'entityId': entityId,
|
||||||
'actionExecutor': actionExecutor,
|
'actionExecutor': actionExecutor,
|
||||||
'function': function,
|
'function': functionCode,
|
||||||
'operationName': operationName,
|
'operationName': operationName,
|
||||||
'value': value,
|
'value': value,
|
||||||
if (condition != null) 'condition': condition,
|
if (condition != null) 'condition': condition,
|
||||||
@ -51,7 +52,7 @@ class DeviceFunctionData {
|
|||||||
return DeviceFunctionData(
|
return DeviceFunctionData(
|
||||||
entityId: json['entityId'],
|
entityId: json['entityId'],
|
||||||
actionExecutor: json['actionExecutor'] ?? 'function',
|
actionExecutor: json['actionExecutor'] ?? 'function',
|
||||||
function: json['function'],
|
functionCode: json['function'],
|
||||||
operationName: json['operationName'],
|
operationName: json['operationName'],
|
||||||
value: json['value'],
|
value: json['value'],
|
||||||
condition: json['condition'],
|
condition: json['condition'],
|
||||||
@ -66,7 +67,7 @@ class DeviceFunctionData {
|
|||||||
return other is DeviceFunctionData &&
|
return other is DeviceFunctionData &&
|
||||||
other.entityId == entityId &&
|
other.entityId == entityId &&
|
||||||
other.actionExecutor == actionExecutor &&
|
other.actionExecutor == actionExecutor &&
|
||||||
other.function == function &&
|
other.functionCode == functionCode &&
|
||||||
other.operationName == operationName &&
|
other.operationName == operationName &&
|
||||||
other.value == value &&
|
other.value == value &&
|
||||||
other.condition == condition &&
|
other.condition == condition &&
|
||||||
@ -77,7 +78,7 @@ class DeviceFunctionData {
|
|||||||
int get hashCode {
|
int get hashCode {
|
||||||
return entityId.hashCode ^
|
return entityId.hashCode ^
|
||||||
actionExecutor.hashCode ^
|
actionExecutor.hashCode ^
|
||||||
function.hashCode ^
|
functionCode.hashCode ^
|
||||||
operationName.hashCode ^
|
operationName.hashCode ^
|
||||||
value.hashCode ^
|
value.hashCode ^
|
||||||
condition.hashCode ^
|
condition.hashCode ^
|
||||||
|
@ -10,8 +10,5 @@ abstract class BaseSwitchFunction extends DeviceFunction<bool> {
|
|||||||
required super.icon,
|
required super.icon,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue);
|
|
||||||
|
|
||||||
List<SwitchOperationalValue> getOperationalValues();
|
List<SwitchOperationalValue> getOperationalValues();
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,6 @@ class OneGangSwitchFunction extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
@ -38,11 +33,6 @@ class OneGangCountdownFunction extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
|
@ -10,11 +10,6 @@ class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
@ -39,11 +34,6 @@ class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
@ -65,11 +55,6 @@ class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
@ -94,11 +79,6 @@ class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
@ -120,11 +100,6 @@ class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
@ -149,11 +124,6 @@ class ThreeGangCountdown3Function extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
|
@ -10,11 +10,6 @@ class TwoGangSwitch1Function extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
@ -31,20 +26,13 @@ class TwoGangSwitch1Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TwoGangSwitch2Function extends BaseSwitchFunction {
|
class TwoGangSwitch2Function extends BaseSwitchFunction {
|
||||||
TwoGangSwitch2Function({required String deviceId, required String deviceName})
|
TwoGangSwitch2Function({required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
deviceId: deviceId,
|
|
||||||
deviceName: deviceName,
|
|
||||||
code: 'switch_2',
|
code: 'switch_2',
|
||||||
operationName: 'Light 2 Switch',
|
operationName: 'Light 2 Switch',
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
@ -69,11 +57,6 @@ class TwoGangCountdown1Function extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
@ -96,11 +79,6 @@ class TwoGangCountdown2Function extends BaseSwitchFunction {
|
|||||||
icon: Assets.assetsLightCountdown,
|
icon: Assets.assetsLightCountdown,
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
|
||||||
bool execute(bool currentStatus, dynamic newValue) {
|
|
||||||
return newValue as bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<SwitchOperationalValue> getOperationalValues() => [
|
List<SwitchOperationalValue> getOperationalValues() => [
|
||||||
SwitchOperationalValue(
|
SwitchOperationalValue(
|
||||||
|
@ -43,95 +43,70 @@ class DraggableCard extends StatelessWidget {
|
|||||||
BuildContext context, List<DeviceFunctionData> deviceFunctions) {
|
BuildContext context, List<DeviceFunctionData> deviceFunctions) {
|
||||||
return Card(
|
return Card(
|
||||||
color: ColorsManager.whiteColors,
|
color: ColorsManager.whiteColors,
|
||||||
child: SizedBox(
|
child: Container(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
width: 90,
|
width: 90,
|
||||||
|
height: deviceFunctions.isEmpty ? 123 : null,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
Column(
|
||||||
height: 123,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
child: Column(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
Container(
|
||||||
children: [
|
height: 50,
|
||||||
Container(
|
width: 50,
|
||||||
height: 50,
|
decoration: BoxDecoration(
|
||||||
width: 50,
|
color: ColorsManager.CircleImageBackground,
|
||||||
decoration: BoxDecoration(
|
borderRadius: BorderRadius.circular(90),
|
||||||
color: ColorsManager.CircleImageBackground,
|
border: Border.all(
|
||||||
borderRadius: BorderRadius.circular(90),
|
color: ColorsManager.graysColor,
|
||||||
border: Border.all(
|
|
||||||
color: ColorsManager.graysColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
child: imagePath.contains('.svg')
|
|
||||||
? SvgPicture.asset(
|
|
||||||
imagePath,
|
|
||||||
)
|
|
||||||
: Image.network(imagePath),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
|
||||||
child: Text(
|
|
||||||
title,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
maxLines: 2,
|
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
|
||||||
color: ColorsManager.blackColor,
|
|
||||||
fontSize: 12,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
padding: const EdgeInsets.all(8),
|
||||||
),
|
child: imagePath.contains('.svg')
|
||||||
|
? SvgPicture.asset(
|
||||||
|
imagePath,
|
||||||
|
)
|
||||||
|
: Image.network(imagePath),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 3),
|
||||||
|
child: Text(
|
||||||
|
title,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 2,
|
||||||
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
|
color: ColorsManager.blackColor,
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
if (deviceFunctions.isNotEmpty) ...[
|
if (deviceFunctions.isNotEmpty)
|
||||||
const Divider(height: 1),
|
// const Divider(height: 1),
|
||||||
ListView.builder(
|
...deviceFunctions.map((function) => Row(
|
||||||
shrinkWrap: true,
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 4),
|
|
||||||
itemCount: deviceFunctions.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final function = deviceFunctions[index];
|
|
||||||
return Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${function.operationName}: ${function.valueDescription}',
|
'${function.operationName}: ${function.value}',
|
||||||
style: context.textTheme.bodySmall?.copyWith(
|
style: context.textTheme.bodySmall?.copyWith(
|
||||||
fontSize: 9,
|
fontSize: 9,
|
||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
height: 1.2,
|
height: 1.2,
|
||||||
),
|
),
|
||||||
|
maxLines: 2,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
InkWell(
|
|
||||||
onTap: () {
|
|
||||||
context.read<RoutineBloc>().add(
|
|
||||||
RemoveFunction(function),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
child: const Padding(
|
|
||||||
padding: EdgeInsets.all(2),
|
|
||||||
child: Icon(
|
|
||||||
Icons.close,
|
|
||||||
size: 12,
|
|
||||||
color: ColorsManager.textGray,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
)),
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -9,9 +9,6 @@ class RoutineDevices extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// Get the RoutineBloc instance from the parent
|
|
||||||
final routineBloc = context.read<RoutineBloc>();
|
|
||||||
|
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (context) => DeviceManagementBloc()..add(FetchDevices()),
|
create: (context) => DeviceManagementBloc()..add(FetchDevices()),
|
||||||
child: BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
|
child: BlocBuilder<DeviceManagementBloc, DeviceManagementState>(
|
||||||
@ -26,32 +23,28 @@ class RoutineDevices extends StatelessWidget {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// Provide the RoutineBloc to the child widgets
|
// Provide the RoutineBloc to the child widgets
|
||||||
return BlocProvider.value(
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||||
value: routineBloc,
|
builder: (context, routineState) {
|
||||||
child: BlocBuilder<RoutineBloc, RoutineState>(
|
return Wrap(
|
||||||
builder: (context, routineState) {
|
spacing: 10,
|
||||||
return Wrap(
|
runSpacing: 10,
|
||||||
spacing: 10,
|
children: deviceList.asMap().entries.map((entry) {
|
||||||
runSpacing: 10,
|
final device = entry.value;
|
||||||
children: deviceList.asMap().entries.map((entry) {
|
return DraggableCard(
|
||||||
final device = entry.value;
|
imagePath: device.getDefaultIcon(device.productType),
|
||||||
return DraggableCard(
|
title: device.name ?? '',
|
||||||
imagePath: device.getDefaultIcon(device.productType),
|
deviceData: {
|
||||||
title: device.name ?? '',
|
'device': device,
|
||||||
deviceData: {
|
'imagePath': device.getDefaultIcon(device.productType),
|
||||||
'key': UniqueKey().toString(),
|
'title': device.name ?? '',
|
||||||
'imagePath':
|
'deviceId': device.uuid,
|
||||||
device.getDefaultIcon(device.productType),
|
'productType': device.productType,
|
||||||
'title': device.name ?? '',
|
'functions': device.functions,
|
||||||
'deviceId': device.uuid,
|
},
|
||||||
'productType': device.productType,
|
);
|
||||||
'functions': device.functions,
|
}).toList(),
|
||||||
},
|
);
|
||||||
);
|
},
|
||||||
}).toList(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
|
@ -30,7 +30,7 @@ class ThenContainer extends StatelessWidget {
|
|||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: state.thenItems
|
children: state.thenItems
|
||||||
.map((item) => DraggableCard(
|
.map((item) => DraggableCard(
|
||||||
key: Key(item['key']!),
|
// key: Key(item['key']!),
|
||||||
imagePath: item['imagePath']!,
|
imagePath: item['imagePath']!,
|
||||||
title: item['title']!,
|
title: item['title']!,
|
||||||
deviceData: item,
|
deviceData: item,
|
||||||
@ -45,6 +45,18 @@ class ThenContainer extends StatelessWidget {
|
|||||||
onAccept: (data) async {
|
onAccept: (data) async {
|
||||||
final result =
|
final result =
|
||||||
await DeviceDialogHelper.showDeviceDialog(context, data);
|
await DeviceDialogHelper.showDeviceDialog(context, data);
|
||||||
|
// if (result != null) {
|
||||||
|
// for (var function in routineBloc.state.selectedFunctions) {
|
||||||
|
// routineBloc.add(AddToThenContainer(
|
||||||
|
// {
|
||||||
|
// 'item': function,
|
||||||
|
// 'imagePath': data['imagePath'],
|
||||||
|
// 'title': data['name'],
|
||||||
|
|
||||||
|
// }
|
||||||
|
// ));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer(data));
|
context.read<RoutineBloc>().add(AddToThenContainer(data));
|
||||||
} else if (!['AC', '1G', '2G', '3G']
|
} else if (!['AC', '1G', '2G', '3G']
|
||||||
|
@ -97,3 +97,9 @@ extension AccessStatusExtension on AccessStatus {
|
|||||||
enum TempModes { hot, cold, wind }
|
enum TempModes { hot, cold, wind }
|
||||||
|
|
||||||
enum FanSpeeds { auto, low, middle, high }
|
enum FanSpeeds { auto, low, middle, high }
|
||||||
|
|
||||||
|
enum AcValuesEnums {
|
||||||
|
Cooling,
|
||||||
|
Heating,
|
||||||
|
Ventilation,
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user