summaryrefslogtreecommitdiff
path: root/plugins/aves_map/lib/src/controller.dart
diff options
context:
space:
mode:
authormirror <mirror@localhost>2026-11-22 08:41:00 +0900
committermirror <mirror@localhost>2026-11-22 08:41:00 +0900
commit449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch)
treec131c3528c4d517f56e19b854a7453fedb097d40 /plugins/aves_map/lib/src/controller.dart
downloadaves-src-master.tar.gz
aves-src-master.zip
snapshot of aves v1.13.12 (secrets removed: android/app/google-services.json)HEADv1.13.12master
Diffstat (limited to 'plugins/aves_map/lib/src/controller.dart')
-rw-r--r--plugins/aves_map/lib/src/controller.dart77
1 files changed, 77 insertions, 0 deletions
diff --git a/plugins/aves_map/lib/src/controller.dart b/plugins/aves_map/lib/src/controller.dart
new file mode 100644
index 0000000..8997993
--- /dev/null
+++ b/plugins/aves_map/lib/src/controller.dart
@@ -0,0 +1,77 @@
+import 'dart:async';
+
+import 'package:aves_map/src/zoomed_bounds.dart';
+import 'package:flutter/foundation.dart';
+import 'package:latlong2/latlong.dart';
+import 'package:leak_tracker/leak_tracker.dart';
+
+class AvesMapController {
+ final StreamController _streamController = StreamController.broadcast();
+ ZoomedBounds? _idleBounds;
+
+ ZoomedBounds? get idleBounds => _idleBounds;
+
+ Stream<dynamic> get _events => _streamController.stream;
+
+ Stream<MapControllerMoveEvent> get moveCommands => _events.where((event) => event is MapControllerMoveEvent).cast<MapControllerMoveEvent>();
+
+ Stream<MapControllerZoomEvent> get zoomCommands => _events.where((event) => event is MapControllerZoomEvent).cast<MapControllerZoomEvent>();
+
+ Stream<MapControllerRotationResetEvent> get rotationResetCommands => _events.where((event) => event is MapControllerRotationResetEvent).cast<MapControllerRotationResetEvent>();
+
+ Stream<MapIdleUpdate> get idleUpdates => _events.where((event) => event is MapIdleUpdate).cast<MapIdleUpdate>();
+
+ Stream<MapMarkerLocationChangeEvent> get markerLocationChanges => _events.where((event) => event is MapMarkerLocationChangeEvent).cast<MapMarkerLocationChangeEvent>();
+
+ AvesMapController() {
+ if (kFlutterMemoryAllocationsEnabled) {
+ LeakTracking.dispatchObjectCreated(
+ library: 'aves',
+ className: '$AvesMapController',
+ object: this,
+ );
+ }
+ }
+
+ void dispose() {
+ if (kFlutterMemoryAllocationsEnabled) {
+ LeakTracking.dispatchObjectDisposed(object: this);
+ }
+ _streamController.close();
+ }
+
+ void moveTo(LatLng latLng) => _streamController.add(MapControllerMoveEvent(latLng));
+
+ void zoomBy(double delta) => _streamController.add(MapControllerZoomEvent(delta));
+
+ void resetRotation() => _streamController.add(MapControllerRotationResetEvent());
+
+ void notifyIdle(ZoomedBounds bounds) {
+ _idleBounds = bounds;
+ _streamController.add(MapIdleUpdate(bounds));
+ }
+
+ void notifyMarkerLocationChange() => _streamController.add(MapMarkerLocationChangeEvent());
+}
+
+class MapControllerMoveEvent {
+ final LatLng latLng;
+
+ MapControllerMoveEvent(this.latLng);
+}
+
+class MapControllerZoomEvent {
+ final double delta;
+
+ MapControllerZoomEvent(this.delta);
+}
+
+class MapControllerRotationResetEvent {}
+
+class MapIdleUpdate {
+ final ZoomedBounds bounds;
+
+ MapIdleUpdate(this.bounds);
+}
+
+class MapMarkerLocationChangeEvent {}