show curtain in devices and implement dialog for if and then

last integrate with backend
This commit is contained in:
raf-dev1
2025-06-17 13:34:23 +03:00
parent 994e9f4e57
commit 056a1daadc
10 changed files with 499 additions and 149 deletions

View File

@ -4,6 +4,7 @@ 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/ceiling_sensor/ceiling_sensor_helper.dart';
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/curtain_dialog.dart';
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/flush_presence_sensor/flush_presence_sensor.dart';
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/gateway/gateway_helper.dart';
import 'package:syncrow_web/pages/routines/widgets/routine_dialogs/one_gang_switch_dialog.dart';
@ -26,7 +27,7 @@ class DeviceDialogHelper {
final result = await _getDialogForDeviceType(
dialogType: dialogType,
context: context,
productType: data['productType'],
productType: data['productType'] as String,
data: data,
functions: functions,
removeComparetors: removeComparetors,
@ -65,7 +66,14 @@ class DeviceDialogHelper {
removeComparetors: removeComparetors,
dialogType: dialogType,
);
case 'CUR':
return CurtainHelper.showControlDialog(
dialogType: dialogType,
context: context,
functions: functions,
uniqueCustomId: data['uniqueCustomId'],
device: data['device'],
);
case '1G':
return OneGangSwitchHelper.showSwitchFunctionsDialog(
dialogType: dialogType,

View File

@ -17,9 +17,10 @@ class SaveRoutineHelper {
builder: (context) {
return BlocBuilder<RoutineBloc, RoutineState>(
builder: (context, state) {
final selectedConditionLabel = state.selectedAutomationOperator == 'and'
? 'All Conditions are met'
: 'Any Condition is met';
final selectedConditionLabel =
state.selectedAutomationOperator == 'and'
? 'All Conditions are met'
: 'Any Condition is met';
return AlertDialog(
contentPadding: EdgeInsets.zero,
@ -37,10 +38,11 @@ class SaveRoutineHelper {
Text(
'Create a scene: ${state.routineName ?? ""}',
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headlineMedium!.copyWith(
color: ColorsManager.primaryColorWithOpacity,
fontWeight: FontWeight.bold,
),
style:
Theme.of(context).textTheme.headlineMedium!.copyWith(
color: ColorsManager.primaryColorWithOpacity,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 18),
_buildDivider(),
@ -58,7 +60,8 @@ class SaveRoutineHelper {
_buildIfConditions(state, context),
Container(
width: 1,
color: ColorsManager.greyColor.withValues(alpha: 0.8),
color: ColorsManager.greyColor
.withValues(alpha: 0.8),
),
_buildThenActions(state, context),
],
@ -97,7 +100,8 @@ class SaveRoutineHelper {
child: Row(
spacing: 16,
children: [
Expanded(child: Text('IF: $selectedConditionLabel', style: textStyle)),
Expanded(
child: Text('IF: $selectedConditionLabel', style: textStyle)),
const Expanded(child: Text('THEN:', style: textStyle)),
],
),
@ -109,7 +113,7 @@ class SaveRoutineHelper {
spacing: 16,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
DialogFooterButton(
DialogFooterButton(
text: 'Back',
onTap: () => Navigator.pop(context),
),
@ -143,7 +147,8 @@ class SaveRoutineHelper {
child: ListView(
// shrinkWrap: true,
children: state.thenItems.map((item) {
final functions = state.selectedFunctions[item['uniqueCustomId']] ?? [];
final functions =
state.selectedFunctions[item['uniqueCustomId']] ?? [];
return functionRow(item, context, functions);
}).toList(),
),
@ -203,19 +208,20 @@ class SaveRoutineHelper {
),
),
child: Center(
child: item['type'] == 'tap_to_run' || item['type'] == 'scene'
? Image.memory(
base64Decode(item['icon']),
width: 12,
height: 22,
fit: BoxFit.scaleDown,
)
: SvgPicture.asset(
item['imagePath'],
width: 12,
height: 12,
fit: BoxFit.scaleDown,
),
child:
item['type'] == 'tap_to_run' || item['type'] == 'scene'
? Image.memory(
base64Decode(item['icon']),
width: 12,
height: 22,
fit: BoxFit.scaleDown,
)
: SvgPicture.asset(
item['imagePath'],
width: 12,
height: 12,
fit: BoxFit.scaleDown,
),
),
),
Flexible(