From c5da615a90aeb1e7751777c8ad0090c27ab3721e Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 13 Jun 2024 13:21:03 +0200 Subject: [PATCH 1/2] 1462: update maplibre, fix properties --- frontend/lib/map/map/map.dart | 10 +++++----- frontend/pubspec.lock | 33 +++++++++++++++------------------ frontend/pubspec.yaml | 5 +---- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/frontend/lib/map/map/map.dart b/frontend/lib/map/map/map.dart index 3360c1c6c..496970789 100644 --- a/frontend/lib/map/map/map.dart +++ b/frontend/lib/map/map/map.dart @@ -81,15 +81,15 @@ class _MapContainerState extends State implements MapController { // There is no way to remove the logo, so set the margins to a really large value to hide it logoViewMargins: const math.Point(double.maxFinite, double.maxFinite), myLocationEnabled: _permissionGiven, - myLocationTrackingMode: _permissionGiven ? MyLocationTrackingMode.Tracking : MyLocationTrackingMode.None, + myLocationTrackingMode: _permissionGiven ? MyLocationTrackingMode.tracking : MyLocationTrackingMode.none, // required to prevent mapbox iOS from requesting location // permissions on startup, as discussed in #249 - myLocationRenderMode: MyLocationRenderMode.NORMAL, + myLocationRenderMode: MyLocationRenderMode.normal, onMapCreated: _onMapCreated, onMapClick: _onMapClick, onStyleLoadedCallback: () {}, compassViewMargins: math.Point(Platform.isIOS ? compassMargin : 0, compassMargin), - compassViewPosition: CompassViewPosition.TopRight, + compassViewPosition: CompassViewPosition.topRight, minMaxZoomPreference: const MinMaxZoomPreference(4.0, 18.0), ), Positioned( @@ -229,7 +229,7 @@ class _MapContainerState extends State implements MapController { final update = zoomLevel != null ? CameraUpdate.newLatLngZoom(location, zoomLevel) : CameraUpdate.newLatLng(location); - await controller.updateMyLocationTrackingMode(MyLocationTrackingMode.None); + await controller.updateMyLocationTrackingMode(MyLocationTrackingMode.none); await controller.animateCamera(update); } @@ -250,7 +250,7 @@ class _MapContainerState extends State implements MapController { ); await controller.animateCamera(cameraUpdate); - await controller.updateMyLocationTrackingMode(MyLocationTrackingMode.Tracking); + await controller.updateMyLocationTrackingMode(MyLocationTrackingMode.tracking); if (!_permissionGiven) { setState(() => _permissionGiven = true); } diff --git a/frontend/pubspec.lock b/frontend/pubspec.lock index 11c111f27..dadbaaf87 100644 --- a/frontend/pubspec.lock +++ b/frontend/pubspec.lock @@ -734,30 +734,27 @@ packages: maplibre_gl: dependency: "direct main" description: - path: "." - ref: "git-release-0.18.0" - resolved-ref: "9397fae65c533e8ff0828bf62511ca34082763ff" - url: "https://github.com/maplibre/flutter-maplibre-gl.git" - source: git - version: "0.18.0" + name: maplibre_gl + sha256: ea2fa443e7d5dc18db7f37a0f6f5af40642888c56b81a14441aeddea077adaea + url: "https://pub.dev" + source: hosted + version: "0.20.0" maplibre_gl_platform_interface: dependency: transitive description: - path: maplibre_gl_platform_interface - ref: "git-release-0.18.0" - resolved-ref: "9397fae65c533e8ff0828bf62511ca34082763ff" - url: "https://github.com/maplibre/flutter-maplibre-gl.git" - source: git - version: "0.18.0" + name: maplibre_gl_platform_interface + sha256: "718c3503f36936fbf35c34d6ddf8bf770474c5ba1e6cb1d8caece44efae424af" + url: "https://pub.dev" + source: hosted + version: "0.20.0" maplibre_gl_web: dependency: transitive description: - path: maplibre_gl_web - ref: "git-release-0.18.0" - resolved-ref: "9397fae65c533e8ff0828bf62511ca34082763ff" - url: "https://github.com/maplibre/flutter-maplibre-gl.git" - source: git - version: "0.18.0" + name: maplibre_gl_web + sha256: e7d71b08f24dca70e9c9cf841b096704a677e6239447d87220ec071355768149 + url: "https://pub.dev" + source: hosted + version: "0.20.0" matcher: dependency: transitive description: diff --git a/frontend/pubspec.yaml b/frontend/pubspec.yaml index b1bce56f1..6f75c799d 100644 --- a/frontend/pubspec.yaml +++ b/frontend/pubspec.yaml @@ -16,10 +16,7 @@ dependencies: flutter_localizations: sdk: flutter intl: ^0.18.0 - maplibre_gl: - git: - url: https://github.com/maplibre/flutter-maplibre-gl.git - ref: git-release-0.18.0 + maplibre_gl: ^0.20.0 provider: ^6.0.3 graphql_flutter: ^5.1.2 url_launcher: ^6.2.5 From 5634430f7f12370e12af0dc4ad399354ce8603e1 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 25 Jun 2024 17:25:14 +0200 Subject: [PATCH 2/2] 1462: update kotlin android plugin, set kotlinOptions to jvm target, add workaround to reload map page if it comes to foreground --- frontend/android/app/build.gradle | 4 ++++ frontend/android/settings.gradle | 2 +- frontend/ios/Podfile.lock | 24 ++++++++++++------------ frontend/lib/home/home_page.dart | 27 +++++++++++++++++++++++++-- frontend/lib/map/map/map.dart | 9 ++++----- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/frontend/android/app/build.gradle b/frontend/android/app/build.gradle index 5e56a3f58..98f9d3c1f 100644 --- a/frontend/android/app/build.gradle +++ b/frontend/android/app/build.gradle @@ -64,6 +64,10 @@ ext.setupVariant = { variant, buildConfigName -> android { compileSdkVersion 34 + kotlinOptions { + jvmTarget=JavaVersion.VERSION_1_8 + } + sourceSets { main.java.srcDirs += 'src/main/kotlin' } diff --git a/frontend/android/settings.gradle b/frontend/android/settings.gradle index ef03c12b4..83b4cf1d3 100644 --- a/frontend/android/settings.gradle +++ b/frontend/android/settings.gradle @@ -19,7 +19,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version "7.3.1" apply false - id "org.jetbrains.kotlin.android" version "1.7.10" apply false + id "org.jetbrains.kotlin.android" version "1.9.10" apply false } include ":app" diff --git a/frontend/ios/Podfile.lock b/frontend/ios/Podfile.lock index 45264fa74..d868d2b84 100644 --- a/frontend/ios/Podfile.lock +++ b/frontend/ios/Podfile.lock @@ -32,23 +32,23 @@ PODS: - GoogleToolboxForMac/Defines (= 2.3.2) - "GoogleToolboxForMac/NSString+URLArguments (= 2.3.2)" - "GoogleToolboxForMac/NSString+URLArguments (2.3.2)" - - GoogleUtilities/Environment (7.13.0): + - GoogleUtilities/Environment (7.13.3): - GoogleUtilities/Privacy - PromisesObjC (< 3.0, >= 1.2) - - GoogleUtilities/Logger (7.13.0): + - GoogleUtilities/Logger (7.13.3): - GoogleUtilities/Environment - GoogleUtilities/Privacy - - GoogleUtilities/Privacy (7.13.0) - - GoogleUtilities/UserDefaults (7.13.0): + - GoogleUtilities/Privacy (7.13.3) + - GoogleUtilities/UserDefaults (7.13.3): - GoogleUtilities/Logger - GoogleUtilities/Privacy - GoogleUtilitiesComponents (1.1.0): - GoogleUtilities/Logger - GTMSessionFetcher/Core (2.3.0) - - MapLibre (5.14.0-pre3) + - MapLibre (6.5.0) - maplibre_gl (0.0.1): - Flutter - - MapLibre (= 5.14.0-pre3) + - MapLibre (= 6.5.0) - MLImage (1.0.0-beta4) - MLKitBarcodeScanning (3.0.0): - MLKitCommon (~> 9.0) @@ -83,7 +83,7 @@ PODS: - permission_handler_apple (9.3.0): - Flutter - PromisesObjC (2.4.0) - - ReachabilitySwift (5.2.1) + - ReachabilitySwift (5.2.3) - Sentry/HybridSDK (8.21.0): - SentryPrivate (= 8.21.0) - sentry_flutter (0.0.1): @@ -172,11 +172,11 @@ SPEC CHECKSUMS: GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a GoogleMLKit: 2bd0dc6253c4d4f227aad460f69215a504b2980e GoogleToolboxForMac: 8bef7c7c5cf7291c687cf5354f39f9db6399ad34 - GoogleUtilities: d053d902a8edaa9904e1bd00c37535385b8ed152 + GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 GoogleUtilitiesComponents: 679b2c881db3b615a2777504623df6122dd20afe GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2 - MapLibre: 620fc933c1d6029b33738c905c1490d024e5d4ef - maplibre_gl: a2efec727dd340e4c65e26d2b03b584f14881fd9 + MapLibre: 0ebfa9329d313cec8bf0a5ba5a336a1dc903785e + maplibre_gl: 943a491fffb3337c1b9de57fd377206d18c16e34 MLImage: 7bb7c4264164ade9bf64f679b40fb29c8f33ee9b MLKitBarcodeScanning: 04e264482c5f3810cb89ebc134ef6b61e67db505 MLKitCommon: c1b791c3e667091918d91bda4bba69a91011e390 @@ -187,7 +187,7 @@ SPEC CHECKSUMS: path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 - ReachabilitySwift: 5ae15e16814b5f9ef568963fb2c87aeb49158c66 + ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979 Sentry: ebc12276bd17613a114ab359074096b6b3725203 sentry_flutter: dff1df05dc39c83d04f9330b36360fc374574c5e SentryPrivate: d651efb234cf385ec9a1cdd3eff94b5e78a0e0fe @@ -196,4 +196,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 911aea8a3150d910789c4f32e348c4d0ff803162 -COCOAPODS: 1.13.0 +COCOAPODS: 1.15.2 diff --git a/frontend/lib/home/home_page.dart b/frontend/lib/home/home_page.dart index c1f51a068..1b8bd7bc1 100644 --- a/frontend/lib/home/home_page.dart +++ b/frontend/lib/home/home_page.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:ehrenamtskarte/about/about_page.dart'; import 'package:ehrenamtskarte/build_config/build_config.dart' show buildConfig; import 'package:ehrenamtskarte/configuration/settings_model.dart'; @@ -13,10 +15,12 @@ import 'package:provider/provider.dart'; import 'package:ehrenamtskarte/l10n/translations.g.dart'; +import 'package:ehrenamtskarte/routing.dart'; + const mapTabIndex = 0; const identityTabIndex = 2; -class HomePage extends StatefulWidget { +class HomePage extends StatefulWidget with WidgetsBindingObserver { final int? initialTabIndex; const HomePage({super.key, this.initialTabIndex}); @@ -24,7 +28,7 @@ class HomePage extends StatefulWidget { HomePageState createState() => HomePageState(); } -class HomePageState extends State { +class HomePageState extends State with WidgetsBindingObserver { late List appFlows; int _currentTabIndex = mapTabIndex; @@ -34,6 +38,7 @@ class HomePageState extends State { @override void initState() { super.initState(); + WidgetsBinding.instance.addObserver(this); _currentTabIndex = widget.initialTabIndex ?? mapTabIndex; appFlows = [ AppFlow( @@ -63,6 +68,24 @@ class HomePageState extends State { ]; } + @override + void dispose() { + WidgetsBinding.instance.removeObserver(this); + super.dispose(); + } + + // Reload map on android devices to solve this issue https://github.com/maplibre/flutter-maplibre-gl/issues/327 + @override + void didChangeAppLifecycleState(AppLifecycleState state) { + if (state == AppLifecycleState.resumed && _currentTabIndex == mapTabIndex && Platform.isAndroid) { + Navigator.of(context, rootNavigator: true).push( + AppRoute( + builder: (context) => HomePage(), + ), + ); + } + } + @override Widget build(BuildContext context) { final settings = Provider.of(context); diff --git a/frontend/lib/map/map/map.dart b/frontend/lib/map/map/map.dart index 496970789..33d22436b 100644 --- a/frontend/lib/map/map/map.dart +++ b/frontend/lib/map/map/map.dart @@ -46,8 +46,8 @@ class MapContainer extends StatefulWidget { const mapboxColor = Color(0xFF979897); -class _MapContainerState extends State implements MapController { - MaplibreMapController? _controller; +class _MapContainerState extends State with WidgetsBindingObserver implements MapController { + MapLibreMapController? _controller; Symbol? _symbol; bool _permissionGiven = false; bool _isMapInitialized = false; @@ -65,7 +65,6 @@ class _MapContainerState extends State implements MapController { final statusBarHeight = MediaQuery.of(context).padding.top; final pixelRatio = MediaQuery.of(context).devicePixelRatio; final compassMargin = Platform.isIOS ? statusBarHeight / pixelRatio : statusBarHeight * pixelRatio; - final userLocation = widget.userLocation; final cameraPosition = userLocation != null ? CameraPosition(target: userLocation, zoom: MapContainer.zoomLevelUserLocation) @@ -73,7 +72,7 @@ class _MapContainerState extends State implements MapController { final mapLibreView = Stack( children: [ - MaplibreMap( + MapLibreMap( initialCameraPosition: cameraPosition, styleString: config.mapStyleUrl, // We provide our own attribution menu @@ -121,7 +120,7 @@ class _MapContainerState extends State implements MapController { : mapLibreView; } - void _onMapCreated(MaplibreMapController controller) { + void _onMapCreated(MapLibreMapController controller) { _controller = controller; setState(() {