From 9af4bad6f628b4d425c6581bab1eeaa5aa075ac8 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Tue, 26 Dec 2023 09:51:04 +0530 Subject: [PATCH 01/45] Implement polyline in google maps ios --- .../example/lib/place_polyline.dart | 4 +-- .../example/lib/place_polyline.dart | 4 +-- .../maps_example_dart/lib/place_polyline.dart | 4 +-- .../ios/Classes/FLTGoogleMapJSONConversions.h | 3 ++ .../ios/Classes/FLTGoogleMapJSONConversions.m | 30 +++++++++++++++++++ .../ios/Classes/GoogleMapPolylineController.m | 12 ++++++++ 6 files changed, 51 insertions(+), 6 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart index e7997fa4445..7cb07ae37db 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart @@ -291,10 +291,10 @@ class PlacePolylineBodyState extends State { child: const Text('change joint type [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) + onPressed: (selectedId == null) ? null : () => _changePattern(selectedId), - child: const Text('change pattern [Android only]'), + child: const Text('change pattern'), ), ], ) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart index 659ef87e87f..d008b7d3b97 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart @@ -292,10 +292,10 @@ class PlacePolylineBodyState extends State { child: const Text('change joint type [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) + onPressed: (selectedId == null) ? null : () => _changePattern(selectedId), - child: const Text('change pattern [Android only]'), + child: const Text('change pattern'), ), ], ) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart index 659ef87e87f..d008b7d3b97 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart @@ -292,10 +292,10 @@ class PlacePolylineBodyState extends State { child: const Text('change joint type [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) + onPressed: (selectedId == null) ? null : () => _changePattern(selectedId), - child: const Text('change pattern [Android only]'), + child: const Text('change pattern'), ), ], ) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h index cfccb7b0b5f..5f472ffff59 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h @@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN + (GMSCoordinateBounds *)coordinateBoundsFromLatLongs:(NSArray *)latlongs; + (GMSMapViewType)mapViewTypeFromTypeValue:(NSNumber *)value; + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelValue; ++ (NSArray *)strokeStylesFromPatterns:(NSArray *)patterns + strokeColor:(UIColor *)strokeColor; ++ (NSArray *)spanLengthsFromPatterns:(NSArray *)patterns; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m index d554c501b1e..3b8fe5f7ecf 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m @@ -141,4 +141,34 @@ + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelVal } return nil; } + ++ (NSArray *)strokeStylesFromPatterns:(NSArray *)patterns + strokeColor:(UIColor *)strokeColor { + NSMutableArray *strokeStyles = [[NSMutableArray alloc] init]; + for (unsigned int i = 0; i < [patterns count]; i++) { + NSString *patternType = patterns[i][0]; + GMSStrokeStyle *strokeStyle; + + if ([patternType isEqualToString:@"gap"]) { + strokeStyle = [GMSStrokeStyle solidColor:[UIColor clearColor]]; + } else { + strokeStyle = [GMSStrokeStyle solidColor:strokeColor]; + } + + [strokeStyles addObject:strokeStyle]; + } + + return strokeStyles; +} + ++ (NSArray *)spanLengthsFromPatterns:(NSArray *)patterns { + NSMutableArray *lengths = [[NSMutableArray alloc] init]; + for (unsigned int i = 0; i < [patterns count]; i++) { + NSNumber *length = [patterns[i] count] > 1 ? patterns[i][1] : @0; + + [lengths addObject:length]; + } + + return lengths; +} @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 77601d4a1bb..345b929297d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -59,6 +59,10 @@ - (void)setGeodesic:(BOOL)isGeodesic { self.polyline.geodesic = isGeodesic; } +- (void)setPattern:(NSArray *)styles lengths:(NSArray *)lengths { + self.polyline.spans = GMSStyleSpans(self.polyline.path, styles, lengths, kGMSLengthRhumb); +} + - (void)interpretPolylineOptions:(NSDictionary *)data registrar:(NSObject *)registrar { NSNumber *consumeTapEvents = data[@"consumeTapEvents"]; @@ -95,6 +99,14 @@ - (void)interpretPolylineOptions:(NSDictionary *)data if (geodesic && geodesic != (id)[NSNull null]) { [self setGeodesic:geodesic.boolValue]; } + + NSArray *patterns = data[@"pattern"]; + if (patterns && patterns != (id)[NSNull null]) { + [self + setPattern:[FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns + strokeColor:self.polyline.strokeColor] + lengths:[FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]]; + } } @end From b6c0d6a398746595fa762a2301dc0f811f10677e Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:55:07 +0530 Subject: [PATCH 02/45] Updated changelog --- .../google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index 96468dc393f..23de03c3549 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -31,7 +31,7 @@ ## 2.3.4 -* Fixes new lint warnings. +* Adds support for patterns in polylines on iOS ## 2.3.3 From 5652138f1ca46f00c9db6e8356b466f0975d217d Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:13:01 +0530 Subject: [PATCH 03/45] Add . to changelog --- .../google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index 23de03c3549..6334a454606 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -31,7 +31,7 @@ ## 2.3.4 -* Adds support for patterns in polylines on iOS +* Adds support for patterns in polylines on iOS. ## 2.3.3 From 3b3f7ac7487f917c41f2138328a635e9f04712a8 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:38:55 +0530 Subject: [PATCH 04/45] Implement tests --- ...TGoogleMapJSONConversionsConversionTests.m | 15 ++++++ .../GoogleMapsPolylinesControllerTests.m | 52 +++++++++++++++++++ .../ios/Classes/GoogleMapPolylineController.h | 4 ++ .../ios/Classes/GoogleMapPolylineController.m | 1 - 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m index bb9020d983c..65b84802d7f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m @@ -287,4 +287,19 @@ - (void)testCameraUpdateFromChannelValueZoomTo { [classMockCameraUpdate stopMocking]; } + +- (void)testLengthsFromPatterns { + NSArray* patterns = @ [@[@"gap", @10], @[@"dash", @10]]; + + NSArray *spanLengths = [FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]; + + XCTAssertEqual([spanLengths count], 2); + + NSNumber * firstSpanLength = spanLengths[0]; + NSNumber * secondSpanLength = spanLengths[1]; + + XCTAssertEqual(firstSpanLength.intValue, 10); + XCTAssertEqual(secondSpanLength.intValue, 10); +} + @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m new file mode 100644 index 00000000000..2d144cb0c2f --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -0,0 +1,52 @@ +@import google_maps_flutter_ios; +@import google_maps_flutter_ios.Test; +@import XCTest; +@import GoogleMaps; + +#import +#import "PartiallyMockedMapView.h" + +@interface GoogleMapsPolylinesControllerTests : XCTestCase +@property (strong, atomic) FLTGoogleMapPolylineController *polylineController; +@end + +@implementation GoogleMapsPolylinesControllerTests + +- (void)setUp { + + NSDictionary *polyline = @{ + @"points": @[ + @[@(52.4816), @(-3.1791)], + @[@(54.043), @(-2.9925)], + @[@(54.1396), @(-4.2739)], + @[@(53.4153), @(-4.0829)] + ], + @"polylineId":@"polyline_id_0", + + }; + + GMSMutablePath *path = [FLTPolylinesController getPath:polyline]; + NSString *identifier = polyline[@"polylineId"]; + + CGRect frame = CGRectMake(0, 0, 100, 100); + PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] + initWithFrame:frame + camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; + + self.polylineController = [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path identifier:identifier mapView:mapView]; +} + +- (void)testSetPatterns { + NSArray *styles=@[[GMSStrokeStyle solidColor:[UIColor clearColor]], [GMSStrokeStyle solidColor:[UIColor redColor]]]; + + NSArray *lengths= @[ @10, @10]; + + XCTAssertNil(self.polylineController.polyline.spans); + + [self.polylineController setPattern:styles lengths:lengths]; + + XCTAssertNotNil(self.polylineController.polyline.spans); +} + +@end + diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h index f85d1a3896f..3ff894ee23a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h @@ -7,10 +7,13 @@ // Defines polyline controllable by Flutter. @interface FLTGoogleMapPolylineController : NSObject +@property(strong, nonatomic) GMSPolyline *polyline; + - (instancetype)initPolylineWithPath:(GMSMutablePath *)path identifier:(NSString *)identifier mapView:(GMSMapView *)mapView; - (void)removePolyline; +- (void)setPattern:(NSArray *)styles lengths:(NSArray *)lengths; @end @interface FLTPolylinesController : NSObject @@ -22,4 +25,5 @@ - (void)removePolylineWithIdentifiers:(NSArray *)identifiers; - (void)didTapPolylineWithIdentifier:(NSString *)identifier; - (bool)hasPolylineWithIdentifier:(NSString *)identifier; ++ (GMSMutablePath *)getPath:(NSDictionary *)polyline; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 345b929297d..1b6b3cba457 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -7,7 +7,6 @@ @interface FLTGoogleMapPolylineController () -@property(strong, nonatomic) GMSPolyline *polyline; @property(weak, nonatomic) GMSMapView *mapView; @end From 8729818e625da0d3e0a6b83c583b35f7fd70501d Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:02:05 +0530 Subject: [PATCH 05/45] Fix formatting in test files --- ...TGoogleMapJSONConversionsConversionTests.m | 23 ++++--- .../GoogleMapsPolylinesControllerTests.m | 64 +++++++++---------- 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m index 65b84802d7f..33d6b6af133 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m @@ -287,19 +287,18 @@ - (void)testCameraUpdateFromChannelValueZoomTo { [classMockCameraUpdate stopMocking]; } - - (void)testLengthsFromPatterns { - NSArray* patterns = @ [@[@"gap", @10], @[@"dash", @10]]; - - NSArray *spanLengths = [FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]; - - XCTAssertEqual([spanLengths count], 2); - - NSNumber * firstSpanLength = spanLengths[0]; - NSNumber * secondSpanLength = spanLengths[1]; - - XCTAssertEqual(firstSpanLength.intValue, 10); - XCTAssertEqual(secondSpanLength.intValue, 10); + NSArray *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; + + NSArray *spanLengths = [FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]; + + XCTAssertEqual([spanLengths count], 2); + + NSNumber *firstSpanLength = spanLengths[0]; + NSNumber *secondSpanLength = spanLengths[1]; + + XCTAssertEqual(firstSpanLength.intValue, 10); + XCTAssertEqual(secondSpanLength.intValue, 10); } @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 2d144cb0c2f..f275f05491b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -7,46 +7,46 @@ #import "PartiallyMockedMapView.h" @interface GoogleMapsPolylinesControllerTests : XCTestCase -@property (strong, atomic) FLTGoogleMapPolylineController *polylineController; +@property(strong, atomic) FLTGoogleMapPolylineController *polylineController; @end @implementation GoogleMapsPolylinesControllerTests - (void)setUp { - - NSDictionary *polyline = @{ - @"points": @[ - @[@(52.4816), @(-3.1791)], - @[@(54.043), @(-2.9925)], - @[@(54.1396), @(-4.2739)], - @[@(53.4153), @(-4.0829)] - ], - @"polylineId":@"polyline_id_0", - - }; - - GMSMutablePath *path = [FLTPolylinesController getPath:polyline]; - NSString *identifier = polyline[@"polylineId"]; - - CGRect frame = CGRectMake(0, 0, 100, 100); - PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] - initWithFrame:frame - camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; - - self.polylineController = [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path identifier:identifier mapView:mapView]; + NSDictionary *polyline = @{ + @"points" : @[ + @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], + @[ @(53.4153), @(-4.0829) ] + ], + @"polylineId" : @"polyline_id_0", + + }; + + GMSMutablePath *path = [FLTPolylinesController getPath:polyline]; + NSString *identifier = polyline[@"polylineId"]; + + CGRect frame = CGRectMake(0, 0, 100, 100); + PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] + initWithFrame:frame + camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; + + self.polylineController = [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path + identifier:identifier + mapView:mapView]; } - (void)testSetPatterns { - NSArray *styles=@[[GMSStrokeStyle solidColor:[UIColor clearColor]], [GMSStrokeStyle solidColor:[UIColor redColor]]]; - - NSArray *lengths= @[ @10, @10]; - - XCTAssertNil(self.polylineController.polyline.spans); - - [self.polylineController setPattern:styles lengths:lengths]; - - XCTAssertNotNil(self.polylineController.polyline.spans); + NSArray *styles = @[ + [GMSStrokeStyle solidColor:[UIColor clearColor]], [GMSStrokeStyle solidColor:[UIColor redColor]] + ]; + + NSArray *lengths = @[ @10, @10 ]; + + XCTAssertNil(self.polylineController.polyline.spans); + + [self.polylineController setPattern:styles lengths:lengths]; + + XCTAssertNotNil(self.polylineController.polyline.spans); } @end - From a4fdeaa986bbd686b8be197afe080ee032a2f2eb Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:03:55 +0530 Subject: [PATCH 06/45] Add license text --- .../ios/RunnerTests/GoogleMapsPolylinesControllerTests.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index f275f05491b..cdb7f20b724 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -1,3 +1,7 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + @import google_maps_flutter_ios; @import google_maps_flutter_ios.Test; @import XCTest; From d184edd695243303a8f195ca3a0de0c23adbc5e0 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:25:36 +0530 Subject: [PATCH 07/45] Revert merge changelog mess --- .../google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index 6334a454606..96468dc393f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -31,7 +31,7 @@ ## 2.3.4 -* Adds support for patterns in polylines on iOS. +* Fixes new lint warnings. ## 2.3.3 From 5859fd2419aa42f446883e5ac8c688facad80f63 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:26:54 +0530 Subject: [PATCH 08/45] Run update-release-info --- .../google_maps_flutter/google_maps_flutter_android/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md index a099bb5ef42..7d738d68cb3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -4,6 +4,7 @@ * Adds support for `getStyleError`. * Updates minimum supported SDK version to Flutter 3.13/Dart 3.1. * Updates compileSdk version to 34. +* Adds support for patterns in polylines on iOS. ## 2.6.2 From 1a314d8fddca9f2b61f75c47c18353dbabc66845 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:40:59 +0530 Subject: [PATCH 09/45] Use floating point value for length --- .../FLTGoogleMapJSONConversionsConversionTests.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m index 33d6b6af133..d2fbd341329 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m @@ -288,7 +288,7 @@ - (void)testCameraUpdateFromChannelValueZoomTo { } - (void)testLengthsFromPatterns { - NSArray *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; + NSArray *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @6.4 ] ]; NSArray *spanLengths = [FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]; @@ -297,8 +297,8 @@ - (void)testLengthsFromPatterns { NSNumber *firstSpanLength = spanLengths[0]; NSNumber *secondSpanLength = spanLengths[1]; - XCTAssertEqual(firstSpanLength.intValue, 10); - XCTAssertEqual(secondSpanLength.intValue, 10); + XCTAssertEqual(firstSpanLength.doubleValue, 10); + XCTAssertEqual(secondSpanLength.doubleValue, 6.4); } @end From 98669dd29d67ab526383f7124d412dd65607a3bc Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Fri, 26 Jan 2024 00:34:52 +0530 Subject: [PATCH 10/45] Comment explaining cannot use isequal --- .../ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index cdb7f20b724..c79fb8b6edd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -50,6 +50,7 @@ - (void)testSetPatterns { [self.polylineController setPattern:styles lengths:lengths]; + // `GMSStyleSpan` doesn't implement `isEqual` so cannot be compared by value at present XCTAssertNotNil(self.polylineController.polyline.spans); } From 00ea57262e95474d337f8a0b069151abf56d5ee1 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Fri, 2 Feb 2024 20:37:05 +0530 Subject: [PATCH 11/45] Add new test file to xcode project --- .../example/ios12/ios/Runner.xcodeproj/project.pbxproj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj index 432bdd7b15f..93b6613ee47 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 4510D964F3B1259FEDD3ABA6 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7755F8F4BABC3D6A0BD4048B /* libPods-Runner.a */; }; + 479E394D2B6D3C7C00CD60F5 /* GoogleMapsPolylinesControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 479E394C2B6D3C7C00CD60F5 /* GoogleMapsPolylinesControllerTests.m */; }; 6851F3562835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */; }; 68E4726A2836FF0C00BDDDAC /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 68E472692836FF0C00BDDDAC /* MapKit.framework */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; @@ -59,6 +60,7 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 479E394C2B6D3C7C00CD60F5 /* GoogleMapsPolylinesControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GoogleMapsPolylinesControllerTests.m; sourceTree = ""; }; 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLTGoogleMapJSONConversionsConversionTests.m; sourceTree = ""; }; 68E472692836FF0C00BDDDAC /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/iOSSupport/System/Library/Frameworks/MapKit.framework; sourceTree = DEVELOPER_DIR; }; 733AFAB37683A9DA7512F09C /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; @@ -198,6 +200,7 @@ F7151F11265D7ED70028CB91 /* RunnerTests */ = { isa = PBXGroup; children = ( + 479E394C2B6D3C7C00CD60F5 /* GoogleMapsPolylinesControllerTests.m */, 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */, F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */, 982F2A6A27BADE17003C81F4 /* PartiallyMockedMapView.h */, From 937a0307a00c0feaf3ef54f61d2077a47172bcb0 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Fri, 2 Feb 2024 20:57:21 +0530 Subject: [PATCH 12/45] Add period to comment --- .../ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index c79fb8b6edd..f63444c7c42 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -50,7 +50,7 @@ - (void)testSetPatterns { [self.polylineController setPattern:styles lengths:lengths]; - // `GMSStyleSpan` doesn't implement `isEqual` so cannot be compared by value at present + // `GMSStyleSpan` doesn't implement `isEqual` so cannot be compared by value at present. XCTAssertNotNil(self.polylineController.polyline.spans); } From 91439c5eecf35c69b76db7184811b4d6eda07e86 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Fri, 2 Feb 2024 20:57:39 +0530 Subject: [PATCH 13/45] Set version in pubspec --- .../example/ios12/ios/Runner.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj index 93b6613ee47..836ff41f730 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj @@ -288,7 +288,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1510; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = "The Flutter Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { From ef1d1a657cde98bb420f004c20e63689bcb78046 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 3 Feb 2024 02:57:00 +0530 Subject: [PATCH 14/45] Make the polyline controller test stateless --- .../GoogleMapsPolylinesControllerTests.m | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index f63444c7c42..8ed02bcf8ea 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -11,12 +11,11 @@ #import "PartiallyMockedMapView.h" @interface GoogleMapsPolylinesControllerTests : XCTestCase -@property(strong, atomic) FLTGoogleMapPolylineController *polylineController; @end @implementation GoogleMapsPolylinesControllerTests -- (void)setUp { +- (FLTGoogleMapPolylineController *)setUpPolyLineControllerWithMockedMap { NSDictionary *polyline = @{ @"points" : @[ @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], @@ -34,9 +33,12 @@ - (void)setUp { initWithFrame:frame camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; - self.polylineController = [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path - identifier:identifier - mapView:mapView]; + FLTGoogleMapPolylineController *polylineControllerWithMockedMap = + [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path + identifier:identifier + mapView:mapView]; + + return polylineControllerWithMockedMap; } - (void)testSetPatterns { @@ -46,12 +48,14 @@ - (void)testSetPatterns { NSArray *lengths = @[ @10, @10 ]; - XCTAssertNil(self.polylineController.polyline.spans); + FLTGoogleMapPolylineController *polylineController = [self setUpPolyLineControllerWithMockedMap]; + + XCTAssertNil(polylineController.polyline.spans); - [self.polylineController setPattern:styles lengths:lengths]; + [polylineController setPattern:styles lengths:lengths]; // `GMSStyleSpan` doesn't implement `isEqual` so cannot be compared by value at present. - XCTAssertNotNil(self.polylineController.polyline.spans); + XCTAssertNotNil(polylineController.polyline.spans); } @end From 5c6a69498f8ce364e99550fd4771e2e21b186466 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 3 Feb 2024 03:05:33 +0530 Subject: [PATCH 15/45] Remove empty line --- .../ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 8ed02bcf8ea..5de1aaf27ce 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -22,7 +22,6 @@ - (FLTGoogleMapPolylineController *)setUpPolyLineControllerWithMockedMap { @[ @(53.4153), @(-4.0829) ] ], @"polylineId" : @"polyline_id_0", - }; GMSMutablePath *path = [FLTPolylinesController getPath:polyline]; From cb7b9eabe1230230e1f82a69f4b9e38b40391770 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 3 Feb 2024 03:32:36 +0530 Subject: [PATCH 16/45] Dont make polyline controller public --- .../example/ios12/ios/Runner.xcodeproj/project.pbxproj | 1 + .../ios/RunnerTests/GoogleMapPolylineController_Test.h | 9 +++++++++ .../ios/RunnerTests/GoogleMapsPolylinesControllerTests.m | 1 + .../ios/Classes/GoogleMapPolylineController.h | 2 -- .../ios/Classes/GoogleMapPolylineController.m | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj index 836ff41f730..cb7e5322d98 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj @@ -61,6 +61,7 @@ 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 479E394C2B6D3C7C00CD60F5 /* GoogleMapsPolylinesControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GoogleMapsPolylinesControllerTests.m; sourceTree = ""; }; + 479E394E2B6D9A0800CD60F5 /* GoogleMapPolylineController_Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GoogleMapPolylineController_Test.h; sourceTree = ""; }; 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLTGoogleMapJSONConversionsConversionTests.m; sourceTree = ""; }; 68E472692836FF0C00BDDDAC /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/iOSSupport/System/Library/Frameworks/MapKit.framework; sourceTree = DEVELOPER_DIR; }; 733AFAB37683A9DA7512F09C /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h new file mode 100644 index 00000000000..5b7da4dd1a9 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h @@ -0,0 +1,9 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "GoogleMapPolylineController.h" + +@interface FLTGoogleMapPolylineController (Test) +@property(strong, nonatomic) GMSPolyline *polyline; +@end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 5de1aaf27ce..0f1eb10f0b9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -8,6 +8,7 @@ @import GoogleMaps; #import +#import "GoogleMapPolylineController_Test.h" #import "PartiallyMockedMapView.h" @interface GoogleMapsPolylinesControllerTests : XCTestCase diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h index 3ff894ee23a..a08cd2567c6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h @@ -7,8 +7,6 @@ // Defines polyline controllable by Flutter. @interface FLTGoogleMapPolylineController : NSObject -@property(strong, nonatomic) GMSPolyline *polyline; - - (instancetype)initPolylineWithPath:(GMSMutablePath *)path identifier:(NSString *)identifier mapView:(GMSMapView *)mapView; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 1b6b3cba457..345b929297d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -7,6 +7,7 @@ @interface FLTGoogleMapPolylineController () +@property(strong, nonatomic) GMSPolyline *polyline; @property(weak, nonatomic) GMSMapView *mapView; @end From 762741e47161f583a4348438f03d82c65a3c8d8d Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 3 Feb 2024 03:51:21 +0530 Subject: [PATCH 17/45] add comments and avoid making get path public --- .../ios/Classes/GoogleMapPolylineController.h | 8 +++++++- .../ios/Classes/GoogleMapPolylineController.m | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h index a08cd2567c6..f448dbe66a6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h @@ -11,6 +11,13 @@ identifier:(NSString *)identifier mapView:(GMSMapView *)mapView; - (void)removePolyline; + +/** + * Sets the pattern on polyline controller + * + * @param styles The styles for repeating pattern sections. + * @param lengths The lengths for repeating pattern sections. + */ - (void)setPattern:(NSArray *)styles lengths:(NSArray *)lengths; @end @@ -23,5 +30,4 @@ - (void)removePolylineWithIdentifiers:(NSArray *)identifiers; - (void)didTapPolylineWithIdentifier:(NSString *)identifier; - (bool)hasPolylineWithIdentifier:(NSString *)identifier; -+ (GMSMutablePath *)getPath:(NSDictionary *)polyline; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 345b929297d..41db00ad4a2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -118,6 +118,14 @@ @interface FLTPolylinesController () @property(weak, nonatomic) NSObject *registrar; @property(weak, nonatomic) GMSMapView *mapView; +/** + * Returns the path for polyline based on the points(locations) the polyline has. + * + * @param polyline The polyline instance for which path is calculated. + * @return An instance of GMSMutablePath. + */ +- (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; + @end ; @@ -137,7 +145,7 @@ - (instancetype)init:(FlutterMethodChannel *)methodChannel } - (void)addPolylines:(NSArray *)polylinesToAdd { for (NSDictionary *polyline in polylinesToAdd) { - GMSMutablePath *path = [FLTPolylinesController getPath:polyline]; + GMSMutablePath *path = [self pathForPolyline:polyline]; NSString *identifier = polyline[@"polylineId"]; FLTGoogleMapPolylineController *controller = [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path @@ -183,7 +191,7 @@ - (bool)hasPolylineWithIdentifier:(NSString *)identifier { } return self.polylineIdentifierToController[identifier] != nil; } -+ (GMSMutablePath *)getPath:(NSDictionary *)polyline { +- (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline { NSArray *pointArray = polyline[@"points"]; NSArray *points = [FLTGoogleMapJSONConversions pointsFromLatLongs:pointArray]; GMSMutablePath *path = [GMSMutablePath path]; From 90537da8abf4aef598f863d3745796748f75fa96 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 3 Feb 2024 07:41:34 +0530 Subject: [PATCH 18/45] Fix test --- .../RunnerTests/GoogleMapPolylineController_Test.h | 4 ++++ .../RunnerTests/GoogleMapsPolylinesControllerTests.m | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h index 5b7da4dd1a9..9f5bf51046e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h @@ -7,3 +7,7 @@ @interface FLTGoogleMapPolylineController (Test) @property(strong, nonatomic) GMSPolyline *polyline; @end + +@interface FLTPolylinesController (Test) +- (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; +@end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 0f1eb10f0b9..b13516cd68a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -25,14 +25,20 @@ - (FLTGoogleMapPolylineController *)setUpPolyLineControllerWithMockedMap { @"polylineId" : @"polyline_id_0", }; - GMSMutablePath *path = [FLTPolylinesController getPath:polyline]; - NSString *identifier = polyline[@"polylineId"]; - CGRect frame = CGRectMake(0, 0, 100, 100); PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] initWithFrame:frame camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; + id registrar = OCMProtocolMock(@protocol(FlutterPluginRegistrar)); + id methodChannel = OCMClassMock([FlutterMethodChannel class]); + FLTPolylinesController *polylinesController = [[FLTPolylinesController alloc] init:methodChannel + mapView:mapView + registrar:registrar]; + + GMSMutablePath *path = [polylinesController pathForPolyline:polyline]; + NSString *identifier = polyline[@"polylineId"]; + FLTGoogleMapPolylineController *polylineControllerWithMockedMap = [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path identifier:identifier From 76b3d5930d588bbec269c14a856271c0df738874 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 3 Feb 2024 07:51:17 +0530 Subject: [PATCH 19/45] Add stroke style json conversion test --- .../RunnerTests/GoogleMapsPolylinesControllerTests.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index b13516cd68a..1dc692b2727 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -64,4 +64,16 @@ - (void)testSetPatterns { XCTAssertNotNil(polylineController.polyline.spans); } +- (void)testStrokeStylesFromPatterns { + NSArray* patterns = @ [@[@"gap", @10], @[@"dash", @10]]; + UIColor* strokeColor = [UIColor redColor]; + + NSArray *patternStrokeStyle = [FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns strokeColor:strokeColor]; + + XCTAssertEqual([patternStrokeStyle count], 2); + + // None of the parameters of patternStrokeStyle is observable, so we limit to testing + // the length of this output array. +} + @end From c10082c3e536784dd6caa4d4e2ba0427b32e608a Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:15:06 +0530 Subject: [PATCH 20/45] Fix formatting issue in new test --- .../GoogleMapsPolylinesControllerTests.m | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 1dc692b2727..ce401d0e733 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -65,15 +65,16 @@ - (void)testSetPatterns { } - (void)testStrokeStylesFromPatterns { - NSArray* patterns = @ [@[@"gap", @10], @[@"dash", @10]]; - UIColor* strokeColor = [UIColor redColor]; - - NSArray *patternStrokeStyle = [FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns strokeColor:strokeColor]; - - XCTAssertEqual([patternStrokeStyle count], 2); - - // None of the parameters of patternStrokeStyle is observable, so we limit to testing - // the length of this output array. + NSArray *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; + UIColor *strokeColor = [UIColor redColor]; + + NSArray *patternStrokeStyle = + [FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns strokeColor:strokeColor]; + + XCTAssertEqual([patternStrokeStyle count], 2); + + // None of the parameters of patternStrokeStyle is observable, so we limit to testing + // the length of this output array. } @end From 28a78407863660a7ab7a1e4b27f4669dcb5dcdd4 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:15:32 +0530 Subject: [PATCH 21/45] Format comment --- .../ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index ce401d0e733..d8412fe4fb5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -73,7 +73,7 @@ - (void)testStrokeStylesFromPatterns { XCTAssertEqual([patternStrokeStyle count], 2); - // None of the parameters of patternStrokeStyle is observable, so we limit to testing + // None of the parameters of `patternStrokeStyle` is observable, so we limit to testing // the length of this output array. } From 41e4a2cb9fae53979c65b308f20a99a5a72db89f Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sun, 24 Mar 2024 09:15:15 +0530 Subject: [PATCH 22/45] Update changelog --- .../google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md | 4 ++++ .../google_maps_flutter/google_maps_flutter_ios/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index 96468dc393f..c021a237923 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.6.0 + +* Adds support for patterns in polylines on iOS. + ## 2.5.1 * Makes the tile overlay callback invoke the platform channel on the platform thread. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml index c1ebb4e2cea..e98f7209380 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_ios description: iOS implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.5.1 +version: 2.6.0 environment: sdk: ^3.2.3 From ef19218e2a3389c3315b1c881229ac70f2dc8bbf Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sun, 24 Mar 2024 09:17:08 +0530 Subject: [PATCH 23/45] Remove android changelog comment --- .../google_maps_flutter/google_maps_flutter_android/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md index 7d738d68cb3..a099bb5ef42 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -4,7 +4,6 @@ * Adds support for `getStyleError`. * Updates minimum supported SDK version to Flutter 3.13/Dart 3.1. * Updates compileSdk version to 34. -* Adds support for patterns in polylines on iOS. ## 2.6.2 From 25e003e4f7dd1f4b0fcd33c6c18cff5407a6793b Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sun, 24 Mar 2024 22:50:22 +0530 Subject: [PATCH 24/45] Fix some of the comments --- .../ios12/ios/Runner.xcodeproj/project.pbxproj | 1 + .../GoogleMapPolylineController_Test.h | 16 ++++++++++++++++ .../ios/Classes/FLTGoogleMapJSONConversions.h | 15 +++++++++++++++ .../ios/Classes/FLTGoogleMapJSONConversions.m | 18 ++++++------------ .../ios/Classes/GoogleMapPolylineController.m | 8 -------- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj index cb7e5322d98..58d0b7053f4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/Runner.xcodeproj/project.pbxproj @@ -201,6 +201,7 @@ F7151F11265D7ED70028CB91 /* RunnerTests */ = { isa = PBXGroup; children = ( + 473DC9E42BAFDC5D0001D54E /* GoogleMapPolylineController_Test.h */, 479E394C2B6D3C7C00CD60F5 /* GoogleMapsPolylinesControllerTests.m */, 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */, F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */, diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h index 9f5bf51046e..22121760593 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h @@ -4,10 +4,26 @@ #import "GoogleMapPolylineController.h" +/** + * Internal APIs exposed for unit testing + */ @interface FLTGoogleMapPolylineController (Test) + +/** + * Polyline instance the controller is attached to + */ @property(strong, nonatomic) GMSPolyline *polyline; @end +/** + * Internal APIs explosed for unit testing + */ @interface FLTPolylinesController (Test) +/** + * Returns the path for polyline based on the points(locations) the polyline has. + * + * @param polyline The polyline instance for which path is calculated. + * @return An instance of GMSMutablePath. + */ - (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h index 5f472ffff59..083742bc3c4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h @@ -24,8 +24,23 @@ NS_ASSUME_NONNULL_BEGIN + (GMSCoordinateBounds *)coordinateBoundsFromLatLongs:(NSArray *)latlongs; + (GMSMapViewType)mapViewTypeFromTypeValue:(NSNumber *)value; + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelValue; + +/** + * Return GMS strokestyle object array populated using the patterns and stroke colors passed in. + * + * @param patterns An array of patterns for each stroke in the polyline. + * @param strokeColor An array of color for each stroke in the polyline. + * @return An array of GMSStrokeStyle. + */ + (NSArray *)strokeStylesFromPatterns:(NSArray *)patterns strokeColor:(UIColor *)strokeColor; +/** + * Return GMS strokestyle object array populated using the patterns and stroke colors passed in. + * Extracts the lengths of each stroke in the polyline from patterns input + * + * @param patterns An array of object representing the pattern params in the polyline. + * @return Array of lengths. + */ + (NSArray *)spanLengthsFromPatterns:(NSArray *)patterns; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m index 3b8fe5f7ecf..ae9d2e37442 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m @@ -144,29 +144,23 @@ + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelVal + (NSArray *)strokeStylesFromPatterns:(NSArray *)patterns strokeColor:(UIColor *)strokeColor { - NSMutableArray *strokeStyles = [[NSMutableArray alloc] init]; + NSMutableArray *strokeStyles = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; for (unsigned int i = 0; i < [patterns count]; i++) { NSString *patternType = patterns[i][0]; - GMSStrokeStyle *strokeStyle; - if ([patternType isEqualToString:@"gap"]) { - strokeStyle = [GMSStrokeStyle solidColor:[UIColor clearColor]]; - } else { - strokeStyle = [GMSStrokeStyle solidColor:strokeColor]; - } - - [strokeStyles addObject:strokeStyle]; + UIColor* color = [patternType isEqualToString:@"gap"] ? [UIColor clearColor] : strokeColor; + strokeStyles[i] = [GMSStrokeStyle solidColor:color]; } + return strokeStyles; } + (NSArray *)spanLengthsFromPatterns:(NSArray *)patterns { - NSMutableArray *lengths = [[NSMutableArray alloc] init]; + NSMutableArray *lengths = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; for (unsigned int i = 0; i < [patterns count]; i++) { NSNumber *length = [patterns[i] count] > 1 ? patterns[i][1] : @0; - - [lengths addObject:length]; + lengths[i]= length; } return lengths; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 41db00ad4a2..d8ced57745a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -118,14 +118,6 @@ @interface FLTPolylinesController () @property(weak, nonatomic) NSObject *registrar; @property(weak, nonatomic) GMSMapView *mapView; -/** - * Returns the path for polyline based on the points(locations) the polyline has. - * - * @param polyline The polyline instance for which path is calculated. - * @return An instance of GMSMutablePath. - */ -- (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; - @end ; From 6d7f7c188c5c0dc850f77d9fa21a6c91d0cb9535 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Mon, 25 Mar 2024 07:55:47 +0530 Subject: [PATCH 25/45] Use helper function to extract nullable field from dict --- .../ios/Classes/GoogleMapPolylineController.m | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index d8ced57745a..9d4c6ba5210 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -12,6 +12,15 @@ @interface FLTGoogleMapPolylineController () @end + +/** + * Returns dict[key], or nil if dict[key] is NSNull. + */ +id GetValueOrNilFromDict(NSDictionary * dict, NSString *key) { + id value = dict[key]; + return value == [NSNull null] ? nil : value; +} + @implementation FLTGoogleMapPolylineController - (instancetype)initPolylineWithPath:(GMSMutablePath *)path @@ -65,43 +74,43 @@ - (void)setPattern:(NSArray *)styles lengths:(NSArray *)registrar { - NSNumber *consumeTapEvents = data[@"consumeTapEvents"]; - if (consumeTapEvents && consumeTapEvents != (id)[NSNull null]) { + NSNumber *consumeTapEvents = GetValueOrNilFromDict(data, @"consumeTapEvents"); + if (consumeTapEvents) { [self setConsumeTapEvents:[consumeTapEvents boolValue]]; } - NSNumber *visible = data[@"visible"]; - if (visible && visible != (id)[NSNull null]) { + NSNumber *visible = GetValueOrNilFromDict(data, @"visible"); + if (visible) { [self setVisible:[visible boolValue]]; } - NSNumber *zIndex = data[@"zIndex"]; - if (zIndex && zIndex != (id)[NSNull null]) { + NSNumber *zIndex = GetValueOrNilFromDict(data, @"zIndex"); + if (zIndex) { [self setZIndex:[zIndex intValue]]; } - NSArray *points = data[@"points"]; - if (points && points != (id)[NSNull null]) { + NSArray *points = GetValueOrNilFromDict(data, @"points"); + if (points) { [self setPoints:[FLTGoogleMapJSONConversions pointsFromLatLongs:points]]; } - NSNumber *strokeColor = data[@"color"]; - if (strokeColor && strokeColor != (id)[NSNull null]) { + NSNumber *strokeColor = GetValueOrNilFromDict(data, @"color"); + if (strokeColor) { [self setColor:[FLTGoogleMapJSONConversions colorFromRGBA:strokeColor]]; } - NSNumber *strokeWidth = data[@"width"]; - if (strokeWidth && strokeWidth != (id)[NSNull null]) { + NSNumber *strokeWidth = GetValueOrNilFromDict(data, @"width"); + if (strokeWidth) { [self setStrokeWidth:[strokeWidth intValue]]; } - NSNumber *geodesic = data[@"geodesic"]; - if (geodesic && geodesic != (id)[NSNull null]) { + NSNumber *geodesic = GetValueOrNilFromDict(data, @"geodesic"); + if (geodesic) { [self setGeodesic:geodesic.boolValue]; } - NSArray *patterns = data[@"pattern"]; - if (patterns && patterns != (id)[NSNull null]) { + NSArray *patterns = GetValueOrNilFromDict(data, @"pattern"); + if (patterns) { [self setPattern:[FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns strokeColor:self.polyline.strokeColor] @@ -121,6 +130,7 @@ @interface FLTPolylinesController () @end ; + @implementation FLTPolylinesController - (instancetype)init:(FlutterMethodChannel *)methodChannel From 2a58ab95103f7d2f02fb731d1d404893848bc695 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Mon, 25 Mar 2024 08:07:53 +0530 Subject: [PATCH 26/45] Revert path for polyline into static function --- .../ios/Classes/GoogleMapPolylineController.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 9d4c6ba5210..407bcab9d7b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -147,7 +147,7 @@ - (instancetype)init:(FlutterMethodChannel *)methodChannel } - (void)addPolylines:(NSArray *)polylinesToAdd { for (NSDictionary *polyline in polylinesToAdd) { - GMSMutablePath *path = [self pathForPolyline:polyline]; + GMSMutablePath *path = [FLTPolylinesController pathForPolyline:polyline]; NSString *identifier = polyline[@"polylineId"]; FLTGoogleMapPolylineController *controller = [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path @@ -193,7 +193,7 @@ - (bool)hasPolylineWithIdentifier:(NSString *)identifier { } return self.polylineIdentifierToController[identifier] != nil; } -- (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline { ++ (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline { NSArray *pointArray = polyline[@"points"]; NSArray *points = [FLTGoogleMapJSONConversions pointsFromLatLongs:pointArray]; GMSMutablePath *path = [GMSMutablePath path]; From 8428c9697270d0f8ea2bfaabfd3f3dfd83073e8e Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sun, 28 Apr 2024 12:09:16 +0530 Subject: [PATCH 27/45] Specify the type more --- .../ios/Classes/FLTGoogleMapJSONConversions.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m index ae9d2e37442..1a8cd06777f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m @@ -142,7 +142,7 @@ + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelVal return nil; } -+ (NSArray *)strokeStylesFromPatterns:(NSArray *)patterns ++ (NSArray *)strokeStylesFromPatterns:(NSArray *)patterns strokeColor:(UIColor *)strokeColor { NSMutableArray *strokeStyles = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; for (unsigned int i = 0; i < [patterns count]; i++) { @@ -156,7 +156,7 @@ + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelVal return strokeStyles; } -+ (NSArray *)spanLengthsFromPatterns:(NSArray *)patterns { ++ (NSArray *)spanLengthsFromPatterns:(NSArray *)patterns { NSMutableArray *lengths = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; for (unsigned int i = 0; i < [patterns count]; i++) { NSNumber *length = [patterns[i] count] > 1 ? patterns[i][1] : @0; From 4eca5a6bcc02c9f5422af167fdeff7bc336945ef Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Wed, 8 May 2024 10:51:35 +0530 Subject: [PATCH 28/45] Remove on ios in changelog --- .../google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index c021a237923..226ec65eb93 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,6 +1,6 @@ ## 2.6.0 -* Adds support for patterns in polylines on iOS. +* Adds support for patterns in polylines. ## 2.5.1 From 3975be2877ab4836b7cd55963d2eb24b45e943b3 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 11 May 2024 16:28:21 +0530 Subject: [PATCH 29/45] Move the header file --- .../Classes}/GoogleMapPolylineController_Test.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/google_maps_flutter/google_maps_flutter_ios/{example/ios12/ios/RunnerTests => ios/Classes}/GoogleMapPolylineController_Test.h (100%) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h similarity index 100% rename from packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapPolylineController_Test.h rename to packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h From 0daeda6d37fdc303ab069f420c8562f7f9c8ffb9 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 11 May 2024 16:31:16 +0530 Subject: [PATCH 30/45] Remove test temporarily --- .../GoogleMapsPolylinesControllerTests.m | 80 ------------------- 1 file changed, 80 deletions(-) delete mode 100644 packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m deleted file mode 100644 index d8412fe4fb5..00000000000 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios12/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -@import google_maps_flutter_ios; -@import google_maps_flutter_ios.Test; -@import XCTest; -@import GoogleMaps; - -#import -#import "GoogleMapPolylineController_Test.h" -#import "PartiallyMockedMapView.h" - -@interface GoogleMapsPolylinesControllerTests : XCTestCase -@end - -@implementation GoogleMapsPolylinesControllerTests - -- (FLTGoogleMapPolylineController *)setUpPolyLineControllerWithMockedMap { - NSDictionary *polyline = @{ - @"points" : @[ - @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], - @[ @(53.4153), @(-4.0829) ] - ], - @"polylineId" : @"polyline_id_0", - }; - - CGRect frame = CGRectMake(0, 0, 100, 100); - PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] - initWithFrame:frame - camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; - - id registrar = OCMProtocolMock(@protocol(FlutterPluginRegistrar)); - id methodChannel = OCMClassMock([FlutterMethodChannel class]); - FLTPolylinesController *polylinesController = [[FLTPolylinesController alloc] init:methodChannel - mapView:mapView - registrar:registrar]; - - GMSMutablePath *path = [polylinesController pathForPolyline:polyline]; - NSString *identifier = polyline[@"polylineId"]; - - FLTGoogleMapPolylineController *polylineControllerWithMockedMap = - [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path - identifier:identifier - mapView:mapView]; - - return polylineControllerWithMockedMap; -} - -- (void)testSetPatterns { - NSArray *styles = @[ - [GMSStrokeStyle solidColor:[UIColor clearColor]], [GMSStrokeStyle solidColor:[UIColor redColor]] - ]; - - NSArray *lengths = @[ @10, @10 ]; - - FLTGoogleMapPolylineController *polylineController = [self setUpPolyLineControllerWithMockedMap]; - - XCTAssertNil(polylineController.polyline.spans); - - [polylineController setPattern:styles lengths:lengths]; - - // `GMSStyleSpan` doesn't implement `isEqual` so cannot be compared by value at present. - XCTAssertNotNil(polylineController.polyline.spans); -} - -- (void)testStrokeStylesFromPatterns { - NSArray *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; - UIColor *strokeColor = [UIColor redColor]; - - NSArray *patternStrokeStyle = - [FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns strokeColor:strokeColor]; - - XCTAssertEqual([patternStrokeStyle count], 2); - - // None of the parameters of `patternStrokeStyle` is observable, so we limit to testing - // the length of this output array. -} - -@end From 35068852771748a0e7fa7bda46cd4df15cbf9650 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 11 May 2024 16:32:46 +0530 Subject: [PATCH 31/45] Add back tests --- .../GoogleMapsPolylinesControllerTests.m | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m new file mode 100644 index 00000000000..d8412fe4fb5 --- /dev/null +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -0,0 +1,80 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +@import google_maps_flutter_ios; +@import google_maps_flutter_ios.Test; +@import XCTest; +@import GoogleMaps; + +#import +#import "GoogleMapPolylineController_Test.h" +#import "PartiallyMockedMapView.h" + +@interface GoogleMapsPolylinesControllerTests : XCTestCase +@end + +@implementation GoogleMapsPolylinesControllerTests + +- (FLTGoogleMapPolylineController *)setUpPolyLineControllerWithMockedMap { + NSDictionary *polyline = @{ + @"points" : @[ + @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], + @[ @(53.4153), @(-4.0829) ] + ], + @"polylineId" : @"polyline_id_0", + }; + + CGRect frame = CGRectMake(0, 0, 100, 100); + PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] + initWithFrame:frame + camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; + + id registrar = OCMProtocolMock(@protocol(FlutterPluginRegistrar)); + id methodChannel = OCMClassMock([FlutterMethodChannel class]); + FLTPolylinesController *polylinesController = [[FLTPolylinesController alloc] init:methodChannel + mapView:mapView + registrar:registrar]; + + GMSMutablePath *path = [polylinesController pathForPolyline:polyline]; + NSString *identifier = polyline[@"polylineId"]; + + FLTGoogleMapPolylineController *polylineControllerWithMockedMap = + [[FLTGoogleMapPolylineController alloc] initPolylineWithPath:path + identifier:identifier + mapView:mapView]; + + return polylineControllerWithMockedMap; +} + +- (void)testSetPatterns { + NSArray *styles = @[ + [GMSStrokeStyle solidColor:[UIColor clearColor]], [GMSStrokeStyle solidColor:[UIColor redColor]] + ]; + + NSArray *lengths = @[ @10, @10 ]; + + FLTGoogleMapPolylineController *polylineController = [self setUpPolyLineControllerWithMockedMap]; + + XCTAssertNil(polylineController.polyline.spans); + + [polylineController setPattern:styles lengths:lengths]; + + // `GMSStyleSpan` doesn't implement `isEqual` so cannot be compared by value at present. + XCTAssertNotNil(polylineController.polyline.spans); +} + +- (void)testStrokeStylesFromPatterns { + NSArray *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; + UIColor *strokeColor = [UIColor redColor]; + + NSArray *patternStrokeStyle = + [FLTGoogleMapJSONConversions strokeStylesFromPatterns:patterns strokeColor:strokeColor]; + + XCTAssertEqual([patternStrokeStyle count], 2); + + // None of the parameters of `patternStrokeStyle` is observable, so we limit to testing + // the length of this output array. +} + +@end From 64006eb64cfc6d310bff1d22a7b03b3424938c69 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 11 May 2024 16:36:52 +0530 Subject: [PATCH 32/45] Add back changelog change --- .../google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index cf9231d6a0a..3a0195b6ca0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.6.1 + +* Adds support for patterns in polylines. + ## 2.6.0 * Updates the minimum allowed verison of the Google Maps SDK to 8.4, for privacy From 9649254c982ef9bde6f87b01ffd01cc7c7c7cb70 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 11 May 2024 16:42:42 +0530 Subject: [PATCH 33/45] Bump pubspec version --- .../google_maps_flutter/google_maps_flutter_ios/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml index e98f7209380..df74168cb10 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_ios description: iOS implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.6.0 +version: 2.6.1 environment: sdk: ^3.2.3 From 4b3ddad3a4689b1439749e3c3f078a457802cf79 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 11 May 2024 17:05:08 +0530 Subject: [PATCH 34/45] Add polyline test file to xcode --- .../example/ios14/ios/Runner.xcodeproj/project.pbxproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj index d5b6d8248e0..660b466a2fd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 4510D964F3B1259FEDD3ABA6 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7755F8F4BABC3D6A0BD4048B /* libPods-Runner.a */; }; + 478116522BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 478116512BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m */; }; 6851F3562835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */; }; 68E4726A2836FF0C00BDDDAC /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 68E472692836FF0C00BDDDAC /* MapKit.framework */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; @@ -18,8 +19,8 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - F269303B2BB389BF00BF17C4 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = F269303A2BB389BF00BF17C4 /* assets */; }; 982F2A6C27BADE17003C81F4 /* PartiallyMockedMapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 982F2A6B27BADE17003C81F4 /* PartiallyMockedMapView.m */; }; + F269303B2BB389BF00BF17C4 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = F269303A2BB389BF00BF17C4 /* assets */; }; F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */; }; F7151F21265D7EE50028CB91 /* GoogleMapsUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = F7151F20265D7EE50028CB91 /* GoogleMapsUITests.m */; }; FC8F35FC8CD533B128950487 /* libPods-RunnerTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F267F68029D1A4E2E4C572A7 /* libPods-RunnerTests.a */; }; @@ -60,6 +61,7 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 478116512BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GoogleMapsPolylinesControllerTests.m; sourceTree = ""; }; 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLTGoogleMapJSONConversionsConversionTests.m; sourceTree = ""; }; 68E472692836FF0C00BDDDAC /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk/System/iOSSupport/System/Library/Frameworks/MapKit.framework; sourceTree = DEVELOPER_DIR; }; 733AFAB37683A9DA7512F09C /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; @@ -203,6 +205,7 @@ F269303A2BB389BF00BF17C4 /* assets */, 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */, F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */, + 478116512BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m */, 982F2A6A27BADE17003C81F4 /* PartiallyMockedMapView.h */, 982F2A6B27BADE17003C81F4 /* PartiallyMockedMapView.m */, F7151F14265D7ED70028CB91 /* Info.plist */, @@ -467,6 +470,7 @@ F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */, 6851F3562835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m in Sources */, 982F2A6C27BADE17003C81F4 /* PartiallyMockedMapView.m in Sources */, + 478116522BEF8F47002F593E /* GoogleMapsPolylinesControllerTests.m in Sources */, 0DD7B6C32B744EEF00E857FD /* FLTTileProviderControllerTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; From e605cb4c9c17c796f146a2b9ffd1f6a0016646ca Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 25 May 2024 18:12:51 +0530 Subject: [PATCH 35/45] Fix comment style and use fast iteration --- .../GoogleMapsPolylinesControllerTests.m | 4 +-- .../ios/Classes/FLTGoogleMapJSONConversions.h | 32 +++++++++---------- .../ios/Classes/FLTGoogleMapJSONConversions.m | 18 +++++------ .../ios/Classes/GoogleMapPolylineController.h | 12 +++---- .../ios/Classes/GoogleMapPolylineController.m | 6 ++-- .../GoogleMapPolylineController_Test.h | 32 +++++++++---------- 6 files changed, 51 insertions(+), 53 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index d8412fe4fb5..1ae8123d31e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -8,7 +8,7 @@ @import GoogleMaps; #import -#import "GoogleMapPolylineController_Test.h" +#import #import "PartiallyMockedMapView.h" @interface GoogleMapsPolylinesControllerTests : XCTestCase @@ -36,7 +36,7 @@ - (FLTGoogleMapPolylineController *)setUpPolyLineControllerWithMockedMap { mapView:mapView registrar:registrar]; - GMSMutablePath *path = [polylinesController pathForPolyline:polyline]; + GMSMutablePath *path = [FLTPolylinesController pathForPolyline:polyline]; NSString *identifier = polyline[@"polylineId"]; FLTGoogleMapPolylineController *polylineControllerWithMockedMap = diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h index 083742bc3c4..d7d66a3117b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h @@ -25,23 +25,23 @@ NS_ASSUME_NONNULL_BEGIN + (GMSMapViewType)mapViewTypeFromTypeValue:(NSNumber *)value; + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelValue; -/** - * Return GMS strokestyle object array populated using the patterns and stroke colors passed in. - * - * @param patterns An array of patterns for each stroke in the polyline. - * @param strokeColor An array of color for each stroke in the polyline. - * @return An array of GMSStrokeStyle. - */ -+ (NSArray *)strokeStylesFromPatterns:(NSArray *)patterns +/// +///Return GMS strokestyle object array populated using the patterns and stroke colors passed in. +/// +/// @param patterns An array of patterns for each stroke in the polyline. +/// @param strokeColor An array of color for each stroke in the polyline. +/// @return An array of GMSStrokeStyle. +/// ++ (NSArray *)strokeStylesFromPatterns:(NSArray *> *)patterns strokeColor:(UIColor *)strokeColor; -/** - * Return GMS strokestyle object array populated using the patterns and stroke colors passed in. - * Extracts the lengths of each stroke in the polyline from patterns input - * - * @param patterns An array of object representing the pattern params in the polyline. - * @return Array of lengths. - */ -+ (NSArray *)spanLengthsFromPatterns:(NSArray *)patterns; +/// +/// Return GMS strokestyle object array populated using the patterns and stroke colors passed in. +/// Extracts the lengths of each stroke in the polyline from patterns input +/// +/// @param patterns An array of object representing the pattern params in the polyline. +/// @return Array of lengths. +/// ++ (NSArray *)spanLengthsFromPatterns:(NSArray *> *)patterns; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m index 1a8cd06777f..f0e7a3ac0f0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m @@ -142,25 +142,23 @@ + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelVal return nil; } -+ (NSArray *)strokeStylesFromPatterns:(NSArray *)patterns ++ (NSArray *)strokeStylesFromPatterns:(NSArray *> *)patterns strokeColor:(UIColor *)strokeColor { NSMutableArray *strokeStyles = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; - for (unsigned int i = 0; i < [patterns count]; i++) { - NSString *patternType = patterns[i][0]; - + for(NSArray *pattern in patterns) { + NSString *patternType = pattern[0]; UIColor* color = [patternType isEqualToString:@"gap"] ? [UIColor clearColor] : strokeColor; - strokeStyles[i] = [GMSStrokeStyle solidColor:color]; + [strokeStyles addObject:[GMSStrokeStyle solidColor:color]]; } - return strokeStyles; } -+ (NSArray *)spanLengthsFromPatterns:(NSArray *)patterns { ++ (NSArray *)spanLengthsFromPatterns:(NSArray *> *)patterns { NSMutableArray *lengths = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; - for (unsigned int i = 0; i < [patterns count]; i++) { - NSNumber *length = [patterns[i] count] > 1 ? patterns[i][1] : @0; - lengths[i]= length; + for (NSArray *pattern in patterns) { + NSNumber *length = [pattern count] > 1 ? pattern[1] : @0; + [lengths addObject:length]; } return lengths; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h index f448dbe66a6..8756ac22ac6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h @@ -12,12 +12,12 @@ mapView:(GMSMapView *)mapView; - (void)removePolyline; -/** - * Sets the pattern on polyline controller - * - * @param styles The styles for repeating pattern sections. - * @param lengths The lengths for repeating pattern sections. - */ +/// +/// Sets the pattern on polyline controller +/// +/// @param styles The styles for repeating pattern sections. +/// @param lengths The lengths for repeating pattern sections. +/// - (void)setPattern:(NSArray *)styles lengths:(NSArray *)lengths; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 407bcab9d7b..36decb28470 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -13,9 +13,9 @@ @interface FLTGoogleMapPolylineController () @end -/** - * Returns dict[key], or nil if dict[key] is NSNull. - */ +/// +/// Returns dict[key], or nil if dict[key] is NSNull. +/// id GetValueOrNilFromDict(NSDictionary * dict, NSString *key) { id value = dict[key]; return value == [NSNull null] ? nil : value; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h index 22121760593..539e0f3f792 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h @@ -4,26 +4,26 @@ #import "GoogleMapPolylineController.h" -/** - * Internal APIs exposed for unit testing - */ +/// +/// Internal APIs exposed for unit testing +/// @interface FLTGoogleMapPolylineController (Test) -/** - * Polyline instance the controller is attached to - */ +/// +/// Polyline instance the controller is attached to +/// @property(strong, nonatomic) GMSPolyline *polyline; @end -/** - * Internal APIs explosed for unit testing - */ +/// +///Internal APIs explosed for unit testing +/// @interface FLTPolylinesController (Test) -/** - * Returns the path for polyline based on the points(locations) the polyline has. - * - * @param polyline The polyline instance for which path is calculated. - * @return An instance of GMSMutablePath. - */ -- (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; +/// +/// Returns the path for polyline based on the points(locations) the polyline has. +/// +/// @param polyline The polyline instance for which path is calculated. +/// @return An instance of GMSMutablePath. +/// ++ (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; @end From c984efb267d3663e2d691d07c442266d524d8135 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 25 May 2024 18:18:22 +0530 Subject: [PATCH 36/45] Fix some formatting --- .../ios/Classes/FLTGoogleMapJSONConversions.m | 2 +- .../ios/Classes/GoogleMapPolylineController.m | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m index f0e7a3ac0f0..f5ffeea42cf 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m @@ -147,7 +147,7 @@ + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelVal NSMutableArray *strokeStyles = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; for(NSArray *pattern in patterns) { NSString *patternType = pattern[0]; - UIColor* color = [patternType isEqualToString:@"gap"] ? [UIColor clearColor] : strokeColor; + UIColor *color = [patternType isEqualToString:@"gap"] ? [UIColor clearColor] : strokeColor; [strokeStyles addObject:[GMSStrokeStyle solidColor:color]]; } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 36decb28470..4402fe5be07 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -16,9 +16,9 @@ @interface FLTGoogleMapPolylineController () /// /// Returns dict[key], or nil if dict[key] is NSNull. /// -id GetValueOrNilFromDict(NSDictionary * dict, NSString *key) { - id value = dict[key]; - return value == [NSNull null] ? nil : value; +id GetValueOrNilFromDict(NSDictionary *dict, NSString *key) { + id value = dict[key]; + return value == [NSNull null] ? nil : value; } @implementation FLTGoogleMapPolylineController From c5f2bb36adba5e27687538a9653abb465f89a8ce Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 25 May 2024 18:25:07 +0530 Subject: [PATCH 37/45] Rename and cleanup --- .../RunnerTests/GoogleMapsPolylinesControllerTests.m | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 1ae8123d31e..11de89d46e2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -16,7 +16,7 @@ @interface GoogleMapsPolylinesControllerTests : XCTestCase @implementation GoogleMapsPolylinesControllerTests -- (FLTGoogleMapPolylineController *)setUpPolyLineControllerWithMockedMap { +- (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { NSDictionary *polyline = @{ @"points" : @[ @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], @@ -30,12 +30,6 @@ - (FLTGoogleMapPolylineController *)setUpPolyLineControllerWithMockedMap { initWithFrame:frame camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; - id registrar = OCMProtocolMock(@protocol(FlutterPluginRegistrar)); - id methodChannel = OCMClassMock([FlutterMethodChannel class]); - FLTPolylinesController *polylinesController = [[FLTPolylinesController alloc] init:methodChannel - mapView:mapView - registrar:registrar]; - GMSMutablePath *path = [FLTPolylinesController pathForPolyline:polyline]; NSString *identifier = polyline[@"polylineId"]; @@ -54,7 +48,7 @@ - (void)testSetPatterns { NSArray *lengths = @[ @10, @10 ]; - FLTGoogleMapPolylineController *polylineController = [self setUpPolyLineControllerWithMockedMap]; + FLTGoogleMapPolylineController *polylineController = [self polylineControllerWithMockedMap]; XCTAssertNil(polylineController.polyline.spans); From 9d8bdcda2f5575c7158667701ace4b8f70c80def Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 25 May 2024 18:27:55 +0530 Subject: [PATCH 38/45] Comment on test method --- .../ios/RunnerTests/GoogleMapsPolylinesControllerTests.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 11de89d46e2..ea5e2bb6667 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -16,6 +16,11 @@ @interface GoogleMapsPolylinesControllerTests : XCTestCase @implementation GoogleMapsPolylinesControllerTests +/// +/// Returns GoogleMapPolylineController object instantiated with a mocked map instance +/// +/// @return An object of FLTGoogleMapPolylineController +/// - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { NSDictionary *polyline = @{ @"points" : @[ From 2e31f57fa939e6603e9b09a82551b6c73afc7b73 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 25 May 2024 18:29:51 +0530 Subject: [PATCH 39/45] Make getvalue or nil static --- .../ios/Classes/GoogleMapPolylineController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 4402fe5be07..fe5667daeaa 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -16,7 +16,7 @@ @interface FLTGoogleMapPolylineController () /// /// Returns dict[key], or nil if dict[key] is NSNull. /// -id GetValueOrNilFromDict(NSDictionary *dict, NSString *key) { +static id GetValueOrNilFromDict(NSDictionary *dict, NSString *key) { id value = dict[key]; return value == [NSNull null] ? nil : value; } From 3d2a257c4e390bee09a5a84308518da731101f14 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sat, 25 May 2024 18:50:29 +0530 Subject: [PATCH 40/45] Run format tool again --- .../ios/Classes/FLTGoogleMapJSONConversions.h | 2 +- .../ios/Classes/FLTGoogleMapJSONConversions.m | 2 +- .../ios/Classes/GoogleMapPolylineController.m | 2 -- .../ios/Classes/GoogleMapPolylineController_Test.h | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h index d7d66a3117b..bae64e95f73 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelValue; /// -///Return GMS strokestyle object array populated using the patterns and stroke colors passed in. +/// Return GMS strokestyle object array populated using the patterns and stroke colors passed in. /// /// @param patterns An array of patterns for each stroke in the polyline. /// @param strokeColor An array of color for each stroke in the polyline. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m index f5ffeea42cf..28307182f2c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m @@ -145,7 +145,7 @@ + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelVal + (NSArray *)strokeStylesFromPatterns:(NSArray *> *)patterns strokeColor:(UIColor *)strokeColor { NSMutableArray *strokeStyles = [[NSMutableArray alloc] initWithCapacity:[patterns count]]; - for(NSArray *pattern in patterns) { + for (NSArray *pattern in patterns) { NSString *patternType = pattern[0]; UIColor *color = [patternType isEqualToString:@"gap"] ? [UIColor clearColor] : strokeColor; [strokeStyles addObject:[GMSStrokeStyle solidColor:color]]; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index fe5667daeaa..1259550129a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -12,7 +12,6 @@ @interface FLTGoogleMapPolylineController () @end - /// /// Returns dict[key], or nil if dict[key] is NSNull. /// @@ -130,7 +129,6 @@ @interface FLTPolylinesController () @end ; - @implementation FLTPolylinesController - (instancetype)init:(FlutterMethodChannel *)methodChannel diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h index 539e0f3f792..c5c0e56564f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h @@ -16,7 +16,7 @@ @end /// -///Internal APIs explosed for unit testing +/// Internal APIs explosed for unit testing /// @interface FLTPolylinesController (Test) /// From 01b1b625efb15e1afc2d54e1124f90ed2db419b3 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Sun, 26 May 2024 00:02:12 +0530 Subject: [PATCH 41/45] Stop using deprecated method --- .../RunnerTests/GoogleMapsPolylinesControllerTests.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index ea5e2bb6667..2d324fb27c1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -31,9 +31,13 @@ - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { }; CGRect frame = CGRectMake(0, 0, 100, 100); - PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] - initWithFrame:frame - camera:[[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]]; + GMSCameraPosition *camera = [[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]; + + GMSMapViewOptions *mapViewOptions = [[GMSMapViewOptions alloc] init]; + mapViewOptions.frame = frame; + mapViewOptions.camera = camera; + + PartiallyMockedMapView *mapView = [[PartiallyMockedMapView alloc] initWithOptions:mapViewOptions]; GMSMutablePath *path = [FLTPolylinesController pathForPolyline:polyline]; NSString *identifier = polyline[@"polylineId"]; From 7e8d346c2021a3637bfefb50c09c98f393a0f56e Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Tue, 28 May 2024 16:37:39 +0530 Subject: [PATCH 42/45] Add some more missing types --- .../RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m | 2 +- .../ios/RunnerTests/GoogleMapsPolylinesControllerTests.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m index b37a92362c6..cc654606d8c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/FLTGoogleMapJSONConversionsConversionTests.m @@ -289,7 +289,7 @@ - (void)testCameraUpdateFromChannelValueZoomTo { } - (void)testLengthsFromPatterns { - NSArray *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @6.4 ] ]; + NSArray *> *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @6.4 ] ]; NSArray *spanLengths = [FLTGoogleMapJSONConversions spanLengthsFromPatterns:patterns]; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 2d324fb27c1..980dc746b8a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -22,7 +22,7 @@ @implementation GoogleMapsPolylinesControllerTests /// @return An object of FLTGoogleMapPolylineController /// - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { - NSDictionary *polyline = @{ + NSDictionary *polyline = @{ @"points" : @[ @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], @[ @(53.4153), @(-4.0829) ] @@ -68,7 +68,7 @@ - (void)testSetPatterns { } - (void)testStrokeStylesFromPatterns { - NSArray *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; + NSArray *> *patterns = @[ @[ @"gap", @10 ], @[ @"dash", @10 ] ]; UIColor *strokeColor = [UIColor redColor]; NSArray *patternStrokeStyle = From 3d83dadaf9132fbdacb51685e6e20ea4cd59b877 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Tue, 28 May 2024 16:38:35 +0530 Subject: [PATCH 43/45] Fix formatting issue --- .../ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 980dc746b8a..980ac1e709d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -22,7 +22,7 @@ @implementation GoogleMapsPolylinesControllerTests /// @return An object of FLTGoogleMapPolylineController /// - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { - NSDictionary *polyline = @{ + NSDictionary *polyline = @{ @"points" : @[ @[ @(52.4816), @(-3.1791) ], @[ @(54.043), @(-2.9925) ], @[ @(54.1396), @(-4.2739) ], @[ @(53.4153), @(-4.0829) ] From a6abf688532c71df1b9e42990d9df7aedbc2c323 Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Tue, 28 May 2024 16:42:58 +0530 Subject: [PATCH 44/45] Remove extra line around comments --- .../RunnerTests/GoogleMapsPolylinesControllerTests.m | 2 -- .../ios/Classes/FLTGoogleMapJSONConversions.h | 5 +---- .../ios/Classes/GoogleMapPolylineController.h | 2 -- .../ios/Classes/GoogleMapPolylineController.m | 2 -- .../ios/Classes/GoogleMapPolylineController_Test.h | 11 +++-------- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m index 980ac1e709d..84714f17c7f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylinesControllerTests.m @@ -16,11 +16,9 @@ @interface GoogleMapsPolylinesControllerTests : XCTestCase @implementation GoogleMapsPolylinesControllerTests -/// /// Returns GoogleMapPolylineController object instantiated with a mocked map instance /// /// @return An object of FLTGoogleMapPolylineController -/// - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { NSDictionary *polyline = @{ @"points" : @[ diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h index bae64e95f73..1fc8d003d91 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h @@ -25,22 +25,19 @@ NS_ASSUME_NONNULL_BEGIN + (GMSMapViewType)mapViewTypeFromTypeValue:(NSNumber *)value; + (nullable GMSCameraUpdate *)cameraUpdateFromChannelValue:(NSArray *)channelValue; -/// /// Return GMS strokestyle object array populated using the patterns and stroke colors passed in. /// /// @param patterns An array of patterns for each stroke in the polyline. /// @param strokeColor An array of color for each stroke in the polyline. /// @return An array of GMSStrokeStyle. -/// + (NSArray *)strokeStylesFromPatterns:(NSArray *> *)patterns strokeColor:(UIColor *)strokeColor; -/// + /// Return GMS strokestyle object array populated using the patterns and stroke colors passed in. /// Extracts the lengths of each stroke in the polyline from patterns input /// /// @param patterns An array of object representing the pattern params in the polyline. /// @return Array of lengths. -/// + (NSArray *)spanLengthsFromPatterns:(NSArray *> *)patterns; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h index 8756ac22ac6..63061392e5a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.h @@ -12,12 +12,10 @@ mapView:(GMSMapView *)mapView; - (void)removePolyline; -/// /// Sets the pattern on polyline controller /// /// @param styles The styles for repeating pattern sections. /// @param lengths The lengths for repeating pattern sections. -/// - (void)setPattern:(NSArray *)styles lengths:(NSArray *)lengths; @end diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index 1259550129a..47334576b1c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -12,9 +12,7 @@ @interface FLTGoogleMapPolylineController () @end -/// /// Returns dict[key], or nil if dict[key] is NSNull. -/// static id GetValueOrNilFromDict(NSDictionary *dict, NSString *key) { id value = dict[key]; return value == [NSNull null] ? nil : value; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h index c5c0e56564f..2b6e91e5d12 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController_Test.h @@ -4,26 +4,21 @@ #import "GoogleMapPolylineController.h" -/// /// Internal APIs exposed for unit testing -/// @interface FLTGoogleMapPolylineController (Test) -/// /// Polyline instance the controller is attached to -/// @property(strong, nonatomic) GMSPolyline *polyline; + @end -/// /// Internal APIs explosed for unit testing -/// @interface FLTPolylinesController (Test) -/// + /// Returns the path for polyline based on the points(locations) the polyline has. /// /// @param polyline The polyline instance for which path is calculated. /// @return An instance of GMSMutablePath. -/// + (GMSMutablePath *)pathForPolyline:(NSDictionary *)polyline; + @end From 26aba97466e7e855215825361bc705aef0c70b1e Mon Sep 17 00:00:00 2001 From: Hari07 <22373191+Hari-07@users.noreply.github.com> Date: Tue, 28 May 2024 16:59:27 +0530 Subject: [PATCH 45/45] Make test header public --- .../ios/Classes/google_maps_flutter_ios-umbrella.h | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h index 791c3aaea6c..4f331de069b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h @@ -6,6 +6,7 @@ #import #import #import +#import FOUNDATION_EXPORT double google_maps_flutterVersionNumber; FOUNDATION_EXPORT const unsigned char google_maps_flutterVersionString[];