mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
Merged with latest changes
This commit is contained in:
@ -19,9 +19,9 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
on<AddToThenContainer>(_onAddToThenContainer);
|
||||
on<LoadScenes>(_onLoadScenes);
|
||||
on<LoadAutomation>(_onLoadAutomation);
|
||||
on<AddFunctionToRoutine>(_onAddFunction);
|
||||
on<RemoveFunction>(_onRemoveFunction);
|
||||
on<ClearFunctions>(_onClearFunctions);
|
||||
on<AddFunctionToRoutine>(_onAddFunctionsToRoutine);
|
||||
// on<RemoveFunction>(_onRemoveFunction);
|
||||
// on<ClearFunctions>(_onClearFunctions);
|
||||
}
|
||||
|
||||
void _onAddToIfContainer(AddToIfContainer event, Emitter<RoutineState> emit) {
|
||||
@ -39,23 +39,32 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
// }
|
||||
}
|
||||
|
||||
void _onAddFunction(AddFunctionToRoutine event, Emitter<RoutineState> emit) {
|
||||
final functions = List<DeviceFunctionData>.from(state.selectedFunctions);
|
||||
functions.add(event.function);
|
||||
debugPrint("******" + functions.toString());
|
||||
emit(state.copyWith(selectedFunctions: functions));
|
||||
void _onAddFunctionsToRoutine(AddFunctionToRoutine event, Emitter<RoutineState> emit) {
|
||||
debugPrint(event.uniqueCustomId.toString());
|
||||
debugPrint(event.functions.toString());
|
||||
final currentSelectedFunctions =
|
||||
Map<String, List<DeviceFunctionData>>.from(state.selectedFunctions);
|
||||
|
||||
if (currentSelectedFunctions.containsKey(event.uniqueCustomId)) {
|
||||
currentSelectedFunctions[event.uniqueCustomId]!.addAll(event.functions);
|
||||
} else {
|
||||
currentSelectedFunctions[event.uniqueCustomId] = event.functions;
|
||||
}
|
||||
|
||||
emit(state.copyWith(selectedFunctions: currentSelectedFunctions));
|
||||
}
|
||||
|
||||
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);
|
||||
emit(state.copyWith(selectedFunctions: functions));
|
||||
}
|
||||
// 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);
|
||||
// emit(state.copyWith(selectedFunctions: functions));
|
||||
// }
|
||||
|
||||
void _onClearFunctions(ClearFunctions event, Emitter<RoutineState> emit) {
|
||||
emit(state.copyWith(selectedFunctions: []));
|
||||
}
|
||||
// void _onClearFunctions(ClearFunctions event, Emitter<RoutineState> emit) {
|
||||
// emit(state.copyWith(selectedFunctions: []));
|
||||
// }
|
||||
|
||||
// bool _isDuplicate(
|
||||
// List<Map<String, dynamic>> items, Map<String, dynamic> newItem) {
|
||||
|
Reference in New Issue
Block a user