mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
* reduce timeline rebuilds * feat: adds bottom sheet map and actions (#19692) * adds bottom sheet map and actions * PR feedbacks * only reload the asset viewer if asset is changed * styling tweak --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com> * rename singleton and remove event prefix * adds bottom sheet map and actions * PR feedbacks * refactor: use provider for viewer state * feat: adds top and bottom app bar * add safe area to bottom app bar * change app and bottom bar color * viewer - always have black background * use the full width for the bottom sheet on landscape as well * constraint the bottom sheet to not expand all the way * add padding for location details in landscape --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
53 lines
1.0 KiB
Dart
53 lines
1.0 KiB
Dart
import 'dart:async';
|
|
|
|
sealed class Event {
|
|
const Event();
|
|
}
|
|
|
|
class TimelineReloadEvent extends Event {
|
|
const TimelineReloadEvent();
|
|
}
|
|
|
|
class ViewerOpenBottomSheetEvent extends Event {
|
|
const ViewerOpenBottomSheetEvent();
|
|
}
|
|
|
|
class EventStream {
|
|
EventStream._();
|
|
|
|
static final EventStream shared = EventStream._();
|
|
|
|
final StreamController<Event> _controller =
|
|
StreamController<Event>.broadcast();
|
|
|
|
void emit(Event event) {
|
|
_controller.add(event);
|
|
}
|
|
|
|
Stream<T> where<T extends Event>() {
|
|
if (T == Event) {
|
|
return _controller.stream as Stream<T>;
|
|
}
|
|
return _controller.stream.where((event) => event is T).cast<T>();
|
|
}
|
|
|
|
StreamSubscription<T> listen<T extends Event>(
|
|
void Function(T event)? onData, {
|
|
Function? onError,
|
|
void Function()? onDone,
|
|
bool? cancelOnError,
|
|
}) {
|
|
return where<T>().listen(
|
|
onData,
|
|
onError: onError,
|
|
onDone: onDone,
|
|
cancelOnError: cancelOnError,
|
|
);
|
|
}
|
|
|
|
/// Closes the stream controller
|
|
void dispose() {
|
|
_controller.close();
|
|
}
|
|
}
|