diff --git a/lib/features/scene/bloc/create_scene/create_scene_bloc.dart b/lib/features/scene/bloc/create_scene/create_scene_bloc.dart index 5db632d..cfbf305 100644 --- a/lib/features/scene/bloc/create_scene/create_scene_bloc.dart +++ b/lib/features/scene/bloc/create_scene/create_scene_bloc.dart @@ -414,19 +414,10 @@ class CreateSceneBloc extends Bloc NavigationService.navigatorKey.currentContext!) .add(SetCustomTime(effectiveTime!.start, effectiveTime!.end)); - // Reset all days to not selected before toggling + // Set the days directly from the API response BlocProvider.of( NavigationService.navigatorKey.currentContext!) - .add(ResetDays()); - - // Iterate over the loops and toggle each day - for (int i = 0; i < effectiveTime!.loops.length; i++) { - if (effectiveTime!.loops[i] == '1') { - BlocProvider.of( - NavigationService.navigatorKey.currentContext!) - .add(ToggleDay(_getDayFromIndex(i))); - } - } + .add(SetDays(response.effectiveTime?.loops ?? '1111111')); emit(AddSceneTask( automationTasksList: automationTasksList, diff --git a/lib/features/scene/bloc/effective_period/effect_period_bloc.dart b/lib/features/scene/bloc/effective_period/effect_period_bloc.dart index ea2c501..551c06b 100644 --- a/lib/features/scene/bloc/effective_period/effect_period_bloc.dart +++ b/lib/features/scene/bloc/effective_period/effect_period_bloc.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:bloc/bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:syncrow_app/features/scene/bloc/create_scene/create_scene_bloc.dart'; @@ -14,6 +16,7 @@ class EffectPeriodBloc extends Bloc { on(_onSetCustomTime); on(_onResetEffectivePeriod); on(_onResetDays); + on(_setAllDays); } void _onSetPeriod(SetPeriod event, Emitter emit) { @@ -120,4 +123,8 @@ class EffectPeriodBloc extends Bloc { const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']; return days.indexOf(day); } + + FutureOr _setAllDays(SetDays event, Emitter emit) { + emit(state.copyWith(selectedDaysBinary: event.daysBinary)); + } } diff --git a/lib/features/scene/bloc/effective_period/effect_period_event.dart b/lib/features/scene/bloc/effective_period/effect_period_event.dart index c628983..cd1a9c0 100644 --- a/lib/features/scene/bloc/effective_period/effect_period_event.dart +++ b/lib/features/scene/bloc/effective_period/effect_period_event.dart @@ -42,3 +42,9 @@ class ResetDays extends EffectPeriodEvent { @override List get props => []; } + +class SetDays extends EffectPeriodEvent { + final String daysBinary; + + const SetDays(this.daysBinary); +} diff --git a/lib/features/scene/widgets/alert_dialogs/alert_dialog_slider_steps.dart b/lib/features/scene/widgets/alert_dialogs/alert_dialog_slider_steps.dart index 3e986e7..18fdb05 100644 --- a/lib/features/scene/widgets/alert_dialogs/alert_dialog_slider_steps.dart +++ b/lib/features/scene/widgets/alert_dialogs/alert_dialog_slider_steps.dart @@ -57,6 +57,15 @@ class _AlertDialogSliderStepsState extends State { } setState(() {}); + + context.read().add( + SelectedValueEvent( + value: _deNormalizeValue(groupValue), + code: widget.taskItem.code, + isAutomation: widget.isAutomation, + comparator: _indexToComparator(selectedToggleIndex), + ), + ); } double _normalizeValue(dynamic value) { diff --git a/lib/features/scene/widgets/if_then_containers/then_added_tasks.dart b/lib/features/scene/widgets/if_then_containers/then_added_tasks.dart index 1af98c4..131f810 100644 --- a/lib/features/scene/widgets/if_then_containers/then_added_tasks.dart +++ b/lib/features/scene/widgets/if_then_containers/then_added_tasks.dart @@ -48,9 +48,9 @@ class ThenAddedTasksContainer extends StatelessWidget "${duration.inHours}h ${duration.inMinutes.remainder(60)}m "; } else if (taskItem.code.contains('temp_set') || taskItem.code.contains('temp_current')) { - if (taskItem.functionValue != null || taskItem.functionValue != 0) { + if ((taskItem.functionValue != null || taskItem.functionValue != 0)) { operationValue = - '${((taskItem.functionValue / 10) as double).round().toString()}°C'; + '${((taskItem.functionValue / 10) as double).toStringAsFixed(1)}°C'; } else { operationValue = '0°C'; }