@ -11,7 +11,6 @@ import 'package:immich_mobile/extensions/maplibrecontroller_extensions.dart';
import ' package:immich_mobile/modules/map/widgets/map_theme_override.dart ' ;
import ' package:immich_mobile/modules/map/widgets/map_theme_override.dart ' ;
import ' package:maplibre_gl/maplibre_gl.dart ' ;
import ' package:maplibre_gl/maplibre_gl.dart ' ;
import ' package:immich_mobile/modules/map/utils/map_utils.dart ' ;
import ' package:immich_mobile/modules/map/utils/map_utils.dart ' ;
import ' package:geolocator/geolocator.dart ' ;
@ RoutePage < LatLng ? > ( )
@ RoutePage < LatLng ? > ( )
class MapLocationPickerPage extends HookConsumerWidget {
class MapLocationPickerPage extends HookConsumerWidget {
@ -46,15 +45,13 @@ class MapLocationPickerPage extends HookConsumerWidget {
}
}
Future < void > getCurrentLocation ( ) async {
Future < void > getCurrentLocation ( ) async {
var ( currentLocation , locationPermission ) =
var ( currentLocation , _ ) =
await MapUtils . checkPermAndGetLocation ( context ) ;
await MapUtils . checkPermAndGetLocation ( context ) ;
if ( locationPermission = = LocationPermission . denied | |
locationPermission = = LocationPermission . deniedForever ) {
return ;
}
if ( currentLocation = = null ) {
if ( currentLocation = = null ) {
return ;
return ;
}
}
var currentLatLng =
var currentLatLng =
LatLng ( currentLocation . latitude , currentLocation . longitude ) ;
LatLng ( currentLocation . latitude , currentLocation . longitude ) ;
selectedLatLng . value = currentLatLng ;
selectedLatLng . value = currentLatLng ;
@ -67,40 +64,35 @@ class MapLocationPickerPage extends HookConsumerWidget {
backgroundColor: ctx . themeData . cardColor ,
backgroundColor: ctx . themeData . cardColor ,
appBar: _AppBar ( onClose: onClose ) ,
appBar: _AppBar ( onClose: onClose ) ,
extendBodyBehindAppBar: true ,
extendBodyBehindAppBar: true ,
body: Column (
primary: true ,
children: [
body: style . widgetWhen (
style . widgetWhen (
onData: ( style ) = > Container (
onData: ( style ) = > Expanded (
clipBehavior: Clip . antiAliasWithSaveLayer ,
child: Container (
decoration: const BoxDecoration (
clipBehavior: Clip . antiAliasWithSaveLayer ,
borderRadius: BorderRadius . only (
decoration: const BoxDecoration (
bottomLeft: Radius . circular ( 40 ) ,
borderRadius: BorderRadius . only (
bottomRight: Radius . circular ( 40 ) ,
bottomLeft: Radius . circular ( 40 ) ,
bottomRight: Radius . circular ( 40 ) ,
) ,
) ,
child: MaplibreMap (
initialCameraPosition:
CameraPosition ( target: initialLatLng , zoom: 12 ) ,
styleString: style ,
onMapCreated: ( mapController ) = >
controller . value = mapController ,
onStyleLoadedCallback: onStyleLoaded ,
onMapClick: onMapClick ,
dragEnabled: false ,
tiltGesturesEnabled: false ,
myLocationEnabled: false ,
attributionButtonMargins: const Point ( 20 , 15 ) ,
) ,
) ,
) ,
) ,
) ,
) ,
_BottomBar (
child: MaplibreMap (
selectedLatLng: selectedLatLng ,
initialCameraPosition:
onUseLocation: ( ) = > onClose ( selectedLatLng . value ) ,
CameraPosition ( target: initialLatLng , zoom: 12 ) ,
onGetCurrentLocation: getCurrentLocation ,
styleString: style ,
onMapCreated: ( mapController ) = >
controller . value = mapController ,
onStyleLoadedCallback: onStyleLoaded ,
onMapClick: onMapClick ,
dragEnabled: false ,
tiltGesturesEnabled: false ,
myLocationEnabled: false ,
attributionButtonMargins: const Point ( 20 , 15 ) ,
) ,
) ,
] ,
) ,
) ,
bottomNavigationBar: _BottomBar (
selectedLatLng: selectedLatLng ,
onUseLocation: ( ) = > onClose ( selectedLatLng . value ) ,
onGetCurrentLocation: getCurrentLocation ,
) ,
) ,
) ,
) ,
) ,
) ,
@ -116,17 +108,15 @@ class _AppBar extends StatelessWidget implements PreferredSizeWidget {
@ override
@ override
Widget build ( BuildContext context ) {
Widget build ( BuildContext context ) {
return Padding (
return Padding (
padding: EdgeInsets . only ( top: MediaQuery . paddingOf ( context ) . top + 25 ) ,
padding: const EdgeInsets . only ( top: 25 ) ,
child: Expanded (
child: Align (
child: Align (
alignment: Alignment . centerLeft ,
alignment: Alignment . centerLeft ,
child: ElevatedButton (
child: ElevatedButton (
onPressed: onClose ,
onPressed: onClose ,
style: ElevatedButton . styleFrom (
style: ElevatedButton . styleFrom (
shape: const CircleBorder ( ) ,
shape: const CircleBorder ( ) ,
) ,
child: const Icon ( Icons . arrow_back_ios_new_rounded ) ,
) ,
) ,
child: const Icon ( Icons . arrow_back_ios_new_rounded ) ,
) ,
) ,
) ,
) ,
) ;
) ;
@ -150,38 +140,42 @@ class _BottomBar extends StatelessWidget {
@ override
@ override
Widget build ( BuildContext context ) {
Widget build ( BuildContext context ) {
return SizedBox (
return SizedBox (
height: 150 ,
height: 150 + context . padding . bottom ,
child: Column (
child: Padding (
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
padding: EdgeInsets . only ( bottom: context . padding . bottom ) ,
crossAxisAlignment: CrossAxisAlignment . start ,
child: Column (
children: [
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
Row (
crossAxisAlignment: CrossAxisAlignment . start ,
mainAxisAlignment: MainAxisAlignment . center ,
children: [
children: [
Row (
const Icon ( Icons . public , size: 18 ) ,
mainAxisAlignment: MainAxisAlignment . center ,
const SizedBox ( width: 15 ) ,
children: [
ValueListenableBuilder (
const Icon ( Icons . public , size: 18 ) ,
valueListenable: selectedLatLng ,
const SizedBox ( width: 15 ) ,
builder: ( _ , value , __ ) = > Text (
ValueListenableBuilder (
" ${ value . latitude . toStringAsFixed ( 4 ) } , ${ value . longitude . toStringAsFixed ( 4 ) } " ,
valueListenable: selectedLatLng ,
builder: ( _ , value , __ ) = > Text (
" ${ value . latitude . toStringAsFixed ( 4 ) } , ${ value . longitude . toStringAsFixed ( 4 ) } " ,
) ,
) ,
) ,
) ,
] ,
] ,
) ,
) ,
Row (
Row (
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
mainAxisAlignment: MainAxisAlignment . spaceEvenly ,
children: [
children: [
ElevatedButton (
ElevatedButton (
onPressed: onUseLocation ,
onPressed: onUseLocation ,
child:
child: const Text ( " map_location_picker_page_use_location " ) . tr ( ) ,
const Text ( " map_location_picker_page_use_location " ) . tr ( ) ,
) ,
) ,
ElevatedButton (
ElevatedButton (
onPressed: onGetCurrentLocation ,
onPressed: onGetCurrentLocation ,
child: const Icon ( Icons . my_location ) ,
child: const Icon ( Icons . my_location ) ,
) ,
) ,
] ,
] ,
) ,
) ,
] ,
] ,
) ,
) ,
) ,
) ;
) ;
}
}