Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1462: Map vanishes app list #1506

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frontend/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ ext.setupVariant = { variant, buildConfigName ->
android {
compileSdkVersion 34

kotlinOptions {
jvmTarget=JavaVersion.VERSION_1_8
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
24 changes: 12 additions & 12 deletions frontend/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -196,4 +196,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 911aea8a3150d910789c4f32e348c4d0ff803162

COCOAPODS: 1.13.0
COCOAPODS: 1.15.2
27 changes: 25 additions & 2 deletions frontend/lib/home/home_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -13,18 +15,20 @@ 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});

@override
HomePageState createState() => HomePageState();
}

class HomePageState extends State<HomePage> {
class HomePageState extends State<HomePage> with WidgetsBindingObserver {
late List<AppFlow> appFlows;
int _currentTabIndex = mapTabIndex;

Expand All @@ -34,6 +38,7 @@ class HomePageState extends State<HomePage> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
_currentTabIndex = widget.initialTabIndex ?? mapTabIndex;
appFlows = [
AppFlow(
Expand Down Expand Up @@ -63,6 +68,24 @@ class HomePageState extends State<HomePage> {
];
}

@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<SettingsModel>(context);
Expand Down
19 changes: 9 additions & 10 deletions frontend/lib/map/map/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class MapContainer extends StatefulWidget {

const mapboxColor = Color(0xFF979897);

class _MapContainerState extends State<MapContainer> implements MapController {
MaplibreMapController? _controller;
class _MapContainerState extends State<MapContainer> with WidgetsBindingObserver implements MapController {
MapLibreMapController? _controller;
Symbol? _symbol;
bool _permissionGiven = false;
bool _isMapInitialized = false;
Expand All @@ -65,31 +65,30 @@ class _MapContainerState extends State<MapContainer> 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)
: CameraPosition(target: MapContainer.centerOfProject, zoom: MapContainer.zoomLevelOverview);

final mapLibreView = Stack(
children: [
MaplibreMap(
MapLibreMap(
initialCameraPosition: cameraPosition,
styleString: config.mapStyleUrl,
// We provide our own attribution menu
attributionButtonMargins: const math.Point(-100, -100),
// 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(
Expand Down Expand Up @@ -121,7 +120,7 @@ class _MapContainerState extends State<MapContainer> implements MapController {
: mapLibreView;
}

void _onMapCreated(MaplibreMapController controller) {
void _onMapCreated(MapLibreMapController controller) {
_controller = controller;

setState(() {
Expand Down Expand Up @@ -229,7 +228,7 @@ class _MapContainerState extends State<MapContainer> 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);
}

Expand All @@ -250,7 +249,7 @@ class _MapContainerState extends State<MapContainer> implements MapController {
);
await controller.animateCamera(cameraUpdate);

await controller.updateMyLocationTrackingMode(MyLocationTrackingMode.Tracking);
await controller.updateMyLocationTrackingMode(MyLocationTrackingMode.tracking);
if (!_permissionGiven) {
setState(() => _permissionGiven = true);
}
Expand Down
33 changes: 15 additions & 18 deletions frontend/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 1 addition & 4 deletions frontend/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down