mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 18:16:34 +00:00
Compare commits
3 Commits
SP-1277-FE
...
SP-1366-FE
Author | SHA1 | Date | |
---|---|---|---|
774f21a55b | |||
9b69ec31e9 | |||
7accf1d4c8 |
@ -247,18 +247,12 @@ SOS
|
|||||||
switch (productType) {
|
switch (productType) {
|
||||||
case 'AC':
|
case 'AC':
|
||||||
return [
|
return [
|
||||||
SwitchFunction(
|
SwitchFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
ModeFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
ModeFunction(
|
TempSetFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
CurrentTempFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
TempSetFunction(
|
LevelFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
ChildLockFunction(deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
CurrentTempFunction(
|
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'IF'),
|
|
||||||
LevelFunction(
|
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
|
||||||
ChildLockFunction(
|
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
case '1G':
|
case '1G':
|
||||||
@ -281,17 +275,17 @@ SOS
|
|||||||
case '3G':
|
case '3G':
|
||||||
return [
|
return [
|
||||||
ThreeGangSwitch1Function(
|
ThreeGangSwitch1Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
ThreeGangSwitch2Function(
|
ThreeGangSwitch2Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
ThreeGangSwitch3Function(
|
ThreeGangSwitch3Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
ThreeGangCountdown1Function(
|
ThreeGangCountdown1Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
ThreeGangCountdown2Function(
|
ThreeGangCountdown2Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
ThreeGangCountdown3Function(
|
ThreeGangCountdown3Function(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'BOTH'),
|
deviceId: uuid ?? '', deviceName: name ?? ''),
|
||||||
];
|
];
|
||||||
case 'WPS':
|
case 'WPS':
|
||||||
return [
|
return [
|
||||||
@ -317,6 +311,8 @@ SOS
|
|||||||
NoOneTimeFunction(
|
NoOneTimeFunction(
|
||||||
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN'),
|
||||||
|
|
||||||
|
// FarDetectionSliderFunction(
|
||||||
|
// deviceId: uuid ?? '', deviceName: name ?? '', type: 'THEN')
|
||||||
];
|
];
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/ac_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/three_gang_switch_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/two_gang_switch_dialog.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/wall_sensor/wall_presence_sensor.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/wall_sensor/wall_presence_sensor.dart';
|
||||||
|
|
||||||
class DeviceDialogHelper {
|
class DeviceDialogHelper {
|
||||||
@ -49,46 +49,45 @@ class DeviceDialogHelper {
|
|||||||
final deviceSelectedFunctions =
|
final deviceSelectedFunctions =
|
||||||
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
routineBloc.state.selectedFunctions[data['uniqueCustomId']] ?? [];
|
||||||
|
|
||||||
|
if (removeComparetors && data['productType'] != 'WPS') {
|
||||||
|
//remove the current temp function in the 'if container'
|
||||||
|
functions.removeAt(3);
|
||||||
|
}
|
||||||
|
|
||||||
switch (productType) {
|
switch (productType) {
|
||||||
case 'AC':
|
case 'AC':
|
||||||
return ACHelper.showACFunctionsDialog(
|
return ACHelper.showACFunctionsDialog(
|
||||||
context: context,
|
context,
|
||||||
functions: functions,
|
functions,
|
||||||
device: data['device'],
|
data['device'],
|
||||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
deviceSelectedFunctions,
|
||||||
uniqueCustomId: data['uniqueCustomId'],
|
data['uniqueCustomId'],
|
||||||
removeComparetors: removeComparetors,
|
removeComparetors);
|
||||||
dialogType: dialogType,
|
|
||||||
);
|
|
||||||
|
|
||||||
case '1G':
|
case '1G':
|
||||||
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
return OneGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
dialogType: dialogType,
|
context,
|
||||||
context: context,
|
functions,
|
||||||
functions: functions,
|
data['device'],
|
||||||
device: data['device'],
|
deviceSelectedFunctions,
|
||||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
data['uniqueCustomId'],
|
||||||
uniqueCustomId: data['uniqueCustomId'],
|
removeComparetors);
|
||||||
removeComparetors: removeComparetors);
|
|
||||||
case '2G':
|
case '2G':
|
||||||
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
return TwoGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
dialogType: dialogType,
|
context,
|
||||||
context: context,
|
functions,
|
||||||
functions: functions,
|
data['device'],
|
||||||
device: data['device'],
|
deviceSelectedFunctions,
|
||||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
data['uniqueCustomId'],
|
||||||
uniqueCustomId: data['uniqueCustomId'],
|
removeComparetors);
|
||||||
removeComparetors: removeComparetors);
|
|
||||||
case '3G':
|
case '3G':
|
||||||
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
return ThreeGangSwitchHelper.showSwitchFunctionsDialog(
|
||||||
dialogType: dialogType,
|
context,
|
||||||
context: context,
|
functions,
|
||||||
functions: functions,
|
data['device'],
|
||||||
device: data['device'],
|
deviceSelectedFunctions,
|
||||||
deviceSelectedFunctions: deviceSelectedFunctions,
|
data['uniqueCustomId'],
|
||||||
uniqueCustomId: data['uniqueCustomId'],
|
removeComparetors);
|
||||||
removeComparetors: removeComparetors);
|
|
||||||
case 'WPS':
|
case 'WPS':
|
||||||
return WallPresenceSensor.showWPSFunctionsDialog(
|
return WallPresenceSensor.showWPSFunctionsDialog(
|
||||||
dialogType: dialogType,
|
dialogType: dialogType,
|
||||||
|
@ -5,28 +5,23 @@ 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> {
|
||||||
final String type;
|
|
||||||
|
|
||||||
ACFunction({
|
ACFunction({
|
||||||
required super.deviceId,
|
required super.deviceId,
|
||||||
required super.deviceName,
|
required super.deviceName,
|
||||||
required super.code,
|
required super.code,
|
||||||
required super.operationName,
|
required super.operationName,
|
||||||
required super.icon,
|
required super.icon,
|
||||||
required this.type,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
List<ACOperationalValue> getOperationalValues();
|
List<ACOperationalValue> getOperationalValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
class SwitchFunction extends ACFunction {
|
class SwitchFunction extends ACFunction {
|
||||||
SwitchFunction(
|
SwitchFunction({required super.deviceId, required super.deviceName})
|
||||||
{required super.deviceId, required super.deviceName, required type})
|
|
||||||
: super(
|
: super(
|
||||||
code: 'switch',
|
code: 'switch',
|
||||||
operationName: 'Power',
|
operationName: 'Power',
|
||||||
icon: Assets.assetsAcPower,
|
icon: Assets.assetsAcPower,
|
||||||
type: type,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -45,13 +40,11 @@ class SwitchFunction extends ACFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ModeFunction extends ACFunction {
|
class ModeFunction extends ACFunction {
|
||||||
ModeFunction(
|
ModeFunction({required super.deviceId, required super.deviceName})
|
||||||
{required super.deviceId, required super.deviceName, required type})
|
|
||||||
: super(
|
: super(
|
||||||
code: 'mode',
|
code: 'mode',
|
||||||
operationName: 'Mode',
|
operationName: 'Mode',
|
||||||
icon: Assets.assetsFreezing,
|
icon: Assets.assetsFreezing,
|
||||||
type: type,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -79,8 +72,7 @@ class TempSetFunction extends ACFunction {
|
|||||||
final int max;
|
final int max;
|
||||||
final int step;
|
final int step;
|
||||||
|
|
||||||
TempSetFunction(
|
TempSetFunction({required super.deviceId, required super.deviceName})
|
||||||
{required super.deviceId, required super.deviceName, required type})
|
|
||||||
: min = 160,
|
: min = 160,
|
||||||
max = 300,
|
max = 300,
|
||||||
step = 1,
|
step = 1,
|
||||||
@ -88,7 +80,6 @@ class TempSetFunction extends ACFunction {
|
|||||||
code: 'temp_set',
|
code: 'temp_set',
|
||||||
operationName: 'Set Temperature',
|
operationName: 'Set Temperature',
|
||||||
icon: Assets.assetsTempreture,
|
icon: Assets.assetsTempreture,
|
||||||
type: type,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -106,10 +97,8 @@ class TempSetFunction extends ACFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LevelFunction extends ACFunction {
|
class LevelFunction extends ACFunction {
|
||||||
LevelFunction(
|
LevelFunction({required super.deviceId, required super.deviceName})
|
||||||
{required super.deviceId, required super.deviceName, required type})
|
|
||||||
: super(
|
: super(
|
||||||
type: type,
|
|
||||||
code: 'level',
|
code: 'level',
|
||||||
operationName: 'Fan Speed',
|
operationName: 'Fan Speed',
|
||||||
icon: Assets.assetsFanSpeed,
|
icon: Assets.assetsFanSpeed,
|
||||||
@ -141,10 +130,8 @@ class LevelFunction extends ACFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ChildLockFunction extends ACFunction {
|
class ChildLockFunction extends ACFunction {
|
||||||
ChildLockFunction(
|
ChildLockFunction({required super.deviceId, required super.deviceName})
|
||||||
{required super.deviceId, required super.deviceName, required type})
|
|
||||||
: super(
|
: super(
|
||||||
type: type,
|
|
||||||
code: 'child_lock',
|
code: 'child_lock',
|
||||||
operationName: 'Child Lock',
|
operationName: 'Child Lock',
|
||||||
icon: Assets.assetsChildLock,
|
icon: Assets.assetsChildLock,
|
||||||
@ -170,13 +157,11 @@ class CurrentTempFunction extends ACFunction {
|
|||||||
final int max;
|
final int max;
|
||||||
final int step;
|
final int step;
|
||||||
|
|
||||||
CurrentTempFunction(
|
CurrentTempFunction({required super.deviceId, required super.deviceName})
|
||||||
{required super.deviceId, required super.deviceName, required type})
|
|
||||||
: min = -100,
|
: min = -100,
|
||||||
max = 990,
|
max = 990,
|
||||||
step = 1,
|
step = 1,
|
||||||
super(
|
super(
|
||||||
type: type,
|
|
||||||
code: 'temp_current',
|
code: 'temp_current',
|
||||||
operationName: 'Current Temperature',
|
operationName: 'Current Temperature',
|
||||||
icon: Assets.currentTemp,
|
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';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
|
|
||||||
class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
||||||
ThreeGangSwitch1Function({required super.deviceId, required super.deviceName ,required type})
|
ThreeGangSwitch1Function({required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'switch_1',
|
code: 'switch_1',
|
||||||
operationName: 'Light 1 Switch',
|
operationName: 'Light 1 Switch',
|
||||||
@ -26,7 +26,7 @@ class ThreeGangSwitch1Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
||||||
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName ,required type})
|
ThreeGangCountdown1Function({required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_1',
|
code: 'countdown_1',
|
||||||
operationName: 'Light 1 Countdown',
|
operationName: 'Light 1 Countdown',
|
||||||
@ -47,7 +47,7 @@ class ThreeGangCountdown1Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
||||||
ThreeGangSwitch2Function({required super.deviceId, required super.deviceName, required type})
|
ThreeGangSwitch2Function({required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'switch_2',
|
code: 'switch_2',
|
||||||
operationName: 'Light 2 Switch',
|
operationName: 'Light 2 Switch',
|
||||||
@ -70,7 +70,7 @@ class ThreeGangSwitch2Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
||||||
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName ,required type})
|
ThreeGangCountdown2Function({required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_2',
|
code: 'countdown_2',
|
||||||
operationName: 'Light 2 Countdown',
|
operationName: 'Light 2 Countdown',
|
||||||
@ -91,7 +91,7 @@ class ThreeGangCountdown2Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
||||||
ThreeGangSwitch3Function({required super.deviceId, required super.deviceName ,required type})
|
ThreeGangSwitch3Function({required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'switch_3',
|
code: 'switch_3',
|
||||||
operationName: 'Light 3 Switch',
|
operationName: 'Light 3 Switch',
|
||||||
@ -114,7 +114,7 @@ class ThreeGangSwitch3Function extends BaseSwitchFunction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ThreeGangCountdown3Function extends BaseSwitchFunction {
|
class ThreeGangCountdown3Function extends BaseSwitchFunction {
|
||||||
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName ,required type})
|
ThreeGangCountdown3Function({required super.deviceId, required super.deviceName})
|
||||||
: super(
|
: super(
|
||||||
code: 'countdown_3',
|
code: 'countdown_3',
|
||||||
operationName: 'Light 3 Countdown',
|
operationName: 'Light 3 Countdown',
|
||||||
|
@ -71,8 +71,7 @@ class IfContainer extends StatelessWidget {
|
|||||||
'1G',
|
'1G',
|
||||||
'2G',
|
'2G',
|
||||||
'3G',
|
'3G',
|
||||||
'WPS',
|
'WPS'
|
||||||
'CPS',
|
|
||||||
].contains(
|
].contains(
|
||||||
state.ifItems[index]['productType'])) {
|
state.ifItems[index]['productType'])) {
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
@ -130,7 +129,7 @@ class IfContainer extends StatelessWidget {
|
|||||||
context
|
context
|
||||||
.read<RoutineBloc>()
|
.read<RoutineBloc>()
|
||||||
.add(AddToIfContainer(mutableData, false));
|
.add(AddToIfContainer(mutableData, false));
|
||||||
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'CPS']
|
} else if (!['AC', '1G', '2G', '3G', 'WPS']
|
||||||
.contains(mutableData['productType'])) {
|
.contains(mutableData['productType'])) {
|
||||||
context
|
context
|
||||||
.read<RoutineBloc>()
|
.read<RoutineBloc>()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_model.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
||||||
|
|
||||||
@ -18,6 +17,8 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
|||||||
context.read<RoutineBloc>().add(FetchDevicesInRoutine());
|
context.read<RoutineBloc>().add(FetchDevicesInRoutine());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const _allowedProductTypes = {'AC', '1G', '2G', '3G', 'WPS', 'GW'};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BlocBuilder<RoutineBloc, RoutineState>(
|
return BlocBuilder<RoutineBloc, RoutineState>(
|
||||||
@ -32,14 +33,8 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
List<AllDevicesModel> deviceList = state.devices
|
final deviceList = state.devices
|
||||||
.where((device) =>
|
.where((device) => _allowedProductTypes.contains(device.productType))
|
||||||
device.productType == 'AC' ||
|
|
||||||
device.productType == '1G' ||
|
|
||||||
device.productType == '2G' ||
|
|
||||||
device.productType == '3G' ||
|
|
||||||
device.productType == 'WPS' ||
|
|
||||||
device.productType == 'CPS')
|
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return Wrap(
|
return Wrap(
|
||||||
@ -47,37 +42,32 @@ class _RoutineDevicesState extends State<RoutineDevices> {
|
|||||||
runSpacing: 10,
|
runSpacing: 10,
|
||||||
children: deviceList.asMap().entries.map((entry) {
|
children: deviceList.asMap().entries.map((entry) {
|
||||||
final device = entry.value;
|
final device = entry.value;
|
||||||
|
|
||||||
|
final deviceData = {
|
||||||
|
'device': device,
|
||||||
|
'imagePath': device.getDefaultIcon(device.productType),
|
||||||
|
'title': device.name ?? '',
|
||||||
|
'deviceId': device.uuid,
|
||||||
|
'productType': device.productType,
|
||||||
|
'functions': device.functions,
|
||||||
|
'uniqueCustomId': '',
|
||||||
|
};
|
||||||
|
|
||||||
if (state.searchText != null && state.searchText!.isNotEmpty) {
|
if (state.searchText != null && state.searchText!.isNotEmpty) {
|
||||||
return device.name!
|
return device.name!
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.contains(state.searchText!.toLowerCase())
|
.contains(state.searchText!.toLowerCase())
|
||||||
? DraggableCard(
|
? DraggableCard(
|
||||||
imagePath: device.getDefaultIcon(device.productType),
|
imagePath: deviceData['imagePath'] as String,
|
||||||
title: device.name ?? '',
|
title: deviceData['title'] as String,
|
||||||
deviceData: {
|
deviceData: deviceData,
|
||||||
'device': device,
|
|
||||||
'imagePath': device.getDefaultIcon(device.productType),
|
|
||||||
'title': device.name ?? '',
|
|
||||||
'deviceId': device.uuid,
|
|
||||||
'productType': device.productType,
|
|
||||||
'functions': device.functions,
|
|
||||||
'uniqueCustomId': '',
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
: Container();
|
: const SizedBox.shrink();
|
||||||
} else {
|
} else {
|
||||||
return DraggableCard(
|
return DraggableCard(
|
||||||
imagePath: device.getDefaultIcon(device.productType),
|
imagePath: deviceData['imagePath'] as String,
|
||||||
title: device.name ?? '',
|
title: deviceData['title'] as String,
|
||||||
deviceData: {
|
deviceData: deviceData,
|
||||||
'device': device,
|
|
||||||
'imagePath': device.getDefaultIcon(device.productType),
|
|
||||||
'title': device.name ?? '',
|
|
||||||
'deviceId': device.uuid,
|
|
||||||
'productType': device.productType,
|
|
||||||
'functions': device.functions,
|
|
||||||
'uniqueCustomId': '',
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}).toList(),
|
}).toList(),
|
||||||
|
@ -13,38 +13,29 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
|
|
||||||
class ACHelper {
|
class ACHelper {
|
||||||
static Future<Map<String, dynamic>?> showACFunctionsDialog({
|
static Future<Map<String, dynamic>?> showACFunctionsDialog(
|
||||||
required BuildContext context,
|
BuildContext context,
|
||||||
required List<DeviceFunction> functions,
|
List<DeviceFunction> functions,
|
||||||
required AllDevicesModel? device,
|
AllDevicesModel? device,
|
||||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
required String uniqueCustomId,
|
String uniqueCustomId,
|
||||||
required bool? removeComparetors,
|
bool? removeComparetors,
|
||||||
required String dialogType,
|
) async {
|
||||||
}) async {
|
List<ACFunction> acFunctions = functions.whereType<ACFunction>().toList();
|
||||||
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>?>(
|
return showDialog<Map<String, dynamic>?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return BlocProvider(
|
return BlocProvider(
|
||||||
create: (_) => FunctionBloc()
|
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
..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 selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData = state.addedFunctions
|
final selectedFunctionData =
|
||||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -74,10 +65,8 @@ class ACHelper {
|
|||||||
child: _buildFunctionsList(
|
child: _buildFunctionsList(
|
||||||
context: context,
|
context: context,
|
||||||
acFunctions: acFunctions,
|
acFunctions: acFunctions,
|
||||||
onFunctionSelected:
|
onFunctionSelected: (functionCode, operationName) =>
|
||||||
(functionCode, operationName) => context
|
context.read<FunctionBloc>().add(SelectFunction(
|
||||||
.read<FunctionBloc>()
|
|
||||||
.add(SelectFunction(
|
|
||||||
functionCode: functionCode,
|
functionCode: functionCode,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
)),
|
)),
|
||||||
@ -205,8 +194,7 @@ class ACHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn =
|
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
acFunctions.firstWhere((f) => f.code == selectedFunction);
|
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -302,8 +290,7 @@ class ACHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected:
|
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -397,13 +384,9 @@ class ACHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected
|
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||||
? Icons.radio_button_checked
|
|
||||||
: Icons.radio_button_unchecked,
|
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected
|
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||||
? ColorsManager.primaryColorWithOpacity
|
|
||||||
: ColorsManager.textGray,
|
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -415,8 +398,7 @@ class ACHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription:
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
selectedFunctionData?.valueDescription,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -5,10 +5,8 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/devices_mo
|
|||||||
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/functions_bloc/functions_bloc_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/helper/duration_format_helper.dart';
|
import 'package:syncrow_web/pages/routines/helper/duration_format_helper.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/ac/ac_function.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
import 'package:syncrow_web/pages/routines/models/device_functions.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
import 'package:syncrow_web/pages/routines/models/gang_switches/base_switch_function.dart';
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/one_gang_switch/one_gang_switch.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
import 'package:syncrow_web/pages/routines/models/gang_switches/switch_operational_value.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dialog_footer.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
import 'package:syncrow_web/pages/routines/widgets/dialog_header.dart';
|
||||||
@ -16,32 +14,29 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
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(
|
||||||
required String dialogType,
|
BuildContext context,
|
||||||
required BuildContext context,
|
List<DeviceFunction> functions,
|
||||||
required List<DeviceFunction> functions,
|
AllDevicesModel? device,
|
||||||
required AllDevicesModel? device,
|
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
String uniqueCustomId,
|
||||||
required String uniqueCustomId,
|
bool removeComparetors,
|
||||||
required bool removeComparetors,
|
) async {
|
||||||
}) async {
|
List<BaseSwitchFunction> acFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
||||||
List<BaseSwitchFunction> oneGangFunctions =
|
|
||||||
functions.whereType<BaseSwitchFunction>().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: (_) => FunctionBloc()
|
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
..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 selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData = state.addedFunctions
|
final selectedFunctionData =
|
||||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -66,12 +61,12 @@ class OneGangSwitchHelper {
|
|||||||
// Left side: Function list
|
// Left side: Function list
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
itemCount: oneGangFunctions.length,
|
itemCount: acFunctions.length,
|
||||||
separatorBuilder: (_, __) => const Divider(
|
separatorBuilder: (_, __) => const Divider(
|
||||||
color: ColorsManager.dividerColor,
|
color: ColorsManager.dividerColor,
|
||||||
),
|
),
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final function = oneGangFunctions[index];
|
final function = acFunctions[index];
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: SvgPicture.asset(
|
leading: SvgPicture.asset(
|
||||||
function.icon,
|
function.icon,
|
||||||
@ -88,12 +83,9 @@ class OneGangSwitchHelper {
|
|||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context
|
context.read<FunctionBloc>().add(SelectFunction(
|
||||||
.read<FunctionBloc>()
|
|
||||||
.add(SelectFunction(
|
|
||||||
functionCode: function.code,
|
functionCode: function.code,
|
||||||
operationName:
|
operationName: function.operationName,
|
||||||
function.operationName,
|
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -107,7 +99,7 @@ class OneGangSwitchHelper {
|
|||||||
context: context,
|
context: context,
|
||||||
selectedFunction: selectedFunction,
|
selectedFunction: selectedFunction,
|
||||||
selectedFunctionData: selectedFunctionData,
|
selectedFunctionData: selectedFunctionData,
|
||||||
acFunctions: oneGangFunctions,
|
acFunctions: acFunctions,
|
||||||
device: device,
|
device: device,
|
||||||
operationName: selectedOperationName ?? '',
|
operationName: selectedOperationName ?? '',
|
||||||
removeComparetors: removeComparetors,
|
removeComparetors: removeComparetors,
|
||||||
@ -182,14 +174,8 @@ class OneGangSwitchHelper {
|
|||||||
removeComparetors: removeComparetors,
|
removeComparetors: removeComparetors,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final selectedFn = acFunctions.firstWhere(
|
|
||||||
(f) => f.code == selectedFunction,
|
|
||||||
orElse: () => OneGangSwitchFunction(
|
|
||||||
deviceId: '',
|
|
||||||
deviceName: '',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
final selectedFn = acFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -226,11 +212,11 @@ class OneGangSwitchHelper {
|
|||||||
selectedFunctionData,
|
selectedFunctionData,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownDisplay(context, initialValue, device, operationName,
|
_buildCountDownDisplay(
|
||||||
selectedFunctionData, selectCode),
|
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownSlider(context, initialValue, device, operationName,
|
_buildCountDownSlider(
|
||||||
selectedFunctionData, selectCode),
|
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -271,8 +257,7 @@ class OneGangSwitchHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected:
|
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -320,8 +305,7 @@ class OneGangSwitchHelper {
|
|||||||
value: (initialValue ?? 0).toDouble(),
|
value: (initialValue ?? 0).toDouble(),
|
||||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||||
divisions: (((operationalValues.maxValue ?? 0) -
|
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
||||||
(operationalValues.minValue ?? 0)) /
|
|
||||||
(operationalValues.stepValue ?? 1))
|
(operationalValues.stepValue ?? 1))
|
||||||
.round(),
|
.round(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -373,13 +357,9 @@ class OneGangSwitchHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected
|
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||||
? Icons.radio_button_checked
|
|
||||||
: Icons.radio_button_unchecked,
|
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected
|
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||||
? ColorsManager.primaryColorWithOpacity
|
|
||||||
: ColorsManager.textGray,
|
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -391,8 +371,7 @@ class OneGangSwitchHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription:
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
selectedFunctionData?.valueDescription,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -14,15 +14,14 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class ThreeGangSwitchHelper {
|
class ThreeGangSwitchHelper {
|
||||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
||||||
required BuildContext context,
|
BuildContext context,
|
||||||
required List<DeviceFunction> functions,
|
List<DeviceFunction> functions,
|
||||||
required AllDevicesModel? device,
|
AllDevicesModel? device,
|
||||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
required String uniqueCustomId,
|
String uniqueCustomId,
|
||||||
required String dialogType,
|
bool removeComparetors,
|
||||||
required bool removeComparetors,
|
) async {
|
||||||
}) async {
|
|
||||||
List<BaseSwitchFunction> switchFunctions =
|
List<BaseSwitchFunction> switchFunctions =
|
||||||
functions.whereType<BaseSwitchFunction>().toList();
|
functions.whereType<BaseSwitchFunction>().toList();
|
||||||
|
|
||||||
|
@ -14,32 +14,29 @@ import 'package:syncrow_web/utils/color_manager.dart';
|
|||||||
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
import 'package:syncrow_web/utils/extension/build_context_x.dart';
|
||||||
|
|
||||||
class TwoGangSwitchHelper {
|
class TwoGangSwitchHelper {
|
||||||
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog({
|
static Future<Map<String, dynamic>?> showSwitchFunctionsDialog(
|
||||||
required BuildContext context,
|
BuildContext context,
|
||||||
required List<DeviceFunction> functions,
|
List<DeviceFunction> functions,
|
||||||
required AllDevicesModel? device,
|
AllDevicesModel? device,
|
||||||
required List<DeviceFunctionData>? deviceSelectedFunctions,
|
List<DeviceFunctionData>? deviceSelectedFunctions,
|
||||||
required String uniqueCustomId,
|
String uniqueCustomId,
|
||||||
required bool removeComparetors,
|
bool removeComparetors,
|
||||||
required String dialogType,
|
) async {
|
||||||
}) async {
|
List<BaseSwitchFunction> switchFunctions = functions.whereType<BaseSwitchFunction>().toList();
|
||||||
List<BaseSwitchFunction> switchFunctions =
|
|
||||||
functions.whereType<BaseSwitchFunction>().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: (_) => FunctionBloc()
|
create: (_) => FunctionBloc()..add(InitializeFunctions(deviceSelectedFunctions ?? [])),
|
||||||
..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 selectedOperationName = state.selectedOperationName;
|
final selectedOperationName = state.selectedOperationName;
|
||||||
final selectedFunctionData = state.addedFunctions
|
final selectedFunctionData =
|
||||||
.firstWhere((f) => f.functionCode == selectedFunction,
|
state.addedFunctions.firstWhere((f) => f.functionCode == selectedFunction,
|
||||||
orElse: () => DeviceFunctionData(
|
orElse: () => DeviceFunctionData(
|
||||||
entityId: '',
|
entityId: '',
|
||||||
functionCode: selectedFunction ?? '',
|
functionCode: selectedFunction ?? '',
|
||||||
@ -86,12 +83,9 @@ class TwoGangSwitchHelper {
|
|||||||
color: ColorsManager.textGray,
|
color: ColorsManager.textGray,
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
context
|
context.read<FunctionBloc>().add(SelectFunction(
|
||||||
.read<FunctionBloc>()
|
|
||||||
.add(SelectFunction(
|
|
||||||
functionCode: function.code,
|
functionCode: function.code,
|
||||||
operationName:
|
operationName: function.operationName,
|
||||||
function.operationName,
|
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -167,8 +161,7 @@ class TwoGangSwitchHelper {
|
|||||||
required String operationName,
|
required String operationName,
|
||||||
required bool removeComparetors,
|
required bool removeComparetors,
|
||||||
}) {
|
}) {
|
||||||
if (selectedFunction == 'countdown_1' ||
|
if (selectedFunction == 'countdown_1' || selectedFunction == 'countdown_2') {
|
||||||
selectedFunction == 'countdown_2') {
|
|
||||||
final initialValue = selectedFunctionData?.value ?? 200;
|
final initialValue = selectedFunctionData?.value ?? 200;
|
||||||
return _buildTemperatureSelector(
|
return _buildTemperatureSelector(
|
||||||
context: context,
|
context: context,
|
||||||
@ -182,8 +175,7 @@ class TwoGangSwitchHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedFn =
|
final selectedFn = switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
||||||
switchFunctions.firstWhere((f) => f.code == selectedFunction);
|
|
||||||
final values = selectedFn.getOperationalValues();
|
final values = selectedFn.getOperationalValues();
|
||||||
|
|
||||||
return _buildOperationalValuesList(
|
return _buildOperationalValuesList(
|
||||||
@ -220,11 +212,11 @@ class TwoGangSwitchHelper {
|
|||||||
selectedFunctionData,
|
selectedFunctionData,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownDisplay(context, initialValue, device, operationName,
|
_buildCountDownDisplay(
|
||||||
selectedFunctionData, selectCode),
|
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
_buildCountDownSlider(context, initialValue, device, operationName,
|
_buildCountDownSlider(
|
||||||
selectedFunctionData, selectCode),
|
context, initialValue, device, operationName, selectedFunctionData, selectCode),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -265,8 +257,7 @@ class TwoGangSwitchHelper {
|
|||||||
minHeight: 40.0,
|
minHeight: 40.0,
|
||||||
minWidth: 40.0,
|
minWidth: 40.0,
|
||||||
),
|
),
|
||||||
isSelected:
|
isSelected: conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
||||||
conditions.map((c) => c == (currentCondition ?? "==")).toList(),
|
|
||||||
children: conditions.map((c) => Text(c)).toList(),
|
children: conditions.map((c) => Text(c)).toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -314,8 +305,7 @@ class TwoGangSwitchHelper {
|
|||||||
value: (initialValue ?? 0).toDouble(),
|
value: (initialValue ?? 0).toDouble(),
|
||||||
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
min: operationalValues.minValue?.toDouble() ?? 0.0,
|
||||||
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
max: operationalValues.maxValue?.toDouble() ?? 0.0,
|
||||||
divisions: (((operationalValues.maxValue ?? 0) -
|
divisions: (((operationalValues.maxValue ?? 0) - (operationalValues.minValue ?? 0)) /
|
||||||
(operationalValues.minValue ?? 0)) /
|
|
||||||
(operationalValues.stepValue ?? 1))
|
(operationalValues.stepValue ?? 1))
|
||||||
.round(),
|
.round(),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@ -367,13 +357,9 @@ class TwoGangSwitchHelper {
|
|||||||
style: context.textTheme.bodyMedium,
|
style: context.textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
isSelected
|
isSelected ? Icons.radio_button_checked : Icons.radio_button_unchecked,
|
||||||
? Icons.radio_button_checked
|
|
||||||
: Icons.radio_button_unchecked,
|
|
||||||
size: 24,
|
size: 24,
|
||||||
color: isSelected
|
color: isSelected ? ColorsManager.primaryColorWithOpacity : ColorsManager.textGray,
|
||||||
? ColorsManager.primaryColorWithOpacity
|
|
||||||
: ColorsManager.textGray,
|
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelected) {
|
if (!isSelected) {
|
||||||
@ -385,8 +371,7 @@ class TwoGangSwitchHelper {
|
|||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
value: value.value,
|
value: value.value,
|
||||||
condition: selectedFunctionData?.condition,
|
condition: selectedFunctionData?.condition,
|
||||||
valueDescription:
|
valueDescription: selectedFunctionData?.valueDescription,
|
||||||
selectedFunctionData?.valueDescription,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
|
||||||
import 'package:syncrow_web/pages/routines/helper/dialog_helper/device_dialog_helper.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/automation_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/automation_dialog.dart';
|
||||||
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/delay_dialog.dart';
|
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/delay_dialog.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/helper/dialog_helper/device_dialog_helper.dart';
|
||||||
|
import 'package:syncrow_web/pages/routines/widgets/dragable_card.dart';
|
||||||
import 'package:syncrow_web/utils/constants/assets.dart';
|
import 'package:syncrow_web/utils/constants/assets.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
@ -113,8 +113,7 @@ class ThenContainer extends StatelessWidget {
|
|||||||
'1G',
|
'1G',
|
||||||
'2G',
|
'2G',
|
||||||
'3G',
|
'3G',
|
||||||
'WPS',
|
'WPS'
|
||||||
'CPS',
|
|
||||||
].contains(state.thenItems[index]
|
].contains(state.thenItems[index]
|
||||||
['productType'])) {
|
['productType'])) {
|
||||||
context.read<RoutineBloc>().add(
|
context.read<RoutineBloc>().add(
|
||||||
@ -230,7 +229,7 @@ class ThenContainer extends StatelessWidget {
|
|||||||
dialogType: "THEN");
|
dialogType: "THEN");
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||||
} else if (!['AC', '1G', '2G', '3G', 'WPS', 'CPS']
|
} else if (!['AC', '1G', '2G', '3G', 'WPS']
|
||||||
.contains(mutableData['productType'])) {
|
.contains(mutableData['productType'])) {
|
||||||
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
context.read<RoutineBloc>().add(AddToThenContainer(mutableData));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user