mirror of
https://github.com/SyncrowIOT/web.git
synced 2026-10-26 00:37:56 +00:00
finished ac devices
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/routiens/models/device_functions.dart';
|
||||
import 'package:syncrow_web/pages/routiens/models/routine_model.dart';
|
||||
import 'package:syncrow_web/services/routines_api.dart';
|
||||
@@ -21,32 +22,33 @@ 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);
|
||||
emit(state.copyWith(ifItems: updatedIfItems));
|
||||
}
|
||||
// if (!_isDuplicate(state.ifItems, event.item)) {
|
||||
final updatedIfItems = List<Map<String, dynamic>>.from(state.ifItems)
|
||||
..add(event.item);
|
||||
emit(state.copyWith(ifItems: updatedIfItems));
|
||||
// }
|
||||
}
|
||||
|
||||
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);
|
||||
emit(state.copyWith(thenItems: updatedThenItems));
|
||||
}
|
||||
// if (!_isDuplicate(state.thenItems, event.item)) {
|
||||
final updatedThenItems = List<Map<String, dynamic>>.from(state.thenItems)
|
||||
..add(event.item);
|
||||
emit(state.copyWith(thenItems: updatedThenItems));
|
||||
// }
|
||||
}
|
||||
|
||||
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 _onRemoveFunction(RemoveFunction event, Emitter<RoutineState> emit) {
|
||||
final functions = List<DeviceFunctionData>.from(state.selectedFunctions)
|
||||
..removeWhere((f) =>
|
||||
f.function == event.function.function &&
|
||||
f.functionCode == event.function.functionCode &&
|
||||
f.value == event.function.value);
|
||||
emit(state.copyWith(selectedFunctions: functions));
|
||||
}
|
||||
@@ -55,12 +57,12 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
emit(state.copyWith(selectedFunctions: []));
|
||||
}
|
||||
|
||||
bool _isDuplicate(
|
||||
List<Map<String, dynamic>> items, Map<String, dynamic> newItem) {
|
||||
return items.any((item) =>
|
||||
item['imagePath'] == newItem['imagePath'] &&
|
||||
item['title'] == newItem['title']);
|
||||
}
|
||||
// bool _isDuplicate(
|
||||
// List<Map<String, dynamic>> items, Map<String, dynamic> newItem) {
|
||||
// return items.any((item) =>
|
||||
// item['imagePath'] == newItem['imagePath'] &&
|
||||
// item['title'] == newItem['title']);
|
||||
// }
|
||||
|
||||
Future<void> _onLoadScenes(
|
||||
LoadScenes event, Emitter<RoutineState> emit) async {
|
||||
|
||||
Reference in New Issue
Block a user