mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
add dialogType to devices and add parameter in showSwitchFunctionsDialog
This commit is contained in:
@ -247,12 +247,18 @@ SOS
|
||||
switch (productType) {
|
||||
case 'AC':
|
||||
return [
|
||||
SwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ModeFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
TempSetFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
CurrentTempFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
LevelFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
ChildLockFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
SwitchFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ModeFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
TempSetFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
CurrentTempFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
||||
LevelFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ChildLockFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
];
|
||||
|
||||
case '1G':
|
||||
@ -275,17 +281,17 @@ SOS
|
||||
case '3G':
|
||||
return [
|
||||
ThreeGangSwitch1Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangSwitch2Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangSwitch3Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangCountdown1Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangCountdown2Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
ThreeGangCountdown3Function(
|
||||
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
||||
];
|
||||
case 'WPS':
|
||||
return [
|
||||
@ -311,8 +317,6 @@ SOS
|
||||
NoOneTimeFunction(
|
||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||
|
||||
// FarDetectionSliderFunction(
|
||||
// deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN')
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
|
@ -49,45 +49,46 @@ class DeviceDialogHelper {
|
||||
final deviceSelectedFunctions =
|
||||
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
||||
|
||||
if (removeComparetors && data['productType'] != 'WPS') {
|
||||
//remove the current temp function in the 'if container'
|
||||
functions.removeAt(3);
|
||||
}
|
||||
|
||||
switch (productType) {
|
||||
case 'AC':
|
||||
return ACHelper.showACFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
context: context,
|
||||
functions: functions,
|
||||
device: data['device'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors,
|
||||
dialogType: dialogType,
|
||||
);
|
||||
|
||||
case '1G':
|
||||
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
dialogType: dialogType,
|
||||
context: context,
|
||||
functions: functions,
|
||||
device: data['device'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors);
|
||||
case '2G':
|
||||
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
dialogType: dialogType,
|
||||
context: context,
|
||||
functions: functions,
|
||||
device: data['device'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors);
|
||||
case '3G':
|
||||
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
||||
context,
|
||||
functions,
|
||||
data['device'],
|
||||
deviceSelectedFunctions,
|
||||
data['uniqueCustomId'],
|
||||
removeComparetors);
|
||||
dialogType: dialogType,
|
||||
context: context,
|
||||
functions: functions,
|
||||
device: data['device'],
|
||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
||||
uniqueCustomId: data['uniqueCustomId'],
|
||||
removeComparetors: removeComparetors);
|
||||
case 'WPS':
|
||||
return WallPresenceSensor.showWPSFunctionsDialog(
|
||||
dialogType: dialogType,
|
||||
|
@ -5,23 +5,28 @@ import 'package:syncrow_web/utils/constants/app_enum.dart';
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
abstract class ACFunction extends DeviceFunction<AcStatusModel> {
|
||||
final String type;
|
||||
|
||||
ACFunction({
|
||||
required super.deviceId,
|
||||
required super.deviceName,
|
||||
required super.code,
|
||||
required super.operationName,
|
||||
required super.icon,
|
||||
required this.type,
|
||||
});
|
||||
|
||||
List<ACOperationalValue> getOperationalValues();
|
||||
}
|
||||
|
||||
class SwitchFunction extends ACFunction {
|
||||
SwitchFunction({required super.deviceId, required super.deviceName})
|
||||
SwitchFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
code: 'switch',
|
||||
operationName: 'Power',
|
||||
icon: Assets.assetsAcPower,
|
||||
type: type,
|
||||
);
|
||||
|
||||
@override
|
||||
@ -40,11 +45,13 @@ class SwitchFunction extends ACFunction {
|
||||
}
|
||||
|
||||
class ModeFunction extends ACFunction {
|
||||
ModeFunction({required super.deviceId, required super.deviceName})
|
||||
ModeFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
code: 'mode',
|
||||
operationName: 'Mode',
|
||||
icon: Assets.assetsFreezing,
|
||||
type: type,
|
||||
);
|
||||
|
||||
@override
|
||||
@ -72,7 +79,8 @@ class TempSetFunction extends ACFunction {
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
TempSetFunction({required super.deviceId, required super.deviceName})
|
||||
TempSetFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = 160,
|
||||
max = 300,
|
||||
step = 1,
|
||||
@ -80,6 +88,7 @@ class TempSetFunction extends ACFunction {
|
||||
code: 'temp_set',
|
||||
operationName: 'Set Temperature',
|
||||
icon: Assets.assetsTempreture,
|
||||
type: type,
|
||||
);
|
||||
|
||||
@override
|
||||
@ -97,8 +106,10 @@ class TempSetFunction extends ACFunction {
|
||||
}
|
||||
|
||||
class LevelFunction extends ACFunction {
|
||||
LevelFunction({required super.deviceId, required super.deviceName})
|
||||
LevelFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
type: type,
|
||||
code: 'level',
|
||||
operationName: 'Fan Speed',
|
||||
icon: Assets.assetsFanSpeed,
|
||||
@ -130,8 +141,10 @@ class LevelFunction extends ACFunction {
|
||||
}
|
||||
|
||||
class ChildLockFunction extends ACFunction {
|
||||
ChildLockFunction({required super.deviceId, required super.deviceName})
|
||||
ChildLockFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
type: type,
|
||||
code: 'child_lock',
|
||||
operationName: 'Child Lock',
|
||||
icon: Assets.assetsChildLock,
|
||||
@ -157,11 +170,13 @@ class CurrentTempFunction extends ACFunction {
|
||||
final int max;
|
||||
final int step;
|
||||
|
||||
CurrentTempFunction({required super.deviceId, required super.deviceName})
|
||||
CurrentTempFunction(
|
||||
{required super.deviceId, required super.deviceName, required type})
|
||||
: min = -100,
|
||||
max = 990,
|
||||
step = 1,
|
||||
super(
|
||||
type: type,
|
||||
code: 'temp_current',
|
||||
operationName: 'Current Temperature',
|
||||
icon: Assets.currentTemp,
|
||||
|
@ -3,7 +3,7 @@ import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operation
|
||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||
|
||||
class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
||||
ThreeGangSwitch1Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangSwitch1Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'switch_1',
|
||||
operationName: 'Light 1 Switch',
|
||||
@ -26,7 +26,7 @@ class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
||||
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'countdown_1',
|
||||
operationName: 'Light 1 Countdown',
|
||||
@ -47,7 +47,7 @@ class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
||||
ThreeGangSwitch2Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangSwitch2Function({required super.deviceId, required super.deviceName, required type})
|
||||
: super(
|
||||
code: 'switch_2',
|
||||
operationName: 'Light 2 Switch',
|
||||
@ -70,7 +70,7 @@ class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
||||
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'countdown_2',
|
||||
operationName: 'Light 2 Countdown',
|
||||
@ -91,7 +91,7 @@ class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
||||
ThreeGangSwitch3Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangSwitch3Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'switch_3',
|
||||
operationName: 'Light 3 Switch',
|
||||
@ -114,7 +114,7 @@ class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
||||
}
|
||||
|
||||
class ThreeGangCountdown3Function extends BaseSwitchFunction {
|
||||
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName})
|
||||
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName ,required type})
|
||||
: super(
|
||||
code: 'countdown_3',
|
||||
operationName: 'Light 3 Countdown',
|
||||
|
@ -13,29 +13,38 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||
|
||||
class ACHelper {
|
||||
static Future<Map<String, dynamic>?> showACFunctionsDialog(
|
||||
BuildContext context,
|
||||
List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String uniqueCustomId,
|
||||
bool? removeComparetors,
|
||||
) async {
|
||||
List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
||||
static Future<Map<String, dynamic>?> showACFunctionsDialog({
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
required AllDevicesModel? device,
|
||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
required String uniqueCustomId,
|
||||
required bool? removeComparetors,
|
||||
required String dialogType,
|
||||
}) async {
|
||||
List<ACFunction> acFunctions =
|
||||
functions.whereType<ACFunction>().where((function) {
|
||||
if (dialogType == 'THEN') {
|
||||
return function.type == 'THEN' || function.type == 'BOTH';
|
||||
}
|
||||
return function.type == 'IF' || function.type == 'BOTH';
|
||||
}).toList();
|
||||
// List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
||||
|
||||
return showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
create: (_) => FunctionBloc()
|
||||
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedOperationName = state.selectedOperationName;
|
||||
final selectedFunctionData =
|
||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
final selectedFunctionData = state.addedFunctions
|
||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
@ -65,8 +74,10 @@ class ACHelper {
|
||||
child: _buildFunctionsList(
|
||||
context: context,
|
||||
acFunctions: acFunctions,
|
||||
onFunctionSelected: (functionCode, operationName) =>
|
||||
context.read<FunctionBloc>().add(SelectFunction(
|
||||
onFunctionSelected:
|
||||
(functionCode, operationName) => context
|
||||
.read<FunctionBloc>()
|
||||
.add(SelectFunction(
|
||||
functionCode: functionCode,
|
||||
operationName: operationName,
|
||||
)),
|
||||
@ -194,7 +205,8 @@ class ACHelper {
|
||||
);
|
||||
}
|
||||
|
||||
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final selectedFn =
|
||||
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final values = selectedFn.getOperationalValues();
|
||||
|
||||
return _buildOperationalValuesList(
|
||||
@ -290,7 +302,8 @@ class ACHelper {
|
||||
minHeight: 40.0,
|
||||
minWidth: 40.0,
|
||||
),
|
||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
isSelected:
|
||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
children: conditions.map((c) => Text(c)).toList(),
|
||||
);
|
||||
}
|
||||
@ -384,9 +397,13 @@ class ACHelper {
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: Icon(
|
||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||
isSelected
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
size: 24,
|
||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||
color: isSelected
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
if (!isSelected) {
|
||||
@ -398,7 +415,8 @@ class ACHelper {
|
||||
operationName: operationName,
|
||||
value: value.value,
|
||||
condition: selectedFunctionData?.condition,
|
||||
valueDescription: selectedFunctionData?.valueDescription,
|
||||
valueDescription:
|
||||
selectedFunctionData?.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -14,29 +14,32 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class OneGangSwitchHelper {
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
||||
BuildContext context,
|
||||
List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String uniqueCustomId,
|
||||
bool removeComparetors,
|
||||
) async {
|
||||
List<BaseSwitchFunction> acFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
||||
required String dialogType,
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
required AllDevicesModel? device,
|
||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
required String uniqueCustomId,
|
||||
required bool removeComparetors,
|
||||
}) async {
|
||||
List<BaseSwitchFunction> acFunctions =
|
||||
functions.whereType<BaseSwitchFunction>().toList();
|
||||
|
||||
return showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
create: (_) => FunctionBloc()
|
||||
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedOperationName = state.selectedOperationName;
|
||||
final selectedFunctionData =
|
||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
final selectedFunctionData = state.addedFunctions
|
||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
@ -83,9 +86,12 @@ class OneGangSwitchHelper {
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
context.read<FunctionBloc>().add(SelectFunction(
|
||||
context
|
||||
.read<FunctionBloc>()
|
||||
.add(SelectFunction(
|
||||
functionCode: function.code,
|
||||
operationName: function.operationName,
|
||||
operationName:
|
||||
function.operationName,
|
||||
));
|
||||
},
|
||||
);
|
||||
@ -175,7 +181,8 @@ class OneGangSwitchHelper {
|
||||
);
|
||||
}
|
||||
|
||||
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final selectedFn =
|
||||
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final values = selectedFn.getOperationalValues();
|
||||
|
||||
return _buildOperationalValuesList(
|
||||
@ -212,11 +219,11 @@ class OneGangSwitchHelper {
|
||||
selectedFunctionData,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownDisplay(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownSlider(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -257,7 +264,8 @@ class OneGangSwitchHelper {
|
||||
minHeight: 40.0,
|
||||
minWidth: 40.0,
|
||||
),
|
||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
isSelected:
|
||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
children: conditions.map((c) => Text(c)).toList(),
|
||||
);
|
||||
}
|
||||
@ -305,7 +313,8 @@ class OneGangSwitchHelper {
|
||||
value: (initialValue ?? 0).toDouble(),
|
||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
||||
divisions: (((operationalValues.maxValue ?? 0) -
|
||||
(operationalValues.minValue ?? 0)) /
|
||||
(operationalValues.stepValue ?? 1))
|
||||
.round(),
|
||||
onChanged: (value) {
|
||||
@ -357,9 +366,13 @@ class OneGangSwitchHelper {
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: Icon(
|
||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||
isSelected
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
size: 24,
|
||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||
color: isSelected
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
if (!isSelected) {
|
||||
@ -371,7 +384,8 @@ class OneGangSwitchHelper {
|
||||
operationName: operationName,
|
||||
value: value.value,
|
||||
condition: selectedFunctionData?.condition,
|
||||
valueDescription: selectedFunctionData?.valueDescription,
|
||||
valueDescription:
|
||||
selectedFunctionData?.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -14,14 +14,15 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class ThreeGangSwitchHelper {
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
||||
BuildContext context,
|
||||
List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String uniqueCustomId,
|
||||
bool removeComparetors,
|
||||
) async {
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
required AllDevicesModel? device,
|
||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
required String uniqueCustomId,
|
||||
required String dialogType,
|
||||
required bool removeComparetors,
|
||||
}) async {
|
||||
List<BaseSwitchFunction> switchFunctions =
|
||||
functions.whereType<BaseSwitchFunction>().toList();
|
||||
|
||||
|
@ -14,29 +14,32 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||
|
||||
class TwoGangSwitchHelper {
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
||||
BuildContext context,
|
||||
List<DeviceFunction> functions,
|
||||
AllDevicesModel? device,
|
||||
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
String uniqueCustomId,
|
||||
bool removeComparetors,
|
||||
) async {
|
||||
List<BaseSwitchFunction> switchFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
||||
required BuildContext context,
|
||||
required List<DeviceFunction> functions,
|
||||
required AllDevicesModel? device,
|
||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||
required String uniqueCustomId,
|
||||
required bool removeComparetors,
|
||||
required String dialogType,
|
||||
}) async {
|
||||
List<BaseSwitchFunction> switchFunctions =
|
||||
functions.whereType<BaseSwitchFunction>().toList();
|
||||
|
||||
return showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
create: (_) => FunctionBloc()
|
||||
..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||
child: AlertDialog(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
content: BlocBuilder<FunctionBloc, FunctionBlocState>(
|
||||
builder: (context, state) {
|
||||
final selectedFunction = state.selectedFunction;
|
||||
final selectedOperationName = state.selectedOperationName;
|
||||
final selectedFunctionData =
|
||||
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
final selectedFunctionData = state.addedFunctions
|
||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
||||
orElse: () => DeviceFunctionData(
|
||||
entityId: '',
|
||||
functionCode: selectedFunction ?? '',
|
||||
@ -83,9 +86,12 @@ class TwoGangSwitchHelper {
|
||||
color: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
context.read<FunctionBloc>().add(SelectFunction(
|
||||
context
|
||||
.read<FunctionBloc>()
|
||||
.add(SelectFunction(
|
||||
functionCode: function.code,
|
||||
operationName: function.operationName,
|
||||
operationName:
|
||||
function.operationName,
|
||||
));
|
||||
},
|
||||
);
|
||||
@ -161,7 +167,8 @@ class TwoGangSwitchHelper {
|
||||
required String operationName,
|
||||
required bool removeComparetors,
|
||||
}) {
|
||||
if (selectedFunction == 'countdown_1' || selectedFunction == 'countdown_2') {
|
||||
if (selectedFunction == 'countdown_1' ||
|
||||
selectedFunction == 'countdown_2') {
|
||||
final initialValue = selectedFunctionData?.value ?? 200;
|
||||
return _buildTemperatureSelector(
|
||||
context: context,
|
||||
@ -175,7 +182,8 @@ class TwoGangSwitchHelper {
|
||||
);
|
||||
}
|
||||
|
||||
final selectedFn = switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final selectedFn =
|
||||
switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||
final values = selectedFn.getOperationalValues();
|
||||
|
||||
return _buildOperationalValuesList(
|
||||
@ -212,11 +220,11 @@ class TwoGangSwitchHelper {
|
||||
selectedFunctionData,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownDisplay(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownDisplay(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
const SizedBox(height: 20),
|
||||
_buildCountDownSlider(
|
||||
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||
_buildCountDownSlider(context, initialValue, device, operationName,
|
||||
selectedFunctionData, selectCode),
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -257,7 +265,8 @@ class TwoGangSwitchHelper {
|
||||
minHeight: 40.0,
|
||||
minWidth: 40.0,
|
||||
),
|
||||
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
isSelected:
|
||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||
children: conditions.map((c) => Text(c)).toList(),
|
||||
);
|
||||
}
|
||||
@ -305,7 +314,8 @@ class TwoGangSwitchHelper {
|
||||
value: (initialValue ?? 0).toDouble(),
|
||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
||||
divisions: (((operationalValues.maxValue ?? 0) -
|
||||
(operationalValues.minValue ?? 0)) /
|
||||
(operationalValues.stepValue ?? 1))
|
||||
.round(),
|
||||
onChanged: (value) {
|
||||
@ -357,9 +367,13 @@ class TwoGangSwitchHelper {
|
||||
style: context.textTheme.bodyMedium,
|
||||
),
|
||||
trailing: Icon(
|
||||
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||
isSelected
|
||||
? Icons.radio_button_checked
|
||||
: Icons.radio_button_unchecked,
|
||||
size: 24,
|
||||
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||
color: isSelected
|
||||
? ColorsManager.primaryColorWithOpacity
|
||||
: ColorsManager.textGray,
|
||||
),
|
||||
onTap: () {
|
||||
if (!isSelected) {
|
||||
@ -371,7 +385,8 @@ class TwoGangSwitchHelper {
|
||||
operationName: operationName,
|
||||
value: value.value,
|
||||
condition: selectedFunctionData?.condition,
|
||||
valueDescription: selectedFunctionData?.valueDescription,
|
||||
valueDescription:
|
||||
selectedFunctionData?.valueDescription,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
Reference in New Issue
Block a user