diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md index 12c93da5a..f605baba5 100644 --- a/packages/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/CHANGELOG.md @@ -1,7 +1,12 @@ +## 0.1.5 + +* Update the example app (`9990a4b1d72158a14924d712e89d4efef3f178d2`). +* Minor cleanups. + ## 0.1.4 * Change dependency from webview_flutter_tizen to webview_flutter_lwe. -* Fix integration test failures +* Fix integration test failures. ## 0.1.3 diff --git a/packages/google_maps_flutter/README.md b/packages/google_maps_flutter/README.md index 5c539c188..f1aee9afe 100644 --- a/packages/google_maps_flutter/README.md +++ b/packages/google_maps_flutter/README.md @@ -21,7 +21,7 @@ This package is not an _endorsed_ implementation of `google_maps_flutter`. There ```yaml dependencies: google_maps_flutter: ^2.1.7 - google_maps_flutter_tizen: ^0.1.3 + google_maps_flutter_tizen: ^0.1.5 ``` For detailed usage, see https://pub.dev/packages/google_maps_flutter#sample-usage. diff --git a/packages/google_maps_flutter/example/README.md b/packages/google_maps_flutter/example/README.md index 801809bfd..a11a5eec2 100644 --- a/packages/google_maps_flutter/example/README.md +++ b/packages/google_maps_flutter/example/README.md @@ -4,4 +4,4 @@ Demonstrates how to use the google_maps_flutter_tizen plugin. ## Getting Started -To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen). \ No newline at end of file +To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen). diff --git a/packages/google_maps_flutter/example/lib/main.dart b/packages/google_maps_flutter/example/lib/main.dart index 4efe56ac2..de75162b0 100644 --- a/packages/google_maps_flutter/example/lib/main.dart +++ b/packages/google_maps_flutter/example/lib/main.dart @@ -2,20 +2,24 @@ // 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 'animate_camera.dart'; +import 'lite_mode.dart'; import 'map_click.dart'; import 'map_coordinates.dart'; import 'map_ui.dart'; import 'marker_icons.dart'; import 'move_camera.dart'; +import 'padding.dart'; import 'page.dart'; import 'place_circle.dart'; import 'place_marker.dart'; import 'place_polygon.dart'; import 'place_polyline.dart'; +import 'scrolling_map.dart'; +import 'snapshot.dart'; +import 'tile_overlay.dart'; final List _allPages = [ const MapUiPage(), @@ -25,9 +29,14 @@ final List _allPages = [ const MoveCameraPage(), const PlaceMarkerPage(), const MarkerIconsPage(), + const ScrollingMapPage(), const PlacePolylinePage(), const PlacePolygonPage(), const PlaceCirclePage(), + const PaddingPage(), + const SnapshotPage(), + const LiteModePage(), + const TileOverlayPage(), ]; /// MapsDemo is the Main Application. diff --git a/packages/google_maps_flutter/example/lib/map_click.dart b/packages/google_maps_flutter/example/lib/map_click.dart index 5cef33845..ed25d475e 100644 --- a/packages/google_maps_flutter/example/lib/map_click.dart +++ b/packages/google_maps_flutter/example/lib/map_click.dart @@ -83,8 +83,12 @@ class _MapClickBodyState extends State<_MapClickBody> { lastLongPress, textAlign: TextAlign.center, ))); + columnChildren.add(Center( + child: Text( + _lastLongPress != null ? 'Long pressed' : '', + textAlign: TextAlign.center, + ))); } - return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: columnChildren, diff --git a/packages/google_maps_flutter/example/lib/map_coordinates.dart b/packages/google_maps_flutter/example/lib/map_coordinates.dart index 53a1cf7e4..12e31be8f 100644 --- a/packages/google_maps_flutter/example/lib/map_coordinates.dart +++ b/packages/google_maps_flutter/example/lib/map_coordinates.dart @@ -42,32 +42,42 @@ class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { final GoogleMap googleMap = GoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, + onCameraIdle: + _updateVisibleRegion, // https://github.com/flutter/flutter/issues/54758 ); - final List columnChildren = [ - Padding( - padding: const EdgeInsets.all(10.0), - child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, + return NotificationListener( + onNotification: (ScrollNotification scrollState) { + _updateVisibleRegion(); + return true; + }, + child: ListView( + children: [ + Padding( + padding: const EdgeInsets.all(10.0), + child: Center( + child: SizedBox( + width: 300.0, + height: 200.0, + child: googleMap, + ), + ), ), - ), + if (mapController != null) + Center( + child: Text('VisibleRegion:' + '\nnortheast: ${_visibleRegion.northeast},' + '\nsouthwest: ${_visibleRegion.southwest}'), + ), + // Add a block at the bottom of this list to allow validation that the visible region of the map + // does not change when scrolled under the safe view on iOS. + // https://github.com/flutter/flutter/issues/107913 + Container( + width: 300, + height: 1000, + ), + ], ), - ]; - - if (mapController != null) { - final String currentVisibleRegion = 'VisibleRegion:' - '\nnortheast: ${_visibleRegion.northeast},' - '\nsouthwest: ${_visibleRegion.southwest}'; - columnChildren.add(Center(child: Text(currentVisibleRegion))); - columnChildren.add(_getVisibleRegionButton()); - } - - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: columnChildren, ); } @@ -79,19 +89,10 @@ class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { }); } - Widget _getVisibleRegionButton() { - return Padding( - padding: const EdgeInsets.all(8.0), - child: ElevatedButton( - child: const Text('Get Visible Region Bounds'), - onPressed: () async { - final LatLngBounds visibleRegion = - await mapController!.getVisibleRegion(); - setState(() { - _visibleRegion = visibleRegion; - }); - }, - ), - ); + Future _updateVisibleRegion() async { + final LatLngBounds visibleRegion = await mapController!.getVisibleRegion(); + setState(() { + _visibleRegion = visibleRegion; + }); } } diff --git a/packages/google_maps_flutter/example/lib/map_ui.dart b/packages/google_maps_flutter/example/lib/map_ui.dart index 942060a4a..0a3146cfa 100644 --- a/packages/google_maps_flutter/example/lib/map_ui.dart +++ b/packages/google_maps_flutter/example/lib/map_ui.dart @@ -43,20 +43,20 @@ class MapUiBodyState extends State { CameraPosition _position = _kInitialPosition; bool _isMapCreated = false; final bool _isMoving = false; - final bool _compassEnabled = true; - final bool _mapToolbarEnabled = true; + bool _compassEnabled = true; + bool _mapToolbarEnabled = true; CameraTargetBounds _cameraTargetBounds = CameraTargetBounds.unbounded; MinMaxZoomPreference _minMaxZoomPreference = MinMaxZoomPreference.unbounded; MapType _mapType = MapType.normal; - final bool _rotateGesturesEnabled = true; + bool _rotateGesturesEnabled = true; bool _scrollGesturesEnabled = true; - final bool _tiltGesturesEnabled = true; + bool _tiltGesturesEnabled = true; bool _zoomControlsEnabled = false; bool _zoomGesturesEnabled = true; - final bool _indoorViewEnabled = true; - final bool _myLocationEnabled = true; + bool _indoorViewEnabled = true; + bool _myLocationEnabled = true; bool _myTrafficEnabled = false; - final bool _myLocationButtonEnabled = true; + bool _myLocationButtonEnabled = true; late GoogleMapController _controller; bool _nightMode = false; @@ -70,6 +70,28 @@ class MapUiBodyState extends State { super.dispose(); } + Widget _compassToggler() { + return TextButton( + child: Text('${_compassEnabled ? 'disable' : 'enable'} compass'), + onPressed: () { + setState(() { + _compassEnabled = !_compassEnabled; + }); + }, + ); + } + + Widget _mapToolbarToggler() { + return TextButton( + child: Text('${_mapToolbarEnabled ? 'disable' : 'enable'} map toolbar'), + onPressed: () { + setState(() { + _mapToolbarEnabled = !_mapToolbarEnabled; + }); + }, + ); + } + Widget _latLngBoundsToggler() { return TextButton( child: Text( @@ -115,6 +137,17 @@ class MapUiBodyState extends State { ); } + Widget _rotateToggler() { + return TextButton( + child: Text('${_rotateGesturesEnabled ? 'disable' : 'enable'} rotate'), + onPressed: () { + setState(() { + _rotateGesturesEnabled = !_rotateGesturesEnabled; + }); + }, + ); + } + Widget _scrollToggler() { return TextButton( child: Text('${_scrollGesturesEnabled ? 'disable' : 'enable'} scroll'), @@ -126,6 +159,17 @@ class MapUiBodyState extends State { ); } + Widget _tiltToggler() { + return TextButton( + child: Text('${_tiltGesturesEnabled ? 'disable' : 'enable'} tilt'), + onPressed: () { + setState(() { + _tiltGesturesEnabled = !_tiltGesturesEnabled; + }); + }, + ); + } + Widget _zoomToggler() { return TextButton( child: Text('${_zoomGesturesEnabled ? 'disable' : 'enable'} zoom'), @@ -149,6 +193,41 @@ class MapUiBodyState extends State { ); } + Widget _indoorViewToggler() { + return TextButton( + child: Text('${_indoorViewEnabled ? 'disable' : 'enable'} indoor'), + onPressed: () { + setState(() { + _indoorViewEnabled = !_indoorViewEnabled; + }); + }, + ); + } + + Widget _myLocationToggler() { + return TextButton( + child: Text( + '${_myLocationEnabled ? 'disable' : 'enable'} my location marker'), + onPressed: () { + setState(() { + _myLocationEnabled = !_myLocationEnabled; + }); + }, + ); + } + + Widget _myLocationButtonToggler() { + return TextButton( + child: Text( + '${_myLocationButtonEnabled ? 'disable' : 'enable'} my location button'), + onPressed: () { + setState(() { + _myLocationButtonEnabled = !_myLocationButtonEnabled; + }); + }, + ); + } + Widget _myTrafficToggler() { return TextButton( child: Text('${_myTrafficEnabled ? 'disable' : 'enable'} my traffic'), @@ -161,7 +240,7 @@ class MapUiBodyState extends State { } Future _getFileData(String path) async { - return await rootBundle.loadString(path); + return rootBundle.loadString(path); } void _setMapStyle(String mapStyle) { @@ -236,12 +315,19 @@ class MapUiBodyState extends State { Text('camera zoom: ${_position.zoom}'), Text('camera tilt: ${_position.tilt}'), Text(_isMoving ? '(Camera moving)' : '(Camera idle)'), + _compassToggler(), + _mapToolbarToggler(), _latLngBoundsToggler(), _mapTypeCycler(), _zoomBoundsToggler(), + _rotateToggler(), _scrollToggler(), + _tiltToggler(), _zoomToggler(), _zoomControlsToggler(), + _indoorViewToggler(), + _myLocationToggler(), + _myLocationButtonToggler(), _myTrafficToggler(), _nightModeToggler(), ], diff --git a/packages/google_maps_flutter/example/lib/place_marker.dart b/packages/google_maps_flutter/example/lib/place_marker.dart index 2687170d3..8fde95016 100644 --- a/packages/google_maps_flutter/example/lib/place_marker.dart +++ b/packages/google_maps_flutter/example/lib/place_marker.dart @@ -6,6 +6,8 @@ import 'dart:async'; import 'dart:math'; +import 'dart:typed_data'; +import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; @@ -186,6 +188,24 @@ class PlaceMarkerBodyState extends State { }); } + Future _toggleDraggable(MarkerId markerId) async { + final Marker marker = markers[markerId]!; + setState(() { + markers[markerId] = marker.copyWith( + draggableParam: !marker.draggable, + ); + }); + } + + Future _toggleFlat(MarkerId markerId) async { + final Marker marker = markers[markerId]!; + setState(() { + markers[markerId] = marker.copyWith( + flatParam: !marker.flat, + ); + }); + } + Future _changeInfo(MarkerId markerId) async { final Marker marker = markers[markerId]!; final String newSnippet = '${marker.infoWindow.snippet!}*'; @@ -208,6 +228,16 @@ class PlaceMarkerBodyState extends State { }); } + Future _changeRotation(MarkerId markerId) async { + final Marker marker = markers[markerId]!; + final double current = marker.rotation; + setState(() { + markers[markerId] = marker.copyWith( + rotationParam: current == 330.0 ? 0.0 : current + 30.0, + ); + }); + } + Future _toggleVisible(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { @@ -227,6 +257,37 @@ class PlaceMarkerBodyState extends State { }); } + void _setMarkerIcon(MarkerId markerId, BitmapDescriptor assetIcon) { + final Marker marker = markers[markerId]!; + setState(() { + markers[markerId] = marker.copyWith( + iconParam: assetIcon, + ); + }); + } + + Future _getAssetIcon(BuildContext context) async { + final Completer bitmapIcon = + Completer(); + final ImageConfiguration config = createLocalImageConfiguration(context); + + const AssetImage('assets/red_square.png') + .resolve(config) + .addListener(ImageStreamListener((ImageInfo image, bool sync) async { + final ByteData? bytes = + await image.image.toByteData(format: ImageByteFormat.png); + if (bytes == null) { + bitmapIcon.completeError(Exception('Unable to encode icon')); + return; + } + final BitmapDescriptor bitmap = + BitmapDescriptor.fromBytes(bytes.buffer.asUint8List()); + bitmapIcon.complete(bitmap); + })); + + return bitmapIcon.future; + } + @override Widget build(BuildContext context) { final MarkerId? selectedId = selectedMarker; @@ -283,12 +344,29 @@ class PlaceMarkerBodyState extends State { selectedId == null ? null : () => _changeAnchor(selectedId), child: const Text('change anchor'), ), + TextButton( + onPressed: selectedId == null + ? null + : () => _toggleDraggable(selectedId), + child: const Text('toggle draggable'), + ), + TextButton( + onPressed: + selectedId == null ? null : () => _toggleFlat(selectedId), + child: const Text('toggle flat'), + ), TextButton( onPressed: selectedId == null ? null : () => _changePosition(selectedId), child: const Text('change position'), ), + TextButton( + onPressed: selectedId == null + ? null + : () => _changeRotation(selectedId), + child: const Text('change rotation'), + ), TextButton( onPressed: selectedId == null ? null @@ -300,6 +378,18 @@ class PlaceMarkerBodyState extends State { selectedId == null ? null : () => _changeZIndex(selectedId), child: const Text('change zIndex'), ), + TextButton( + onPressed: selectedId == null + ? null + : () { + _getAssetIcon(context).then( + (BitmapDescriptor icon) { + _setMarkerIcon(selectedId, icon); + }, + ); + }, + child: const Text('set marker icon'), + ), ], ), ], diff --git a/packages/google_maps_flutter/example/lib/place_polyline.dart b/packages/google_maps_flutter/example/lib/place_polyline.dart index 8b8ae3f27..7a7c5d2f4 100644 --- a/packages/google_maps_flutter/example/lib/place_polyline.dart +++ b/packages/google_maps_flutter/example/lib/place_polyline.dart @@ -4,6 +4,7 @@ // ignore_for_file: public_member_api_docs +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; @@ -164,8 +165,46 @@ class PlacePolylineBodyState extends State { }); } + void _changeJointType(PolylineId polylineId) { + final Polyline polyline = polylines[polylineId]!; + setState(() { + polylines[polylineId] = polyline.copyWith( + jointTypeParam: jointTypes[++jointTypesIndex % jointTypes.length], + ); + }); + } + + void _changeEndCap(PolylineId polylineId) { + final Polyline polyline = polylines[polylineId]!; + setState(() { + polylines[polylineId] = polyline.copyWith( + endCapParam: endCaps[++endCapsIndex % endCaps.length], + ); + }); + } + + void _changeStartCap(PolylineId polylineId) { + final Polyline polyline = polylines[polylineId]!; + setState(() { + polylines[polylineId] = polyline.copyWith( + startCapParam: startCaps[++startCapsIndex % startCaps.length], + ); + }); + } + + void _changePattern(PolylineId polylineId) { + final Polyline polyline = polylines[polylineId]!; + setState(() { + polylines[polylineId] = polyline.copyWith( + patternsParam: patterns[++patternsIndex % patterns.length], + ); + }); + } + @override Widget build(BuildContext context) { + final bool isIOS = !kIsWeb && defaultTargetPlatform == TargetPlatform.iOS; + final PolylineId? selectedId = selectedPolyline; return Column( @@ -233,6 +272,30 @@ class PlacePolylineBodyState extends State { : () => _changeColor(selectedId), child: const Text('change color'), ), + TextButton( + onPressed: isIOS || (selectedId == null) + ? null + : () => _changeStartCap(selectedId), + child: const Text('change start cap [Android only]'), + ), + TextButton( + onPressed: isIOS || (selectedId == null) + ? null + : () => _changeEndCap(selectedId), + child: const Text('change end cap [Android only]'), + ), + TextButton( + onPressed: isIOS || (selectedId == null) + ? null + : () => _changeJointType(selectedId), + child: const Text('change joint type [Android only]'), + ), + TextButton( + onPressed: isIOS || (selectedId == null) + ? null + : () => _changePattern(selectedId), + child: const Text('change pattern [Android only]'), + ), ], ) ], diff --git a/packages/google_maps_flutter/example/pubspec.yaml b/packages/google_maps_flutter/example/pubspec.yaml index 436a004ef..e9cf14426 100644 --- a/packages/google_maps_flutter/example/pubspec.yaml +++ b/packages/google_maps_flutter/example/pubspec.yaml @@ -16,11 +16,12 @@ dependencies: dev_dependencies: flutter_driver: sdk: flutter + flutter_test: + sdk: flutter integration_test: sdk: flutter integration_test_tizen: path: ../../integration_test/ - pedantic: ^1.10.0 flutter: uses-material-design: true diff --git a/packages/google_maps_flutter/example/tizen/tizen-manifest.xml b/packages/google_maps_flutter/example/tizen/tizen-manifest.xml index 03b3113d6..7ab29e90f 100644 --- a/packages/google_maps_flutter/example/tizen/tizen-manifest.xml +++ b/packages/google_maps_flutter/example/tizen/tizen-manifest.xml @@ -1,7 +1,7 @@ - + ic_launcher.png diff --git a/packages/google_maps_flutter/lib/src/google_maps_flutter_tizen.dart b/packages/google_maps_flutter/lib/src/google_maps_flutter_tizen.dart index 873b658de..6f963b6ae 100644 --- a/packages/google_maps_flutter/lib/src/google_maps_flutter_tizen.dart +++ b/packages/google_maps_flutter/lib/src/google_maps_flutter_tizen.dart @@ -11,8 +11,6 @@ part of google_maps_flutter_tizen; class GoogleMapsPlugin extends GoogleMapsFlutterPlatform { /// Registers this class as the default instance of [GoogleMapsFlutterPlatform]. static void register() { - print( - 'Registers GoogleMapsPlugin() as the default instance [GoogleMapsFlutterPlatform]'); GoogleMapsFlutterPlatform.instance = GoogleMapsPlugin(); } diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml index 186f81006..6068cd106 100644 --- a/packages/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/pubspec.yaml @@ -1,31 +1,23 @@ name: google_maps_flutter_tizen -description: Tizen platform implementation of google_maps_flutter +description: Tizen implementation of the google_maps_flutter plugin. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/master/packages/google_maps_flutter -version: 0.1.4 +version: 0.1.5 flutter: plugin: platforms: tizen: dartPluginClass: GoogleMapsPlugin - fileName: google_maps_flutter_tizen.dart dependencies: flutter: sdk: flutter - flutter_lints: ^1.0.4 google_maps_flutter_platform_interface: ^2.1.2 - meta: ^1.3.0 stream_transform: ^2.0.0 webview_flutter: ^3.0.4 webview_flutter_lwe: ^0.1.0 -dev_dependencies: - flutter_test: - sdk: flutter - pedantic: ^1.10.0 - environment: sdk: ">=2.17.0 <3.0.0" flutter: ">=2.0.0"