From eec761d72b66459f01705f458da0d89f87b39a2f Mon Sep 17 00:00:00 2001 From: Xennis Date: Wed, 4 Oct 2023 22:46:18 +0200 Subject: [PATCH] Smaller code improvements --- green_walking/lib/library/map_utils.dart | 4 ++-- green_walking/lib/widgets/map_view.dart | 17 ++--------------- .../lib/widgets/search_result_card.dart | 12 ++++++------ 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/green_walking/lib/library/map_utils.dart b/green_walking/lib/library/map_utils.dart index d3029ad..44f429b 100644 --- a/green_walking/lib/library/map_utils.dart +++ b/green_walking/lib/library/map_utils.dart @@ -14,7 +14,7 @@ extension MapboxMapPosition on MapboxMap { Future getCameraPosition() async { try { final CameraState mapCameraState = await getCameraState(); - return positionForCoordinate(mapCameraState.center); + return _positionForCoordinate(mapCameraState.center); } catch (e) { log('failed to get camera position: $e'); return null; @@ -35,7 +35,7 @@ extension MapboxMapPosition on MapboxMap { } } -Position positionForCoordinate(Map raw) { +Position _positionForCoordinate(Map raw) { final List coordinates = raw['coordinates'] as List; return Position(coordinates[0] as num, coordinates[1] as num); } diff --git a/green_walking/lib/widgets/map_view.dart b/green_walking/lib/widgets/map_view.dart index caf8159..effd485 100644 --- a/green_walking/lib/widgets/map_view.dart +++ b/green_walking/lib/widgets/map_view.dart @@ -9,7 +9,6 @@ import '../library/map_utils.dart'; import '../pages/search.dart'; import '../services/shared_prefs.dart'; import '../widgets/app_bar.dart'; -import '../widgets/gdpr_dialog.dart'; import '../widgets/page_route.dart'; import '../widgets/location_button.dart'; import '../config.dart'; @@ -33,21 +32,12 @@ class _MapViewState extends State { CircleAnnotationManager? _circleAnnotationManager; Timer? _timer; - @override - void initState() { - super.initState(); - WidgetsBinding.instance.addPostFrameCallback((_) => enableAnalyticsOrConsent(context)); - } - @override Widget build(BuildContext context) { final AppLocalizations locale = AppLocalizations.of(context)!; return Stack( children: [ _mapWidget(), - /*Attribution( - satelliteLayer: - _mapboxStyle == MabboxTileset.satellite),*/ LocationButton( trackUserLocation: _userlocationTracking, onOkay: (bool permissionGranted) => _onLocationSearchPressed(locale, permissionGranted), @@ -80,12 +70,9 @@ class _MapViewState extends State { onMapCreated: (MapboxMap mapboxMap) { _mapboxMap = mapboxMap; - //mapboxMap.setTelemetryEnabled(false); + //_mapboxMap.setTelemetryEnabled(false); _mapboxMap.compass.updateSettings(CompassSettings(marginTop: 400.0)); _mapboxMap.scaleBar.updateSettings(ScaleBarSettings(enabled: false)); - //mapController!.onSymbolTapped.add(_onSymbolTapped); - //onPositionChanged(mapController!.cameraPosition); - _mapboxMap.annotations.createCircleAnnotationManager().then((value) { _circleAnnotationManager = value; }); @@ -212,7 +199,7 @@ class _MapViewState extends State { }); } - Future _displaySearchResult(Position? position) async { + void _displaySearchResult(Position? position) async { if (position == null) { return; } diff --git a/green_walking/lib/widgets/search_result_card.dart b/green_walking/lib/widgets/search_result_card.dart index 6cdc85a..58b8041 100644 --- a/green_walking/lib/widgets/search_result_card.dart +++ b/green_walking/lib/widgets/search_result_card.dart @@ -26,19 +26,19 @@ class SearchResultCard extends StatelessWidget { subtitle: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(subtitle), const Padding(padding: EdgeInsets.only(bottom: 8.0)), - _PlaceCardFooterRow( + _FooterRow( userPosition: userPosition, place: place, ) ]), - trailing: _PlaceCardTrailingWidget(place: place), + trailing: _TrailingWidget(place: place), ), ); } } -class _PlaceCardTrailingWidget extends StatelessWidget { - const _PlaceCardTrailingWidget({required this.place}); +class _TrailingWidget extends StatelessWidget { + const _TrailingWidget({required this.place}); final GeocodingPlace place; @@ -68,8 +68,8 @@ class _PlaceCardTrailingWidget extends StatelessWidget { } } -class _PlaceCardFooterRow extends StatelessWidget { - const _PlaceCardFooterRow({required this.place, required this.userPosition}); +class _FooterRow extends StatelessWidget { + const _FooterRow({required this.place, required this.userPosition}); final GeocodingPlace place; final Position? userPosition;