From 99c6fdbc1c7fe2524767b5c96a616bee1e288fef Mon Sep 17 00:00:00 2001
From: Muhideen Mujeeb Adeoye <41507005+Mujhtech@users.noreply.github.com>
Date: Mon, 17 Jun 2024 23:27:54 +0100
Subject: [PATCH] fix(mobile): upgrade maplibre_gl package to fix issue with
 crash in ios7.4 above simulator (#10182)

* fix(mobile): upgrade maplibre_gl package to fix issue with crash in ios7.4 above simulator

* chore: switch from deprecated widget and controller name to new name in latest sdk

* remove todo

---------

Co-authored-by: Alex <alex.tran1502@gmail.com>
---
 mobile/ios/Podfile.lock                       | 24 +++++++-------
 .../maplibrecontroller_extensions.dart        |  2 +-
 mobile/lib/pages/search/map/map.page.dart     |  8 ++---
 .../search/map/map_location_picker.page.dart  |  4 +--
 .../search/search_page_state.provider.dart    |  2 +-
 mobile/lib/widgets/map/map_thumbnail.dart     |  6 ++--
 mobile/pubspec.lock                           | 33 +++++++++----------
 mobile/pubspec.yaml                           |  6 +---
 8 files changed, 39 insertions(+), 46 deletions(-)

diff --git a/mobile/ios/Podfile.lock b/mobile/ios/Podfile.lock
index bc79594ee9..87092a591b 100644
--- a/mobile/ios/Podfile.lock
+++ b/mobile/ios/Podfile.lock
@@ -17,9 +17,9 @@ PODS:
   - fluttertoast (0.0.2):
     - Flutter
     - Toast
-  - FMDB (2.7.5):
-    - FMDB/standard (= 2.7.5)
-  - FMDB/standard (2.7.5)
+  - FMDB (2.7.11):
+    - FMDB/standard (= 2.7.11)
+  - FMDB/standard (2.7.11)
   - geolocator_apple (1.2.0):
     - Flutter
   - image_picker_ios (0.0.1):
@@ -28,10 +28,10 @@ PODS:
     - Flutter
   - isar_flutter_libs (1.0.0):
     - Flutter
-  - MapLibre (5.14.0-pre3)
+  - MapLibre (6.5.0)
   - maplibre_gl (0.0.1):
     - Flutter
-    - MapLibre (= 5.14.0-pre3)
+    - MapLibre (= 6.5.0)
   - package_info_plus (0.4.5):
     - Flutter
   - path_provider_foundation (0.0.1):
@@ -44,7 +44,7 @@ PODS:
   - photo_manager (2.0.0):
     - Flutter
     - FlutterMacOS
-  - ReachabilitySwift (5.0.0)
+  - ReachabilitySwift (5.2.3)
   - SAMKeychain (1.5.3)
   - share_plus (0.0.1):
     - Flutter
@@ -54,7 +54,7 @@ PODS:
   - sqflite (0.0.3):
     - Flutter
     - FMDB (>= 2.7.5)
-  - Toast (4.0.0)
+  - Toast (4.1.1)
   - url_launcher_ios (0.0.1):
     - Flutter
   - video_player_avfoundation (0.0.1):
@@ -156,24 +156,24 @@ SPEC CHECKSUMS:
   flutter_udid: a2482c67a61b9c806ef59dd82ed8d007f1b7ac04
   flutter_web_auth: c25208760459cec375a3c39f6a8759165ca0fa4d
   fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265
-  FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
+  FMDB: 57486c1117fd8e0e6b947b2f54c3f42bf8e57a4e
   geolocator_apple: 9157311f654584b9bb72686c55fc02a97b73f461
   image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
   integration_test: ce0a3ffa1de96d1a89ca0ac26fca7ea18a749ef4
   isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
-  MapLibre: 620fc933c1d6029b33738c905c1490d024e5d4ef
-  maplibre_gl: a2efec727dd340e4c65e26d2b03b584f14881fd9
+  MapLibre: 0ebfa9329d313cec8bf0a5ba5a336a1dc903785e
+  maplibre_gl: 943a491fffb3337c1b9de57fd377206d18c16e34
   package_info_plus: 115f4ad11e0698c8c1c5d8a689390df880f47e85
   path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
   path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
   permission_handler_apple: e76247795d700c14ea09e3a2d8855d41ee80a2e6
   photo_manager: 4f6810b7dfc4feb03b461ac1a70dacf91fba7604
-  ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
+  ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979
   SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c
   share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5
   shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
   sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a
-  Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
+  Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4e
   url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812
   video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579
   wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47
diff --git a/mobile/lib/extensions/maplibrecontroller_extensions.dart b/mobile/lib/extensions/maplibrecontroller_extensions.dart
index 83074be137..9636df012c 100644
--- a/mobile/lib/extensions/maplibrecontroller_extensions.dart
+++ b/mobile/lib/extensions/maplibrecontroller_extensions.dart
@@ -6,7 +6,7 @@ import 'package:immich_mobile/models/map/map_marker.model.dart';
 import 'package:immich_mobile/utils/map_utils.dart';
 import 'package:maplibre_gl/maplibre_gl.dart';
 
-extension MapMarkers on MaplibreMapController {
+extension MapMarkers on MapLibreMapController {
   static var _completer = Completer()..complete();
 
   Future<void> addGeoJSONSourceForMarkers(List<MapMarker> markers) async {
diff --git a/mobile/lib/pages/search/map/map.page.dart b/mobile/lib/pages/search/map/map.page.dart
index e686994557..341be93c2d 100644
--- a/mobile/lib/pages/search/map/map.page.dart
+++ b/mobile/lib/pages/search/map/map.page.dart
@@ -35,7 +35,7 @@ class MapPage extends HookConsumerWidget {
 
   @override
   Widget build(BuildContext context, WidgetRef ref) {
-    final mapController = useRef<MaplibreMapController?>(null);
+    final mapController = useRef<MapLibreMapController?>(null);
     final markers = useRef<List<MapMarker>>([]);
     final markersInBounds = useRef<List<MapMarker>>([]);
     final bottomSheetStreamController = useStreamController<MapEvent>();
@@ -155,7 +155,7 @@ class MapPage extends HookConsumerWidget {
       }
     }
 
-    void onMapCreated(MaplibreMapController controller) async {
+    void onMapCreated(MapLibreMapController controller) async {
       mapController.value = controller;
       controller.addListener(() {
         if (controller.isCameraMoving && selectedMarker.value != null) {
@@ -373,7 +373,7 @@ class _MapWithMarker extends StatelessWidget {
         child: Stack(
           children: [
             style.widgetWhen(
-              onData: (style) => MaplibreMap(
+              onData: (style) => MapLibreMap(
                 initialCameraPosition:
                     const CameraPosition(target: LatLng(0, 0)),
                 styleString: style,
@@ -387,7 +387,7 @@ class _MapWithMarker extends StatelessWidget {
                 tiltGesturesEnabled: false,
                 dragEnabled: false,
                 myLocationEnabled: false,
-                attributionButtonPosition: AttributionButtonPosition.TopRight,
+                attributionButtonPosition: AttributionButtonPosition.topRight,
                 rotateGesturesEnabled: false,
               ),
             ),
diff --git a/mobile/lib/pages/search/map/map_location_picker.page.dart b/mobile/lib/pages/search/map/map_location_picker.page.dart
index db0c980c89..1ec6560c6a 100644
--- a/mobile/lib/pages/search/map/map_location_picker.page.dart
+++ b/mobile/lib/pages/search/map/map_location_picker.page.dart
@@ -24,7 +24,7 @@ class MapLocationPickerPage extends HookConsumerWidget {
   @override
   Widget build(BuildContext context, WidgetRef ref) {
     final selectedLatLng = useValueNotifier<LatLng>(initialLatLng);
-    final controller = useRef<MaplibreMapController?>(null);
+    final controller = useRef<MapLibreMapController?>(null);
     final marker = useRef<Symbol?>(null);
 
     Future<void> onStyleLoaded() async {
@@ -74,7 +74,7 @@ class MapLocationPickerPage extends HookConsumerWidget {
                   bottomRight: Radius.circular(40),
                 ),
               ),
-              child: MaplibreMap(
+              child: MapLibreMap(
                 initialCameraPosition:
                     CameraPosition(target: initialLatLng, zoom: 12),
                 styleString: style,
diff --git a/mobile/lib/providers/search/search_page_state.provider.dart b/mobile/lib/providers/search/search_page_state.provider.dart
index d0e3720c0f..f3409c33d1 100644
--- a/mobile/lib/providers/search/search_page_state.provider.dart
+++ b/mobile/lib/providers/search/search_page_state.provider.dart
@@ -41,7 +41,7 @@ final getAllPlacesProvider =
   final curatedContent = assetPlaces
       .map(
         (data) => SearchCuratedContent(
-          label: data.exifInfo!.city!,
+          label: data.exifInfo?.city ?? '',
           id: data.id,
         ),
       )
diff --git a/mobile/lib/widgets/map/map_thumbnail.dart b/mobile/lib/widgets/map/map_thumbnail.dart
index d02c016791..6e0e9ac339 100644
--- a/mobile/lib/widgets/map/map_thumbnail.dart
+++ b/mobile/lib/widgets/map/map_thumbnail.dart
@@ -41,10 +41,10 @@ class MapThumbnail extends HookConsumerWidget {
   @override
   Widget build(BuildContext context, WidgetRef ref) {
     final offsettedCentre = LatLng(centre.latitude + 0.002, centre.longitude);
-    final controller = useRef<MaplibreMapController?>(null);
+    final controller = useRef<MapLibreMapController?>(null);
     final position = useValueNotifier<Point<num>?>(null);
 
-    Future<void> onMapCreated(MaplibreMapController mapController) async {
+    Future<void> onMapCreated(MapLibreMapController mapController) async {
       controller.value = mapController;
       if (assetMarkerRemoteId != null) {
         // The iOS impl returns wrong toScreenLocation without the delay
@@ -73,7 +73,7 @@ class MapThumbnail extends HookConsumerWidget {
             alignment: Alignment.center,
             children: [
               style.widgetWhen(
-                onData: (style) => MaplibreMap(
+                onData: (style) => MapLibreMap(
                   initialCameraPosition:
                       CameraPosition(target: offsettedCentre, zoom: zoom),
                   styleString: style,
diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock
index 2804dd50a9..8bf94d0da8 100644
--- a/mobile/pubspec.lock
+++ b/mobile/pubspec.lock
@@ -911,30 +911,27 @@ packages:
   maplibre_gl:
     dependency: "direct main"
     description:
-      path: "."
-      ref: acb428a005efd9832a0a8e7ef0945f899dfb3ca5
-      resolved-ref: acb428a005efd9832a0a8e7ef0945f899dfb3ca5
-      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: main
-      resolved-ref: acb428a005efd9832a0a8e7ef0945f899dfb3ca5
-      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: main
-      resolved-ref: acb428a005efd9832a0a8e7ef0945f899dfb3ca5
-      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/mobile/pubspec.yaml b/mobile/pubspec.yaml
index fd65d1bb95..53570eaf73 100644
--- a/mobile/pubspec.yaml
+++ b/mobile/pubspec.yaml
@@ -28,11 +28,7 @@ dependencies:
   video_player: ^2.8.2
   chewie: ^1.7.4
   socket_io_client: ^2.0.3+1
-  # TODO: Update it to tag once next stable release
-  maplibre_gl:
-    git:
-      url: https://github.com/maplibre/flutter-maplibre-gl.git
-      ref: acb428a005efd9832a0a8e7ef0945f899dfb3ca5
+  maplibre_gl: ^0.20.0
   geolocator: ^11.0.0 # used to move to current location in map view
   flutter_udid: ^3.0.0
   flutter_svg: ^2.0.9