diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/AndroidAutoBaseScreen.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/AndroidAutoBaseScreen.kt index c2fff07..574e656 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/AndroidAutoBaseScreen.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/AndroidAutoBaseScreen.kt @@ -121,7 +121,7 @@ open class AndroidAutoBaseScreen(carContext: CarContext) : mViewRegistry = viewRegistry mAutoMapView = GoogleMapsAutoMapView( - GoogleMapOptions(), + MapOptions(GoogleMapOptions(), null), viewRegistry, imageRegistry, navigationView, diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/Convert.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/Convert.kt index f69e1a3..ae580f0 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/Convert.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/Convert.kt @@ -61,28 +61,28 @@ object Convert { * @param options pigeon message [NavigationViewCreationOptionsDto]. * @return Google Map Options [GoogleMapOptions]. */ - fun convertMapOptionsFromDto(options: MapOptionsDto): GoogleMapOptions { - val mapOptions = GoogleMapOptions() + fun convertMapOptionsFromDto(options: MapOptionsDto): MapOptions { + val googleMapOptions = GoogleMapOptions() - mapOptions.camera(convertCameraPositionFromDto(options.cameraPosition)) - mapOptions.mapType(convertMapTypeFromDto(options.mapType)) - mapOptions.compassEnabled(options.compassEnabled) - mapOptions.rotateGesturesEnabled(options.rotateGesturesEnabled) - mapOptions.scrollGesturesEnabled(options.scrollGesturesEnabled) - mapOptions.tiltGesturesEnabled(options.tiltGesturesEnabled) - mapOptions.zoomGesturesEnabled(options.zoomGesturesEnabled) - mapOptions.scrollGesturesEnabledDuringRotateOrZoom( + googleMapOptions.camera(convertCameraPositionFromDto(options.cameraPosition)) + googleMapOptions.mapType(convertMapTypeFromDto(options.mapType)) + googleMapOptions.compassEnabled(options.compassEnabled) + googleMapOptions.rotateGesturesEnabled(options.rotateGesturesEnabled) + googleMapOptions.scrollGesturesEnabled(options.scrollGesturesEnabled) + googleMapOptions.tiltGesturesEnabled(options.tiltGesturesEnabled) + googleMapOptions.zoomGesturesEnabled(options.zoomGesturesEnabled) + googleMapOptions.scrollGesturesEnabledDuringRotateOrZoom( options.scrollGesturesEnabledDuringRotateOrZoom ) - mapOptions.mapToolbarEnabled(options.mapToolbarEnabled) + googleMapOptions.mapToolbarEnabled(options.mapToolbarEnabled) options.cameraTargetBounds?.let { - mapOptions.latLngBoundsForCameraTarget(convertLatLngBoundsFromDto(it)) + googleMapOptions.latLngBoundsForCameraTarget(convertLatLngBoundsFromDto(it)) } - options.minZoomPreference?.let { mapOptions.minZoomPreference(it.toFloat()) } - options.maxZoomPreference?.let { mapOptions.maxZoomPreference(it.toFloat()) } - mapOptions.zoomControlsEnabled(options.zoomControlsEnabled) + options.minZoomPreference?.let { googleMapOptions.minZoomPreference(it.toFloat()) } + options.maxZoomPreference?.let { googleMapOptions.maxZoomPreference(it.toFloat()) } + googleMapOptions.zoomControlsEnabled(options.zoomControlsEnabled) - return mapOptions + return MapOptions(googleMapOptions, options.padding) } /** diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt index b11a2c9..0b946ea 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapView.kt @@ -18,20 +18,19 @@ package com.google.maps.flutter.navigation import android.content.Context import android.view.View -import com.google.android.gms.maps.GoogleMapOptions import com.google.android.gms.maps.MapView import io.flutter.plugin.platform.PlatformView class GoogleMapView internal constructor( context: Context, - mapOptions: GoogleMapOptions, + mapOptions: MapOptions, viewId: Int, viewEventApi: ViewEventApi, private val viewRegistry: GoogleMapsViewRegistry, imageRegistry: ImageRegistry, ) : PlatformView, GoogleMapsBaseMapView(viewId, mapOptions, viewEventApi, imageRegistry) { - private val _mapView: MapView = MapView(context, mapOptions) + private val _mapView: MapView = MapView(context, mapOptions.googleMapOptions) override fun getView(): View { return _mapView @@ -51,6 +50,7 @@ internal constructor( initListeners() imageRegistry.mapViewInitializationComplete() mapReady() + mapOptions.padding?.let { setPadding(it) } invalidateViewAfterMapLoad() } } diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt index 4402072..43a65c6 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoMapView.kt @@ -18,12 +18,11 @@ package com.google.maps.flutter.navigation import android.view.View import com.google.android.gms.maps.GoogleMap -import com.google.android.gms.maps.GoogleMapOptions import com.google.android.libraries.navigation.NavigationViewForAuto class GoogleMapsAutoMapView internal constructor( - mapOptions: GoogleMapOptions, + mapOptions: MapOptions, private val viewRegistry: GoogleMapsViewRegistry, imageRegistry: ImageRegistry, private val mapView: NavigationViewForAuto, diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoViewMessageHandler.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoViewMessageHandler.kt index 351a4fe..a1baaee 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoViewMessageHandler.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsAutoViewMessageHandler.kt @@ -385,4 +385,12 @@ class GoogleMapsAutoViewMessageHandler(private val viewRegistry: GoogleMapsViewR override fun isAutoScreenAvailable(): Boolean { return viewRegistry.getAndroidAutoView() != null } + + override fun setPadding(padding: MapPaddingDto) { + getView().setPadding(padding) + } + + override fun getPadding(): MapPaddingDto { + return getView().getPadding() + } } diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsBaseMapView.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsBaseMapView.kt index 9223b98..27d05ce 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsBaseMapView.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsBaseMapView.kt @@ -25,7 +25,6 @@ import com.google.android.gms.maps.CameraUpdate import com.google.android.gms.maps.CameraUpdateFactory import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.GoogleMap.OnMarkerDragListener -import com.google.android.gms.maps.GoogleMapOptions import com.google.android.gms.maps.model.CameraPosition import com.google.android.gms.maps.model.Circle import com.google.android.gms.maps.model.FollowMyLocationOptions @@ -39,7 +38,7 @@ import com.google.android.libraries.navigation.NavigationView abstract class GoogleMapsBaseMapView( protected val viewId: Int?, - mapOptions: GoogleMapOptions, + mapOptions: MapOptions, protected val viewEventApi: ViewEventApi?, private val imageRegistry: ImageRegistry, ) { @@ -59,6 +58,8 @@ abstract class GoogleMapsBaseMapView( private var _minZoomLevelPreference: Float? = null private var _maxZoomLevelPreference: Float? = null + private var _mapOptions: MapOptions? = null + // Nullable variable to hold the callback function private var _mapReadyCallback: ((Result) -> Unit)? = null private var _loadedCallbackPending = false @@ -100,8 +101,9 @@ abstract class GoogleMapsBaseMapView( } init { - _minZoomLevelPreference = mapOptions.minZoomPreference - _maxZoomLevelPreference = mapOptions.maxZoomPreference + _minZoomLevelPreference = mapOptions.googleMapOptions.minZoomPreference + _maxZoomLevelPreference = mapOptions.googleMapOptions.maxZoomPreference + _mapOptions = mapOptions } protected fun mapReady() { @@ -942,4 +944,19 @@ abstract class GoogleMapsBaseMapView( ) {} } } + + fun setPadding(padding: MapPaddingDto) { + _mapOptions?.padding = padding + getMap() + .setPadding( + padding.left.toInt(), + padding.top.toInt(), + padding.right.toInt(), + padding.bottom.toInt(), + ) + } + + fun getPadding(): MapPaddingDto { + return _mapOptions?.padding ?: MapPaddingDto(0, 0, 0, 0) + } } diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationView.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationView.kt index d6237e3..7d51ef7 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationView.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsNavigationView.kt @@ -20,21 +20,20 @@ import android.content.Context import android.content.res.Configuration import android.view.View import com.google.android.gms.maps.CameraUpdateFactory -import com.google.android.gms.maps.GoogleMapOptions import com.google.android.libraries.navigation.NavigationView import io.flutter.plugin.platform.PlatformView class GoogleMapsNavigationView internal constructor( context: Context, - mapOptions: GoogleMapOptions, + mapOptions: MapOptions, navigationOptions: NavigationViewOptions?, viewId: Int, private val viewRegistry: GoogleMapsViewRegistry, viewEventApi: ViewEventApi, private val imageRegistry: ImageRegistry, ) : PlatformView, GoogleMapsBaseMapView(viewId, mapOptions, viewEventApi, imageRegistry) { - private val _navigationView: NavigationView = NavigationView(context, mapOptions) + private val _navigationView: NavigationView = NavigationView(context, mapOptions.googleMapOptions) /// Default values for UI features. private var _isNavigationTripProgressBarEnabled: Boolean = false @@ -79,11 +78,12 @@ internal constructor( // respected. _navigationView.isNavigationUiEnabled = navigationViewEnabled if (!navigationViewEnabled) { - map.moveCamera(CameraUpdateFactory.newCameraPosition(mapOptions.camera)) + map.moveCamera(CameraUpdateFactory.newCameraPosition(mapOptions.googleMapOptions.camera)) } // Call and clear view ready callback if available. mapReady() + mapOptions.padding?.let { setPadding(it) } invalidateViewAfterMapLoad() } } diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsViewMessageHandler.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsViewMessageHandler.kt index 2215a6f..13dd436 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsViewMessageHandler.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/GoogleMapsViewMessageHandler.kt @@ -475,4 +475,12 @@ class GoogleMapsViewMessageHandler(private val viewRegistry: GoogleMapsViewRegis override fun registerOnCameraChangedListener(viewId: Long) { getView(viewId.toInt()).registerOnCameraChangedListener() } + + override fun setPadding(viewId: Long, padding: MapPaddingDto) { + getView(viewId.toInt()).setPadding(padding) + } + + override fun getPadding(viewId: Long): MapPaddingDto { + return getView(viewId.toInt()).getPadding() + } } diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/MapOptions.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/MapOptions.kt new file mode 100644 index 0000000..562665b --- /dev/null +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/MapOptions.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.maps.flutter.navigation + +import com.google.android.gms.maps.GoogleMapOptions + +class MapOptions(val googleMapOptions: GoogleMapOptions, var padding: MapPaddingDto?) {} diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/messages.g.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/messages.g.kt index 57ab185..71014ec 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/messages.g.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/messages.g.kt @@ -542,6 +542,8 @@ data class MapOptionsDto( * the camera target does not move outside these bounds. */ val cameraTargetBounds: LatLngBoundsDto? = null, + /** Specifies the padding for the map. */ + val padding: MapPaddingDto? = null, ) { companion object { @Suppress("UNCHECKED_CAST") @@ -560,6 +562,7 @@ data class MapOptionsDto( val zoomControlsEnabled = list[11] as Boolean val cameraTargetBounds: LatLngBoundsDto? = (list[12] as List?)?.let { LatLngBoundsDto.fromList(it) } + val padding: MapPaddingDto? = (list[13] as List?)?.let { MapPaddingDto.fromList(it) } return MapOptionsDto( cameraPosition, mapType, @@ -574,6 +577,7 @@ data class MapOptionsDto( maxZoomPreference, zoomControlsEnabled, cameraTargetBounds, + padding, ) } } @@ -593,6 +597,7 @@ data class MapOptionsDto( maxZoomPreference, zoomControlsEnabled, cameraTargetBounds?.toList(), + padding?.toList(), ) } } @@ -1103,6 +1108,25 @@ data class CircleOptionsDto( } } +/** Generated class from Pigeon that represents data sent in messages. */ +data class MapPaddingDto(val top: Long, val left: Long, val bottom: Long, val right: Long) { + + companion object { + @Suppress("UNCHECKED_CAST") + fun fromList(list: List): MapPaddingDto { + val top = list[0].let { if (it is Int) it.toLong() else it as Long } + val left = list[1].let { if (it is Int) it.toLong() else it as Long } + val bottom = list[2].let { if (it is Int) it.toLong() else it as Long } + val right = list[3].let { if (it is Int) it.toLong() else it as Long } + return MapPaddingDto(top, left, bottom, right) + } + } + + fun toList(): List { + return listOf(top, left, bottom, right) + } +} + /** Generated class from Pigeon that represents data sent in messages. */ data class RouteTokenOptionsDto(val routeToken: String, val travelMode: TravelModeDto? = null) { @@ -1707,9 +1731,12 @@ private object NavigationViewCreationApiCodec : StandardMessageCodec() { return (readValue(buffer) as? List)?.let { MapOptionsDto.fromList(it) } } 132.toByte() -> { - return (readValue(buffer) as? List)?.let { NavigationViewOptionsDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MapPaddingDto.fromList(it) } } 133.toByte() -> { + return (readValue(buffer) as? List)?.let { NavigationViewOptionsDto.fromList(it) } + } + 134.toByte() -> { return (readValue(buffer) as? List)?.let { ViewCreationOptionsDto.fromList(it) } } else -> super.readValueOfType(type, buffer) @@ -1734,14 +1761,18 @@ private object NavigationViewCreationApiCodec : StandardMessageCodec() { stream.write(131) writeValue(stream, value.toList()) } - is NavigationViewOptionsDto -> { + is MapPaddingDto -> { stream.write(132) writeValue(stream, value.toList()) } - is ViewCreationOptionsDto -> { + is NavigationViewOptionsDto -> { stream.write(133) writeValue(stream, value.toList()) } + is ViewCreationOptionsDto -> { + stream.write(134) + writeValue(stream, value.toList()) + } else -> super.writeValue(stream, value) } } @@ -1825,36 +1856,39 @@ private object MapViewApiCodec : StandardMessageCodec() { return (readValue(buffer) as? List)?.let { LatLngDto.fromList(it) } } 136.toByte() -> { - return (readValue(buffer) as? List)?.let { MarkerAnchorDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MapPaddingDto.fromList(it) } } 137.toByte() -> { - return (readValue(buffer) as? List)?.let { MarkerDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MarkerAnchorDto.fromList(it) } } 138.toByte() -> { - return (readValue(buffer) as? List)?.let { MarkerOptionsDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MarkerDto.fromList(it) } } 139.toByte() -> { - return (readValue(buffer) as? List)?.let { PatternItemDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MarkerOptionsDto.fromList(it) } } 140.toByte() -> { - return (readValue(buffer) as? List)?.let { PolygonDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PatternItemDto.fromList(it) } } 141.toByte() -> { - return (readValue(buffer) as? List)?.let { PolygonHoleDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolygonDto.fromList(it) } } 142.toByte() -> { - return (readValue(buffer) as? List)?.let { PolygonOptionsDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolygonHoleDto.fromList(it) } } 143.toByte() -> { - return (readValue(buffer) as? List)?.let { PolylineDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolygonOptionsDto.fromList(it) } } 144.toByte() -> { - return (readValue(buffer) as? List)?.let { PolylineOptionsDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolylineDto.fromList(it) } } 145.toByte() -> { - return (readValue(buffer) as? List)?.let { StyleSpanDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolylineOptionsDto.fromList(it) } } 146.toByte() -> { + return (readValue(buffer) as? List)?.let { StyleSpanDto.fromList(it) } + } + 147.toByte() -> { return (readValue(buffer) as? List)?.let { StyleSpanStrokeStyleDto.fromList(it) } } else -> super.readValueOfType(type, buffer) @@ -1895,50 +1929,54 @@ private object MapViewApiCodec : StandardMessageCodec() { stream.write(135) writeValue(stream, value.toList()) } - is MarkerAnchorDto -> { + is MapPaddingDto -> { stream.write(136) writeValue(stream, value.toList()) } - is MarkerDto -> { + is MarkerAnchorDto -> { stream.write(137) writeValue(stream, value.toList()) } - is MarkerOptionsDto -> { + is MarkerDto -> { stream.write(138) writeValue(stream, value.toList()) } - is PatternItemDto -> { + is MarkerOptionsDto -> { stream.write(139) writeValue(stream, value.toList()) } - is PolygonDto -> { + is PatternItemDto -> { stream.write(140) writeValue(stream, value.toList()) } - is PolygonHoleDto -> { + is PolygonDto -> { stream.write(141) writeValue(stream, value.toList()) } - is PolygonOptionsDto -> { + is PolygonHoleDto -> { stream.write(142) writeValue(stream, value.toList()) } - is PolylineDto -> { + is PolygonOptionsDto -> { stream.write(143) writeValue(stream, value.toList()) } - is PolylineOptionsDto -> { + is PolylineDto -> { stream.write(144) writeValue(stream, value.toList()) } - is StyleSpanDto -> { + is PolylineOptionsDto -> { stream.write(145) writeValue(stream, value.toList()) } - is StyleSpanStrokeStyleDto -> { + is StyleSpanDto -> { stream.write(146) writeValue(stream, value.toList()) } + is StyleSpanStrokeStyleDto -> { + stream.write(147) + writeValue(stream, value.toList()) + } else -> super.writeValue(stream, value) } } @@ -2166,6 +2204,10 @@ interface MapViewApi { fun registerOnCameraChangedListener(viewId: Long) + fun setPadding(viewId: Long, padding: MapPaddingDto) + + fun getPadding(viewId: Long): MapPaddingDto + companion object { /** The codec used by MapViewApi. */ val codec: MessageCodec by lazy { MapViewApiCodec } @@ -4376,6 +4418,54 @@ interface MapViewApi { channel.setMessageHandler(null) } } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setPadding", + codec, + ) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val viewIdArg = args[0].let { if (it is Int) it.toLong() else it as Long } + val paddingArg = args[1] as MapPaddingDto + var wrapped: List + try { + api.setPadding(viewIdArg, paddingArg) + wrapped = listOf(null) + } catch (exception: Throwable) { + wrapped = wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getPadding", + codec, + ) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val viewIdArg = args[0].let { if (it is Int) it.toLong() else it as Long } + var wrapped: List + try { + wrapped = listOf(api.getPadding(viewIdArg)) + } catch (exception: Throwable) { + wrapped = wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } } } } @@ -6119,36 +6209,39 @@ private object AutoMapViewApiCodec : StandardMessageCodec() { return (readValue(buffer) as? List)?.let { LatLngDto.fromList(it) } } 136.toByte() -> { - return (readValue(buffer) as? List)?.let { MarkerAnchorDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MapPaddingDto.fromList(it) } } 137.toByte() -> { - return (readValue(buffer) as? List)?.let { MarkerDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MarkerAnchorDto.fromList(it) } } 138.toByte() -> { - return (readValue(buffer) as? List)?.let { MarkerOptionsDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MarkerDto.fromList(it) } } 139.toByte() -> { - return (readValue(buffer) as? List)?.let { PatternItemDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MarkerOptionsDto.fromList(it) } } 140.toByte() -> { - return (readValue(buffer) as? List)?.let { PolygonDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PatternItemDto.fromList(it) } } 141.toByte() -> { - return (readValue(buffer) as? List)?.let { PolygonHoleDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolygonDto.fromList(it) } } 142.toByte() -> { - return (readValue(buffer) as? List)?.let { PolygonOptionsDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolygonHoleDto.fromList(it) } } 143.toByte() -> { - return (readValue(buffer) as? List)?.let { PolylineDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolygonOptionsDto.fromList(it) } } 144.toByte() -> { - return (readValue(buffer) as? List)?.let { PolylineOptionsDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolylineDto.fromList(it) } } 145.toByte() -> { - return (readValue(buffer) as? List)?.let { StyleSpanDto.fromList(it) } + return (readValue(buffer) as? List)?.let { PolylineOptionsDto.fromList(it) } } 146.toByte() -> { + return (readValue(buffer) as? List)?.let { StyleSpanDto.fromList(it) } + } + 147.toByte() -> { return (readValue(buffer) as? List)?.let { StyleSpanStrokeStyleDto.fromList(it) } } else -> super.readValueOfType(type, buffer) @@ -6189,50 +6282,54 @@ private object AutoMapViewApiCodec : StandardMessageCodec() { stream.write(135) writeValue(stream, value.toList()) } - is MarkerAnchorDto -> { + is MapPaddingDto -> { stream.write(136) writeValue(stream, value.toList()) } - is MarkerDto -> { + is MarkerAnchorDto -> { stream.write(137) writeValue(stream, value.toList()) } - is MarkerOptionsDto -> { + is MarkerDto -> { stream.write(138) writeValue(stream, value.toList()) } - is PatternItemDto -> { + is MarkerOptionsDto -> { stream.write(139) writeValue(stream, value.toList()) } - is PolygonDto -> { + is PatternItemDto -> { stream.write(140) writeValue(stream, value.toList()) } - is PolygonHoleDto -> { + is PolygonDto -> { stream.write(141) writeValue(stream, value.toList()) } - is PolygonOptionsDto -> { + is PolygonHoleDto -> { stream.write(142) writeValue(stream, value.toList()) } - is PolylineDto -> { + is PolygonOptionsDto -> { stream.write(143) writeValue(stream, value.toList()) } - is PolylineOptionsDto -> { + is PolylineDto -> { stream.write(144) writeValue(stream, value.toList()) } - is StyleSpanDto -> { + is PolylineOptionsDto -> { stream.write(145) writeValue(stream, value.toList()) } - is StyleSpanStrokeStyleDto -> { + is StyleSpanDto -> { stream.write(146) writeValue(stream, value.toList()) } + is StyleSpanStrokeStyleDto -> { + stream.write(147) + writeValue(stream, value.toList()) + } else -> super.writeValue(stream, value) } } @@ -6411,6 +6508,10 @@ interface AutoMapViewApi { fun isAutoScreenAvailable(): Boolean + fun setPadding(padding: MapPaddingDto) + + fun getPadding(): MapPaddingDto + companion object { /** The codec used by AutoMapViewApi. */ val codec: MessageCodec by lazy { AutoMapViewApiCodec } @@ -8109,6 +8210,51 @@ interface AutoMapViewApi { channel.setMessageHandler(null) } } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.setPadding", + codec, + ) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val paddingArg = args[0] as MapPaddingDto + var wrapped: List + try { + api.setPadding(paddingArg) + wrapped = listOf(null) + } catch (exception: Throwable) { + wrapped = wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.getPadding", + codec, + ) + if (api != null) { + channel.setMessageHandler { _, reply -> + var wrapped: List + try { + wrapped = listOf(api.getPadding()) + } catch (exception: Throwable) { + wrapped = wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } } } } @@ -8151,88 +8297,91 @@ private object AutoViewEventApiCodec : StandardMessageCodec() { return (readValue(buffer) as? List)?.let { MapOptionsDto.fromList(it) } } 139.toByte() -> { - return (readValue(buffer) as? List)?.let { MarkerAnchorDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MapPaddingDto.fromList(it) } } 140.toByte() -> { - return (readValue(buffer) as? List)?.let { MarkerDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MarkerAnchorDto.fromList(it) } } 141.toByte() -> { - return (readValue(buffer) as? List)?.let { MarkerOptionsDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MarkerDto.fromList(it) } } 142.toByte() -> { - return (readValue(buffer) as? List)?.let { NavInfoDto.fromList(it) } + return (readValue(buffer) as? List)?.let { MarkerOptionsDto.fromList(it) } } 143.toByte() -> { + return (readValue(buffer) as? List)?.let { NavInfoDto.fromList(it) } + } + 144.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationAudioGuidanceSettingsDto.fromList(it) } } - 144.toByte() -> { + 145.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationDisplayOptionsDto.fromList(it) } } - 145.toByte() -> { + 146.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationTimeAndDistanceDto.fromList(it) } } - 146.toByte() -> { + 147.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationViewOptionsDto.fromList(it) } } - 147.toByte() -> { + 148.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationWaypointDto.fromList(it) } } - 148.toByte() -> { + 149.toByte() -> { return (readValue(buffer) as? List)?.let { PatternItemDto.fromList(it) } } - 149.toByte() -> { + 150.toByte() -> { return (readValue(buffer) as? List)?.let { PolygonDto.fromList(it) } } - 150.toByte() -> { + 151.toByte() -> { return (readValue(buffer) as? List)?.let { PolygonHoleDto.fromList(it) } } - 151.toByte() -> { + 152.toByte() -> { return (readValue(buffer) as? List)?.let { PolygonOptionsDto.fromList(it) } } - 152.toByte() -> { + 153.toByte() -> { return (readValue(buffer) as? List)?.let { PolylineDto.fromList(it) } } - 153.toByte() -> { + 154.toByte() -> { return (readValue(buffer) as? List)?.let { PolylineOptionsDto.fromList(it) } } - 154.toByte() -> { + 155.toByte() -> { return (readValue(buffer) as? List)?.let { RouteSegmentDto.fromList(it) } } - 155.toByte() -> { + 156.toByte() -> { return (readValue(buffer) as? List)?.let { RouteSegmentTrafficDataDto.fromList(it) } } - 156.toByte() -> { + 157.toByte() -> { return (readValue(buffer) as? List)?.let { RouteSegmentTrafficDataRoadStretchRenderingDataDto.fromList(it) } } - 157.toByte() -> { + 158.toByte() -> { return (readValue(buffer) as? List)?.let { RouteTokenOptionsDto.fromList(it) } } - 158.toByte() -> { + 159.toByte() -> { return (readValue(buffer) as? List)?.let { RoutingOptionsDto.fromList(it) } } - 159.toByte() -> { + 160.toByte() -> { return (readValue(buffer) as? List)?.let { SimulationOptionsDto.fromList(it) } } - 160.toByte() -> { + 161.toByte() -> { return (readValue(buffer) as? List)?.let { SpeedAlertOptionsDto.fromList(it) } } - 161.toByte() -> { + 162.toByte() -> { return (readValue(buffer) as? List)?.let { SpeedingUpdatedEventDto.fromList(it) } } - 162.toByte() -> { + 163.toByte() -> { return (readValue(buffer) as? List)?.let { StepInfoDto.fromList(it) } } - 163.toByte() -> { + 164.toByte() -> { return (readValue(buffer) as? List)?.let { StyleSpanDto.fromList(it) } } - 164.toByte() -> { + 165.toByte() -> { return (readValue(buffer) as? List)?.let { StyleSpanStrokeStyleDto.fromList(it) } } - 165.toByte() -> { + 166.toByte() -> { return (readValue(buffer) as? List)?.let { ViewCreationOptionsDto.fromList(it) } } else -> super.readValueOfType(type, buffer) @@ -8285,114 +8434,118 @@ private object AutoViewEventApiCodec : StandardMessageCodec() { stream.write(138) writeValue(stream, value.toList()) } - is MarkerAnchorDto -> { + is MapPaddingDto -> { stream.write(139) writeValue(stream, value.toList()) } - is MarkerDto -> { + is MarkerAnchorDto -> { stream.write(140) writeValue(stream, value.toList()) } - is MarkerOptionsDto -> { + is MarkerDto -> { stream.write(141) writeValue(stream, value.toList()) } - is NavInfoDto -> { + is MarkerOptionsDto -> { stream.write(142) writeValue(stream, value.toList()) } - is NavigationAudioGuidanceSettingsDto -> { + is NavInfoDto -> { stream.write(143) writeValue(stream, value.toList()) } - is NavigationDisplayOptionsDto -> { + is NavigationAudioGuidanceSettingsDto -> { stream.write(144) writeValue(stream, value.toList()) } - is NavigationTimeAndDistanceDto -> { + is NavigationDisplayOptionsDto -> { stream.write(145) writeValue(stream, value.toList()) } - is NavigationViewOptionsDto -> { + is NavigationTimeAndDistanceDto -> { stream.write(146) writeValue(stream, value.toList()) } - is NavigationWaypointDto -> { + is NavigationViewOptionsDto -> { stream.write(147) writeValue(stream, value.toList()) } - is PatternItemDto -> { + is NavigationWaypointDto -> { stream.write(148) writeValue(stream, value.toList()) } - is PolygonDto -> { + is PatternItemDto -> { stream.write(149) writeValue(stream, value.toList()) } - is PolygonHoleDto -> { + is PolygonDto -> { stream.write(150) writeValue(stream, value.toList()) } - is PolygonOptionsDto -> { + is PolygonHoleDto -> { stream.write(151) writeValue(stream, value.toList()) } - is PolylineDto -> { + is PolygonOptionsDto -> { stream.write(152) writeValue(stream, value.toList()) } - is PolylineOptionsDto -> { + is PolylineDto -> { stream.write(153) writeValue(stream, value.toList()) } - is RouteSegmentDto -> { + is PolylineOptionsDto -> { stream.write(154) writeValue(stream, value.toList()) } - is RouteSegmentTrafficDataDto -> { + is RouteSegmentDto -> { stream.write(155) writeValue(stream, value.toList()) } - is RouteSegmentTrafficDataRoadStretchRenderingDataDto -> { + is RouteSegmentTrafficDataDto -> { stream.write(156) writeValue(stream, value.toList()) } - is RouteTokenOptionsDto -> { + is RouteSegmentTrafficDataRoadStretchRenderingDataDto -> { stream.write(157) writeValue(stream, value.toList()) } - is RoutingOptionsDto -> { + is RouteTokenOptionsDto -> { stream.write(158) writeValue(stream, value.toList()) } - is SimulationOptionsDto -> { + is RoutingOptionsDto -> { stream.write(159) writeValue(stream, value.toList()) } - is SpeedAlertOptionsDto -> { + is SimulationOptionsDto -> { stream.write(160) writeValue(stream, value.toList()) } - is SpeedingUpdatedEventDto -> { + is SpeedAlertOptionsDto -> { stream.write(161) writeValue(stream, value.toList()) } - is StepInfoDto -> { + is SpeedingUpdatedEventDto -> { stream.write(162) writeValue(stream, value.toList()) } - is StyleSpanDto -> { + is StepInfoDto -> { stream.write(163) writeValue(stream, value.toList()) } - is StyleSpanStrokeStyleDto -> { + is StyleSpanDto -> { stream.write(164) writeValue(stream, value.toList()) } - is ViewCreationOptionsDto -> { + is StyleSpanStrokeStyleDto -> { stream.write(165) writeValue(stream, value.toList()) } + is ViewCreationOptionsDto -> { + stream.write(166) + writeValue(stream, value.toList()) + } else -> super.writeValue(stream, value) } } diff --git a/android/src/test/kotlin/com/google/maps/flutter/navigation/ConvertTest.kt b/android/src/test/kotlin/com/google/maps/flutter/navigation/ConvertTest.kt index ae3fb01..64d88cf 100644 --- a/android/src/test/kotlin/com/google/maps/flutter/navigation/ConvertTest.kt +++ b/android/src/test/kotlin/com/google/maps/flutter/navigation/ConvertTest.kt @@ -376,58 +376,76 @@ internal class ConvertTest { val mapOptions = Convert.convertMapOptionsFromDto(testOptions) - assertEquals(mapOptions.camera.target.latitude, testOptions.cameraPosition.target.latitude) + assertEquals( + mapOptions.googleMapOptions.camera.target.latitude, + testOptions.cameraPosition.target.latitude, + ) - assertEquals(mapOptions.camera.target.longitude, testOptions.cameraPosition.target.longitude) + assertEquals( + mapOptions.googleMapOptions.camera.target.longitude, + testOptions.cameraPosition.target.longitude, + ) - assertEquals(mapOptions.camera.bearing, testOptions.cameraPosition.bearing.toFloat()) + assertEquals( + mapOptions.googleMapOptions.camera.bearing, + testOptions.cameraPosition.bearing.toFloat(), + ) - assertEquals(mapOptions.camera.tilt, testOptions.cameraPosition.tilt.toFloat()) + assertEquals(mapOptions.googleMapOptions.camera.tilt, testOptions.cameraPosition.tilt.toFloat()) - assertEquals(mapOptions.camera.zoom, testOptions.cameraPosition.zoom.toFloat()) + assertEquals(mapOptions.googleMapOptions.camera.zoom, testOptions.cameraPosition.zoom.toFloat()) - assertEquals(mapOptions.mapType, GoogleMap.MAP_TYPE_HYBRID) + assertEquals(mapOptions.googleMapOptions.mapType, GoogleMap.MAP_TYPE_HYBRID) - assertEquals(mapOptions.compassEnabled, testOptions.compassEnabled) + assertEquals(mapOptions.googleMapOptions.compassEnabled, testOptions.compassEnabled) - assertEquals(mapOptions.scrollGesturesEnabled, testOptions.scrollGesturesEnabled) + assertEquals( + mapOptions.googleMapOptions.scrollGesturesEnabled, + testOptions.scrollGesturesEnabled, + ) - assertEquals(mapOptions.tiltGesturesEnabled, testOptions.tiltGesturesEnabled) + assertEquals(mapOptions.googleMapOptions.tiltGesturesEnabled, testOptions.tiltGesturesEnabled) - assertEquals(mapOptions.zoomGesturesEnabled, testOptions.zoomGesturesEnabled) + assertEquals(mapOptions.googleMapOptions.zoomGesturesEnabled, testOptions.zoomGesturesEnabled) assertEquals( - mapOptions.scrollGesturesEnabledDuringRotateOrZoom, + mapOptions.googleMapOptions.scrollGesturesEnabledDuringRotateOrZoom, testOptions.scrollGesturesEnabledDuringRotateOrZoom, ) - assertEquals(mapOptions.mapToolbarEnabled, testOptions.mapToolbarEnabled) + assertEquals(mapOptions.googleMapOptions.mapToolbarEnabled, testOptions.mapToolbarEnabled) assertEquals( - mapOptions.latLngBoundsForCameraTarget.northeast.latitude, + mapOptions.googleMapOptions.latLngBoundsForCameraTarget.northeast.latitude, testOptions.cameraTargetBounds?.northeast?.latitude, ) assertEquals( - mapOptions.latLngBoundsForCameraTarget.northeast.longitude, + mapOptions.googleMapOptions.latLngBoundsForCameraTarget.northeast.longitude, testOptions.cameraTargetBounds?.northeast?.longitude, ) assertEquals( - mapOptions.latLngBoundsForCameraTarget.southwest.latitude, + mapOptions.googleMapOptions.latLngBoundsForCameraTarget.southwest.latitude, testOptions.cameraTargetBounds?.southwest?.latitude, ) assertEquals( - mapOptions.latLngBoundsForCameraTarget.southwest.longitude, + mapOptions.googleMapOptions.latLngBoundsForCameraTarget.southwest.longitude, testOptions.cameraTargetBounds?.southwest?.longitude, ) - assertEquals(mapOptions.minZoomPreference, testOptions.minZoomPreference?.toFloat()) + assertEquals( + mapOptions.googleMapOptions.minZoomPreference, + testOptions.minZoomPreference?.toFloat(), + ) - assertEquals(mapOptions.maxZoomPreference, testOptions.maxZoomPreference?.toFloat()) + assertEquals( + mapOptions.googleMapOptions.maxZoomPreference, + testOptions.maxZoomPreference?.toFloat(), + ) - assertEquals(mapOptions.zoomControlsEnabled, testOptions.zoomControlsEnabled) + assertEquals(mapOptions.googleMapOptions.zoomControlsEnabled, testOptions.zoomControlsEnabled) // Test nullable values val testOptions2 = @@ -438,11 +456,11 @@ internal class ConvertTest { ) val mapOptions2 = Convert.convertMapOptionsFromDto(testOptions2) - assertEquals(mapOptions2.minZoomPreference, null) + assertEquals(mapOptions2.googleMapOptions.minZoomPreference, null) - assertEquals(mapOptions2.maxZoomPreference, null) + assertEquals(mapOptions2.googleMapOptions.maxZoomPreference, null) - assertEquals(mapOptions2.latLngBoundsForCameraTarget, null) + assertEquals(mapOptions2.googleMapOptions.latLngBoundsForCameraTarget, null) } @Test diff --git a/example/integration_test/t06_map_test.dart b/example/integration_test/t06_map_test.dart index a556a08..707e6a7 100644 --- a/example/integration_test/t06_map_test.dart +++ b/example/integration_test/t06_map_test.dart @@ -373,4 +373,70 @@ void main() { }, variant: mapTypeVariants, ); + + patrol( + 'Test map padding', + (PatrolIntegrationTester $) async { + /// For some reason the functionality works on Android example app, but it doesn't work + /// during the testing. Will skip Android testing for now. + final Completer viewControllerCompleter = + Completer(); + + await checkLocationDialogAcceptance($); + + switch (mapTypeVariants.currentValue!) { + case TestMapType.mapView: + + /// Display map view. + final Key key = GlobalKey(); + await pumpMapView( + $, + GoogleMapsMapView( + key: key, + onViewCreated: (GoogleMapViewController controller) { + viewControllerCompleter.complete(controller); + }, + ), + ); + break; + case TestMapType.navigationView: + + /// Display navigation view. + final Key key = GlobalKey(); + await pumpNavigationView( + $, + GoogleMapsNavigationView( + key: key, + onViewCreated: (GoogleNavigationViewController controller) { + viewControllerCompleter.complete(controller); + }, + ), + ); + break; + } + + final GoogleMapViewController viewController = + await viewControllerCompleter.future; + + // Test initial values + EdgeInsets initialPadding = await viewController.getPadding(); + + expect(initialPadding.left, 0.0); + expect(initialPadding.top, 0.0); + expect(initialPadding.right, 0.0); + expect(initialPadding.bottom, 0.0); + + await viewController.setPadding( + const EdgeInsets.only(left: 50, top: 60, right: 70, bottom: 80)); + + // Test that the padding values were changed. + EdgeInsets newPadding = await viewController.getPadding(); + + expect(newPadding.left, 50.0); + expect(newPadding.top, 60.0); + expect(newPadding.right, 70.0); + expect(newPadding.bottom, 80.0); + }, + variant: mapTypeVariants, + ); } diff --git a/example/lib/pages/navigation.dart b/example/lib/pages/navigation.dart index 1058084..2f94f67 100644 --- a/example/lib/pages/navigation.dart +++ b/example/lib/pages/navigation.dart @@ -142,6 +142,9 @@ class _NavigationPageState extends ExamplePageState { int _nextWaypointIndex = 0; + EdgeInsets _mapPadding = const EdgeInsets.all(0); + EdgeInsets _autoViewMapPadding = const EdgeInsets.all(0); + @override void initState() { super.initState(); @@ -975,6 +978,28 @@ class _NavigationPageState extends ExamplePageState { 'Current route segment destination: ${segment?.destinationWaypoint?.title ?? 'unknown'}'); } + Future _setPadding(EdgeInsets padding) async { + try { + await _navigationViewController!.setPadding(padding); + setState(() { + _mapPadding = padding; + }); + } catch (e) { + showMessage(e.toString()); + } + } + + Future _setAutoViewPadding(EdgeInsets padding) async { + try { + await _autoViewController.setPadding(padding); + setState(() { + _autoViewMapPadding = padding; + }); + } catch (e) { + showMessage(e.toString()); + } + } + @override Widget build(BuildContext context) => buildPage( context, @@ -1003,7 +1028,7 @@ class _NavigationPageState extends ExamplePageState { initialNavigationUIEnabledPreference: _guidanceRunning ? NavigationUIEnabledPreference.automatic : NavigationUIEnabledPreference.disabled, - ) + initialPadding: const EdgeInsets.all(0)) : const Center( child: Column( mainAxisSize: MainAxisSize.min, @@ -1476,6 +1501,66 @@ class _NavigationPageState extends ExamplePageState { _trafficIndicentCardsEnabled = newValue; }); }), + Text( + 'Map left padding: ${_mapPadding.left.toStringAsFixed(0)}'), + Slider( + value: _mapPadding.left.toDouble(), + min: 0, + max: 200, + divisions: 20, + label: _mapPadding.left.toStringAsFixed(0), + onChanged: (double value) { + _setPadding(EdgeInsets.only( + top: _mapPadding.top, + left: value, + bottom: _mapPadding.bottom, + right: _mapPadding.right)); + }), + Text( + 'Map right padding: ${_mapPadding.right.toStringAsFixed(0)}'), + Slider( + value: _mapPadding.right.toDouble(), + min: 0, + max: 200, + divisions: 20, + label: _mapPadding.right.toStringAsFixed(0), + onChanged: (double value) { + _setPadding(EdgeInsets.only( + top: _mapPadding.top, + left: _mapPadding.left, + bottom: _mapPadding.bottom, + right: value)); + }), + Text( + 'Map top padding: ${_mapPadding.top.toStringAsFixed(0)}'), + Slider( + value: _mapPadding.top.toDouble(), + min: 0, + max: 200, + divisions: 20, + label: _mapPadding.top.toStringAsFixed(0), + onChanged: (double value) { + _setPadding(EdgeInsets.only( + top: value, + left: _mapPadding.left, + bottom: _mapPadding.bottom, + right: _mapPadding.right)); + }), + Text( + 'Map bottom padding: ${_mapPadding.bottom.toStringAsFixed(0)}'), + Slider( + value: _mapPadding.bottom.toDouble(), + min: 0, + max: 200, + divisions: 20, + label: _mapPadding.bottom.toStringAsFixed(0), + onChanged: (double value) { + _setPadding(EdgeInsets.only( + top: _mapPadding.top, + left: _mapPadding.left, + bottom: value, + right: _mapPadding.right)); + }), ]), )), Card( @@ -1499,6 +1584,62 @@ class _NavigationPageState extends ExamplePageState { onPressed: () => _addMarkerForAuto(), child: const Text('Add marker'), ), + Text('Map left padding: ${_autoViewMapPadding.left}'), + Slider( + value: _autoViewMapPadding.left.toDouble(), + min: 0, + max: 200, + divisions: 20, + label: _autoViewMapPadding.left.toString(), + onChanged: (double value) { + _setAutoViewPadding(EdgeInsets.only( + top: _autoViewMapPadding.top, + left: value, + bottom: _autoViewMapPadding.bottom, + right: _autoViewMapPadding.right)); + }), + Text('Map right padding: ${_autoViewMapPadding.right}'), + Slider( + value: _autoViewMapPadding.right.toDouble(), + min: 0, + max: 200, + divisions: 20, + label: _autoViewMapPadding.right.toString(), + onChanged: (double value) { + _setAutoViewPadding(EdgeInsets.only( + top: _autoViewMapPadding.top, + left: _autoViewMapPadding.left, + bottom: _autoViewMapPadding.bottom, + right: value)); + }), + Text('Map top padding: ${_autoViewMapPadding.top}'), + Slider( + value: _autoViewMapPadding.top.toDouble(), + min: 0, + max: 200, + divisions: 20, + label: _autoViewMapPadding.top.toString(), + onChanged: (double value) { + _setAutoViewPadding(EdgeInsets.only( + top: value, + left: _autoViewMapPadding.left, + bottom: _autoViewMapPadding.bottom, + right: _autoViewMapPadding.right)); + }), + Text('Map bottom padding: ${_autoViewMapPadding.bottom}'), + Slider( + value: _autoViewMapPadding.bottom.toDouble(), + min: 0, + max: 200, + divisions: 20, + label: _autoViewMapPadding.bottom.toString(), + onChanged: (double value) { + _setAutoViewPadding(EdgeInsets.only( + top: _autoViewMapPadding.top, + left: _autoViewMapPadding.left, + bottom: value, + right: _autoViewMapPadding.right)); + }), ]), ), IgnorePointer( diff --git a/example/lib/pages/widget_initialization.dart b/example/lib/pages/widget_initialization.dart index 42ed0c3..9456390 100644 --- a/example/lib/pages/widget_initialization.dart +++ b/example/lib/pages/widget_initialization.dart @@ -49,6 +49,7 @@ class _ViewInitializationPageState double? _initialMaxZoomPreference; bool _initialZoomControlsEnabled = true; LatLngBounds? _initialCameraTargetBounds; + EdgeInsets? _initialPadding; NavigationUIEnabledPreference _initialNavigationUIEnabledPreference = NavigationUIEnabledPreference.automatic; TextDirection? _layoutDirection; @@ -107,6 +108,7 @@ class _ViewInitializationPageState initialMaxZoomPreference: _initialMaxZoomPreference, initialZoomControlsEnabled: _initialZoomControlsEnabled, initialCameraTargetBounds: _initialCameraTargetBounds, + initialPadding: _initialPadding, initialNavigationUIEnabledPreference: _initialNavigationUIEnabledPreference, layoutDirection: _layoutDirection, @@ -404,6 +406,7 @@ class _InitializedViewPage extends StatelessWidget { required this.initialMaxZoomPreference, required this.initialZoomControlsEnabled, required this.initialCameraTargetBounds, + required this.initialPadding, required this.initialNavigationUIEnabledPreference, required this.layoutDirection, }); @@ -422,6 +425,7 @@ class _InitializedViewPage extends StatelessWidget { final double? initialMaxZoomPreference; final bool initialZoomControlsEnabled; final LatLngBounds? initialCameraTargetBounds; + final EdgeInsets? initialPadding; final NavigationUIEnabledPreference initialNavigationUIEnabledPreference; @override @@ -453,6 +457,7 @@ class _InitializedViewPage extends StatelessWidget { initialMaxZoomPreference: initialMaxZoomPreference, initialZoomControlsEnabled: initialZoomControlsEnabled, initialCameraTargetBounds: initialCameraTargetBounds, + initialPadding: initialPadding, initialNavigationUIEnabledPreference: initialNavigationUIEnabledPreference, ), diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert+MapConfiguration.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert+MapConfiguration.swift index c2659b7..4d1c256 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert+MapConfiguration.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert+MapConfiguration.swift @@ -48,7 +48,13 @@ extension Convert { scrollGesturesEnabledDuringRotateOrZoom: mapOptions.scrollGesturesEnabledDuringRotateOrZoom, cameraTargetBounds: cameraTargetBounds, minZoomPreference: mapOptions.minZoomPreference.map { Float($0) }, - maxZoomPreference: mapOptions.maxZoomPreference.map { Float($0) } + maxZoomPreference: mapOptions.maxZoomPreference.map { Float($0) }, + padding: UIEdgeInsets( + top: CGFloat(mapOptions.padding?.top ?? 0), + left: CGFloat(mapOptions.padding?.left ?? 0), + bottom: CGFloat(mapOptions.padding?.bottom ?? 0), + right: CGFloat(mapOptions.padding?.right ?? 0) + ) ) } } diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsAutoViewMessageHandler.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsAutoViewMessageHandler.swift index 6048a58..576061d 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsAutoViewMessageHandler.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsAutoViewMessageHandler.swift @@ -441,4 +441,12 @@ class GoogleMapsAutoViewMessageHandler: AutoMapViewApi { func isAutoScreenAvailable() throws -> Bool { viewRegistry.getCarPlayView() != nil } + + func setPadding(padding: MapPaddingDto) throws { + try getView().setPadding(padding: padding) + } + + func getPadding() throws -> MapPaddingDto { + try getView().getPadding() + } } diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift index 6c0afa9..6ae60a1 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift @@ -825,6 +825,24 @@ public class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettle // boolean to control if camera changes are sent over the event channel. _listenCameraChanges = true } + + func setPadding(padding: MapPaddingDto) throws { + _mapView.padding = UIEdgeInsets( + top: CGFloat(padding.top), + left: CGFloat(padding.left), + bottom: CGFloat(padding.bottom), + right: CGFloat(padding.right) + ) + } + + func getPadding() throws -> MapPaddingDto { + MapPaddingDto( + top: Int64(_mapView.padding.top), + left: Int64(_mapView.padding.left), + bottom: Int64(_mapView.padding.bottom), + right: Int64(_mapView.padding.right) + ) + } } extension GoogleMapsNavigationView: GMSMapViewNavigationUIDelegate { diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewMessageHandler.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewMessageHandler.swift index 85b95e8..ac5e7ab 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewMessageHandler.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewMessageHandler.swift @@ -505,4 +505,12 @@ class GoogleMapsNavigationViewMessageHandler: MapViewApi { func registerOnCameraChangedListener(viewId: Int64) throws { try getView(viewId).registerOnCameraChangedListener() } + + func setPadding(viewId: Int64, padding: MapPaddingDto) throws { + try getView(viewId).setPadding(padding: padding) + } + + func getPadding(viewId: Int64) throws -> MapPaddingDto { + try getView(viewId).getPadding() + } } diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/MapConfiguration.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/MapConfiguration.swift index 2e9fa2b..80aa055 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/MapConfiguration.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/MapConfiguration.swift @@ -37,6 +37,7 @@ struct MapConfiguration { var cameraTargetBounds: GMSCoordinateBounds? var minZoomPreference: Float? var maxZoomPreference: Float? + var padding: UIEdgeInsets? } extension MapConfiguration { @@ -57,6 +58,9 @@ extension MapConfiguration { minZoomPreference ?? kGMSMinZoomLevel, maxZoom: maxZoomPreference ?? kGMSMaxZoomLevel ) + if let padding { + mapView.padding = padding + } } // Applies the configuration to the given diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/messages.g.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/messages.g.swift index b6071ea..0a7ccf1 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/messages.g.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/messages.g.swift @@ -403,6 +403,8 @@ struct MapOptionsDto { /// Specifies a bounds to constrain the camera target, so that when users scroll and pan the map, /// the camera target does not move outside these bounds. var cameraTargetBounds: LatLngBoundsDto? + /// Specifies the padding for the map. + var padding: MapPaddingDto? static func fromList(_ list: [Any?]) -> MapOptionsDto? { let cameraPosition = CameraPositionDto.fromList(list[0] as! [Any?])! @@ -421,6 +423,10 @@ struct MapOptionsDto { if let cameraTargetBoundsList: [Any?] = nilOrValue(list[12]) { cameraTargetBounds = LatLngBoundsDto.fromList(cameraTargetBoundsList) } + var padding: MapPaddingDto? + if let paddingList: [Any?] = nilOrValue(list[13]) { + padding = MapPaddingDto.fromList(paddingList) + } return MapOptionsDto( cameraPosition: cameraPosition, @@ -435,7 +441,8 @@ struct MapOptionsDto { minZoomPreference: minZoomPreference, maxZoomPreference: maxZoomPreference, zoomControlsEnabled: zoomControlsEnabled, - cameraTargetBounds: cameraTargetBounds + cameraTargetBounds: cameraTargetBounds, + padding: padding ) } @@ -454,6 +461,7 @@ struct MapOptionsDto { maxZoomPreference, zoomControlsEnabled, cameraTargetBounds?.toList(), + padding?.toList(), ] } } @@ -1039,6 +1047,37 @@ struct CircleOptionsDto { } } +/// Generated class from Pigeon that represents data sent in messages. +struct MapPaddingDto { + var top: Int64 + var left: Int64 + var bottom: Int64 + var right: Int64 + + static func fromList(_ list: [Any?]) -> MapPaddingDto? { + let top = list[0] is Int64 ? list[0] as! Int64 : Int64(list[0] as! Int32) + let left = list[1] is Int64 ? list[1] as! Int64 : Int64(list[1] as! Int32) + let bottom = list[2] is Int64 ? list[2] as! Int64 : Int64(list[2] as! Int32) + let right = list[3] is Int64 ? list[3] as! Int64 : Int64(list[3] as! Int32) + + return MapPaddingDto( + top: top, + left: left, + bottom: bottom, + right: right + ) + } + + func toList() -> [Any?] { + [ + top, + left, + bottom, + right, + ] + } +} + /// Generated class from Pigeon that represents data sent in messages. struct RouteTokenOptionsDto { var routeToken: String @@ -1708,8 +1747,10 @@ private class NavigationViewCreationApiCodecReader: FlutterStandardReader { case 131: return MapOptionsDto.fromList(readValue() as! [Any?]) case 132: - return NavigationViewOptionsDto.fromList(readValue() as! [Any?]) + return MapPaddingDto.fromList(readValue() as! [Any?]) case 133: + return NavigationViewOptionsDto.fromList(readValue() as! [Any?]) + case 134: return ViewCreationOptionsDto.fromList(readValue() as! [Any?]) default: return super.readValue(ofType: type) @@ -1731,12 +1772,15 @@ private class NavigationViewCreationApiCodecWriter: FlutterStandardWriter { } else if let value = value as? MapOptionsDto { super.writeByte(131) super.writeValue(value.toList()) - } else if let value = value as? NavigationViewOptionsDto { + } else if let value = value as? MapPaddingDto { super.writeByte(132) super.writeValue(value.toList()) - } else if let value = value as? ViewCreationOptionsDto { + } else if let value = value as? NavigationViewOptionsDto { super.writeByte(133) super.writeValue(value.toList()) + } else if let value = value as? ViewCreationOptionsDto { + super.writeByte(134) + super.writeValue(value.toList()) } else { super.writeValue(value) } @@ -1770,7 +1814,7 @@ protocol NavigationViewCreationApi { } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. -class NavigationViewCreationApiSetup { +enum NavigationViewCreationApiSetup { /// The codec used by NavigationViewCreationApi. static var codec: FlutterStandardMessageCodec { NavigationViewCreationApiCodec.shared } /// Sets up an instance of `NavigationViewCreationApi` to handle messages through the @@ -1818,26 +1862,28 @@ private class MapViewApiCodecReader: FlutterStandardReader { case 135: return LatLngDto.fromList(readValue() as! [Any?]) case 136: - return MarkerAnchorDto.fromList(readValue() as! [Any?]) + return MapPaddingDto.fromList(readValue() as! [Any?]) case 137: - return MarkerDto.fromList(readValue() as! [Any?]) + return MarkerAnchorDto.fromList(readValue() as! [Any?]) case 138: - return MarkerOptionsDto.fromList(readValue() as! [Any?]) + return MarkerDto.fromList(readValue() as! [Any?]) case 139: - return PatternItemDto.fromList(readValue() as! [Any?]) + return MarkerOptionsDto.fromList(readValue() as! [Any?]) case 140: - return PolygonDto.fromList(readValue() as! [Any?]) + return PatternItemDto.fromList(readValue() as! [Any?]) case 141: - return PolygonHoleDto.fromList(readValue() as! [Any?]) + return PolygonDto.fromList(readValue() as! [Any?]) case 142: - return PolygonOptionsDto.fromList(readValue() as! [Any?]) + return PolygonHoleDto.fromList(readValue() as! [Any?]) case 143: - return PolylineDto.fromList(readValue() as! [Any?]) + return PolygonOptionsDto.fromList(readValue() as! [Any?]) case 144: - return PolylineOptionsDto.fromList(readValue() as! [Any?]) + return PolylineDto.fromList(readValue() as! [Any?]) case 145: - return StyleSpanDto.fromList(readValue() as! [Any?]) + return PolylineOptionsDto.fromList(readValue() as! [Any?]) case 146: + return StyleSpanDto.fromList(readValue() as! [Any?]) + case 147: return StyleSpanStrokeStyleDto.fromList(readValue() as! [Any?]) default: return super.readValue(ofType: type) @@ -1871,39 +1917,42 @@ private class MapViewApiCodecWriter: FlutterStandardWriter { } else if let value = value as? LatLngDto { super.writeByte(135) super.writeValue(value.toList()) - } else if let value = value as? MarkerAnchorDto { + } else if let value = value as? MapPaddingDto { super.writeByte(136) super.writeValue(value.toList()) - } else if let value = value as? MarkerDto { + } else if let value = value as? MarkerAnchorDto { super.writeByte(137) super.writeValue(value.toList()) - } else if let value = value as? MarkerOptionsDto { + } else if let value = value as? MarkerDto { super.writeByte(138) super.writeValue(value.toList()) - } else if let value = value as? PatternItemDto { + } else if let value = value as? MarkerOptionsDto { super.writeByte(139) super.writeValue(value.toList()) - } else if let value = value as? PolygonDto { + } else if let value = value as? PatternItemDto { super.writeByte(140) super.writeValue(value.toList()) - } else if let value = value as? PolygonHoleDto { + } else if let value = value as? PolygonDto { super.writeByte(141) super.writeValue(value.toList()) - } else if let value = value as? PolygonOptionsDto { + } else if let value = value as? PolygonHoleDto { super.writeByte(142) super.writeValue(value.toList()) - } else if let value = value as? PolylineDto { + } else if let value = value as? PolygonOptionsDto { super.writeByte(143) super.writeValue(value.toList()) - } else if let value = value as? PolylineOptionsDto { + } else if let value = value as? PolylineDto { super.writeByte(144) super.writeValue(value.toList()) - } else if let value = value as? StyleSpanDto { + } else if let value = value as? PolylineOptionsDto { super.writeByte(145) super.writeValue(value.toList()) - } else if let value = value as? StyleSpanStrokeStyleDto { + } else if let value = value as? StyleSpanDto { super.writeByte(146) super.writeValue(value.toList()) + } else if let value = value as? StyleSpanStrokeStyleDto { + super.writeByte(147) + super.writeValue(value.toList()) } else { super.writeValue(value) } @@ -2025,10 +2074,12 @@ protocol MapViewApi { func removeCircles(viewId: Int64, circles: [CircleDto]) throws func clearCircles(viewId: Int64) throws func registerOnCameraChangedListener(viewId: Int64) throws + func setPadding(viewId: Int64, padding: MapPaddingDto) throws + func getPadding(viewId: Int64) throws -> MapPaddingDto } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. -class MapViewApiSetup { +enum MapViewApiSetup { /// The codec used by MapViewApi. static var codec: FlutterStandardMessageCodec { MapViewApiCodec.shared } /// Sets up an instance of `MapViewApi` to handle messages through the `binaryMessenger`. @@ -3882,6 +3933,45 @@ class MapViewApiSetup { } else { registerOnCameraChangedListenerChannel.setMessageHandler(nil) } + let setPaddingChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setPadding", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { + setPaddingChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let viewIdArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) + let paddingArg = args[1] as! MapPaddingDto + do { + try api.setPadding(viewId: viewIdArg, padding: paddingArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + setPaddingChannel.setMessageHandler(nil) + } + let getPaddingChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getPadding", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { + getPaddingChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let viewIdArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) + do { + let result = try api.getPadding(viewId: viewIdArg) + reply(wrapResult(result)) + } catch { + reply(wrapError(error)) + } + } + } else { + getPaddingChannel.setMessageHandler(nil) + } } } @@ -3937,7 +4027,7 @@ protocol ImageRegistryApi { } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. -class ImageRegistryApiSetup { +enum ImageRegistryApiSetup { /// The codec used by ImageRegistryApi. static var codec: FlutterStandardMessageCodec { ImageRegistryApiCodec.shared } /// Sets up an instance of `ImageRegistryApi` to handle messages through the `binaryMessenger`. @@ -4588,7 +4678,7 @@ protocol NavigationSessionApi { } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. -class NavigationSessionApiSetup { +enum NavigationSessionApiSetup { /// The codec used by NavigationSessionApi. static var codec: FlutterStandardMessageCodec { NavigationSessionApiCodec.shared } /// Sets up an instance of `NavigationSessionApi` to handle messages through the @@ -5629,26 +5719,28 @@ private class AutoMapViewApiCodecReader: FlutterStandardReader { case 135: return LatLngDto.fromList(readValue() as! [Any?]) case 136: - return MarkerAnchorDto.fromList(readValue() as! [Any?]) + return MapPaddingDto.fromList(readValue() as! [Any?]) case 137: - return MarkerDto.fromList(readValue() as! [Any?]) + return MarkerAnchorDto.fromList(readValue() as! [Any?]) case 138: - return MarkerOptionsDto.fromList(readValue() as! [Any?]) + return MarkerDto.fromList(readValue() as! [Any?]) case 139: - return PatternItemDto.fromList(readValue() as! [Any?]) + return MarkerOptionsDto.fromList(readValue() as! [Any?]) case 140: - return PolygonDto.fromList(readValue() as! [Any?]) + return PatternItemDto.fromList(readValue() as! [Any?]) case 141: - return PolygonHoleDto.fromList(readValue() as! [Any?]) + return PolygonDto.fromList(readValue() as! [Any?]) case 142: - return PolygonOptionsDto.fromList(readValue() as! [Any?]) + return PolygonHoleDto.fromList(readValue() as! [Any?]) case 143: - return PolylineDto.fromList(readValue() as! [Any?]) + return PolygonOptionsDto.fromList(readValue() as! [Any?]) case 144: - return PolylineOptionsDto.fromList(readValue() as! [Any?]) + return PolylineDto.fromList(readValue() as! [Any?]) case 145: - return StyleSpanDto.fromList(readValue() as! [Any?]) + return PolylineOptionsDto.fromList(readValue() as! [Any?]) case 146: + return StyleSpanDto.fromList(readValue() as! [Any?]) + case 147: return StyleSpanStrokeStyleDto.fromList(readValue() as! [Any?]) default: return super.readValue(ofType: type) @@ -5682,39 +5774,42 @@ private class AutoMapViewApiCodecWriter: FlutterStandardWriter { } else if let value = value as? LatLngDto { super.writeByte(135) super.writeValue(value.toList()) - } else if let value = value as? MarkerAnchorDto { + } else if let value = value as? MapPaddingDto { super.writeByte(136) super.writeValue(value.toList()) - } else if let value = value as? MarkerDto { + } else if let value = value as? MarkerAnchorDto { super.writeByte(137) super.writeValue(value.toList()) - } else if let value = value as? MarkerOptionsDto { + } else if let value = value as? MarkerDto { super.writeByte(138) super.writeValue(value.toList()) - } else if let value = value as? PatternItemDto { + } else if let value = value as? MarkerOptionsDto { super.writeByte(139) super.writeValue(value.toList()) - } else if let value = value as? PolygonDto { + } else if let value = value as? PatternItemDto { super.writeByte(140) super.writeValue(value.toList()) - } else if let value = value as? PolygonHoleDto { + } else if let value = value as? PolygonDto { super.writeByte(141) super.writeValue(value.toList()) - } else if let value = value as? PolygonOptionsDto { + } else if let value = value as? PolygonHoleDto { super.writeByte(142) super.writeValue(value.toList()) - } else if let value = value as? PolylineDto { + } else if let value = value as? PolygonOptionsDto { super.writeByte(143) super.writeValue(value.toList()) - } else if let value = value as? PolylineOptionsDto { + } else if let value = value as? PolylineDto { super.writeByte(144) super.writeValue(value.toList()) - } else if let value = value as? StyleSpanDto { + } else if let value = value as? PolylineOptionsDto { super.writeByte(145) super.writeValue(value.toList()) - } else if let value = value as? StyleSpanStrokeStyleDto { + } else if let value = value as? StyleSpanDto { super.writeByte(146) super.writeValue(value.toList()) + } else if let value = value as? StyleSpanStrokeStyleDto { + super.writeByte(147) + super.writeValue(value.toList()) } else { super.writeValue(value) } @@ -5817,10 +5912,12 @@ protocol AutoMapViewApi { func clearCircles() throws func registerOnCameraChangedListener() throws func isAutoScreenAvailable() throws -> Bool + func setPadding(padding: MapPaddingDto) throws + func getPadding() throws -> MapPaddingDto } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. -class AutoMapViewApiSetup { +enum AutoMapViewApiSetup { /// The codec used by AutoMapViewApi. static var codec: FlutterStandardMessageCodec { AutoMapViewApiCodec.shared } /// Sets up an instance of `AutoMapViewApi` to handle messages through the `binaryMessenger`. @@ -7208,6 +7305,42 @@ class AutoMapViewApiSetup { } else { isAutoScreenAvailableChannel.setMessageHandler(nil) } + let setPaddingChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.setPadding", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { + setPaddingChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let paddingArg = args[0] as! MapPaddingDto + do { + try api.setPadding(padding: paddingArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + setPaddingChannel.setMessageHandler(nil) + } + let getPaddingChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.getPadding", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { + getPaddingChannel.setMessageHandler { _, reply in + do { + let result = try api.getPadding() + reply(wrapResult(result)) + } catch { + reply(wrapError(error)) + } + } + } else { + getPaddingChannel.setMessageHandler(nil) + } } } @@ -7237,58 +7370,60 @@ private class AutoViewEventApiCodecReader: FlutterStandardReader { case 138: return MapOptionsDto.fromList(readValue() as! [Any?]) case 139: - return MarkerAnchorDto.fromList(readValue() as! [Any?]) + return MapPaddingDto.fromList(readValue() as! [Any?]) case 140: - return MarkerDto.fromList(readValue() as! [Any?]) + return MarkerAnchorDto.fromList(readValue() as! [Any?]) case 141: - return MarkerOptionsDto.fromList(readValue() as! [Any?]) + return MarkerDto.fromList(readValue() as! [Any?]) case 142: - return NavInfoDto.fromList(readValue() as! [Any?]) + return MarkerOptionsDto.fromList(readValue() as! [Any?]) case 143: - return NavigationAudioGuidanceSettingsDto.fromList(readValue() as! [Any?]) + return NavInfoDto.fromList(readValue() as! [Any?]) case 144: - return NavigationDisplayOptionsDto.fromList(readValue() as! [Any?]) + return NavigationAudioGuidanceSettingsDto.fromList(readValue() as! [Any?]) case 145: - return NavigationTimeAndDistanceDto.fromList(readValue() as! [Any?]) + return NavigationDisplayOptionsDto.fromList(readValue() as! [Any?]) case 146: - return NavigationViewOptionsDto.fromList(readValue() as! [Any?]) + return NavigationTimeAndDistanceDto.fromList(readValue() as! [Any?]) case 147: - return NavigationWaypointDto.fromList(readValue() as! [Any?]) + return NavigationViewOptionsDto.fromList(readValue() as! [Any?]) case 148: - return PatternItemDto.fromList(readValue() as! [Any?]) + return NavigationWaypointDto.fromList(readValue() as! [Any?]) case 149: - return PolygonDto.fromList(readValue() as! [Any?]) + return PatternItemDto.fromList(readValue() as! [Any?]) case 150: - return PolygonHoleDto.fromList(readValue() as! [Any?]) + return PolygonDto.fromList(readValue() as! [Any?]) case 151: - return PolygonOptionsDto.fromList(readValue() as! [Any?]) + return PolygonHoleDto.fromList(readValue() as! [Any?]) case 152: - return PolylineDto.fromList(readValue() as! [Any?]) + return PolygonOptionsDto.fromList(readValue() as! [Any?]) case 153: - return PolylineOptionsDto.fromList(readValue() as! [Any?]) + return PolylineDto.fromList(readValue() as! [Any?]) case 154: - return RouteSegmentDto.fromList(readValue() as! [Any?]) + return PolylineOptionsDto.fromList(readValue() as! [Any?]) case 155: - return RouteSegmentTrafficDataDto.fromList(readValue() as! [Any?]) + return RouteSegmentDto.fromList(readValue() as! [Any?]) case 156: - return RouteSegmentTrafficDataRoadStretchRenderingDataDto.fromList(readValue() as! [Any?]) + return RouteSegmentTrafficDataDto.fromList(readValue() as! [Any?]) case 157: - return RouteTokenOptionsDto.fromList(readValue() as! [Any?]) + return RouteSegmentTrafficDataRoadStretchRenderingDataDto.fromList(readValue() as! [Any?]) case 158: - return RoutingOptionsDto.fromList(readValue() as! [Any?]) + return RouteTokenOptionsDto.fromList(readValue() as! [Any?]) case 159: - return SimulationOptionsDto.fromList(readValue() as! [Any?]) + return RoutingOptionsDto.fromList(readValue() as! [Any?]) case 160: - return SpeedAlertOptionsDto.fromList(readValue() as! [Any?]) + return SimulationOptionsDto.fromList(readValue() as! [Any?]) case 161: - return SpeedingUpdatedEventDto.fromList(readValue() as! [Any?]) + return SpeedAlertOptionsDto.fromList(readValue() as! [Any?]) case 162: - return StepInfoDto.fromList(readValue() as! [Any?]) + return SpeedingUpdatedEventDto.fromList(readValue() as! [Any?]) case 163: - return StyleSpanDto.fromList(readValue() as! [Any?]) + return StepInfoDto.fromList(readValue() as! [Any?]) case 164: - return StyleSpanStrokeStyleDto.fromList(readValue() as! [Any?]) + return StyleSpanDto.fromList(readValue() as! [Any?]) case 165: + return StyleSpanStrokeStyleDto.fromList(readValue() as! [Any?]) + case 166: return ViewCreationOptionsDto.fromList(readValue() as! [Any?]) default: return super.readValue(ofType: type) @@ -7331,87 +7466,90 @@ private class AutoViewEventApiCodecWriter: FlutterStandardWriter { } else if let value = value as? MapOptionsDto { super.writeByte(138) super.writeValue(value.toList()) - } else if let value = value as? MarkerAnchorDto { + } else if let value = value as? MapPaddingDto { super.writeByte(139) super.writeValue(value.toList()) - } else if let value = value as? MarkerDto { + } else if let value = value as? MarkerAnchorDto { super.writeByte(140) super.writeValue(value.toList()) - } else if let value = value as? MarkerOptionsDto { + } else if let value = value as? MarkerDto { super.writeByte(141) super.writeValue(value.toList()) - } else if let value = value as? NavInfoDto { + } else if let value = value as? MarkerOptionsDto { super.writeByte(142) super.writeValue(value.toList()) - } else if let value = value as? NavigationAudioGuidanceSettingsDto { + } else if let value = value as? NavInfoDto { super.writeByte(143) super.writeValue(value.toList()) - } else if let value = value as? NavigationDisplayOptionsDto { + } else if let value = value as? NavigationAudioGuidanceSettingsDto { super.writeByte(144) super.writeValue(value.toList()) - } else if let value = value as? NavigationTimeAndDistanceDto { + } else if let value = value as? NavigationDisplayOptionsDto { super.writeByte(145) super.writeValue(value.toList()) - } else if let value = value as? NavigationViewOptionsDto { + } else if let value = value as? NavigationTimeAndDistanceDto { super.writeByte(146) super.writeValue(value.toList()) - } else if let value = value as? NavigationWaypointDto { + } else if let value = value as? NavigationViewOptionsDto { super.writeByte(147) super.writeValue(value.toList()) - } else if let value = value as? PatternItemDto { + } else if let value = value as? NavigationWaypointDto { super.writeByte(148) super.writeValue(value.toList()) - } else if let value = value as? PolygonDto { + } else if let value = value as? PatternItemDto { super.writeByte(149) super.writeValue(value.toList()) - } else if let value = value as? PolygonHoleDto { + } else if let value = value as? PolygonDto { super.writeByte(150) super.writeValue(value.toList()) - } else if let value = value as? PolygonOptionsDto { + } else if let value = value as? PolygonHoleDto { super.writeByte(151) super.writeValue(value.toList()) - } else if let value = value as? PolylineDto { + } else if let value = value as? PolygonOptionsDto { super.writeByte(152) super.writeValue(value.toList()) - } else if let value = value as? PolylineOptionsDto { + } else if let value = value as? PolylineDto { super.writeByte(153) super.writeValue(value.toList()) - } else if let value = value as? RouteSegmentDto { + } else if let value = value as? PolylineOptionsDto { super.writeByte(154) super.writeValue(value.toList()) - } else if let value = value as? RouteSegmentTrafficDataDto { + } else if let value = value as? RouteSegmentDto { super.writeByte(155) super.writeValue(value.toList()) - } else if let value = value as? RouteSegmentTrafficDataRoadStretchRenderingDataDto { + } else if let value = value as? RouteSegmentTrafficDataDto { super.writeByte(156) super.writeValue(value.toList()) - } else if let value = value as? RouteTokenOptionsDto { + } else if let value = value as? RouteSegmentTrafficDataRoadStretchRenderingDataDto { super.writeByte(157) super.writeValue(value.toList()) - } else if let value = value as? RoutingOptionsDto { + } else if let value = value as? RouteTokenOptionsDto { super.writeByte(158) super.writeValue(value.toList()) - } else if let value = value as? SimulationOptionsDto { + } else if let value = value as? RoutingOptionsDto { super.writeByte(159) super.writeValue(value.toList()) - } else if let value = value as? SpeedAlertOptionsDto { + } else if let value = value as? SimulationOptionsDto { super.writeByte(160) super.writeValue(value.toList()) - } else if let value = value as? SpeedingUpdatedEventDto { + } else if let value = value as? SpeedAlertOptionsDto { super.writeByte(161) super.writeValue(value.toList()) - } else if let value = value as? StepInfoDto { + } else if let value = value as? SpeedingUpdatedEventDto { super.writeByte(162) super.writeValue(value.toList()) - } else if let value = value as? StyleSpanDto { + } else if let value = value as? StepInfoDto { super.writeByte(163) super.writeValue(value.toList()) - } else if let value = value as? StyleSpanStrokeStyleDto { + } else if let value = value as? StyleSpanDto { super.writeByte(164) super.writeValue(value.toList()) - } else if let value = value as? ViewCreationOptionsDto { + } else if let value = value as? StyleSpanStrokeStyleDto { super.writeByte(165) super.writeValue(value.toList()) + } else if let value = value as? ViewCreationOptionsDto { + super.writeByte(166) + super.writeValue(value.toList()) } else { super.writeValue(value) } @@ -7507,7 +7645,7 @@ protocol NavigationInspector { } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. -class NavigationInspectorSetup { +enum NavigationInspectorSetup { /// The codec used by NavigationInspector. /// Sets up an instance of `NavigationInspector` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: NavigationInspector?) { diff --git a/lib/src/google_maps_auto_view_controller.dart b/lib/src/google_maps_auto_view_controller.dart index ae332e7..0ddd05d 100644 --- a/lib/src/google_maps_auto_view_controller.dart +++ b/lib/src/google_maps_auto_view_controller.dart @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import 'package:flutter/widgets.dart'; + import '../google_navigation_flutter.dart'; import 'google_navigation_flutter_platform_interface.dart'; @@ -325,6 +327,17 @@ class GoogleMapsAutoViewController { return GoogleMapsNavigationPlatform.instance.clearForAuto(); } + /// Set padding for the map view. + Future setPadding(EdgeInsets padding) { + return GoogleMapsNavigationPlatform.instance + .setPaddingForAuto(padding: padding); + } + + // Gets the map padding from the map view. + Future getPadding() async { + return GoogleMapsNavigationPlatform.instance.getPaddingForAuto(); + } + Future isAutoScreenAvailable() { return GoogleMapsNavigationPlatform.instance.isAutoScreenAvailable(); } diff --git a/lib/src/google_maps_map_view.dart b/lib/src/google_maps_map_view.dart index c29a809..61d2ca0 100644 --- a/lib/src/google_maps_map_view.dart +++ b/lib/src/google_maps_map_view.dart @@ -44,6 +44,7 @@ abstract class GoogleMapsBaseMapView extends StatefulWidget { this.initialMaxZoomPreference, this.initialZoomControlsEnabled = true, this.initialCameraTargetBounds, + this.initialPadding, this.layoutDirection, this.gestureRecognizers = const >{}, this.onRecenterButtonClicked, @@ -147,6 +148,11 @@ abstract class GoogleMapsBaseMapView extends StatefulWidget { /// Null by default (unbounded). final LatLngBounds? initialCameraTargetBounds; + /// Specifies the initial padding for the map view. + /// + /// Null by default (no padding). + final EdgeInsets? initialPadding; + /// Which gestures should be forwarded to the PlatformView. /// /// When this set is empty, the map will only handle pointer events for gestures that @@ -252,6 +258,7 @@ class GoogleMapsMapView extends GoogleMapsBaseMapView { super.initialMaxZoomPreference, super.initialZoomControlsEnabled = true, super.initialCameraTargetBounds, + super.initialPadding, super.layoutDirection, super.gestureRecognizers = const >{}, @@ -377,6 +384,7 @@ class GoogleMapsMapViewState extends MapViewState { maxZoomPreference: widget.initialMaxZoomPreference, zoomControlsEnabled: widget.initialZoomControlsEnabled, cameraTargetBounds: widget.initialCameraTargetBounds, + padding: widget.initialPadding, ), ), onMapReady: _onPlatformViewCreated); diff --git a/lib/src/google_maps_map_view_controller.dart b/lib/src/google_maps_map_view_controller.dart index fa1604b..ce638a2 100644 --- a/lib/src/google_maps_map_view_controller.dart +++ b/lib/src/google_maps_map_view_controller.dart @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import 'package:flutter/widgets.dart'; + import '../google_navigation_flutter.dart'; import 'google_navigation_flutter_platform_interface.dart'; @@ -363,4 +365,15 @@ class GoogleMapViewController { Future clear() { return GoogleMapsNavigationPlatform.instance.clear(viewId: _viewId); } + + /// Set padding for the map view. + Future setPadding(EdgeInsets padding) { + return GoogleMapsNavigationPlatform.instance + .setPadding(viewId: _viewId, padding: padding); + } + + // Gets the map padding from the map view. + Future getPadding() async { + return GoogleMapsNavigationPlatform.instance.getPadding(viewId: _viewId); + } } diff --git a/lib/src/google_maps_navigation_view.dart b/lib/src/google_maps_navigation_view.dart index f68ac66..9624e59 100644 --- a/lib/src/google_maps_navigation_view.dart +++ b/lib/src/google_maps_navigation_view.dart @@ -60,6 +60,7 @@ class GoogleMapsNavigationView extends GoogleMapsBaseMapView { super.initialMaxZoomPreference, super.initialZoomControlsEnabled = true, super.initialCameraTargetBounds, + super.initialPadding, this.initialNavigationUIEnabledPreference = NavigationUIEnabledPreference.automatic, super.layoutDirection, @@ -140,6 +141,7 @@ class GoogleMapsNavigationViewState maxZoomPreference: widget.initialMaxZoomPreference, zoomControlsEnabled: widget.initialZoomControlsEnabled, cameraTargetBounds: widget.initialCameraTargetBounds, + padding: widget.initialPadding, ), navigationViewOptions: NavigationViewOptions( navigationUIEnabledPreference: diff --git a/lib/src/google_navigation_flutter_platform_interface.dart b/lib/src/google_navigation_flutter_platform_interface.dart index 288f3f6..8d215b6 100644 --- a/lib/src/google_navigation_flutter_platform_interface.dart +++ b/lib/src/google_navigation_flutter_platform_interface.dart @@ -532,6 +532,12 @@ abstract mixin class MapViewAPIInterface { /// Register camera changed listeners. Future registerOnCameraChangedListener({required int viewId}); + // Sets the map padding for the map view. + Future setPadding({required int viewId, required EdgeInsets padding}); + + // Gets the map padding from the map view. + Future getPadding({required int viewId}); + /// Get navigation view marker event stream from the navigation view. Stream getMarkerEventStream({required int viewId}); @@ -769,6 +775,12 @@ abstract mixin class AutoMapViewAPIInterface { // Check whether auto screen is available; Future isAutoScreenAvailable(); + // Sets the map padding for the auto map view. + Future setPaddingForAuto({required EdgeInsets padding}); + + // Gets the map padding from the auto map view. + Future getPaddingForAuto(); + /// Get custom navigation auto event stream from the auto view. Stream getCustomNavigationAutoEventStream(); diff --git a/lib/src/method_channel/common_auto_view_api.dart b/lib/src/method_channel/common_auto_view_api.dart index 88d70b1..6acbe84 100644 --- a/lib/src/method_channel/common_auto_view_api.dart +++ b/lib/src/method_channel/common_auto_view_api.dart @@ -16,6 +16,7 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import '../../google_navigation_flutter.dart'; import '../google_navigation_flutter_platform_interface.dart'; @@ -735,6 +736,26 @@ mixin CommonAutoMapViewAPI on AutoMapViewAPIInterface { return _viewApi.registerOnCameraChangedListener(); } + @override + Future setPaddingForAuto({required EdgeInsets padding}) { + return _viewApi.setPadding(MapPaddingDto( + top: padding.top.toInt(), + left: padding.left.toInt(), + bottom: padding.bottom.toInt(), + right: padding.right.toInt())); + } + + // Gets the map padding from the map view. + @override + Future getPaddingForAuto() async { + final MapPaddingDto padding = await _viewApi.getPadding(); + return EdgeInsets.only( + top: padding.top.toDouble(), + left: padding.left.toDouble(), + bottom: padding.bottom.toDouble(), + right: padding.right.toDouble()); + } + @override Future isAutoScreenAvailable() { return _viewApi.isAutoScreenAvailable(); diff --git a/lib/src/method_channel/common_view_api.dart b/lib/src/method_channel/common_view_api.dart index 342dc46..8f16d62 100644 --- a/lib/src/method_channel/common_view_api.dart +++ b/lib/src/method_channel/common_view_api.dart @@ -16,6 +16,7 @@ import 'dart:async'; import 'dart:io'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import '../../google_navigation_flutter.dart'; import '../google_navigation_flutter_platform_interface.dart'; @@ -106,7 +107,14 @@ mixin CommonMapViewAPI on MapViewAPIInterface { minZoomPreference: mapOptions.minZoomPreference, maxZoomPreference: mapOptions.maxZoomPreference, zoomControlsEnabled: mapOptions.zoomControlsEnabled, - cameraTargetBounds: mapOptions.cameraTargetBounds?.toDto()); + cameraTargetBounds: mapOptions.cameraTargetBounds?.toDto(), + padding: mapOptions.padding != null + ? MapPaddingDto( + top: mapOptions.padding!.top.toInt(), + left: mapOptions.padding!.left.toInt(), + bottom: mapOptions.padding!.bottom.toInt(), + right: mapOptions.padding!.right.toInt()) + : null); // Initialize navigation view options if given NavigationViewOptionsDto? navigationOptionsMessage; @@ -935,6 +943,28 @@ mixin CommonMapViewAPI on MapViewAPIInterface { return _viewApi.registerOnCameraChangedListener(viewId); } + @override + Future setPadding({required int viewId, required EdgeInsets padding}) { + return _viewApi.setPadding( + viewId, + MapPaddingDto( + top: padding.top.toInt(), + left: padding.left.toInt(), + bottom: padding.bottom.toInt(), + right: padding.right.toInt())); + } + + // Gets the map padding from the map view. + @override + Future getPadding({required int viewId}) async { + final MapPaddingDto padding = await _viewApi.getPadding(viewId); + return EdgeInsets.only( + top: padding.top.toDouble(), + left: padding.left.toDouble(), + bottom: padding.bottom.toDouble(), + right: padding.right.toDouble()); + } + @override Stream getMapClickEventStream({required int viewId}) { return _unwrapEventStream(viewId: viewId); diff --git a/lib/src/method_channel/messages.g.dart b/lib/src/method_channel/messages.g.dart index 6c19dba..529abc5 100644 --- a/lib/src/method_channel/messages.g.dart +++ b/lib/src/method_channel/messages.g.dart @@ -446,6 +446,7 @@ class MapOptionsDto { this.maxZoomPreference, required this.zoomControlsEnabled, this.cameraTargetBounds, + this.padding, }); /// The initial positioning of the camera in the map view. @@ -488,6 +489,9 @@ class MapOptionsDto { /// the camera target does not move outside these bounds. LatLngBoundsDto? cameraTargetBounds; + /// Specifies the padding for the map. + MapPaddingDto? padding; + Object encode() { return [ cameraPosition.encode(), @@ -503,6 +507,7 @@ class MapOptionsDto { maxZoomPreference, zoomControlsEnabled, cameraTargetBounds?.encode(), + padding?.encode(), ]; } @@ -524,6 +529,9 @@ class MapOptionsDto { cameraTargetBounds: result[12] != null ? LatLngBoundsDto.decode(result[12]! as List) : null, + padding: result[13] != null + ? MapPaddingDto.decode(result[13]! as List) + : null, ); } } @@ -1191,6 +1199,42 @@ class CircleOptionsDto { } } +class MapPaddingDto { + MapPaddingDto({ + required this.top, + required this.left, + required this.bottom, + required this.right, + }); + + int top; + + int left; + + int bottom; + + int right; + + Object encode() { + return [ + top, + left, + bottom, + right, + ]; + } + + static MapPaddingDto decode(Object result) { + result as List; + return MapPaddingDto( + top: result[0]! as int, + left: result[1]! as int, + bottom: result[2]! as int, + right: result[3]! as int, + ); + } +} + class RouteTokenOptionsDto { RouteTokenOptionsDto({ required this.routeToken, @@ -1924,12 +1968,15 @@ class _NavigationViewCreationApiCodec extends StandardMessageCodec { } else if (value is MapOptionsDto) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is NavigationViewOptionsDto) { + } else if (value is MapPaddingDto) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is ViewCreationOptionsDto) { + } else if (value is NavigationViewOptionsDto) { buffer.putUint8(133); writeValue(buffer, value.encode()); + } else if (value is ViewCreationOptionsDto) { + buffer.putUint8(134); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -1947,8 +1994,10 @@ class _NavigationViewCreationApiCodec extends StandardMessageCodec { case 131: return MapOptionsDto.decode(readValue(buffer)!); case 132: - return NavigationViewOptionsDto.decode(readValue(buffer)!); + return MapPaddingDto.decode(readValue(buffer)!); case 133: + return NavigationViewOptionsDto.decode(readValue(buffer)!); + case 134: return ViewCreationOptionsDto.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -2025,39 +2074,42 @@ class _MapViewApiCodec extends StandardMessageCodec { } else if (value is LatLngDto) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is MarkerAnchorDto) { + } else if (value is MapPaddingDto) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is MarkerDto) { + } else if (value is MarkerAnchorDto) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is MarkerOptionsDto) { + } else if (value is MarkerDto) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is PatternItemDto) { + } else if (value is MarkerOptionsDto) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is PolygonDto) { + } else if (value is PatternItemDto) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is PolygonHoleDto) { + } else if (value is PolygonDto) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is PolygonOptionsDto) { + } else if (value is PolygonHoleDto) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is PolylineDto) { + } else if (value is PolygonOptionsDto) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is PolylineOptionsDto) { + } else if (value is PolylineDto) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is StyleSpanDto) { + } else if (value is PolylineOptionsDto) { buffer.putUint8(145); writeValue(buffer, value.encode()); - } else if (value is StyleSpanStrokeStyleDto) { + } else if (value is StyleSpanDto) { buffer.putUint8(146); writeValue(buffer, value.encode()); + } else if (value is StyleSpanStrokeStyleDto) { + buffer.putUint8(147); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -2083,26 +2135,28 @@ class _MapViewApiCodec extends StandardMessageCodec { case 135: return LatLngDto.decode(readValue(buffer)!); case 136: - return MarkerAnchorDto.decode(readValue(buffer)!); + return MapPaddingDto.decode(readValue(buffer)!); case 137: - return MarkerDto.decode(readValue(buffer)!); + return MarkerAnchorDto.decode(readValue(buffer)!); case 138: - return MarkerOptionsDto.decode(readValue(buffer)!); + return MarkerDto.decode(readValue(buffer)!); case 139: - return PatternItemDto.decode(readValue(buffer)!); + return MarkerOptionsDto.decode(readValue(buffer)!); case 140: - return PolygonDto.decode(readValue(buffer)!); + return PatternItemDto.decode(readValue(buffer)!); case 141: - return PolygonHoleDto.decode(readValue(buffer)!); + return PolygonDto.decode(readValue(buffer)!); case 142: - return PolygonOptionsDto.decode(readValue(buffer)!); + return PolygonHoleDto.decode(readValue(buffer)!); case 143: - return PolylineDto.decode(readValue(buffer)!); + return PolygonOptionsDto.decode(readValue(buffer)!); case 144: - return PolylineOptionsDto.decode(readValue(buffer)!); + return PolylineDto.decode(readValue(buffer)!); case 145: - return StyleSpanDto.decode(readValue(buffer)!); + return PolylineOptionsDto.decode(readValue(buffer)!); case 146: + return StyleSpanDto.decode(readValue(buffer)!); + case 147: return StyleSpanStrokeStyleDto.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -4528,6 +4582,59 @@ class MapViewApi { return; } } + + Future setPadding(int viewId, MapPaddingDto padding) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setPadding'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = await __pigeon_channel + .send([viewId, padding]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + Future getPadding(int viewId) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getPadding'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([viewId]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as MapPaddingDto?)!; + } + } } class _ImageRegistryApiCodec extends StandardMessageCodec { @@ -6532,39 +6639,42 @@ class _AutoMapViewApiCodec extends StandardMessageCodec { } else if (value is LatLngDto) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is MarkerAnchorDto) { + } else if (value is MapPaddingDto) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is MarkerDto) { + } else if (value is MarkerAnchorDto) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is MarkerOptionsDto) { + } else if (value is MarkerDto) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is PatternItemDto) { + } else if (value is MarkerOptionsDto) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is PolygonDto) { + } else if (value is PatternItemDto) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is PolygonHoleDto) { + } else if (value is PolygonDto) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is PolygonOptionsDto) { + } else if (value is PolygonHoleDto) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is PolylineDto) { + } else if (value is PolygonOptionsDto) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is PolylineOptionsDto) { + } else if (value is PolylineDto) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is StyleSpanDto) { + } else if (value is PolylineOptionsDto) { buffer.putUint8(145); writeValue(buffer, value.encode()); - } else if (value is StyleSpanStrokeStyleDto) { + } else if (value is StyleSpanDto) { buffer.putUint8(146); writeValue(buffer, value.encode()); + } else if (value is StyleSpanStrokeStyleDto) { + buffer.putUint8(147); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -6590,26 +6700,28 @@ class _AutoMapViewApiCodec extends StandardMessageCodec { case 135: return LatLngDto.decode(readValue(buffer)!); case 136: - return MarkerAnchorDto.decode(readValue(buffer)!); + return MapPaddingDto.decode(readValue(buffer)!); case 137: - return MarkerDto.decode(readValue(buffer)!); + return MarkerAnchorDto.decode(readValue(buffer)!); case 138: - return MarkerOptionsDto.decode(readValue(buffer)!); + return MarkerDto.decode(readValue(buffer)!); case 139: - return PatternItemDto.decode(readValue(buffer)!); + return MarkerOptionsDto.decode(readValue(buffer)!); case 140: - return PolygonDto.decode(readValue(buffer)!); + return PatternItemDto.decode(readValue(buffer)!); case 141: - return PolygonHoleDto.decode(readValue(buffer)!); + return PolygonDto.decode(readValue(buffer)!); case 142: - return PolygonOptionsDto.decode(readValue(buffer)!); + return PolygonHoleDto.decode(readValue(buffer)!); case 143: - return PolylineDto.decode(readValue(buffer)!); + return PolygonOptionsDto.decode(readValue(buffer)!); case 144: - return PolylineOptionsDto.decode(readValue(buffer)!); + return PolylineDto.decode(readValue(buffer)!); case 145: - return StyleSpanDto.decode(readValue(buffer)!); + return PolylineOptionsDto.decode(readValue(buffer)!); case 146: + return StyleSpanDto.decode(readValue(buffer)!); + case 147: return StyleSpanStrokeStyleDto.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -8575,6 +8687,59 @@ class AutoMapViewApi { return (__pigeon_replyList[0] as bool?)!; } } + + Future setPadding(MapPaddingDto padding) async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.setPadding'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send([padding]) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else { + return; + } + } + + Future getPadding() async { + const String __pigeon_channelName = + 'dev.flutter.pigeon.google_navigation_flutter.AutoMapViewApi.getPadding'; + final BasicMessageChannel __pigeon_channel = + BasicMessageChannel( + __pigeon_channelName, + pigeonChannelCodec, + binaryMessenger: __pigeon_binaryMessenger, + ); + final List? __pigeon_replyList = + await __pigeon_channel.send(null) as List?; + if (__pigeon_replyList == null) { + throw _createConnectionError(__pigeon_channelName); + } else if (__pigeon_replyList.length > 1) { + throw PlatformException( + code: __pigeon_replyList[0]! as String, + message: __pigeon_replyList[1] as String?, + details: __pigeon_replyList[2], + ); + } else if (__pigeon_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (__pigeon_replyList[0] as MapPaddingDto?)!; + } + } } class _AutoViewEventApiCodec extends StandardMessageCodec { @@ -8614,87 +8779,90 @@ class _AutoViewEventApiCodec extends StandardMessageCodec { } else if (value is MapOptionsDto) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is MarkerAnchorDto) { + } else if (value is MapPaddingDto) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is MarkerDto) { + } else if (value is MarkerAnchorDto) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is MarkerOptionsDto) { + } else if (value is MarkerDto) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is NavInfoDto) { + } else if (value is MarkerOptionsDto) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is NavigationAudioGuidanceSettingsDto) { + } else if (value is NavInfoDto) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is NavigationDisplayOptionsDto) { + } else if (value is NavigationAudioGuidanceSettingsDto) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is NavigationTimeAndDistanceDto) { + } else if (value is NavigationDisplayOptionsDto) { buffer.putUint8(145); writeValue(buffer, value.encode()); - } else if (value is NavigationViewOptionsDto) { + } else if (value is NavigationTimeAndDistanceDto) { buffer.putUint8(146); writeValue(buffer, value.encode()); - } else if (value is NavigationWaypointDto) { + } else if (value is NavigationViewOptionsDto) { buffer.putUint8(147); writeValue(buffer, value.encode()); - } else if (value is PatternItemDto) { + } else if (value is NavigationWaypointDto) { buffer.putUint8(148); writeValue(buffer, value.encode()); - } else if (value is PolygonDto) { + } else if (value is PatternItemDto) { buffer.putUint8(149); writeValue(buffer, value.encode()); - } else if (value is PolygonHoleDto) { + } else if (value is PolygonDto) { buffer.putUint8(150); writeValue(buffer, value.encode()); - } else if (value is PolygonOptionsDto) { + } else if (value is PolygonHoleDto) { buffer.putUint8(151); writeValue(buffer, value.encode()); - } else if (value is PolylineDto) { + } else if (value is PolygonOptionsDto) { buffer.putUint8(152); writeValue(buffer, value.encode()); - } else if (value is PolylineOptionsDto) { + } else if (value is PolylineDto) { buffer.putUint8(153); writeValue(buffer, value.encode()); - } else if (value is RouteSegmentDto) { + } else if (value is PolylineOptionsDto) { buffer.putUint8(154); writeValue(buffer, value.encode()); - } else if (value is RouteSegmentTrafficDataDto) { + } else if (value is RouteSegmentDto) { buffer.putUint8(155); writeValue(buffer, value.encode()); - } else if (value is RouteSegmentTrafficDataRoadStretchRenderingDataDto) { + } else if (value is RouteSegmentTrafficDataDto) { buffer.putUint8(156); writeValue(buffer, value.encode()); - } else if (value is RouteTokenOptionsDto) { + } else if (value is RouteSegmentTrafficDataRoadStretchRenderingDataDto) { buffer.putUint8(157); writeValue(buffer, value.encode()); - } else if (value is RoutingOptionsDto) { + } else if (value is RouteTokenOptionsDto) { buffer.putUint8(158); writeValue(buffer, value.encode()); - } else if (value is SimulationOptionsDto) { + } else if (value is RoutingOptionsDto) { buffer.putUint8(159); writeValue(buffer, value.encode()); - } else if (value is SpeedAlertOptionsDto) { + } else if (value is SimulationOptionsDto) { buffer.putUint8(160); writeValue(buffer, value.encode()); - } else if (value is SpeedingUpdatedEventDto) { + } else if (value is SpeedAlertOptionsDto) { buffer.putUint8(161); writeValue(buffer, value.encode()); - } else if (value is StepInfoDto) { + } else if (value is SpeedingUpdatedEventDto) { buffer.putUint8(162); writeValue(buffer, value.encode()); - } else if (value is StyleSpanDto) { + } else if (value is StepInfoDto) { buffer.putUint8(163); writeValue(buffer, value.encode()); - } else if (value is StyleSpanStrokeStyleDto) { + } else if (value is StyleSpanDto) { buffer.putUint8(164); writeValue(buffer, value.encode()); - } else if (value is ViewCreationOptionsDto) { + } else if (value is StyleSpanStrokeStyleDto) { buffer.putUint8(165); writeValue(buffer, value.encode()); + } else if (value is ViewCreationOptionsDto) { + buffer.putUint8(166); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -8726,59 +8894,61 @@ class _AutoViewEventApiCodec extends StandardMessageCodec { case 138: return MapOptionsDto.decode(readValue(buffer)!); case 139: - return MarkerAnchorDto.decode(readValue(buffer)!); + return MapPaddingDto.decode(readValue(buffer)!); case 140: - return MarkerDto.decode(readValue(buffer)!); + return MarkerAnchorDto.decode(readValue(buffer)!); case 141: - return MarkerOptionsDto.decode(readValue(buffer)!); + return MarkerDto.decode(readValue(buffer)!); case 142: - return NavInfoDto.decode(readValue(buffer)!); + return MarkerOptionsDto.decode(readValue(buffer)!); case 143: - return NavigationAudioGuidanceSettingsDto.decode(readValue(buffer)!); + return NavInfoDto.decode(readValue(buffer)!); case 144: - return NavigationDisplayOptionsDto.decode(readValue(buffer)!); + return NavigationAudioGuidanceSettingsDto.decode(readValue(buffer)!); case 145: - return NavigationTimeAndDistanceDto.decode(readValue(buffer)!); + return NavigationDisplayOptionsDto.decode(readValue(buffer)!); case 146: - return NavigationViewOptionsDto.decode(readValue(buffer)!); + return NavigationTimeAndDistanceDto.decode(readValue(buffer)!); case 147: - return NavigationWaypointDto.decode(readValue(buffer)!); + return NavigationViewOptionsDto.decode(readValue(buffer)!); case 148: - return PatternItemDto.decode(readValue(buffer)!); + return NavigationWaypointDto.decode(readValue(buffer)!); case 149: - return PolygonDto.decode(readValue(buffer)!); + return PatternItemDto.decode(readValue(buffer)!); case 150: - return PolygonHoleDto.decode(readValue(buffer)!); + return PolygonDto.decode(readValue(buffer)!); case 151: - return PolygonOptionsDto.decode(readValue(buffer)!); + return PolygonHoleDto.decode(readValue(buffer)!); case 152: - return PolylineDto.decode(readValue(buffer)!); + return PolygonOptionsDto.decode(readValue(buffer)!); case 153: - return PolylineOptionsDto.decode(readValue(buffer)!); + return PolylineDto.decode(readValue(buffer)!); case 154: - return RouteSegmentDto.decode(readValue(buffer)!); + return PolylineOptionsDto.decode(readValue(buffer)!); case 155: - return RouteSegmentTrafficDataDto.decode(readValue(buffer)!); + return RouteSegmentDto.decode(readValue(buffer)!); case 156: + return RouteSegmentTrafficDataDto.decode(readValue(buffer)!); + case 157: return RouteSegmentTrafficDataRoadStretchRenderingDataDto.decode( readValue(buffer)!); - case 157: - return RouteTokenOptionsDto.decode(readValue(buffer)!); case 158: - return RoutingOptionsDto.decode(readValue(buffer)!); + return RouteTokenOptionsDto.decode(readValue(buffer)!); case 159: - return SimulationOptionsDto.decode(readValue(buffer)!); + return RoutingOptionsDto.decode(readValue(buffer)!); case 160: - return SpeedAlertOptionsDto.decode(readValue(buffer)!); + return SimulationOptionsDto.decode(readValue(buffer)!); case 161: - return SpeedingUpdatedEventDto.decode(readValue(buffer)!); + return SpeedAlertOptionsDto.decode(readValue(buffer)!); case 162: - return StepInfoDto.decode(readValue(buffer)!); + return SpeedingUpdatedEventDto.decode(readValue(buffer)!); case 163: - return StyleSpanDto.decode(readValue(buffer)!); + return StepInfoDto.decode(readValue(buffer)!); case 164: - return StyleSpanStrokeStyleDto.decode(readValue(buffer)!); + return StyleSpanDto.decode(readValue(buffer)!); case 165: + return StyleSpanStrokeStyleDto.decode(readValue(buffer)!); + case 166: return ViewCreationOptionsDto.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); diff --git a/lib/src/types/view_initialization_options.dart b/lib/src/types/view_initialization_options.dart index 21b8c5e..83ccc73 100644 --- a/lib/src/types/view_initialization_options.dart +++ b/lib/src/types/view_initialization_options.dart @@ -11,10 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; +import 'package:flutter/widgets.dart'; import '../../google_navigation_flutter.dart'; @@ -100,6 +100,7 @@ class MapOptions { this.maxZoomPreference, this.zoomControlsEnabled = true, this.cameraTargetBounds, + this.padding, }) : assert( minZoomPreference == null || maxZoomPreference == null || @@ -183,6 +184,11 @@ class MapOptions { /// /// Null by default (unbounded). final LatLngBounds? cameraTargetBounds; + + /// Specifies the initial padding for the map view. + /// + /// Null by default (no padding). + final EdgeInsets? padding; } /// Determines the initial visibility of the navigation UI on map initialization. diff --git a/pigeons/messages.dart b/pigeons/messages.dart index b351b76..a7c7ac4 100644 --- a/pigeons/messages.dart +++ b/pigeons/messages.dart @@ -53,6 +53,7 @@ class MapOptionsDto { required this.maxZoomPreference, required this.zoomControlsEnabled, required this.cameraTargetBounds, + required this.padding, }); /// The initial positioning of the camera in the map view. @@ -94,6 +95,9 @@ class MapOptionsDto { /// Specifies a bounds to constrain the camera target, so that when users scroll and pan the map, /// the camera target does not move outside these bounds. final LatLngBoundsDto? cameraTargetBounds; + + /// Specifies the padding for the map. + final MapPaddingDto? padding; } /// Determines the initial visibility of the navigation UI on map initialization. @@ -378,6 +382,19 @@ enum CameraEventTypeDto { onCameraStoppedFollowingLocation } +class MapPaddingDto { + MapPaddingDto( + {required this.top, + required this.left, + required this.bottom, + required this.right}); + + final int top; + final int left; + final int bottom; + final int right; +} + @HostApi(dartHostTestHandler: 'TestMapViewApi') abstract class MapViewApi { @async @@ -498,6 +515,8 @@ abstract class MapViewApi { void clearCircles(int viewId); void registerOnCameraChangedListener(int viewId); + void setPadding(int viewId, MapPaddingDto padding); + MapPaddingDto getPadding(int viewId); } @HostApi(dartHostTestHandler: 'TestImageRegistryApi') @@ -1352,6 +1371,8 @@ abstract class AutoMapViewApi { void registerOnCameraChangedListener(); bool isAutoScreenAvailable(); + void setPadding(MapPaddingDto padding); + MapPaddingDto getPadding(); } @FlutterApi() diff --git a/test/messages_test.g.dart b/test/messages_test.g.dart index e753f6c..8f54c95 100644 --- a/test/messages_test.g.dart +++ b/test/messages_test.g.dart @@ -52,39 +52,42 @@ class _TestMapViewApiCodec extends StandardMessageCodec { } else if (value is LatLngDto) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is MarkerAnchorDto) { + } else if (value is MapPaddingDto) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is MarkerDto) { + } else if (value is MarkerAnchorDto) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is MarkerOptionsDto) { + } else if (value is MarkerDto) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is PatternItemDto) { + } else if (value is MarkerOptionsDto) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is PolygonDto) { + } else if (value is PatternItemDto) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is PolygonHoleDto) { + } else if (value is PolygonDto) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is PolygonOptionsDto) { + } else if (value is PolygonHoleDto) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is PolylineDto) { + } else if (value is PolygonOptionsDto) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is PolylineOptionsDto) { + } else if (value is PolylineDto) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is StyleSpanDto) { + } else if (value is PolylineOptionsDto) { buffer.putUint8(145); writeValue(buffer, value.encode()); - } else if (value is StyleSpanStrokeStyleDto) { + } else if (value is StyleSpanDto) { buffer.putUint8(146); writeValue(buffer, value.encode()); + } else if (value is StyleSpanStrokeStyleDto) { + buffer.putUint8(147); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -110,26 +113,28 @@ class _TestMapViewApiCodec extends StandardMessageCodec { case 135: return LatLngDto.decode(readValue(buffer)!); case 136: - return MarkerAnchorDto.decode(readValue(buffer)!); + return MapPaddingDto.decode(readValue(buffer)!); case 137: - return MarkerDto.decode(readValue(buffer)!); + return MarkerAnchorDto.decode(readValue(buffer)!); case 138: - return MarkerOptionsDto.decode(readValue(buffer)!); + return MarkerDto.decode(readValue(buffer)!); case 139: - return PatternItemDto.decode(readValue(buffer)!); + return MarkerOptionsDto.decode(readValue(buffer)!); case 140: - return PolygonDto.decode(readValue(buffer)!); + return PatternItemDto.decode(readValue(buffer)!); case 141: - return PolygonHoleDto.decode(readValue(buffer)!); + return PolygonDto.decode(readValue(buffer)!); case 142: - return PolygonOptionsDto.decode(readValue(buffer)!); + return PolygonHoleDto.decode(readValue(buffer)!); case 143: - return PolylineDto.decode(readValue(buffer)!); + return PolygonOptionsDto.decode(readValue(buffer)!); case 144: - return PolylineOptionsDto.decode(readValue(buffer)!); + return PolylineDto.decode(readValue(buffer)!); case 145: - return StyleSpanDto.decode(readValue(buffer)!); + return PolylineOptionsDto.decode(readValue(buffer)!); case 146: + return StyleSpanDto.decode(readValue(buffer)!); + case 147: return StyleSpanStrokeStyleDto.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -332,6 +337,10 @@ abstract class TestMapViewApi { void registerOnCameraChangedListener(int viewId); + void setPadding(int viewId, MapPaddingDto padding); + + MapPaddingDto getPadding(int viewId); + static void setup(TestMapViewApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel __pigeon_channel = BasicMessageChannel< @@ -3346,6 +3355,71 @@ abstract class TestMapViewApi { }); } } + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setPadding', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(__pigeon_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(__pigeon_channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setPadding was null.'); + final List args = (message as List?)!; + final int? arg_viewId = (args[0] as int?); + assert(arg_viewId != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setPadding was null, expected non-null int.'); + final MapPaddingDto? arg_padding = (args[1] as MapPaddingDto?); + assert(arg_padding != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setPadding was null, expected non-null MapPaddingDto.'); + try { + api.setPadding(arg_viewId!, arg_padding!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } + { + final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getPadding', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(__pigeon_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(__pigeon_channel, + (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getPadding was null.'); + final List args = (message as List?)!; + final int? arg_viewId = (args[0] as int?); + assert(arg_viewId != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getPadding was null, expected non-null int.'); + try { + final MapPaddingDto output = api.getPadding(arg_viewId!); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } } }