mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(mobile): location button map beta timeline (#21590)
fix(mobile): location button map
This commit is contained in:
parent
51aec1e93d
commit
538263dc38
1 changed files with 47 additions and 13 deletions
|
|
@ -47,10 +47,12 @@ class _DriftMapState extends ConsumerState<DriftMap> {
|
||||||
MapLibreMapController? mapController;
|
MapLibreMapController? mapController;
|
||||||
final _reloadMutex = AsyncMutex();
|
final _reloadMutex = AsyncMutex();
|
||||||
final _debouncer = Debouncer(interval: const Duration(milliseconds: 500), maxWaitTime: const Duration(seconds: 2));
|
final _debouncer = Debouncer(interval: const Duration(milliseconds: 500), maxWaitTime: const Duration(seconds: 2));
|
||||||
|
final ValueNotifier<double> bottomSheetOffset = ValueNotifier(0.25);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_debouncer.dispose();
|
_debouncer.dispose();
|
||||||
|
bottomSheetOffset.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,8 +159,8 @@ class _DriftMapState extends ConsumerState<DriftMap> {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
_Map(initialLocation: widget.initialLocation, onMapCreated: onMapCreated, onMapReady: onMapReady),
|
_Map(initialLocation: widget.initialLocation, onMapCreated: onMapCreated, onMapReady: onMapReady),
|
||||||
_MyLocationButton(onZoomToLocation: onZoomToLocation),
|
_DynamicBottomSheet(bottomSheetOffset: bottomSheetOffset),
|
||||||
const MapBottomSheet(),
|
_DynamicMyLocationButton(onZoomToLocation: onZoomToLocation, bottomSheetOffset: bottomSheetOffset),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -191,21 +193,53 @@ class _Map extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MyLocationButton extends StatelessWidget {
|
class _DynamicBottomSheet extends StatefulWidget {
|
||||||
const _MyLocationButton({required this.onZoomToLocation});
|
final ValueNotifier<double> bottomSheetOffset;
|
||||||
|
|
||||||
final VoidCallback onZoomToLocation;
|
const _DynamicBottomSheet({required this.bottomSheetOffset});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_DynamicBottomSheet> createState() => _DynamicBottomSheetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DynamicBottomSheetState extends State<_DynamicBottomSheet> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Positioned(
|
return NotificationListener<DraggableScrollableNotification>(
|
||||||
right: 0,
|
onNotification: (notification) {
|
||||||
bottom: context.padding.bottom + 16,
|
widget.bottomSheetOffset.value = notification.extent;
|
||||||
child: ElevatedButton(
|
return true;
|
||||||
onPressed: onZoomToLocation,
|
},
|
||||||
style: ElevatedButton.styleFrom(shape: const CircleBorder()),
|
child: const MapBottomSheet(),
|
||||||
child: const Icon(Icons.my_location),
|
);
|
||||||
),
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DynamicMyLocationButton extends StatelessWidget {
|
||||||
|
const _DynamicMyLocationButton({required this.onZoomToLocation, required this.bottomSheetOffset});
|
||||||
|
|
||||||
|
final VoidCallback onZoomToLocation;
|
||||||
|
final ValueNotifier<double> bottomSheetOffset;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ValueListenableBuilder<double>(
|
||||||
|
valueListenable: bottomSheetOffset,
|
||||||
|
builder: (context, offset, child) {
|
||||||
|
return Positioned(
|
||||||
|
right: 16,
|
||||||
|
bottom: context.height * (offset - 0.02) + context.padding.bottom,
|
||||||
|
child: AnimatedOpacity(
|
||||||
|
opacity: offset < 0.8 ? 1 : 0,
|
||||||
|
duration: const Duration(milliseconds: 150),
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: onZoomToLocation,
|
||||||
|
style: ElevatedButton.styleFrom(shape: const CircleBorder()),
|
||||||
|
child: const Icon(Icons.my_location),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue