mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
Added tab to run to if container
This commit is contained in:
@ -11,6 +11,9 @@ part 'routine_state.dart';
|
||||
const spaceId = '25c96044-fadf-44bb-93c7-3c079e527ce6';
|
||||
|
||||
class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
bool isAutomation = false;
|
||||
bool isTabToRun = false;
|
||||
|
||||
RoutineBloc() : super(const RoutineState()) {
|
||||
on<AddToIfContainer>(_onAddToIfContainer);
|
||||
on<AddToThenContainer>(_onAddToThenContainer);
|
||||
@ -23,17 +26,15 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
|
||||
void _onAddToIfContainer(AddToIfContainer event, Emitter<RoutineState> emit) {
|
||||
// if (!_isDuplicate(state.ifItems, event.item)) {
|
||||
final updatedIfItems = List<Map<String, dynamic>>.from(state.ifItems)
|
||||
..add(event.item);
|
||||
final updatedIfItems = List<Map<String, dynamic>>.from(state.ifItems)..add(event.item);
|
||||
isTabToRun = event.isTabToRun;
|
||||
emit(state.copyWith(ifItems: updatedIfItems));
|
||||
// }
|
||||
}
|
||||
|
||||
void _onAddToThenContainer(
|
||||
AddToThenContainer event, Emitter<RoutineState> emit) {
|
||||
void _onAddToThenContainer(AddToThenContainer event, Emitter<RoutineState> emit) {
|
||||
// if (!_isDuplicate(state.thenItems, event.item)) {
|
||||
final updatedThenItems = List<Map<String, dynamic>>.from(state.thenItems)
|
||||
..add(event.item);
|
||||
final updatedThenItems = List<Map<String, dynamic>>.from(state.thenItems)..add(event.item);
|
||||
emit(state.copyWith(thenItems: updatedThenItems));
|
||||
// }
|
||||
}
|
||||
@ -47,9 +48,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
|
||||
void _onRemoveFunction(RemoveFunction event, Emitter<RoutineState> emit) {
|
||||
final functions = List<DeviceFunctionData>.from(state.selectedFunctions)
|
||||
..removeWhere((f) =>
|
||||
f.functionCode == event.function.functionCode &&
|
||||
f.value == event.function.value);
|
||||
..removeWhere(
|
||||
(f) => f.functionCode == event.function.functionCode && f.value == event.function.value);
|
||||
emit(state.copyWith(selectedFunctions: functions));
|
||||
}
|
||||
|
||||
@ -64,8 +64,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
// item['title'] == newItem['title']);
|
||||
// }
|
||||
|
||||
Future<void> _onLoadScenes(
|
||||
LoadScenes event, Emitter<RoutineState> emit) async {
|
||||
Future<void> _onLoadScenes(LoadScenes event, Emitter<RoutineState> emit) async {
|
||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||
|
||||
try {
|
||||
@ -82,8 +81,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onLoadAutomation(
|
||||
LoadAutomation event, Emitter<RoutineState> emit) async {
|
||||
Future<void> _onLoadAutomation(LoadAutomation event, Emitter<RoutineState> emit) async {
|
||||
emit(state.copyWith(isLoading: true, errorMessage: null));
|
||||
|
||||
try {
|
||||
|
Reference in New Issue
Block a user