Skip to content

Commit 0ad8af3

Browse files
[google_maps_flutter] Convert heatmap controller to Swift (flutter#12713)
This converts HeatmapController and the remaining utility functions to Swift in the `_sdk*` packages. The final remaining Obj-C code will be migrated in a follow-up PRs. The conversion process was: - Initial conversion via Gemini, with explicit instruction to keep the structure the same. - Side-by-side manual review of the old and new versions of the files. - Manual fixes and improvements. The conversion code utils have much more change than previous PRs, since the direct conversion code felt very non-idiomatic in Swift. Almost all of the free functions for Pigeon<->Maps SDK type conversions were converted to extensions on the Pigeon types: - To avoid the fragile pattern of putting extension methods on types we don't control (which can lead to collisions), all the extensions are on the Pigeon types, and so the APIs aren't symmetrical: - Maps -> Pigeon is done via a convenience constructor (generally called `make(from:)` - Pigeon -> Maps is done via a `toMapsSDKClassName()` method on the Pigeon type (I'm not sold on that naming pattern; alternate suggestions welcome) - Conversions functions that were array-based have been changed to single-element conversions following the pattern above, and then the call sites changed to just `map` that conversion function, since `map` is a simple and idiomatic pattern in Swift, unlike the loop-and-add construction that had been required in Obj-C. - This in turn caused some tests to be simplified, since we didn't need to test things like the number of list items converted, and can instead just test the individual conversion. The test bridging header is removed since there are no longer any `_Test` headers. Part of flutter#119108 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent bfc3b6c commit 0ad8af3

102 files changed

Lines changed: 2539 additions & 3448 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/google_maps_flutter/google_maps_flutter_ios_sdk10/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.18.11
2+
3+
* Converts heatmap controller and data conversion to Swift.
4+
15
## 2.18.10
26

37
* Converts marker controllers to Swift.

‎packages/google_maps_flutter/google_maps_flutter_ios_sdk10/example/ios/Runner.xcodeproj/project.pbxproj‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
350A657853294B478D70CD62 /* PolylineControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PolylineControllerTests.swift; sourceTree = "<group>"; };
7878
0F65543ABD25496A92F8F91F /* TileOverlayControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileOverlayControllerTests.swift; sourceTree = "<group>"; };
7979
54CD823EECFC4BDD8755DD92 /* TileProviderControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TileProviderControllerTests.swift; sourceTree = "<group>"; };
80-
65E43D60708A4C5DA931E12E /* RunnerTests-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RunnerTests-Bridging-Header.h; sourceTree = "<group>"; };
8180
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
8281
3351C2253008164500700458 /* GoogleMapsUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleMapsUITests.swift; sourceTree = "<group>"; };
8382
3390B4582F33AFA60094DEB9 /* PartiallyMockedMapView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PartiallyMockedMapView.swift; sourceTree = "<group>"; };
@@ -208,7 +207,6 @@
208207
350A657853294B478D70CD62 /* PolylineControllerTests.swift */,
209208
0F65543ABD25496A92F8F91F /* TileOverlayControllerTests.swift */,
210209
54CD823EECFC4BDD8755DD92 /* TileProviderControllerTests.swift */,
211-
65E43D60708A4C5DA931E12E /* RunnerTests-Bridging-Header.h */,
212210
);
213211
path = RunnerTests;
214212
sourceTree = "<group>";
@@ -649,7 +647,6 @@
649647
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests;
650648
PRODUCT_NAME = "$(TARGET_NAME)";
651649
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner";
652-
SWIFT_OBJC_BRIDGING_HEADER = "RunnerTests/RunnerTests-Bridging-Header.h";
653650
SWIFT_VERSION = 5.0;
654651
};
655652
name = Debug;
@@ -670,7 +667,6 @@
670667
PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.RunnerTests;
671668
PRODUCT_NAME = "$(TARGET_NAME)";
672669
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/Runner";
673-
SWIFT_OBJC_BRIDGING_HEADER = "RunnerTests/RunnerTests-Bridging-Header.h";
674670
SWIFT_VERSION = 5.0;
675671
};
676672
name = Release;

‎packages/google_maps_flutter/google_maps_flutter_ios_sdk10/example/ios/RunnerTests/CircleControllerTests.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import GoogleMaps
66
import Testing
7+
import google_maps_flutter_ios_sdk10_objc
78

89
@testable import google_maps_flutter_ios_sdk10
910

‎packages/google_maps_flutter/google_maps_flutter_ios_sdk10/example/ios/RunnerTests/ClusterManagersControllerTests.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import Flutter
66
import GoogleMaps
77
import Testing
8+
import google_maps_flutter_ios_sdk10_objc
89

910
@testable import google_maps_flutter_ios_sdk10
1011

0 commit comments

Comments
 (0)