mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-15 01:35:25 +00:00
add reset event
This commit is contained in:
@ -24,6 +24,7 @@ class DeviceManagementBloc
|
|||||||
on<SearchDevices>(_onSearchDevices);
|
on<SearchDevices>(_onSearchDevices);
|
||||||
on<SelectDevice>(_onSelectDevice);
|
on<SelectDevice>(_onSelectDevice);
|
||||||
on<ResetFilters>(_onResetFilters);
|
on<ResetFilters>(_onResetFilters);
|
||||||
|
on<ResetSelectedDevices>(_onResetSelectedDevices);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onFetchDevices(
|
Future<void> _onFetchDevices(
|
||||||
@ -98,6 +99,33 @@ class DeviceManagementBloc
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _onResetSelectedDevices(
|
||||||
|
ResetSelectedDevices event, Emitter<DeviceManagementState> emit) {
|
||||||
|
_selectedDevices.clear();
|
||||||
|
|
||||||
|
if (state is DeviceManagementLoaded) {
|
||||||
|
emit(DeviceManagementLoaded(
|
||||||
|
devices: _devices,
|
||||||
|
selectedIndex: _selectedIndex,
|
||||||
|
onlineCount: _onlineCount,
|
||||||
|
offlineCount: _offlineCount,
|
||||||
|
lowBatteryCount: _lowBatteryCount,
|
||||||
|
selectedDevice: null,
|
||||||
|
isControlButtonEnabled: false,
|
||||||
|
));
|
||||||
|
} else if (state is DeviceManagementFiltered) {
|
||||||
|
emit(DeviceManagementFiltered(
|
||||||
|
filteredDevices: (state as DeviceManagementFiltered).filteredDevices,
|
||||||
|
selectedIndex: _selectedIndex,
|
||||||
|
onlineCount: _onlineCount,
|
||||||
|
offlineCount: _offlineCount,
|
||||||
|
lowBatteryCount: _lowBatteryCount,
|
||||||
|
selectedDevice: null,
|
||||||
|
isControlButtonEnabled: false,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _onSelectedFilterChanged(
|
void _onSelectedFilterChanged(
|
||||||
SelectedFilterChanged event, Emitter<DeviceManagementState> emit) {
|
SelectedFilterChanged event, Emitter<DeviceManagementState> emit) {
|
||||||
_selectedIndex = event.selectedIndex;
|
_selectedIndex = event.selectedIndex;
|
||||||
|
@ -52,3 +52,5 @@ class SelectDevice extends DeviceManagementEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ResetFilters extends DeviceManagementEvent {}
|
class ResetFilters extends DeviceManagementEvent {}
|
||||||
|
|
||||||
|
class ResetSelectedDevices extends DeviceManagementEvent {}
|
||||||
|
Reference in New Issue
Block a user