This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[google_maps_flutter] Add liteModeEnabled option #2449
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
073fca5
Merge pull request #1 from flutter/master
otopba bb12418
Merge pull request #2 from flutter/master
otopba a03ee88
Merge pull request #3 from flutter/master
otopba e2613e0
Merge pull request #4 from flutter/master
otopba 1c98d10
Merge pull request #5 from flutter/master
otopba b50c88e
Merge pull request #6 from flutter/master
otopba ce695b1
Merge pull request #7 from flutter/master
otopba 58192f4
Merge pull request #8 from flutter/master
otopba 485a419
Merge pull request #9 from flutter/master
otopba dde8df7
Merge pull request #10 from flutter/master
otopba 33ed689
Merge pull request #11 from flutter/master
otopba 7ec3707
Merge remote-tracking branch 'upstream/master'
otopba f056c49
Merge remote-tracking branch 'upstream/master'
otopba ab1d5bc
Merge remote-tracking branch 'upstream/master'
otopba e4a6011
Merge remote-tracking branch 'upstream/master'
otopba 6d8f634
Add liteModeEnabled option
otopba fb15656
Merge remote-tracking branch 'upstream/master'
otopba 596184c
Merge remote-tracking branch 'upstream/master'
otopba e038a3e
Add dummy map initialization
otopba 4345ed5
Revert "Add dummy map initialization"
otopba 2d0abd4
Merge branch 'master' into liteModeEnabled
otopba 7d9a2ac
format
otopba b4a4989
format
otopba 2fe0b72
format
otopba ee302c1
Merge remote-tracking branch 'upstream/master'
otopba 125fffd
Merge branch 'master' into liteModeEnabled
otopba 97598ab
Merge remote-tracking branch 'upstream/master'
otopba c5a688e
Merge branch 'master' into liteModeEnabled
otopba 76991a4
add exception of liteModeEnabled not for android
otopba e7ddaec
change exception to assert
otopba 4c8d45a
Merge remote-tracking branch 'upstream/master'
otopba c5ac627
Merge branch 'master' into liteModeEnabled
otopba 786e731
merge
otopba b7458b3
fix readme
otopba 12722fa
fix assert
otopba 6c7ff06
fix assert
otopba 8788a6e
separate tests
otopba ce83d97
run limeDode test only on Android
otopba c267dca
Merge remote-tracking branch 'upstream/master'
otopba d6c7eb0
Merge branch 'master' into liteModeEnabled
otopba 56b897d
merge
otopba 454faa7
move file
otopba 4816227
Merge remote-tracking branch 'upstream/master'
otopba bb4e5be
Merge remote-tracking branch 'upstream/master'
otopba 5862774
Merge branch 'master' into liteModeEnabled
otopba bf0e39e
merge
otopba 0a86ebc
Merge remote-tracking branch 'upstream/master'
otopba 6cd64da
Merge remote-tracking branch 'upstream/master'
otopba a39de59
Merge branch 'master' into liteModeEnabled
otopba 696468f
fix example
otopba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
packages/google_maps_flutter/google_maps_flutter/example/lib/lite_mode.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
// ignore_for_file: public_member_api_docs | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:google_maps_flutter/google_maps_flutter.dart'; | ||
import 'page.dart'; | ||
|
||
const CameraPosition _kInitialPosition = | ||
CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); | ||
|
||
class LiteModePage extends GoogleMapExampleAppPage { | ||
LiteModePage() : super(const Icon(Icons.map), 'Lite mode'); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const _LiteModeBody(); | ||
} | ||
} | ||
|
||
class _LiteModeBody extends StatelessWidget { | ||
const _LiteModeBody(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Card( | ||
child: Padding( | ||
padding: const EdgeInsets.symmetric(vertical: 30.0), | ||
child: Center( | ||
child: SizedBox( | ||
width: 300.0, | ||
height: 300.0, | ||
child: GoogleMap( | ||
initialCameraPosition: _kInitialPosition, | ||
liteModeEnabled: true, | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ class GoogleMap extends StatefulWidget { | |
this.scrollGesturesEnabled = true, | ||
this.zoomControlsEnabled = true, | ||
this.zoomGesturesEnabled = true, | ||
this.liteModeEnabled = false, | ||
this.tiltGesturesEnabled = true, | ||
this.myLocationEnabled = false, | ||
this.myLocationButtonEnabled = true, | ||
|
@@ -90,6 +91,11 @@ class GoogleMap extends StatefulWidget { | |
/// True if the map view should respond to zoom gestures. | ||
final bool zoomGesturesEnabled; | ||
|
||
/// True if the map view should be in lite mode. Android only. | ||
/// | ||
/// See https://developers.google.com/maps/documentation/android-sdk/lite#overview_of_lite_mode for more details. | ||
final bool liteModeEnabled; | ||
|
||
/// True if the map view should respond to tilt gestures. | ||
final bool tiltGesturesEnabled; | ||
|
||
|
@@ -372,13 +378,18 @@ class _GoogleMapOptions { | |
this.trackCameraPosition, | ||
this.zoomControlsEnabled, | ||
this.zoomGesturesEnabled, | ||
this.liteModeEnabled, | ||
this.myLocationEnabled, | ||
this.myLocationButtonEnabled, | ||
this.padding, | ||
this.indoorViewEnabled, | ||
this.trafficEnabled, | ||
this.buildingsEnabled, | ||
}); | ||
}) { | ||
assert(liteModeEnabled == null || | ||
!liteModeEnabled || | ||
(liteModeEnabled && Platform.isAndroid)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: what about leaving this as a noop if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can leave it as is, an assertion helps the user to be more explicit when using liteMode so they are aware it doesn't work on iOS. |
||
} | ||
|
||
static _GoogleMapOptions fromWidget(GoogleMap map) { | ||
return _GoogleMapOptions( | ||
|
@@ -393,6 +404,7 @@ class _GoogleMapOptions { | |
trackCameraPosition: map.onCameraMove != null, | ||
zoomControlsEnabled: map.zoomControlsEnabled, | ||
zoomGesturesEnabled: map.zoomGesturesEnabled, | ||
liteModeEnabled: map.liteModeEnabled, | ||
myLocationEnabled: map.myLocationEnabled, | ||
myLocationButtonEnabled: map.myLocationButtonEnabled, | ||
padding: map.padding, | ||
|
@@ -424,6 +436,8 @@ class _GoogleMapOptions { | |
|
||
final bool zoomGesturesEnabled; | ||
|
||
final bool liteModeEnabled; | ||
|
||
final bool myLocationEnabled; | ||
|
||
final bool myLocationButtonEnabled; | ||
|
@@ -455,6 +469,7 @@ class _GoogleMapOptions { | |
addIfNonNull('tiltGesturesEnabled', tiltGesturesEnabled); | ||
addIfNonNull('zoomControlsEnabled', zoomControlsEnabled); | ||
addIfNonNull('zoomGesturesEnabled', zoomGesturesEnabled); | ||
addIfNonNull('liteModeEnabled', liteModeEnabled); | ||
addIfNonNull('trackCameraPosition', trackCameraPosition); | ||
addIfNonNull('myLocationEnabled', myLocationEnabled); | ||
addIfNonNull('myLocationButtonEnabled', myLocationButtonEnabled); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/google_maps_flutter/test/android_google_map_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
@TestOn('android') | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:google_maps_flutter/google_maps_flutter.dart'; | ||
|
||
import 'fake_maps_controllers.dart'; | ||
|
||
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
final FakePlatformViewsController fakePlatformViewsController = | ||
FakePlatformViewsController(); | ||
|
||
setUpAll(() { | ||
SystemChannels.platform_views.setMockMethodCallHandler( | ||
fakePlatformViewsController.fakePlatformViewsMethodHandler); | ||
}); | ||
|
||
setUp(() { | ||
fakePlatformViewsController.reset(); | ||
}); | ||
|
||
testWidgets('Can update liteModeEnabled', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
const Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: GoogleMap( | ||
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)), | ||
liteModeEnabled: false, | ||
), | ||
), | ||
); | ||
|
||
final FakePlatformGoogleMap platformGoogleMap = | ||
fakePlatformViewsController.lastCreatedView; | ||
|
||
expect(platformGoogleMap.liteModeEnabled, false); | ||
|
||
await tester.pumpWidget( | ||
const Directionality( | ||
textDirection: TextDirection.ltr, | ||
child: GoogleMap( | ||
initialCameraPosition: CameraPosition(target: LatLng(10.0, 15.0)), | ||
liteModeEnabled: true, | ||
), | ||
), | ||
); | ||
|
||
expect(platformGoogleMap.liteModeEnabled, true); | ||
}); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.