From 6b2d730a3c4680e279ce3a85124c54feaee615e5 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Mon, 8 Dec 2025 15:25:20 +0200 Subject: [PATCH 1/2] feat: ability to control light and dart modes --- README.md | 87 +++- .../google/maps/flutter/navigation/Convert.kt | 62 ++- .../navigation/GoogleMapsBaseMapView.kt | 8 + .../navigation/GoogleMapsNavigationView.kt | 17 + .../GoogleMapsViewMessageHandler.kt | 20 + .../navigation/NavigationViewConfiguration.kt | 5 +- .../maps/flutter/navigation/messages.g.kt | 402 +++++++++++----- .../maps/flutter/navigation/ConvertTest.kt | 1 + .../t01_initialization_test.dart | 19 + .../t04_navigation_ui_test.dart | 35 ++ example/ios/Flutter/AppFrameworkInfo.plist | 4 +- example/ios/RunnerTests/ConvertTests.swift | 11 +- example/lib/pages/map.dart | 100 ++++ example/lib/pages/navigation.dart | 163 ++++++- example/lib/pages/widget_initialization.dart | 47 +- example/lib/widgets/page.dart | 12 +- .../BaseCarSceneDelegate.swift | 4 +- .../Convert+MapConfiguration.swift | 3 +- .../google_navigation_flutter/Convert.swift | 54 +++ .../GoogleMapsNavigationView.swift | 44 ++ .../GoogleMapsNavigationViewFactory.swift | 4 + ...ogleMapsNavigationViewMessageHandler.swift | 20 + .../MapConfiguration.swift | 2 + .../messages.g.swift | 370 ++++++++++----- lib/src/google_maps_map_view.dart | 11 + lib/src/google_maps_map_view_controller.dart | 32 ++ lib/src/google_maps_navigation_view.dart | 18 + ...oogle_maps_navigation_view_controller.dart | 41 ++ lib/src/method_channel/convert/convert.dart | 2 + .../convert/map_color_scheme.dart | 48 ++ .../method_channel/convert/navigation.dart | 5 +- .../convert/navigation_force_night_mode.dart | 48 ++ lib/src/method_channel/map_view_api.dart | 53 ++- lib/src/method_channel/messages.g.dart | 415 ++++++++++++----- lib/src/types/navigation_view_types.dart | 33 ++ .../types/view_initialization_options.dart | 38 +- pigeons/messages.dart | 45 +- .../google_navigation_flutter_test.mocks.dart | 32 ++ test/messages_test.g.dart | 432 +++++++++++++----- test/navigation_types_test.dart | 76 +++ tool/test-ios.sh | 2 +- 41 files changed, 2304 insertions(+), 521 deletions(-) create mode 100644 lib/src/method_channel/convert/map_color_scheme.dart create mode 100644 lib/src/method_channel/convert/navigation_force_night_mode.dart diff --git a/README.md b/README.md index 8b9e4e3a..9cf81cab 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ in an unbounded widget will cause the application to throw a Flutter exception. You can also add a bare GoogleMapsMapView that works as a normal map view without navigation functionality. -### Add a navigation view +### Add a navigation view and start a navigation session ```dart import 'package:flutter/material.dart'; @@ -199,7 +199,7 @@ This parameter has only an effect on Android. ``` -#### Using Map IDs +### Using Map IDs You can configure your map by providing a `mapId` parameter during map initialization. Map IDs are created in the [Google Cloud Console](https://console.cloud.google.com/google/maps-apis/studio/maps) and allow you to [enable various Google Maps Platform features](https://developers.google.com/maps/documentation/android-sdk/map-ids/mapid-over#features-available), such as cloud-based map styling. > [!NOTE] @@ -262,6 +262,89 @@ Widget build(BuildContext context) { } ``` +### Controlling Light and Dark Mode + +The SDK provides two different settings to control the appearance of maps and navigation UI: `mapColorScheme` and `forceNightMode`. Which setting to use depends on whether navigation UI is enabled or disabled. + +These settings can be configured both during initialization and dynamically changed after initialization using the view controllers. + +#### For Navigation Views (GoogleMapsNavigationView) + +**When navigation UI is enabled:** +- Use `forceNightMode` (or `initialForceNightMode` during initialization) to control both the navigation UI elements and the map tile colors. +- The `mapColorScheme` setting is ignored when navigation UI is enabled. + +> [!TIP] +> When navigation guidance is running, it's recommended to use `NavigationForceNightMode.auto` (the default). This allows the Navigation SDK to automatically determine the appropriate day or night mode based on the user's location and local time, which may differ from the device's system settings. + +```dart +GoogleMapsNavigationView( + initialForceNightMode: NavigationForceNightMode.auto, + initialMapColorScheme: MapColorScheme.dark, // IGNORED when navigation UI is enabled +) +``` + +To manually force a specific mode: +```dart +GoogleMapsNavigationView( + initialForceNightMode: NavigationForceNightMode.forceNight, +) +``` + +You can also change the setting dynamically after initialization: + +```dart +// Change after initialization when navigation UI is enabled +await navigationViewController.setForceNightMode(NavigationForceNightMode.forceNight); +``` + +**When navigation UI is disabled:** +- Use `mapColorScheme` (or `initialMapColorScheme` during initialization) to control the map tile colors. +- The `forceNightMode` setting has no effect when navigation UI is disabled. + +```dart +GoogleMapsNavigationView( + initialNavigationUIEnabledPreference: NavigationUIEnabledPreference.disabled, + initialMapColorScheme: MapColorScheme.dark, + initialForceNightMode: NavigationForceNightMode.forceDay // IGNORED when navigation UI is disabled +) +``` + +You can also change the setting dynamically after initialization: + +```dart +// Change after initialization when navigation UI is disabled +await navigationViewController.setMapColorScheme(MapColorScheme.dark); +``` + +#### For Map Views (GoogleMapsMapView) + +Map views only support `mapColorScheme` to control the map tile colors: + +```dart +GoogleMapsMapView( + initialMapColorScheme: MapColorScheme.dark, +) +``` + +You can also change the setting dynamically after initialization: + +```dart +// Change after initialization +await mapViewController.setMapColorScheme(MapColorScheme.dark); +``` + +#### Available Options + +- `NavigationForceNightMode`: + - `auto` (default and recommended) - SDK determines day/night mode based on user's location and local time + - `forceDay` - Force day mode regardless of time or location + - `forceNight` - Force night mode regardless of time or location +- `MapColorScheme`: + - `followSystem` (default) - Follow device system settings + - `light` - Force light color scheme + - `dark` - Force dark color scheme + ## Support for Android Auto and Apple CarPlay This plugin is compatible with both Android Auto and Apple CarPlay infotainment systems. For more details, please refer to the respective platform documentation: 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 95ee3621..05de8f9b 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 @@ -28,6 +28,7 @@ import com.google.android.gms.maps.model.Gap import com.google.android.gms.maps.model.JointType import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.LatLngBounds +import com.google.android.gms.maps.model.MapColorScheme import com.google.android.gms.maps.model.PatternItem import com.google.android.gms.maps.model.Polygon import com.google.android.gms.maps.model.Polyline @@ -41,6 +42,7 @@ import com.google.android.libraries.mapsplatform.turnbyturn.model.NavState import com.google.android.libraries.mapsplatform.turnbyturn.model.StepInfo import com.google.android.libraries.navigation.AlternateRoutesStrategy import com.google.android.libraries.navigation.DisplayOptions +import com.google.android.libraries.navigation.ForceNightMode import com.google.android.libraries.navigation.NavigationRoadStretchRenderingData import com.google.android.libraries.navigation.NavigationTrafficData import com.google.android.libraries.navigation.Navigator @@ -82,6 +84,7 @@ object Convert { options.minZoomPreference?.let { googleMapOptions.minZoomPreference(it.toFloat()) } options.maxZoomPreference?.let { googleMapOptions.maxZoomPreference(it.toFloat()) } googleMapOptions.zoomControlsEnabled(options.zoomControlsEnabled) + googleMapOptions.mapColorScheme(convertMapColorSchemeFromDto(options.mapColorScheme)) options.mapId?.let { googleMapOptions.mapId(it) } return MapOptions(googleMapOptions, options.padding) @@ -114,7 +117,8 @@ object Convert { return NavigationViewOptions( navigationUiEnabledPreference = - convertNavigationUIEnabledPreferenceFromDto(options.navigationUIEnabledPreference) + convertNavigationUIEnabledPreferenceFromDto(options.navigationUIEnabledPreference), + forceNightMode = convertNavigationForceNightModeFromDto(options.forceNightMode), ) } @@ -279,6 +283,62 @@ object Convert { } } + /** + * Converts pigeon [MapColorSchemeDto] to [MapColorScheme]. + * + * @param mapColorScheme pigeon [MapColorSchemeDto]. + * @return [MapColorScheme]. + */ + fun convertMapColorSchemeFromDto(mapColorScheme: MapColorSchemeDto): Int { + return when (mapColorScheme) { + MapColorSchemeDto.FOLLOW_SYSTEM -> MapColorScheme.FOLLOW_SYSTEM + MapColorSchemeDto.LIGHT -> MapColorScheme.LIGHT + MapColorSchemeDto.DARK -> MapColorScheme.DARK + } + } + + /** + * Converts [MapColorScheme] to pigeon [MapColorSchemeDto]. + * + * @param mapColorScheme [MapColorScheme]. + * @return pigeon [MapColorSchemeDto]. + */ + fun convertMapColorSchemeToDto(mapColorScheme: Int): MapColorSchemeDto { + return when (mapColorScheme) { + MapColorScheme.LIGHT -> MapColorSchemeDto.LIGHT + MapColorScheme.DARK -> MapColorSchemeDto.DARK + else -> MapColorSchemeDto.FOLLOW_SYSTEM + } + } + + /** + * Converts pigeon [NavigationForceNightModeDto] to [ForceNightMode]. + * + * @param forceNightMode pigeon [NavigationForceNightModeDto]. + * @return [ForceNightMode]. + */ + fun convertNavigationForceNightModeFromDto(forceNightMode: NavigationForceNightModeDto): Int { + return when (forceNightMode) { + NavigationForceNightModeDto.AUTO -> ForceNightMode.AUTO + NavigationForceNightModeDto.FORCE_DAY -> ForceNightMode.FORCE_DAY + NavigationForceNightModeDto.FORCE_NIGHT -> ForceNightMode.FORCE_NIGHT + } + } + + /** + * Converts [ForceNightMode] to pigeon [NavigationForceNightModeDto]. + * + * @param forceNightMode [ForceNightMode]. + * @return pigeon [NavigationForceNightModeDto]. + */ + fun convertNavigationForceNightModeToDto(forceNightMode: Int): NavigationForceNightModeDto { + return when (forceNightMode) { + ForceNightMode.FORCE_DAY -> NavigationForceNightModeDto.FORCE_DAY + ForceNightMode.FORCE_NIGHT -> NavigationForceNightModeDto.FORCE_NIGHT + else -> NavigationForceNightModeDto.AUTO + } + } + /** * Converts pigeon [NavigationWaypointDto] to Google Navigation [Waypoint]. * 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 6038b3aa..4f0dd924 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 @@ -1055,4 +1055,12 @@ abstract class GoogleMapsBaseMapView( fun getPadding(): MapPaddingDto { return _mapOptions?.padding ?: MapPaddingDto(0, 0, 0, 0) } + + fun getMapColorScheme(): Int { + return getMap().mapColorScheme + } + + fun setMapColorScheme(mapColorScheme: Int) { + getMap().mapColorScheme = mapColorScheme + } } 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 09268f80..7f4e0f9d 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,6 +20,7 @@ import android.content.Context import android.content.res.Configuration import android.view.View import com.google.android.gms.maps.CameraUpdateFactory +import com.google.android.libraries.navigation.ForceNightMode import com.google.android.libraries.navigation.NavigationView import com.google.android.libraries.navigation.OnNavigationUiChangedListener import com.google.android.libraries.navigation.PromptVisibilityChangedListener @@ -38,6 +39,7 @@ internal constructor( private val _navigationView: NavigationView = NavigationView(context, mapOptions.googleMapOptions) /// Default values for UI features. + private var _forceNightMode: Int = ForceNightMode.AUTO private var _isNavigationTripProgressBarEnabled: Boolean = false private var _isNavigationHeaderEnabled: Boolean = true private var _isNavigationFooterEnabled: Boolean = true @@ -76,6 +78,12 @@ internal constructor( } _navigationView.isNavigationUiEnabled = navigationViewEnabled + // Initialize force night mode if provided + navigationOptions?.forceNightMode?.let { forceNightMode -> + _forceNightMode = forceNightMode + _navigationView.setForceNightMode(forceNightMode) + } + viewRegistry.registerNavigationView(viewId, this) _navigationView.getMapAsync { map -> @@ -288,4 +296,13 @@ internal constructor( fun showRouteOverview() { _navigationView.showRouteOverview() } + + fun getForceNightMode(): Int { + return _forceNightMode + } + + fun setForceNightMode(forceNightMode: Int) { + _forceNightMode = forceNightMode + _navigationView.setForceNightMode(forceNightMode) + } } 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 8fe3f67c..cc51332f 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 @@ -519,4 +519,24 @@ class GoogleMapsViewMessageHandler(private val viewRegistry: GoogleMapsViewRegis override fun getPadding(viewId: Long): MapPaddingDto { return getView(viewId.toInt()).getPadding() } + + override fun getMapColorScheme(viewId: Long): MapColorSchemeDto { + val colorScheme = getView(viewId.toInt()).getMapColorScheme() + return Convert.convertMapColorSchemeToDto(colorScheme) + } + + override fun setMapColorScheme(viewId: Long, mapColorScheme: MapColorSchemeDto) { + val colorScheme = Convert.convertMapColorSchemeFromDto(mapColorScheme) + getView(viewId.toInt()).setMapColorScheme(colorScheme) + } + + override fun getForceNightMode(viewId: Long): NavigationForceNightModeDto { + val forceNightMode = getNavigationView(viewId.toInt()).getForceNightMode() + return Convert.convertNavigationForceNightModeToDto(forceNightMode) + } + + override fun setForceNightMode(viewId: Long, forceNightMode: NavigationForceNightModeDto) { + val nightMode = Convert.convertNavigationForceNightModeFromDto(forceNightMode) + getNavigationView(viewId.toInt()).setForceNightMode(nightMode) + } } diff --git a/android/src/main/kotlin/com/google/maps/flutter/navigation/NavigationViewConfiguration.kt b/android/src/main/kotlin/com/google/maps/flutter/navigation/NavigationViewConfiguration.kt index 5e5bd97c..ebd3bd1d 100644 --- a/android/src/main/kotlin/com/google/maps/flutter/navigation/NavigationViewConfiguration.kt +++ b/android/src/main/kotlin/com/google/maps/flutter/navigation/NavigationViewConfiguration.kt @@ -26,4 +26,7 @@ enum class NavigationUIEnabledPreference { } /** Class for navigation view configuration options. */ -data class NavigationViewOptions(val navigationUiEnabledPreference: NavigationUIEnabledPreference?) +data class NavigationViewOptions( + val navigationUiEnabledPreference: NavigationUIEnabledPreference?, + val forceNightMode: Int?, +) 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 e4317645..f732b780 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 @@ -137,6 +137,38 @@ enum class MapTypeDto(val raw: Int) { } } +/** Map color scheme mode. */ +enum class MapColorSchemeDto(val raw: Int) { + /** Follow system or SDK default (automatic). */ + FOLLOW_SYSTEM(0), + /** Force light color scheme. */ + LIGHT(1), + /** Force dark color scheme. */ + DARK(2); + + companion object { + fun ofRaw(raw: Int): MapColorSchemeDto? { + return values().firstOrNull { it.raw == raw } + } + } +} + +/** Navigation night mode. */ +enum class NavigationForceNightModeDto(val raw: Int) { + /** Let the SDK automatically determine day or night. */ + AUTO(0), + /** Force day mode regardless of time or location. */ + FORCE_DAY(1), + /** Force night mode regardless of time or location. */ + FORCE_NIGHT(2); + + companion object { + fun ofRaw(raw: Int): NavigationForceNightModeDto? { + return values().firstOrNull { it.raw == raw } + } + } +} + enum class CameraPerspectiveDto(val raw: Int) { TILTED(0), TOP_DOWN_HEADING_UP(1), @@ -599,6 +631,8 @@ data class MapOptionsDto( * map initialization and cannot be changed afterwards. */ val mapId: String? = null, + /** The map color scheme mode for the map view. */ + val mapColorScheme: MapColorSchemeDto, ) { companion object { fun fromList(pigeonVar_list: List): MapOptionsDto { @@ -617,6 +651,7 @@ data class MapOptionsDto( val cameraTargetBounds = pigeonVar_list[12] as LatLngBoundsDto? val padding = pigeonVar_list[13] as MapPaddingDto? val mapId = pigeonVar_list[14] as String? + val mapColorScheme = pigeonVar_list[15] as MapColorSchemeDto return MapOptionsDto( cameraPosition, mapType, @@ -633,6 +668,7 @@ data class MapOptionsDto( cameraTargetBounds, padding, mapId, + mapColorScheme, ) } } @@ -654,6 +690,7 @@ data class MapOptionsDto( cameraTargetBounds, padding, mapId, + mapColorScheme, ) } @@ -677,17 +714,20 @@ data class MapOptionsDto( */ data class NavigationViewOptionsDto( /** Determines the initial visibility of the navigation UI on map initialization. */ - val navigationUIEnabledPreference: NavigationUIEnabledPreferenceDto + val navigationUIEnabledPreference: NavigationUIEnabledPreferenceDto, + /** Controls the navigation night mode for Navigation UI. */ + val forceNightMode: NavigationForceNightModeDto, ) { companion object { fun fromList(pigeonVar_list: List): NavigationViewOptionsDto { val navigationUIEnabledPreference = pigeonVar_list[0] as NavigationUIEnabledPreferenceDto - return NavigationViewOptionsDto(navigationUIEnabledPreference) + val forceNightMode = pigeonVar_list[1] as NavigationForceNightModeDto + return NavigationViewOptionsDto(navigationUIEnabledPreference, forceNightMode) } } fun toList(): List { - return listOf(navigationUIEnabledPreference) + return listOf(navigationUIEnabledPreference, forceNightMode) } override fun equals(other: Any?): Boolean { @@ -2237,195 +2277,201 @@ private open class messagesPigeonCodec : StandardMessageCodec() { return (readValue(buffer) as Long?)?.let { MapTypeDto.ofRaw(it.toInt()) } } 132.toByte() -> { - return (readValue(buffer) as Long?)?.let { CameraPerspectiveDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { MapColorSchemeDto.ofRaw(it.toInt()) } } 133.toByte() -> { - return (readValue(buffer) as Long?)?.let { MarkerEventTypeDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { NavigationForceNightModeDto.ofRaw(it.toInt()) } } 134.toByte() -> { - return (readValue(buffer) as Long?)?.let { MarkerDragEventTypeDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { CameraPerspectiveDto.ofRaw(it.toInt()) } } 135.toByte() -> { - return (readValue(buffer) as Long?)?.let { StrokeJointTypeDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { MarkerEventTypeDto.ofRaw(it.toInt()) } } 136.toByte() -> { - return (readValue(buffer) as Long?)?.let { PatternTypeDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { MarkerDragEventTypeDto.ofRaw(it.toInt()) } } 137.toByte() -> { - return (readValue(buffer) as Long?)?.let { CameraEventTypeDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { StrokeJointTypeDto.ofRaw(it.toInt()) } } 138.toByte() -> { - return (readValue(buffer) as Long?)?.let { AlternateRoutesStrategyDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { PatternTypeDto.ofRaw(it.toInt()) } } 139.toByte() -> { - return (readValue(buffer) as Long?)?.let { RoutingStrategyDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { CameraEventTypeDto.ofRaw(it.toInt()) } } 140.toByte() -> { - return (readValue(buffer) as Long?)?.let { TravelModeDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { AlternateRoutesStrategyDto.ofRaw(it.toInt()) } } 141.toByte() -> { - return (readValue(buffer) as Long?)?.let { RouteStatusDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { RoutingStrategyDto.ofRaw(it.toInt()) } } 142.toByte() -> { - return (readValue(buffer) as Long?)?.let { AudioGuidanceTypeDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { TravelModeDto.ofRaw(it.toInt()) } } 143.toByte() -> { - return (readValue(buffer) as Long?)?.let { SpeedAlertSeverityDto.ofRaw(it.toInt()) } + return (readValue(buffer) as Long?)?.let { RouteStatusDto.ofRaw(it.toInt()) } } 144.toByte() -> { + return (readValue(buffer) as Long?)?.let { AudioGuidanceTypeDto.ofRaw(it.toInt()) } + } + 145.toByte() -> { + return (readValue(buffer) as Long?)?.let { SpeedAlertSeverityDto.ofRaw(it.toInt()) } + } + 146.toByte() -> { return (readValue(buffer) as Long?)?.let { RouteSegmentTrafficDataStatusDto.ofRaw(it.toInt()) } } - 145.toByte() -> { + 147.toByte() -> { return (readValue(buffer) as Long?)?.let { RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto.ofRaw(it.toInt()) } } - 146.toByte() -> { + 148.toByte() -> { return (readValue(buffer) as Long?)?.let { ManeuverDto.ofRaw(it.toInt()) } } - 147.toByte() -> { + 149.toByte() -> { return (readValue(buffer) as Long?)?.let { DrivingSideDto.ofRaw(it.toInt()) } } - 148.toByte() -> { + 150.toByte() -> { return (readValue(buffer) as Long?)?.let { NavStateDto.ofRaw(it.toInt()) } } - 149.toByte() -> { + 151.toByte() -> { return (readValue(buffer) as Long?)?.let { LaneShapeDto.ofRaw(it.toInt()) } } - 150.toByte() -> { + 152.toByte() -> { return (readValue(buffer) as Long?)?.let { TaskRemovedBehaviorDto.ofRaw(it.toInt()) } } - 151.toByte() -> { + 153.toByte() -> { return (readValue(buffer) as? List)?.let { MapOptionsDto.fromList(it) } } - 152.toByte() -> { + 154.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationViewOptionsDto.fromList(it) } } - 153.toByte() -> { + 155.toByte() -> { return (readValue(buffer) as? List)?.let { ViewCreationOptionsDto.fromList(it) } } - 154.toByte() -> { + 156.toByte() -> { return (readValue(buffer) as? List)?.let { CameraPositionDto.fromList(it) } } - 155.toByte() -> { + 157.toByte() -> { return (readValue(buffer) as? List)?.let { MarkerDto.fromList(it) } } - 156.toByte() -> { + 158.toByte() -> { return (readValue(buffer) as? List)?.let { MarkerOptionsDto.fromList(it) } } - 157.toByte() -> { + 159.toByte() -> { return (readValue(buffer) as? List)?.let { ImageDescriptorDto.fromList(it) } } - 158.toByte() -> { + 160.toByte() -> { return (readValue(buffer) as? List)?.let { InfoWindowDto.fromList(it) } } - 159.toByte() -> { + 161.toByte() -> { return (readValue(buffer) as? List)?.let { MarkerAnchorDto.fromList(it) } } - 160.toByte() -> { + 162.toByte() -> { return (readValue(buffer) as? List)?.let { PolygonDto.fromList(it) } } - 161.toByte() -> { + 163.toByte() -> { return (readValue(buffer) as? List)?.let { PolygonOptionsDto.fromList(it) } } - 162.toByte() -> { + 164.toByte() -> { return (readValue(buffer) as? List)?.let { PolygonHoleDto.fromList(it) } } - 163.toByte() -> { + 165.toByte() -> { return (readValue(buffer) as? List)?.let { StyleSpanStrokeStyleDto.fromList(it) } } - 164.toByte() -> { + 166.toByte() -> { return (readValue(buffer) as? List)?.let { StyleSpanDto.fromList(it) } } - 165.toByte() -> { + 167.toByte() -> { return (readValue(buffer) as? List)?.let { PolylineDto.fromList(it) } } - 166.toByte() -> { + 168.toByte() -> { return (readValue(buffer) as? List)?.let { PatternItemDto.fromList(it) } } - 167.toByte() -> { + 169.toByte() -> { return (readValue(buffer) as? List)?.let { PolylineOptionsDto.fromList(it) } } - 168.toByte() -> { + 170.toByte() -> { return (readValue(buffer) as? List)?.let { CircleDto.fromList(it) } } - 169.toByte() -> { + 171.toByte() -> { return (readValue(buffer) as? List)?.let { CircleOptionsDto.fromList(it) } } - 170.toByte() -> { + 172.toByte() -> { return (readValue(buffer) as? List)?.let { MapPaddingDto.fromList(it) } } - 171.toByte() -> { + 173.toByte() -> { return (readValue(buffer) as? List)?.let { RouteTokenOptionsDto.fromList(it) } } - 172.toByte() -> { + 174.toByte() -> { return (readValue(buffer) as? List)?.let { DestinationsDto.fromList(it) } } - 173.toByte() -> { + 175.toByte() -> { return (readValue(buffer) as? List)?.let { RoutingOptionsDto.fromList(it) } } - 174.toByte() -> { + 176.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationDisplayOptionsDto.fromList(it) } } - 175.toByte() -> { + 177.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationWaypointDto.fromList(it) } } - 176.toByte() -> { + 178.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationTimeAndDistanceDto.fromList(it) } } - 177.toByte() -> { + 179.toByte() -> { return (readValue(buffer) as? List)?.let { NavigationAudioGuidanceSettingsDto.fromList(it) } } - 178.toByte() -> { + 180.toByte() -> { return (readValue(buffer) as? List)?.let { SimulationOptionsDto.fromList(it) } } - 179.toByte() -> { + 181.toByte() -> { return (readValue(buffer) as? List)?.let { LatLngDto.fromList(it) } } - 180.toByte() -> { + 182.toByte() -> { return (readValue(buffer) as? List)?.let { LatLngBoundsDto.fromList(it) } } - 181.toByte() -> { + 183.toByte() -> { return (readValue(buffer) as? List)?.let { SpeedingUpdatedEventDto.fromList(it) } } - 182.toByte() -> { + 184.toByte() -> { return (readValue(buffer) as? List)?.let { GpsAvailabilityChangeEventDto.fromList(it) } } - 183.toByte() -> { + 185.toByte() -> { return (readValue(buffer) as? List)?.let { SpeedAlertOptionsThresholdPercentageDto.fromList(it) } } - 184.toByte() -> { + 186.toByte() -> { return (readValue(buffer) as? List)?.let { SpeedAlertOptionsDto.fromList(it) } } - 185.toByte() -> { + 187.toByte() -> { return (readValue(buffer) as? List)?.let { RouteSegmentTrafficDataRoadStretchRenderingDataDto.fromList(it) } } - 186.toByte() -> { + 188.toByte() -> { return (readValue(buffer) as? List)?.let { RouteSegmentTrafficDataDto.fromList(it) } } - 187.toByte() -> { + 189.toByte() -> { return (readValue(buffer) as? List)?.let { RouteSegmentDto.fromList(it) } } - 188.toByte() -> { + 190.toByte() -> { return (readValue(buffer) as? List)?.let { LaneDirectionDto.fromList(it) } } - 189.toByte() -> { + 191.toByte() -> { return (readValue(buffer) as? List)?.let { LaneDto.fromList(it) } } - 190.toByte() -> { + 192.toByte() -> { return (readValue(buffer) as? List)?.let { StepInfoDto.fromList(it) } } - 191.toByte() -> { + 193.toByte() -> { return (readValue(buffer) as? List)?.let { NavInfoDto.fromList(it) } } else -> super.readValueOfType(type, buffer) @@ -2446,244 +2492,252 @@ private open class messagesPigeonCodec : StandardMessageCodec() { stream.write(131) writeValue(stream, value.raw) } - is CameraPerspectiveDto -> { + is MapColorSchemeDto -> { stream.write(132) writeValue(stream, value.raw) } - is MarkerEventTypeDto -> { + is NavigationForceNightModeDto -> { stream.write(133) writeValue(stream, value.raw) } - is MarkerDragEventTypeDto -> { + is CameraPerspectiveDto -> { stream.write(134) writeValue(stream, value.raw) } - is StrokeJointTypeDto -> { + is MarkerEventTypeDto -> { stream.write(135) writeValue(stream, value.raw) } - is PatternTypeDto -> { + is MarkerDragEventTypeDto -> { stream.write(136) writeValue(stream, value.raw) } - is CameraEventTypeDto -> { + is StrokeJointTypeDto -> { stream.write(137) writeValue(stream, value.raw) } - is AlternateRoutesStrategyDto -> { + is PatternTypeDto -> { stream.write(138) writeValue(stream, value.raw) } - is RoutingStrategyDto -> { + is CameraEventTypeDto -> { stream.write(139) writeValue(stream, value.raw) } - is TravelModeDto -> { + is AlternateRoutesStrategyDto -> { stream.write(140) writeValue(stream, value.raw) } - is RouteStatusDto -> { + is RoutingStrategyDto -> { stream.write(141) writeValue(stream, value.raw) } - is AudioGuidanceTypeDto -> { + is TravelModeDto -> { stream.write(142) writeValue(stream, value.raw) } - is SpeedAlertSeverityDto -> { + is RouteStatusDto -> { stream.write(143) writeValue(stream, value.raw) } - is RouteSegmentTrafficDataStatusDto -> { + is AudioGuidanceTypeDto -> { stream.write(144) writeValue(stream, value.raw) } - is RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto -> { + is SpeedAlertSeverityDto -> { stream.write(145) writeValue(stream, value.raw) } - is ManeuverDto -> { + is RouteSegmentTrafficDataStatusDto -> { stream.write(146) writeValue(stream, value.raw) } - is DrivingSideDto -> { + is RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto -> { stream.write(147) writeValue(stream, value.raw) } - is NavStateDto -> { + is ManeuverDto -> { stream.write(148) writeValue(stream, value.raw) } - is LaneShapeDto -> { + is DrivingSideDto -> { stream.write(149) writeValue(stream, value.raw) } - is TaskRemovedBehaviorDto -> { + is NavStateDto -> { stream.write(150) writeValue(stream, value.raw) } - is MapOptionsDto -> { + is LaneShapeDto -> { stream.write(151) + writeValue(stream, value.raw) + } + is TaskRemovedBehaviorDto -> { + stream.write(152) + writeValue(stream, value.raw) + } + is MapOptionsDto -> { + stream.write(153) writeValue(stream, value.toList()) } is NavigationViewOptionsDto -> { - stream.write(152) + stream.write(154) writeValue(stream, value.toList()) } is ViewCreationOptionsDto -> { - stream.write(153) + stream.write(155) writeValue(stream, value.toList()) } is CameraPositionDto -> { - stream.write(154) + stream.write(156) writeValue(stream, value.toList()) } is MarkerDto -> { - stream.write(155) + stream.write(157) writeValue(stream, value.toList()) } is MarkerOptionsDto -> { - stream.write(156) + stream.write(158) writeValue(stream, value.toList()) } is ImageDescriptorDto -> { - stream.write(157) + stream.write(159) writeValue(stream, value.toList()) } is InfoWindowDto -> { - stream.write(158) + stream.write(160) writeValue(stream, value.toList()) } is MarkerAnchorDto -> { - stream.write(159) + stream.write(161) writeValue(stream, value.toList()) } is PolygonDto -> { - stream.write(160) + stream.write(162) writeValue(stream, value.toList()) } is PolygonOptionsDto -> { - stream.write(161) + stream.write(163) writeValue(stream, value.toList()) } is PolygonHoleDto -> { - stream.write(162) + stream.write(164) writeValue(stream, value.toList()) } is StyleSpanStrokeStyleDto -> { - stream.write(163) + stream.write(165) writeValue(stream, value.toList()) } is StyleSpanDto -> { - stream.write(164) + stream.write(166) writeValue(stream, value.toList()) } is PolylineDto -> { - stream.write(165) + stream.write(167) writeValue(stream, value.toList()) } is PatternItemDto -> { - stream.write(166) + stream.write(168) writeValue(stream, value.toList()) } is PolylineOptionsDto -> { - stream.write(167) + stream.write(169) writeValue(stream, value.toList()) } is CircleDto -> { - stream.write(168) + stream.write(170) writeValue(stream, value.toList()) } is CircleOptionsDto -> { - stream.write(169) + stream.write(171) writeValue(stream, value.toList()) } is MapPaddingDto -> { - stream.write(170) + stream.write(172) writeValue(stream, value.toList()) } is RouteTokenOptionsDto -> { - stream.write(171) + stream.write(173) writeValue(stream, value.toList()) } is DestinationsDto -> { - stream.write(172) + stream.write(174) writeValue(stream, value.toList()) } is RoutingOptionsDto -> { - stream.write(173) + stream.write(175) writeValue(stream, value.toList()) } is NavigationDisplayOptionsDto -> { - stream.write(174) + stream.write(176) writeValue(stream, value.toList()) } is NavigationWaypointDto -> { - stream.write(175) + stream.write(177) writeValue(stream, value.toList()) } is NavigationTimeAndDistanceDto -> { - stream.write(176) + stream.write(178) writeValue(stream, value.toList()) } is NavigationAudioGuidanceSettingsDto -> { - stream.write(177) + stream.write(179) writeValue(stream, value.toList()) } is SimulationOptionsDto -> { - stream.write(178) + stream.write(180) writeValue(stream, value.toList()) } is LatLngDto -> { - stream.write(179) + stream.write(181) writeValue(stream, value.toList()) } is LatLngBoundsDto -> { - stream.write(180) + stream.write(182) writeValue(stream, value.toList()) } is SpeedingUpdatedEventDto -> { - stream.write(181) + stream.write(183) writeValue(stream, value.toList()) } is GpsAvailabilityChangeEventDto -> { - stream.write(182) + stream.write(184) writeValue(stream, value.toList()) } is SpeedAlertOptionsThresholdPercentageDto -> { - stream.write(183) + stream.write(185) writeValue(stream, value.toList()) } is SpeedAlertOptionsDto -> { - stream.write(184) + stream.write(186) writeValue(stream, value.toList()) } is RouteSegmentTrafficDataRoadStretchRenderingDataDto -> { - stream.write(185) + stream.write(187) writeValue(stream, value.toList()) } is RouteSegmentTrafficDataDto -> { - stream.write(186) + stream.write(188) writeValue(stream, value.toList()) } is RouteSegmentDto -> { - stream.write(187) + stream.write(189) writeValue(stream, value.toList()) } is LaneDirectionDto -> { - stream.write(188) + stream.write(190) writeValue(stream, value.toList()) } is LaneDto -> { - stream.write(189) + stream.write(191) writeValue(stream, value.toList()) } is StepInfoDto -> { - stream.write(190) + stream.write(192) writeValue(stream, value.toList()) } is NavInfoDto -> { - stream.write(191) + stream.write(193) writeValue(stream, value.toList()) } else -> super.writeValue(stream, value) @@ -2988,6 +3042,14 @@ interface MapViewApi { fun getPadding(viewId: Long): MapPaddingDto + fun getMapColorScheme(viewId: Long): MapColorSchemeDto + + fun setMapColorScheme(viewId: Long, mapColorScheme: MapColorSchemeDto) + + fun getForceNightMode(viewId: Long): NavigationForceNightModeDto + + fun setForceNightMode(viewId: Long, forceNightMode: NavigationForceNightModeDto) + companion object { /** The codec used by MapViewApi. */ val codec: MessageCodec by lazy { messagesPigeonCodec() } @@ -5443,6 +5505,102 @@ interface MapViewApi { channel.setMessageHandler(null) } } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getMapColorScheme$separatedMessageChannelSuffix", + codec, + ) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val viewIdArg = args[0] as Long + val wrapped: List = + try { + listOf(api.getMapColorScheme(viewIdArg)) + } catch (exception: Throwable) { + MessagesPigeonUtils.wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setMapColorScheme$separatedMessageChannelSuffix", + codec, + ) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val viewIdArg = args[0] as Long + val mapColorSchemeArg = args[1] as MapColorSchemeDto + val wrapped: List = + try { + api.setMapColorScheme(viewIdArg, mapColorSchemeArg) + listOf(null) + } catch (exception: Throwable) { + MessagesPigeonUtils.wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getForceNightMode$separatedMessageChannelSuffix", + codec, + ) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val viewIdArg = args[0] as Long + val wrapped: List = + try { + listOf(api.getForceNightMode(viewIdArg)) + } catch (exception: Throwable) { + MessagesPigeonUtils.wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } + run { + val channel = + BasicMessageChannel( + binaryMessenger, + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setForceNightMode$separatedMessageChannelSuffix", + codec, + ) + if (api != null) { + channel.setMessageHandler { message, reply -> + val args = message as List + val viewIdArg = args[0] as Long + val forceNightModeArg = args[1] as NavigationForceNightModeDto + val wrapped: List = + try { + api.setForceNightMode(viewIdArg, forceNightModeArg) + listOf(null) + } catch (exception: Throwable) { + MessagesPigeonUtils.wrapError(exception) + } + reply.reply(wrapped) + } + } else { + channel.setMessageHandler(null) + } + } } } } 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 4fe19f12..3f6c4ae3 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 @@ -374,6 +374,7 @@ internal class ConvertTest { minZoomPreference = 1.1, maxZoomPreference = 2.2, zoomControlsEnabled = false, + mapColorScheme = MapColorSchemeDto.DARK, ) val mapOptions = Convert.convertMapOptionsFromDto(testOptions) diff --git a/example/integration_test/t01_initialization_test.dart b/example/integration_test/t01_initialization_test.dart index 2a88e38e..67bbcca9 100644 --- a/example/integration_test/t01_initialization_test.dart +++ b/example/integration_test/t01_initialization_test.dart @@ -212,6 +212,9 @@ void main() { const double maxZoomPreference = 18.0; const NavigationUIEnabledPreference navigationUiEnabledPreference = NavigationUIEnabledPreference.disabled; + const MapColorScheme mapColorScheme = MapColorScheme.dark; + const NavigationForceNightMode forceNightMode = + NavigationForceNightMode.forceNight; /// Display navigation view. final Key key = GlobalKey(); @@ -247,6 +250,8 @@ void main() { initialMaxZoomPreference: maxZoomPreference, // ignore: avoid_redundant_argument_values initialNavigationUIEnabledPreference: navigationUiEnabledPreference, + initialMapColorScheme: mapColorScheme, + initialForceNightMode: forceNightMode, ), ); case TestMapType.mapView: @@ -270,6 +275,7 @@ void main() { initialZoomControlsEnabled: zoomControlsEnabled, initialMinZoomPreference: minZoomPreference, initialMaxZoomPreference: maxZoomPreference, + initialMapColorScheme: mapColorScheme, ), ); } @@ -349,6 +355,13 @@ void main() { maxZoomPreference, reason: 'Max zoom preference mismatch', ); + // Test map color scheme initial value + expect( + await controller.getMapColorScheme(), + mapColorScheme, + reason: 'Map color scheme mismatch', + ); + if (mapTypeVariants.currentValue == TestMapType.navigationView) { expect(controller, isA()); var navViewController = controller as GoogleNavigationViewController; @@ -357,6 +370,12 @@ void main() { false, reason: 'Navigation UI enabled mismatch', ); + // Test force night mode initial value (navigation view only) + expect( + await navViewController.getForceNightMode(), + forceNightMode, + reason: 'Force night mode mismatch', + ); } }, variant: mapTypeVariants); } diff --git a/example/integration_test/t04_navigation_ui_test.dart b/example/integration_test/t04_navigation_ui_test.dart index 3402c2cb..abb6e319 100644 --- a/example/integration_test/t04_navigation_ui_test.dart +++ b/example/integration_test/t04_navigation_ui_test.dart @@ -278,6 +278,41 @@ void main() { ); } + /// Test map color scheme getter and setter. + final List mapColorSchemes = [ + MapColorScheme.followSystem, + MapColorScheme.light, + MapColorScheme.dark, + MapColorScheme.followSystem, + ]; + for (final MapColorScheme scheme in mapColorSchemes) { + await viewController.setMapColorScheme(scheme); + await $.pumpAndSettle(); + final MapColorScheme currentScheme = + await viewController.getMapColorScheme(); + expect(currentScheme, scheme, reason: 'MapColorScheme should be $scheme'); + } + + /// Test force night mode getter and setter (navigation view only). + final List nightModes = + [ + NavigationForceNightMode.auto, + NavigationForceNightMode.forceDay, + NavigationForceNightMode.forceNight, + NavigationForceNightMode.auto, + ]; + for (final NavigationForceNightMode mode in nightModes) { + await viewController.setForceNightMode(mode); + await $.pumpAndSettle(); + final NavigationForceNightMode currentMode = + await viewController.getForceNightMode(); + expect( + currentMode, + mode, + reason: 'NavigationForceNightMode should be $mode', + ); + } + /// Test incident reporting availability. final bool isIncidentReportingAvailable = await viewController.isIncidentReportingAvailable(); diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 1f6b98f1..e717722e 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -25,6 +25,6 @@ arm64 MinimumOSVersion - 13.0 + 16.0 - + \ No newline at end of file diff --git a/example/ios/RunnerTests/ConvertTests.swift b/example/ios/RunnerTests/ConvertTests.swift index aea3c097..32f10ed1 100644 --- a/example/ios/RunnerTests/ConvertTests.swift +++ b/example/ios/RunnerTests/ConvertTests.swift @@ -552,13 +552,15 @@ class ConvertTests: XCTestCase { scrollGesturesEnabledDuringRotateOrZoom: false, mapToolbarEnabled: false, zoomControlsEnabled: false, - mapId: "test-map-id" + mapId: "test-map-id", + mapColorScheme: MapColorSchemeDto.dark ) let navigationViewOptions = NavigationViewOptionsDto( navigationUIEnabledPreference: NavigationUIEnabledPreferenceDto - .automatic) + .automatic, + forceNightMode: NavigationForceNightModeDto.forceNight) let configuration = Convert.convertMapOptions(mapOptions) @@ -586,6 +588,11 @@ class ConvertTests: XCTestCase { configuration.scrollGesturesEnabledDuringRotateOrZoom ) XCTAssertEqual(mapOptions.mapId, configuration.mapId) + XCTAssertEqual(configuration.mapColorScheme, UIUserInterfaceStyle.dark) + let convertedNightMode = Convert.convertNavigationForceNightMode( + forceNightMode: navigationViewOptions.forceNightMode + ) + XCTAssertEqual(convertedNightMode, GMSNavigationLightingMode.lowLight) } func testConvertPath() { diff --git a/example/lib/pages/map.dart b/example/lib/pages/map.dart index cad9affb..a3f66c77 100644 --- a/example/lib/pages/map.dart +++ b/example/lib/pages/map.dart @@ -50,6 +50,7 @@ class _MapPageState extends ExamplePageState { late bool isTiltGesturesEnabled = true; late bool isTrafficEnabled = false; late MapType mapType = MapType.normal; + late MapColorScheme mapColorScheme = MapColorScheme.followSystem; Future setMapType(MapType type) async { mapType = type; @@ -75,12 +76,31 @@ class _MapPageState extends ExamplePageState { await _mapViewController.setMapStyle(jsonString); } + Future getMapColorScheme() async { + final MapColorScheme colorScheme = + await _mapViewController.getMapColorScheme(); + setState(() { + mapColorScheme = colorScheme; + }); + } + + Future setMapColorScheme(MapColorScheme scheme) async { + await _mapViewController.setMapColorScheme(scheme); + await getMapColorScheme(); + } + // ignore: use_setters_to_change_properties Future _onViewCreated(GoogleMapViewController controller) async { _mapViewController = controller; setState(() {}); } + // Adds day/night mode toggle button to app bar. + @override + List? getAppBarActions() { + return [_colorSchemeToggle]; + } + void _showMessage(String message) { ScaffoldMessenger.of(context).removeCurrentSnackBar(); final SnackBar snackBar = SnackBar( @@ -198,6 +218,51 @@ class _MapPageState extends ExamplePageState { ); } + Widget get _colorSchemeToggle => Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), + child: InkWell( + onTap: _cycleColorScheme, + child: Container( + padding: const EdgeInsets.all(8), + child: Icon( + _getColorSchemeIcon(), + size: 30, + color: Theme.of(context).colorScheme.primary, + ), + ), + ), + ); + + IconData _getColorSchemeIcon() { + switch (mapColorScheme) { + case MapColorScheme.light: + return Icons.brightness_7; + case MapColorScheme.dark: + return Icons.brightness_3; + case MapColorScheme.followSystem: + return Icons.brightness_auto; + } + } + + Future _cycleColorScheme() async { + setState(() { + switch (mapColorScheme) { + case MapColorScheme.followSystem: + mapColorScheme = MapColorScheme.light; + case MapColorScheme.light: + mapColorScheme = MapColorScheme.dark; + case MapColorScheme.dark: + mapColorScheme = MapColorScheme.followSystem; + } + }); + + try { + await setMapColorScheme(mapColorScheme); + } catch (e) { + _showMessage('Failed to update color scheme: $e'); + } + } + @override Widget buildOverlayContent(BuildContext context) { return Column( @@ -358,7 +423,42 @@ class _MapPageState extends ExamplePageState { title: const Text('Enable traffic'), value: isTrafficEnabled, ), + const Divider(), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Map Color Scheme:', + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + const SizedBox(height: 8), + Wrap( + spacing: 8, + children: [ + _buildColorSchemeChip(MapColorScheme.followSystem, 'Auto'), + _buildColorSchemeChip(MapColorScheme.light, 'Light'), + _buildColorSchemeChip(MapColorScheme.dark, 'Dark'), + ], + ), + ], + ), + ), ], ); } + + Widget _buildColorSchemeChip(MapColorScheme scheme, String label) { + final bool isSelected = mapColorScheme == scheme; + return FilterChip( + label: Text(label), + selected: isSelected, + onSelected: (bool selected) async { + if (selected) { + await setMapColorScheme(scheme); + } + }, + ); + } } diff --git a/example/lib/pages/navigation.dart b/example/lib/pages/navigation.dart index c2b3c77b..7ea6ba65 100644 --- a/example/lib/pages/navigation.dart +++ b/example/lib/pages/navigation.dart @@ -127,6 +127,8 @@ class _NavigationPageState extends ExamplePageState { SimulationState _simulationState = SimulationState.notRunning; NavigationTravelMode _travelMode = NavigationTravelMode.driving; final List _waypoints = []; + MapColorScheme _mapColorScheme = MapColorScheme.followSystem; + NavigationForceNightMode _forceNightMode = NavigationForceNightMode.auto; /// If true, route tokens and Routes API are used to calculate the route. bool _routeTokensEnabled = false; @@ -178,6 +180,12 @@ class _NavigationPageState extends ExamplePageState { super.dispose(); } + // Adds day/night mode toggle button to app bar. + @override + List? getAppBarActions() { + return [_colorSchemeToggle]; + } + Future _initialize() async { // Check if terms and conditions have been accepted and show dialog if not. await _showTermsAndConditionsDialogIfNeeded(); @@ -1207,7 +1215,7 @@ class _NavigationPageState extends ExamplePageState { children: [ Column( children: [ - _travelModeSelection, + _topBarControls, Expanded( child: _navigatorInitializedAtLeastOnce && _userLocation != null @@ -1231,6 +1239,8 @@ class _NavigationPageState extends ExamplePageState { : NavigationUIEnabledPreference.disabled, initialPadding: const EdgeInsets.all(0), mapId: MapIdManager.instance.mapId, + initialMapColorScheme: _mapColorScheme, + initialForceNightMode: _forceNightMode, ) : const Center( child: Column( @@ -1837,6 +1847,66 @@ class _NavigationPageState extends ExamplePageState { }); }, ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Map Color Scheme:', + style: TextStyle(fontSize: 16), + ), + const SizedBox(height: 8), + Wrap( + spacing: 8, + children: [ + _buildColorSchemeChip( + MapColorScheme.followSystem, + 'Auto', + ), + _buildColorSchemeChip(MapColorScheme.light, 'Light'), + _buildColorSchemeChip(MapColorScheme.dark, 'Dark'), + ], + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 8, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Navigation Night Mode:', + style: TextStyle(fontSize: 16), + ), + const SizedBox(height: 8), + Wrap( + spacing: 8, + children: [ + _buildNightModeChip( + NavigationForceNightMode.auto, + 'Auto', + ), + _buildNightModeChip( + NavigationForceNightMode.forceDay, + 'Day', + ), + _buildNightModeChip( + NavigationForceNightMode.forceNight, + 'Night', + ), + ], + ), + ], + ), + ), Text( 'Map left padding: ${_mapPadding.left.toStringAsFixed(0)}', ), @@ -2083,7 +2153,56 @@ class _NavigationPageState extends ExamplePageState { ); } - Widget get _travelModeSelection => Row( + Widget get _colorSchemeToggle => Padding( + padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), + child: InkWell( + onTap: _cycleColorScheme, + child: Container( + padding: const EdgeInsets.all(8), + child: Icon( + _getColorSchemeIcon(), + size: 30, + color: Theme.of(context).colorScheme.primary, + ), + ), + ), + ); + + IconData _getColorSchemeIcon() { + switch (_mapColorScheme) { + case MapColorScheme.light: + return Icons.brightness_7; + case MapColorScheme.dark: + return Icons.brightness_3; + case MapColorScheme.followSystem: + return Icons.brightness_auto; + } + } + + Future _cycleColorScheme() async { + setState(() { + switch (_mapColorScheme) { + case MapColorScheme.followSystem: + _mapColorScheme = MapColorScheme.light; + _forceNightMode = NavigationForceNightMode.forceDay; + case MapColorScheme.light: + _mapColorScheme = MapColorScheme.dark; + _forceNightMode = NavigationForceNightMode.forceNight; + case MapColorScheme.dark: + _mapColorScheme = MapColorScheme.followSystem; + _forceNightMode = NavigationForceNightMode.auto; + } + }); + + try { + await _navigationViewController?.setMapColorScheme(_mapColorScheme); + await _navigationViewController?.setForceNightMode(_forceNightMode); + } catch (e) { + showMessage('Failed to update color scheme: $e'); + } + } + + Widget get _topBarControls => Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ _buildTravelModeChoice( @@ -2152,6 +2271,46 @@ class _NavigationPageState extends ExamplePageState { } } + Widget _buildColorSchemeChip(MapColorScheme scheme, String label) { + final bool isSelected = _mapColorScheme == scheme; + return FilterChip( + label: Text(label), + selected: isSelected, + onSelected: (bool selected) async { + if (selected) { + setState(() { + _mapColorScheme = scheme; + }); + try { + await _navigationViewController?.setMapColorScheme(scheme); + } catch (e) { + showMessage('Failed to set map color scheme: $e'); + } + } + }, + ); + } + + Widget _buildNightModeChip(NavigationForceNightMode mode, String label) { + final bool isSelected = _forceNightMode == mode; + return FilterChip( + label: Text(label), + selected: isSelected, + onSelected: (bool selected) async { + if (selected) { + setState(() { + _forceNightMode = mode; + }); + try { + await _navigationViewController?.setForceNightMode(mode); + } catch (e) { + showMessage('Failed to set force night mode: $e'); + } + } + }, + ); + } + void showMessage(String message) { if (isOverlayVisible) { showOverlaySnackBar(message); diff --git a/example/lib/pages/widget_initialization.dart b/example/lib/pages/widget_initialization.dart index 532a24c8..72c04db7 100644 --- a/example/lib/pages/widget_initialization.dart +++ b/example/lib/pages/widget_initialization.dart @@ -54,6 +54,9 @@ class _ViewInitializationPageState EdgeInsets? _initialPadding; NavigationUIEnabledPreference _initialNavigationUIEnabledPreference = NavigationUIEnabledPreference.automatic; + MapColorScheme _initialMapColorScheme = MapColorScheme.followSystem; + NavigationForceNightMode _initialForceNightMode = + NavigationForceNightMode.auto; TextDirection? _layoutDirection; bool _isMinZoomPreferenceEnabled = false; bool _isMaxZoomPreferenceEnabled = false; @@ -115,6 +118,8 @@ class _ViewInitializationPageState initialPadding: _initialPadding, initialNavigationUIEnabledPreference: _initialNavigationUIEnabledPreference, + initialMapColorScheme: _initialMapColorScheme, + initialForceNightMode: _initialForceNightMode, layoutDirection: _layoutDirection, ), ), @@ -140,6 +145,11 @@ class _ViewInitializationPageState await _updateNavigationInitializationState(); } + Future _disposeNavigation() async { + await GoogleMapsNavigator.cleanup(); + await _updateNavigationInitializationState(); + } + @override Widget build(BuildContext context) => buildPage( context, @@ -198,6 +208,17 @@ class _ViewInitializationPageState }); }, ), + ExampleDropdownButton( + title: 'Map Color Scheme', + value: _initialMapColorScheme, + items: MapColorScheme.values, + onChanged: (MapColorScheme? newValue) { + setState(() { + _initialMapColorScheme = + newValue ?? MapColorScheme.followSystem; + }); + }, + ), ExampleDropdownButton( title: 'Layout direction', value: _layoutDirection, @@ -386,6 +407,17 @@ class _ViewInitializationPageState }); }, ), + ExampleDropdownButton( + title: 'Navigation Force Night Mode', + value: _initialForceNightMode, + items: NavigationForceNightMode.values, + onChanged: (NavigationForceNightMode? newValue) { + setState(() { + _initialForceNightMode = + newValue ?? NavigationForceNightMode.auto; + }); + }, + ), ], ), ], @@ -400,9 +432,14 @@ class _ViewInitializationPageState spacing: 10, children: [ ElevatedButton( - onPressed: !_navigationInitialized ? _startNavigation : null, + onPressed: + _navigationInitialized + ? _disposeNavigation + : _startNavigation, child: Text( - _navigationInitialized ? 'Initialized' : 'Init navigation', + _navigationInitialized + ? 'Dispose navigation' + : 'Init navigation', ), ), ElevatedButton( @@ -434,6 +471,8 @@ class _InitializedViewPage extends StatelessWidget { required this.initialCameraTargetBounds, required this.initialPadding, required this.initialNavigationUIEnabledPreference, + required this.initialMapColorScheme, + required this.initialForceNightMode, required this.layoutDirection, }); @@ -453,6 +492,8 @@ class _InitializedViewPage extends StatelessWidget { final LatLngBounds? initialCameraTargetBounds; final EdgeInsets? initialPadding; final NavigationUIEnabledPreference initialNavigationUIEnabledPreference; + final MapColorScheme initialMapColorScheme; + final NavigationForceNightMode initialForceNightMode; @override Widget build(BuildContext context) { @@ -486,6 +527,8 @@ class _InitializedViewPage extends StatelessWidget { initialPadding: initialPadding, initialNavigationUIEnabledPreference: initialNavigationUIEnabledPreference, + initialMapColorScheme: initialMapColorScheme, + initialForceNightMode: initialForceNightMode, mapId: MapIdManager.instance.mapId, ), ); diff --git a/example/lib/widgets/page.dart b/example/lib/widgets/page.dart index 87017d1a..e1a66128 100644 --- a/example/lib/widgets/page.dart +++ b/example/lib/widgets/page.dart @@ -90,13 +90,23 @@ abstract class ExamplePageState extends State throw UnimplementedError(); } + /// Returns custom actions for the AppBar. + /// Override this method to add custom actions to the AppBar. + @protected + List? getAppBarActions() { + return null; + } + /// Wraps page content with scaffold and overlay. @protected Widget buildPage(BuildContext context, WidgetBuilder builder) { return Stack( children: [ Scaffold( - appBar: AppBar(title: Text(widget.title)), + appBar: AppBar( + title: Text(widget.title), + actions: getAppBarActions(), + ), body: Builder(builder: (BuildContext context) => builder(context)), ), if (_isOverlayVisible) _buildOverlay(), diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/BaseCarSceneDelegate.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/BaseCarSceneDelegate.swift index ea50269c..577ea77a 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/BaseCarSceneDelegate.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/BaseCarSceneDelegate.swift @@ -86,6 +86,7 @@ open class BaseCarSceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate viewRegistry: viewRegistry, viewEventApi: nil, navigationUIEnabledPreference: NavigationUIEnabledPreference.automatic, + forceNightMode: nil, mapConfiguration: MapConfiguration( cameraPosition: nil, mapType: .normal, @@ -94,7 +95,8 @@ open class BaseCarSceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate scrollGesturesEnabled: true, tiltGesturesEnabled: false, zoomGesturesEnabled: true, - scrollGesturesEnabledDuringRotateOrZoom: false + scrollGesturesEnabledDuringRotateOrZoom: false, + mapColorScheme: .unspecified ), imageRegistry: imageRegistry, isCarPlayView: true 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 6002ba35..a4433d07 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 @@ -57,7 +57,8 @@ extension Convert { bottom: CGFloat(mapOptions.padding?.bottom ?? 0), right: CGFloat(mapOptions.padding?.right ?? 0) ), - mapId: mapOptions.mapId + mapId: mapOptions.mapId, + mapColorScheme: convertMapColorScheme(mapColorScheme: mapOptions.mapColorScheme) ) } } diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert.swift index 6e2d78dd..24f1840a 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/Convert.swift @@ -49,6 +49,60 @@ enum Convert { } } + static func convertMapColorScheme(mapColorScheme: MapColorSchemeDto) -> UIUserInterfaceStyle { + switch mapColorScheme { + case .followSystem: + return .unspecified + case .light: + return .light + case .dark: + return .dark + } + } + + static func convertMapColorScheme(uiUserInterfaceStyle: UIUserInterfaceStyle) -> MapColorSchemeDto + { + switch uiUserInterfaceStyle { + case .light: + return .light + case .dark: + return .dark + case .unspecified: + return .followSystem + @unknown default: + return .followSystem + } + } + + static func convertNavigationForceNightMode(forceNightMode: NavigationForceNightModeDto) + -> GMSNavigationLightingMode? + { + switch forceNightMode { + case .auto: + return nil + case .forceDay: + return .normal + case .forceNight: + return .lowLight + } + } + + static func convertNavigationForceNightMode(gmsNavigationLightingMode: GMSNavigationLightingMode?) + -> NavigationForceNightModeDto + { + guard let gmsNavigationLightingMode else { + return .auto + } + switch gmsNavigationLightingMode { + case .normal: + return .forceDay + case .lowLight: + return .forceNight + @unknown default: + return .auto + } + } + static func convertCameraPosition(position: GMSCameraPosition) -> CameraPositionDto { let target = LatLngDto( latitude: position.target.latitude, 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 e79419fa..f49b5323 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationView.swift @@ -41,6 +41,7 @@ public class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettle private var _gmsCircles: [GMSCircle] = [] private var _mapConfiguration: MapConfiguration! private var _navigationUIEnabledPreference: NavigationUIEnabledPreference! + private var _forceNightMode: GMSNavigationLightingMode? private var _mapViewReady: Bool = false private var _mapReadyCallback: ((Result) -> Void)? @@ -74,6 +75,7 @@ public class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettle viewRegistry registry: GoogleMapsNavigationViewRegistry, viewEventApi: ViewEventApi?, navigationUIEnabledPreference: NavigationUIEnabledPreference, + forceNightMode: GMSNavigationLightingMode?, mapConfiguration: MapConfiguration, imageRegistry: ImageRegistry, isCarPlayView: Bool @@ -89,6 +91,7 @@ public class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettle _mapConfiguration = mapConfiguration _imageRegistry = imageRegistry _isCarPlayView = isCarPlayView + _forceNightMode = forceNightMode let mapViewOptions = GMSMapViewOptions() _mapConfiguration.apply(to: mapViewOptions, withFrame: frame) @@ -103,6 +106,11 @@ public class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettle _navigationUIEnabledPreference = navigationUIEnabledPreference applyNavigationUIEnabledPreference() + + // Apply force night mode if this is a navigation view + if _isNavigationView { + applyForceNightMode() + } } deinit { @@ -166,6 +174,34 @@ public class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettle setNavigationUIEnabled(navigationUIEnabled) } + func applyForceNightMode() { + guard _isNavigationView else { return } + if let mode = _forceNightMode { + _mapView.lightingMode = mode + } else { + // Allow the SDK to determine the lighting mode automatically. + // Use perform selector to call setLightingMode: with nil (Objective-C style) + if _mapView.responds(to: Selector(("setLightingMode:"))) { + _mapView.perform(Selector(("setLightingMode:")), with: nil) + } + } + } + + func getForceNightMode() throws -> GMSNavigationLightingMode? { + guard _isNavigationView else { + throw GoogleMapsNavigationViewError.notSupported + } + return _forceNightMode + } + + func setForceNightMode(_ mode: GMSNavigationLightingMode?) throws { + guard _isNavigationView else { + throw GoogleMapsNavigationViewError.notSupported + } + _forceNightMode = mode + applyForceNightMode() + } + func awaitMapReady(callback: @escaping (Result) -> Void) { if _mapViewReady { callback(.success(())) @@ -241,6 +277,14 @@ public class GoogleMapsNavigationView: NSObject, FlutterPlatformView, ViewSettle _mapView.mapType = mapType } + public func getMapColorScheme() -> UIUserInterfaceStyle { + _mapView.overrideUserInterfaceStyle + } + + public func setMapColorScheme(colorScheme: UIUserInterfaceStyle) { + _mapView.overrideUserInterfaceStyle = colorScheme + } + func setMapStyle(styleJson: String) throws { do { _mapView.mapStyle = try GMSMapStyle(jsonString: styleJson) diff --git a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewFactory.swift b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewFactory.swift index 4171bc80..ee8badd6 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewFactory.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewFactory.swift @@ -58,6 +58,10 @@ class GoogleMapsNavigationViewFactory: NSObject, FlutterPlatformViewFactory { .convertNavigationUIEnabledPreference( preference: params.navigationViewOptions? .navigationUIEnabledPreference), + forceNightMode: + Convert + .convertNavigationForceNightMode( + forceNightMode: params.navigationViewOptions?.forceNightMode ?? .auto), mapConfiguration: mapConfiguration, imageRegistry: imageRegistry, isCarPlayView: false 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 521e540b..4534ceb1 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewMessageHandler.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/GoogleMapsNavigationViewMessageHandler.swift @@ -577,4 +577,24 @@ class GoogleMapsNavigationViewMessageHandler: MapViewApi { func getPadding(viewId: Int64) throws -> MapPaddingDto { try getView(viewId).getPadding() } + + func getMapColorScheme(viewId: Int64) throws -> MapColorSchemeDto { + let colorScheme = try getView(viewId).getMapColorScheme() + return Convert.convertMapColorScheme(uiUserInterfaceStyle: colorScheme) + } + + func setMapColorScheme(viewId: Int64, mapColorScheme: MapColorSchemeDto) throws { + let colorScheme = Convert.convertMapColorScheme(mapColorScheme: mapColorScheme) + try getView(viewId).setMapColorScheme(colorScheme: colorScheme) + } + + func getForceNightMode(viewId: Int64) throws -> NavigationForceNightModeDto { + let mode = try getView(viewId).getForceNightMode() + return Convert.convertNavigationForceNightMode(gmsNavigationLightingMode: mode) + } + + func setForceNightMode(viewId: Int64, forceNightMode: NavigationForceNightModeDto) throws { + let mode = Convert.convertNavigationForceNightMode(forceNightMode: forceNightMode) + try getView(viewId).setForceNightMode(mode) + } } 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 105b29c7..2a0ae047 100644 --- a/ios/google_navigation_flutter/Sources/google_navigation_flutter/MapConfiguration.swift +++ b/ios/google_navigation_flutter/Sources/google_navigation_flutter/MapConfiguration.swift @@ -39,6 +39,7 @@ struct MapConfiguration { var maxZoomPreference: Float? var padding: UIEdgeInsets? var mapId: String? + var mapColorScheme: UIUserInterfaceStyle } extension MapConfiguration { @@ -47,6 +48,7 @@ extension MapConfiguration { // - Parameter to: The GMSMapView to configure. func apply(to mapView: GMSMapView) { mapView.mapType = mapType + mapView.overrideUserInterfaceStyle = mapColorScheme mapView.settings.compassButton = compassEnabled mapView.settings.rotateGestures = rotateGesturesEnabled mapView.settings.scrollGestures = scrollGesturesEnabled 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 6fb465f2..d424aa11 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 @@ -171,6 +171,26 @@ enum MapTypeDto: Int { case hybrid = 4 } +/// Map color scheme mode. +enum MapColorSchemeDto: Int { + /// Follow system or SDK default (automatic). + case followSystem = 0 + /// Force light color scheme. + case light = 1 + /// Force dark color scheme. + case dark = 2 +} + +/// Navigation night mode. +enum NavigationForceNightModeDto: Int { + /// Let the SDK automatically determine day or night. + case auto = 0 + /// Force day mode regardless of time or location. + case forceDay = 1 + /// Force night mode regardless of time or location. + case forceNight = 2 +} + enum CameraPerspectiveDto: Int { case tilted = 0 case topDownHeadingUp = 1 @@ -500,6 +520,8 @@ struct MapOptionsDto: Hashable { /// The map ID for advanced map options eg. cloud-based map styling. /// This value can only be set on map initialization and cannot be changed afterwards. var mapId: String? = nil + /// The map color scheme mode for the map view. + var mapColorScheme: MapColorSchemeDto // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> MapOptionsDto? { @@ -518,6 +540,7 @@ struct MapOptionsDto: Hashable { let cameraTargetBounds: LatLngBoundsDto? = nilOrValue(pigeonVar_list[12]) let padding: MapPaddingDto? = nilOrValue(pigeonVar_list[13]) let mapId: String? = nilOrValue(pigeonVar_list[14]) + let mapColorScheme = pigeonVar_list[15] as! MapColorSchemeDto return MapOptionsDto( cameraPosition: cameraPosition, @@ -534,7 +557,8 @@ struct MapOptionsDto: Hashable { zoomControlsEnabled: zoomControlsEnabled, cameraTargetBounds: cameraTargetBounds, padding: padding, - mapId: mapId + mapId: mapId, + mapColorScheme: mapColorScheme ) } func toList() -> [Any?] { @@ -554,6 +578,7 @@ struct MapOptionsDto: Hashable { cameraTargetBounds, padding, mapId, + mapColorScheme, ] } static func == (lhs: MapOptionsDto, rhs: MapOptionsDto) -> Bool { @@ -570,18 +595,23 @@ struct MapOptionsDto: Hashable { struct NavigationViewOptionsDto: Hashable { /// Determines the initial visibility of the navigation UI on map initialization. var navigationUIEnabledPreference: NavigationUIEnabledPreferenceDto + /// Controls the navigation night mode for Navigation UI. + var forceNightMode: NavigationForceNightModeDto // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> NavigationViewOptionsDto? { let navigationUIEnabledPreference = pigeonVar_list[0] as! NavigationUIEnabledPreferenceDto + let forceNightMode = pigeonVar_list[1] as! NavigationForceNightModeDto return NavigationViewOptionsDto( - navigationUIEnabledPreference: navigationUIEnabledPreference + navigationUIEnabledPreference: navigationUIEnabledPreference, + forceNightMode: forceNightMode ) } func toList() -> [Any?] { return [ - navigationUIEnabledPreference + navigationUIEnabledPreference, + forceNightMode, ] } static func == (lhs: NavigationViewOptionsDto, rhs: NavigationViewOptionsDto) -> Bool { @@ -2094,199 +2124,211 @@ private class MessagesPigeonCodecReader: FlutterStandardReader { case 132: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return CameraPerspectiveDto(rawValue: enumResultAsInt) + return MapColorSchemeDto(rawValue: enumResultAsInt) } return nil case 133: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return MarkerEventTypeDto(rawValue: enumResultAsInt) + return NavigationForceNightModeDto(rawValue: enumResultAsInt) } return nil case 134: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return MarkerDragEventTypeDto(rawValue: enumResultAsInt) + return CameraPerspectiveDto(rawValue: enumResultAsInt) } return nil case 135: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return StrokeJointTypeDto(rawValue: enumResultAsInt) + return MarkerEventTypeDto(rawValue: enumResultAsInt) } return nil case 136: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return PatternTypeDto(rawValue: enumResultAsInt) + return MarkerDragEventTypeDto(rawValue: enumResultAsInt) } return nil case 137: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return CameraEventTypeDto(rawValue: enumResultAsInt) + return StrokeJointTypeDto(rawValue: enumResultAsInt) } return nil case 138: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return AlternateRoutesStrategyDto(rawValue: enumResultAsInt) + return PatternTypeDto(rawValue: enumResultAsInt) } return nil case 139: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return RoutingStrategyDto(rawValue: enumResultAsInt) + return CameraEventTypeDto(rawValue: enumResultAsInt) } return nil case 140: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return TravelModeDto(rawValue: enumResultAsInt) + return AlternateRoutesStrategyDto(rawValue: enumResultAsInt) } return nil case 141: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return RouteStatusDto(rawValue: enumResultAsInt) + return RoutingStrategyDto(rawValue: enumResultAsInt) } return nil case 142: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return AudioGuidanceTypeDto(rawValue: enumResultAsInt) + return TravelModeDto(rawValue: enumResultAsInt) } return nil case 143: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return SpeedAlertSeverityDto(rawValue: enumResultAsInt) + return RouteStatusDto(rawValue: enumResultAsInt) } return nil case 144: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return RouteSegmentTrafficDataStatusDto(rawValue: enumResultAsInt) + return AudioGuidanceTypeDto(rawValue: enumResultAsInt) } return nil case 145: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto(rawValue: enumResultAsInt) + return SpeedAlertSeverityDto(rawValue: enumResultAsInt) } return nil case 146: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return ManeuverDto(rawValue: enumResultAsInt) + return RouteSegmentTrafficDataStatusDto(rawValue: enumResultAsInt) } return nil case 147: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return DrivingSideDto(rawValue: enumResultAsInt) + return RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto(rawValue: enumResultAsInt) } return nil case 148: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return NavStateDto(rawValue: enumResultAsInt) + return ManeuverDto(rawValue: enumResultAsInt) } return nil case 149: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return LaneShapeDto(rawValue: enumResultAsInt) + return DrivingSideDto(rawValue: enumResultAsInt) } return nil case 150: let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { - return TaskRemovedBehaviorDto(rawValue: enumResultAsInt) + return NavStateDto(rawValue: enumResultAsInt) } return nil case 151: - return MapOptionsDto.fromList(self.readValue() as! [Any?]) + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) + if let enumResultAsInt = enumResultAsInt { + return LaneShapeDto(rawValue: enumResultAsInt) + } + return nil case 152: - return NavigationViewOptionsDto.fromList(self.readValue() as! [Any?]) + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) + if let enumResultAsInt = enumResultAsInt { + return TaskRemovedBehaviorDto(rawValue: enumResultAsInt) + } + return nil case 153: - return ViewCreationOptionsDto.fromList(self.readValue() as! [Any?]) + return MapOptionsDto.fromList(self.readValue() as! [Any?]) case 154: - return CameraPositionDto.fromList(self.readValue() as! [Any?]) + return NavigationViewOptionsDto.fromList(self.readValue() as! [Any?]) case 155: - return MarkerDto.fromList(self.readValue() as! [Any?]) + return ViewCreationOptionsDto.fromList(self.readValue() as! [Any?]) case 156: - return MarkerOptionsDto.fromList(self.readValue() as! [Any?]) + return CameraPositionDto.fromList(self.readValue() as! [Any?]) case 157: - return ImageDescriptorDto.fromList(self.readValue() as! [Any?]) + return MarkerDto.fromList(self.readValue() as! [Any?]) case 158: - return InfoWindowDto.fromList(self.readValue() as! [Any?]) + return MarkerOptionsDto.fromList(self.readValue() as! [Any?]) case 159: - return MarkerAnchorDto.fromList(self.readValue() as! [Any?]) + return ImageDescriptorDto.fromList(self.readValue() as! [Any?]) case 160: - return PolygonDto.fromList(self.readValue() as! [Any?]) + return InfoWindowDto.fromList(self.readValue() as! [Any?]) case 161: - return PolygonOptionsDto.fromList(self.readValue() as! [Any?]) + return MarkerAnchorDto.fromList(self.readValue() as! [Any?]) case 162: - return PolygonHoleDto.fromList(self.readValue() as! [Any?]) + return PolygonDto.fromList(self.readValue() as! [Any?]) case 163: - return StyleSpanStrokeStyleDto.fromList(self.readValue() as! [Any?]) + return PolygonOptionsDto.fromList(self.readValue() as! [Any?]) case 164: - return StyleSpanDto.fromList(self.readValue() as! [Any?]) + return PolygonHoleDto.fromList(self.readValue() as! [Any?]) case 165: - return PolylineDto.fromList(self.readValue() as! [Any?]) + return StyleSpanStrokeStyleDto.fromList(self.readValue() as! [Any?]) case 166: - return PatternItemDto.fromList(self.readValue() as! [Any?]) + return StyleSpanDto.fromList(self.readValue() as! [Any?]) case 167: - return PolylineOptionsDto.fromList(self.readValue() as! [Any?]) + return PolylineDto.fromList(self.readValue() as! [Any?]) case 168: - return CircleDto.fromList(self.readValue() as! [Any?]) + return PatternItemDto.fromList(self.readValue() as! [Any?]) case 169: - return CircleOptionsDto.fromList(self.readValue() as! [Any?]) + return PolylineOptionsDto.fromList(self.readValue() as! [Any?]) case 170: - return MapPaddingDto.fromList(self.readValue() as! [Any?]) + return CircleDto.fromList(self.readValue() as! [Any?]) case 171: - return RouteTokenOptionsDto.fromList(self.readValue() as! [Any?]) + return CircleOptionsDto.fromList(self.readValue() as! [Any?]) case 172: - return DestinationsDto.fromList(self.readValue() as! [Any?]) + return MapPaddingDto.fromList(self.readValue() as! [Any?]) case 173: - return RoutingOptionsDto.fromList(self.readValue() as! [Any?]) + return RouteTokenOptionsDto.fromList(self.readValue() as! [Any?]) case 174: - return NavigationDisplayOptionsDto.fromList(self.readValue() as! [Any?]) + return DestinationsDto.fromList(self.readValue() as! [Any?]) case 175: - return NavigationWaypointDto.fromList(self.readValue() as! [Any?]) + return RoutingOptionsDto.fromList(self.readValue() as! [Any?]) case 176: - return NavigationTimeAndDistanceDto.fromList(self.readValue() as! [Any?]) + return NavigationDisplayOptionsDto.fromList(self.readValue() as! [Any?]) case 177: - return NavigationAudioGuidanceSettingsDto.fromList(self.readValue() as! [Any?]) + return NavigationWaypointDto.fromList(self.readValue() as! [Any?]) case 178: - return SimulationOptionsDto.fromList(self.readValue() as! [Any?]) + return NavigationTimeAndDistanceDto.fromList(self.readValue() as! [Any?]) case 179: - return LatLngDto.fromList(self.readValue() as! [Any?]) + return NavigationAudioGuidanceSettingsDto.fromList(self.readValue() as! [Any?]) case 180: - return LatLngBoundsDto.fromList(self.readValue() as! [Any?]) + return SimulationOptionsDto.fromList(self.readValue() as! [Any?]) case 181: - return SpeedingUpdatedEventDto.fromList(self.readValue() as! [Any?]) + return LatLngDto.fromList(self.readValue() as! [Any?]) case 182: - return GpsAvailabilityChangeEventDto.fromList(self.readValue() as! [Any?]) + return LatLngBoundsDto.fromList(self.readValue() as! [Any?]) case 183: - return SpeedAlertOptionsThresholdPercentageDto.fromList(self.readValue() as! [Any?]) + return SpeedingUpdatedEventDto.fromList(self.readValue() as! [Any?]) case 184: - return SpeedAlertOptionsDto.fromList(self.readValue() as! [Any?]) + return GpsAvailabilityChangeEventDto.fromList(self.readValue() as! [Any?]) case 185: + return SpeedAlertOptionsThresholdPercentageDto.fromList(self.readValue() as! [Any?]) + case 186: + return SpeedAlertOptionsDto.fromList(self.readValue() as! [Any?]) + case 187: return RouteSegmentTrafficDataRoadStretchRenderingDataDto.fromList( self.readValue() as! [Any?]) - case 186: + case 188: return RouteSegmentTrafficDataDto.fromList(self.readValue() as! [Any?]) - case 187: + case 189: return RouteSegmentDto.fromList(self.readValue() as! [Any?]) - case 188: + case 190: return LaneDirectionDto.fromList(self.readValue() as! [Any?]) - case 189: + case 191: return LaneDto.fromList(self.readValue() as! [Any?]) - case 190: + case 192: return StepInfoDto.fromList(self.readValue() as! [Any?]) - case 191: + case 193: return NavInfoDto.fromList(self.readValue() as! [Any?]) default: return super.readValue(ofType: type) @@ -2305,185 +2347,191 @@ private class MessagesPigeonCodecWriter: FlutterStandardWriter { } else if let value = value as? MapTypeDto { super.writeByte(131) super.writeValue(value.rawValue) - } else if let value = value as? CameraPerspectiveDto { + } else if let value = value as? MapColorSchemeDto { super.writeByte(132) super.writeValue(value.rawValue) - } else if let value = value as? MarkerEventTypeDto { + } else if let value = value as? NavigationForceNightModeDto { super.writeByte(133) super.writeValue(value.rawValue) - } else if let value = value as? MarkerDragEventTypeDto { + } else if let value = value as? CameraPerspectiveDto { super.writeByte(134) super.writeValue(value.rawValue) - } else if let value = value as? StrokeJointTypeDto { + } else if let value = value as? MarkerEventTypeDto { super.writeByte(135) super.writeValue(value.rawValue) - } else if let value = value as? PatternTypeDto { + } else if let value = value as? MarkerDragEventTypeDto { super.writeByte(136) super.writeValue(value.rawValue) - } else if let value = value as? CameraEventTypeDto { + } else if let value = value as? StrokeJointTypeDto { super.writeByte(137) super.writeValue(value.rawValue) - } else if let value = value as? AlternateRoutesStrategyDto { + } else if let value = value as? PatternTypeDto { super.writeByte(138) super.writeValue(value.rawValue) - } else if let value = value as? RoutingStrategyDto { + } else if let value = value as? CameraEventTypeDto { super.writeByte(139) super.writeValue(value.rawValue) - } else if let value = value as? TravelModeDto { + } else if let value = value as? AlternateRoutesStrategyDto { super.writeByte(140) super.writeValue(value.rawValue) - } else if let value = value as? RouteStatusDto { + } else if let value = value as? RoutingStrategyDto { super.writeByte(141) super.writeValue(value.rawValue) - } else if let value = value as? AudioGuidanceTypeDto { + } else if let value = value as? TravelModeDto { super.writeByte(142) super.writeValue(value.rawValue) - } else if let value = value as? SpeedAlertSeverityDto { + } else if let value = value as? RouteStatusDto { super.writeByte(143) super.writeValue(value.rawValue) - } else if let value = value as? RouteSegmentTrafficDataStatusDto { + } else if let value = value as? AudioGuidanceTypeDto { super.writeByte(144) super.writeValue(value.rawValue) - } else if let value = value as? RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto { + } else if let value = value as? SpeedAlertSeverityDto { super.writeByte(145) super.writeValue(value.rawValue) - } else if let value = value as? ManeuverDto { + } else if let value = value as? RouteSegmentTrafficDataStatusDto { super.writeByte(146) super.writeValue(value.rawValue) - } else if let value = value as? DrivingSideDto { + } else if let value = value as? RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto { super.writeByte(147) super.writeValue(value.rawValue) - } else if let value = value as? NavStateDto { + } else if let value = value as? ManeuverDto { super.writeByte(148) super.writeValue(value.rawValue) - } else if let value = value as? LaneShapeDto { + } else if let value = value as? DrivingSideDto { super.writeByte(149) super.writeValue(value.rawValue) - } else if let value = value as? TaskRemovedBehaviorDto { + } else if let value = value as? NavStateDto { super.writeByte(150) super.writeValue(value.rawValue) - } else if let value = value as? MapOptionsDto { + } else if let value = value as? LaneShapeDto { super.writeByte(151) + super.writeValue(value.rawValue) + } else if let value = value as? TaskRemovedBehaviorDto { + super.writeByte(152) + super.writeValue(value.rawValue) + } else if let value = value as? MapOptionsDto { + super.writeByte(153) super.writeValue(value.toList()) } else if let value = value as? NavigationViewOptionsDto { - super.writeByte(152) + super.writeByte(154) super.writeValue(value.toList()) } else if let value = value as? ViewCreationOptionsDto { - super.writeByte(153) + super.writeByte(155) super.writeValue(value.toList()) } else if let value = value as? CameraPositionDto { - super.writeByte(154) + super.writeByte(156) super.writeValue(value.toList()) } else if let value = value as? MarkerDto { - super.writeByte(155) + super.writeByte(157) super.writeValue(value.toList()) } else if let value = value as? MarkerOptionsDto { - super.writeByte(156) + super.writeByte(158) super.writeValue(value.toList()) } else if let value = value as? ImageDescriptorDto { - super.writeByte(157) + super.writeByte(159) super.writeValue(value.toList()) } else if let value = value as? InfoWindowDto { - super.writeByte(158) + super.writeByte(160) super.writeValue(value.toList()) } else if let value = value as? MarkerAnchorDto { - super.writeByte(159) + super.writeByte(161) super.writeValue(value.toList()) } else if let value = value as? PolygonDto { - super.writeByte(160) + super.writeByte(162) super.writeValue(value.toList()) } else if let value = value as? PolygonOptionsDto { - super.writeByte(161) + super.writeByte(163) super.writeValue(value.toList()) } else if let value = value as? PolygonHoleDto { - super.writeByte(162) + super.writeByte(164) super.writeValue(value.toList()) } else if let value = value as? StyleSpanStrokeStyleDto { - super.writeByte(163) + super.writeByte(165) super.writeValue(value.toList()) } else if let value = value as? StyleSpanDto { - super.writeByte(164) + super.writeByte(166) super.writeValue(value.toList()) } else if let value = value as? PolylineDto { - super.writeByte(165) + super.writeByte(167) super.writeValue(value.toList()) } else if let value = value as? PatternItemDto { - super.writeByte(166) + super.writeByte(168) super.writeValue(value.toList()) } else if let value = value as? PolylineOptionsDto { - super.writeByte(167) + super.writeByte(169) super.writeValue(value.toList()) } else if let value = value as? CircleDto { - super.writeByte(168) + super.writeByte(170) super.writeValue(value.toList()) } else if let value = value as? CircleOptionsDto { - super.writeByte(169) + super.writeByte(171) super.writeValue(value.toList()) } else if let value = value as? MapPaddingDto { - super.writeByte(170) + super.writeByte(172) super.writeValue(value.toList()) } else if let value = value as? RouteTokenOptionsDto { - super.writeByte(171) + super.writeByte(173) super.writeValue(value.toList()) } else if let value = value as? DestinationsDto { - super.writeByte(172) + super.writeByte(174) super.writeValue(value.toList()) } else if let value = value as? RoutingOptionsDto { - super.writeByte(173) + super.writeByte(175) super.writeValue(value.toList()) } else if let value = value as? NavigationDisplayOptionsDto { - super.writeByte(174) + super.writeByte(176) super.writeValue(value.toList()) } else if let value = value as? NavigationWaypointDto { - super.writeByte(175) + super.writeByte(177) super.writeValue(value.toList()) } else if let value = value as? NavigationTimeAndDistanceDto { - super.writeByte(176) + super.writeByte(178) super.writeValue(value.toList()) } else if let value = value as? NavigationAudioGuidanceSettingsDto { - super.writeByte(177) + super.writeByte(179) super.writeValue(value.toList()) } else if let value = value as? SimulationOptionsDto { - super.writeByte(178) + super.writeByte(180) super.writeValue(value.toList()) } else if let value = value as? LatLngDto { - super.writeByte(179) + super.writeByte(181) super.writeValue(value.toList()) } else if let value = value as? LatLngBoundsDto { - super.writeByte(180) + super.writeByte(182) super.writeValue(value.toList()) } else if let value = value as? SpeedingUpdatedEventDto { - super.writeByte(181) + super.writeByte(183) super.writeValue(value.toList()) } else if let value = value as? GpsAvailabilityChangeEventDto { - super.writeByte(182) + super.writeByte(184) super.writeValue(value.toList()) } else if let value = value as? SpeedAlertOptionsThresholdPercentageDto { - super.writeByte(183) + super.writeByte(185) super.writeValue(value.toList()) } else if let value = value as? SpeedAlertOptionsDto { - super.writeByte(184) + super.writeByte(186) super.writeValue(value.toList()) } else if let value = value as? RouteSegmentTrafficDataRoadStretchRenderingDataDto { - super.writeByte(185) + super.writeByte(187) super.writeValue(value.toList()) } else if let value = value as? RouteSegmentTrafficDataDto { - super.writeByte(186) + super.writeByte(188) super.writeValue(value.toList()) } else if let value = value as? RouteSegmentDto { - super.writeByte(187) + super.writeByte(189) super.writeValue(value.toList()) } else if let value = value as? LaneDirectionDto { - super.writeByte(188) + super.writeByte(190) super.writeValue(value.toList()) } else if let value = value as? LaneDto { - super.writeByte(189) + super.writeByte(191) super.writeValue(value.toList()) } else if let value = value as? StepInfoDto { - super.writeByte(190) + super.writeByte(192) super.writeValue(value.toList()) } else if let value = value as? NavInfoDto { - super.writeByte(191) + super.writeByte(193) super.writeValue(value.toList()) } else { super.writeValue(value) @@ -2661,6 +2709,10 @@ protocol MapViewApi { func enableOnCameraChangedEvents(viewId: Int64) throws func setPadding(viewId: Int64, padding: MapPaddingDto) throws func getPadding(viewId: Int64) throws -> MapPaddingDto + func getMapColorScheme(viewId: Int64) throws -> MapColorSchemeDto + func setMapColorScheme(viewId: Int64, mapColorScheme: MapColorSchemeDto) throws + func getForceNightMode(viewId: Int64) throws -> NavigationForceNightModeDto + func setForceNightMode(viewId: Int64, forceNightMode: NavigationForceNightModeDto) throws } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. @@ -4555,6 +4607,80 @@ class MapViewApiSetup { } else { getPaddingChannel.setMessageHandler(nil) } + let getMapColorSchemeChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getMapColorScheme\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + getMapColorSchemeChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let viewIdArg = args[0] as! Int64 + do { + let result = try api.getMapColorScheme(viewId: viewIdArg) + reply(wrapResult(result)) + } catch { + reply(wrapError(error)) + } + } + } else { + getMapColorSchemeChannel.setMessageHandler(nil) + } + let setMapColorSchemeChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setMapColorScheme\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + setMapColorSchemeChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let viewIdArg = args[0] as! Int64 + let mapColorSchemeArg = args[1] as! MapColorSchemeDto + do { + try api.setMapColorScheme(viewId: viewIdArg, mapColorScheme: mapColorSchemeArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + setMapColorSchemeChannel.setMessageHandler(nil) + } + let getForceNightModeChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getForceNightMode\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + getForceNightModeChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let viewIdArg = args[0] as! Int64 + do { + let result = try api.getForceNightMode(viewId: viewIdArg) + reply(wrapResult(result)) + } catch { + reply(wrapError(error)) + } + } + } else { + getForceNightModeChannel.setMessageHandler(nil) + } + let setForceNightModeChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setForceNightMode\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + setForceNightModeChannel.setMessageHandler { message, reply in + let args = message as! [Any?] + let viewIdArg = args[0] as! Int64 + let forceNightModeArg = args[1] as! NavigationForceNightModeDto + do { + try api.setForceNightMode(viewId: viewIdArg, forceNightMode: forceNightModeArg) + reply(wrapResult(nil)) + } catch { + reply(wrapError(error)) + } + } + } else { + setForceNightModeChannel.setMessageHandler(nil) + } } } /// Generated protocol from Pigeon that represents a handler of messages from Flutter. diff --git a/lib/src/google_maps_map_view.dart b/lib/src/google_maps_map_view.dart index bcda2465..8c772ee4 100644 --- a/lib/src/google_maps_map_view.dart +++ b/lib/src/google_maps_map_view.dart @@ -45,6 +45,7 @@ abstract class GoogleMapsBaseMapView extends StatefulWidget { this.initialCameraTargetBounds, this.initialPadding, this.mapId, + this.initialMapColorScheme = MapColorScheme.followSystem, this.layoutDirection, this.gestureRecognizers = const >{}, this.onRecenterButtonClicked, @@ -167,6 +168,14 @@ abstract class GoogleMapsBaseMapView extends StatefulWidget { /// Null by default (no map ID). final String? mapId; + /// The map color scheme mode for the map view. + /// + /// Controls whether the map should use light, dark, or system-following color scheme. + /// This setting affects the map tiles and basic map styling. + /// + /// Defaults to [MapColorScheme.followSystem]. + final MapColorScheme initialMapColorScheme; + /// Which gestures should be forwarded to the PlatformView. /// /// When this set is empty, the map will only handle pointer events for gestures that @@ -274,6 +283,7 @@ class GoogleMapsMapView extends GoogleMapsBaseMapView { super.initialCameraTargetBounds, super.initialPadding, super.mapId, + super.initialMapColorScheme = MapColorScheme.followSystem, super.layoutDirection, super.gestureRecognizers = const >{}, super.onRecenterButtonClicked, @@ -456,6 +466,7 @@ class GoogleMapsMapViewState extends MapViewState { cameraTargetBounds: widget.initialCameraTargetBounds, padding: widget.initialPadding, mapId: widget.mapId, + mapColorScheme: widget.initialMapColorScheme, ), ), onPlatformViewCreated: _onPlatformViewCreated, diff --git a/lib/src/google_maps_map_view_controller.dart b/lib/src/google_maps_map_view_controller.dart index 4328077a..489a6c63 100644 --- a/lib/src/google_maps_map_view_controller.dart +++ b/lib/src/google_maps_map_view_controller.dart @@ -462,4 +462,36 @@ class GoogleMapViewController { viewId: _viewId, ); } + + /// Gets the current map color scheme from the map view. + /// + /// Returns the current [MapColorScheme] setting which controls whether + /// the map uses light, dark, or system-following color scheme. + Future getMapColorScheme() async { + return GoogleMapsNavigationPlatform.instance.viewAPI.getMapColorScheme( + viewId: _viewId, + ); + } + + /// Sets the map color scheme for the map view. + /// + /// Controls whether the map should use light, dark, or system-following + /// color scheme. This affects the map tiles and basic map styling. + /// + /// Example usage: + /// ```dart + /// // Force dark mode + /// await controller.setMapColorScheme(MapColorScheme.dark); + /// + /// // Follow system settings + /// await controller.setMapColorScheme(MapColorScheme.followSystem); + /// ``` + /// + /// See also [MapColorScheme] for available options. + Future setMapColorScheme(MapColorScheme mapColorScheme) { + return GoogleMapsNavigationPlatform.instance.viewAPI.setMapColorScheme( + viewId: _viewId, + mapColorScheme: mapColorScheme, + ); + } } diff --git a/lib/src/google_maps_navigation_view.dart b/lib/src/google_maps_navigation_view.dart index 412445a5..b7dc8103 100644 --- a/lib/src/google_maps_navigation_view.dart +++ b/lib/src/google_maps_navigation_view.dart @@ -61,8 +61,10 @@ class GoogleMapsNavigationView extends GoogleMapsBaseMapView { super.initialCameraTargetBounds, super.initialPadding, super.mapId, + super.initialMapColorScheme = MapColorScheme.followSystem, this.initialNavigationUIEnabledPreference = NavigationUIEnabledPreference.automatic, + this.initialForceNightMode = NavigationForceNightMode.auto, super.layoutDirection, super.gestureRecognizers = const >{}, super.onRecenterButtonClicked, @@ -135,6 +137,20 @@ class GoogleMapsNavigationView extends GoogleMapsBaseMapView { /// the terms and conditions is enough. final NavigationUIEnabledPreference initialNavigationUIEnabledPreference; + /// Controls the initial navigation night mode for Navigation UI and map tiles. + /// + /// **When navigation UI is enabled:** This setting controls both the + /// navigation UI elements (turn-by-turn guidance, route preview, etc.) and + /// the map tile colors. The [initialMapColorScheme] setting is ignored in + /// this case. + /// + /// **When navigation UI is disabled:** This setting has no effect. Use + /// [initialMapColorScheme] to control the map tile colors instead. + /// + /// Defaults to [NavigationForceNightMode.auto], which lets the SDK + /// automatically determine day or night mode based on time and location. + final NavigationForceNightMode initialForceNightMode; + /// On navigation UI enabled changed callback. final OnNavigationUIEnabledChanged? onNavigationUIEnabledChanged; @@ -176,10 +192,12 @@ class GoogleMapsNavigationViewState cameraTargetBounds: widget.initialCameraTargetBounds, padding: widget.initialPadding, mapId: widget.mapId, + mapColorScheme: widget.initialMapColorScheme, ), navigationViewOptions: NavigationViewOptions( navigationUIEnabledPreference: widget.initialNavigationUIEnabledPreference, + forceNightMode: widget.initialForceNightMode, ), ), onPlatformViewCreated: _onPlatformViewCreated, diff --git a/lib/src/google_maps_navigation_view_controller.dart b/lib/src/google_maps_navigation_view_controller.dart index 35cfc823..cbc304a8 100644 --- a/lib/src/google_maps_navigation_view_controller.dart +++ b/lib/src/google_maps_navigation_view_controller.dart @@ -204,4 +204,45 @@ class GoogleNavigationViewController extends GoogleMapViewController { viewId: getViewId(), ); } + + /// Gets the current force night mode setting from the navigation view. + /// + /// Returns the current [NavigationForceNightMode] setting which controls + /// the navigation UI lighting mode. + Future getForceNightMode() async { + return GoogleMapsNavigationPlatform.instance.viewAPI.getForceNightMode( + viewId: getViewId(), + ); + } + + /// Sets the force night mode for the navigation UI and map tiles. + /// + /// **When navigation UI is enabled:** This setting controls both the + /// navigation UI elements (turn-by-turn guidance, route preview, etc.) and + /// the map tile colors. Using [GoogleMapViewController.setMapColorScheme] + /// will have no effect. + /// + /// **When navigation UI is disabled:** This setting has no effect. Use + /// [GoogleMapViewController.setMapColorScheme] to control the map tile colors + /// instead. + /// + /// Example usage: + /// ```dart + /// // Force night mode (when navigation UI is enabled) + /// await controller.setForceNightMode(NavigationForceNightMode.forceNight); + /// + /// // Let SDK automatically determine day or night + /// await controller.setForceNightMode(NavigationForceNightMode.auto); + /// ``` + /// + /// See also: + /// - [NavigationForceNightMode] for available options + /// - [GoogleMapViewController.setMapColorScheme] for controlling map tile + /// colors when navigation UI is disabled + Future setForceNightMode(NavigationForceNightMode forceNightMode) { + return GoogleMapsNavigationPlatform.instance.viewAPI.setForceNightMode( + viewId: getViewId(), + forceNightMode: forceNightMode, + ); + } } diff --git a/lib/src/method_channel/convert/convert.dart b/lib/src/method_channel/convert/convert.dart index 49590f7c..813b0c6b 100644 --- a/lib/src/method_channel/convert/convert.dart +++ b/lib/src/method_channel/convert/convert.dart @@ -17,10 +17,12 @@ export 'circle.dart'; export 'destinations.dart'; export 'latlng.dart'; export 'latlng_bounds.dart'; +export 'map_color_scheme.dart'; export 'map_type.dart'; export 'marker.dart'; export 'navigation.dart'; export 'navigation_display_options.dart'; +export 'navigation_force_night_mode.dart'; export 'navigation_routing_options.dart'; export 'navinfo.dart'; export 'pattern.dart'; diff --git a/lib/src/method_channel/convert/map_color_scheme.dart b/lib/src/method_channel/convert/map_color_scheme.dart new file mode 100644 index 00000000..c95cb4db --- /dev/null +++ b/lib/src/method_channel/convert/map_color_scheme.dart @@ -0,0 +1,48 @@ +// Copyright 2023 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. + +import '../../types/types.dart'; +import '../method_channel.dart'; + +/// [MapColorScheme] convert extension. +/// @nodoc +extension ConvertMapColorScheme on MapColorScheme { + /// Converts [MapColorScheme] to [MapColorSchemeDto] + MapColorSchemeDto toDto() { + switch (this) { + case MapColorScheme.followSystem: + return MapColorSchemeDto.followSystem; + case MapColorScheme.light: + return MapColorSchemeDto.light; + case MapColorScheme.dark: + return MapColorSchemeDto.dark; + } + } +} + +/// [MapColorSchemeDto] convert extension. +/// @nodoc +extension ConvertMapColorSchemeDto on MapColorSchemeDto { + /// Converts [MapColorSchemeDto] to [MapColorScheme] + MapColorScheme toMapColorScheme() { + switch (this) { + case MapColorSchemeDto.followSystem: + return MapColorScheme.followSystem; + case MapColorSchemeDto.light: + return MapColorScheme.light; + case MapColorSchemeDto.dark: + return MapColorScheme.dark; + } + } +} diff --git a/lib/src/method_channel/convert/navigation.dart b/lib/src/method_channel/convert/navigation.dart index 0132a294..a145944f 100644 --- a/lib/src/method_channel/convert/navigation.dart +++ b/lib/src/method_channel/convert/navigation.dart @@ -209,7 +209,10 @@ extension ConvertNavigationViewOptions on NavigationViewOptions { preference = NavigationUIEnabledPreferenceDto.disabled; } - return NavigationViewOptionsDto(navigationUIEnabledPreference: preference); + return NavigationViewOptionsDto( + navigationUIEnabledPreference: preference, + forceNightMode: forceNightMode.toDto(), + ); } } diff --git a/lib/src/method_channel/convert/navigation_force_night_mode.dart b/lib/src/method_channel/convert/navigation_force_night_mode.dart new file mode 100644 index 00000000..6d187e3c --- /dev/null +++ b/lib/src/method_channel/convert/navigation_force_night_mode.dart @@ -0,0 +1,48 @@ +// Copyright 2023 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. + +import '../../types/types.dart'; +import '../method_channel.dart'; + +/// [NavigationForceNightMode] convert extension. +/// @nodoc +extension ConvertNavigationForceNightMode on NavigationForceNightMode { + /// Converts [NavigationForceNightMode] to [NavigationForceNightModeDto] + NavigationForceNightModeDto toDto() { + switch (this) { + case NavigationForceNightMode.auto: + return NavigationForceNightModeDto.auto; + case NavigationForceNightMode.forceDay: + return NavigationForceNightModeDto.forceDay; + case NavigationForceNightMode.forceNight: + return NavigationForceNightModeDto.forceNight; + } + } +} + +/// [NavigationForceNightModeDto] convert extension. +/// @nodoc +extension ConvertNavigationForceNightModeDto on NavigationForceNightModeDto { + /// Converts [NavigationForceNightModeDto] to [NavigationForceNightMode] + NavigationForceNightMode toNavigationForceNightMode() { + switch (this) { + case NavigationForceNightModeDto.auto: + return NavigationForceNightMode.auto; + case NavigationForceNightModeDto.forceDay: + return NavigationForceNightMode.forceDay; + case NavigationForceNightModeDto.forceNight: + return NavigationForceNightMode.forceNight; + } + } +} diff --git a/lib/src/method_channel/map_view_api.dart b/lib/src/method_channel/map_view_api.dart index 34465fed..eada1492 100644 --- a/lib/src/method_channel/map_view_api.dart +++ b/lib/src/method_channel/map_view_api.dart @@ -131,26 +131,12 @@ class MapViewAPIImpl { ) : null, mapId: mapOptions.mapId, + mapColorScheme: mapOptions.mapColorScheme.toDto(), ); // Initialize navigation view options if given - NavigationViewOptionsDto? navigationOptionsMessage; - final NavigationViewOptions? navigationViewOptions = - initializationSettings.navigationViewOptions; - if (navigationViewOptions != null) { - switch (navigationViewOptions.navigationUIEnabledPreference) { - case NavigationUIEnabledPreference.automatic: - navigationOptionsMessage = NavigationViewOptionsDto( - navigationUIEnabledPreference: - NavigationUIEnabledPreferenceDto.automatic, - ); - case NavigationUIEnabledPreference.disabled: - navigationOptionsMessage = NavigationViewOptionsDto( - navigationUIEnabledPreference: - NavigationUIEnabledPreferenceDto.disabled, - ); - } - } + final NavigationViewOptionsDto? navigationOptionsMessage = + initializationSettings.navigationViewOptions?.toDto(); // Build ViewCreationMessage return ViewCreationOptionsDto( @@ -1198,6 +1184,39 @@ class MapViewAPIImpl { ); } + /// Gets the current map color scheme from the map view. + Future getMapColorScheme({required int viewId}) async { + final MapColorSchemeDto colorScheme = await _viewApi.getMapColorScheme( + viewId, + ); + return colorScheme.toMapColorScheme(); + } + + /// Sets the map color scheme for the map view. + Future setMapColorScheme({ + required int viewId, + required MapColorScheme mapColorScheme, + }) { + return _viewApi.setMapColorScheme(viewId, mapColorScheme.toDto()); + } + + /// Gets the current force night mode from the navigation view. + Future getForceNightMode({ + required int viewId, + }) async { + final NavigationForceNightModeDto forceNightMode = await _viewApi + .getForceNightMode(viewId); + return forceNightMode.toNavigationForceNightMode(); + } + + /// Sets the force night mode for the navigation view. + Future setForceNightMode({ + required int viewId, + required NavigationForceNightMode forceNightMode, + }) { + return _viewApi.setForceNightMode(viewId, forceNightMode.toDto()); + } + 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 0d93812a..e2bc153e 100644 --- a/lib/src/method_channel/messages.g.dart +++ b/lib/src/method_channel/messages.g.dart @@ -82,6 +82,30 @@ enum NavigationUIEnabledPreferenceDto { enum MapTypeDto { none, normal, satellite, terrain, hybrid } +/// Map color scheme mode. +enum MapColorSchemeDto { + /// Follow system or SDK default (automatic). + followSystem, + + /// Force light color scheme. + light, + + /// Force dark color scheme. + dark, +} + +/// Navigation night mode. +enum NavigationForceNightModeDto { + /// Let the SDK automatically determine day or night. + auto, + + /// Force day mode regardless of time or location. + forceDay, + + /// Force night mode regardless of time or location. + forceNight, +} + enum CameraPerspectiveDto { tilted, topDownHeadingUp, topDownNorthUp } enum MarkerEventTypeDto { @@ -431,6 +455,7 @@ class MapOptionsDto { this.cameraTargetBounds, this.padding, this.mapId, + required this.mapColorScheme, }); /// The initial positioning of the camera in the map view. @@ -480,6 +505,9 @@ class MapOptionsDto { /// This value can only be set on map initialization and cannot be changed afterwards. String? mapId; + /// The map color scheme mode for the map view. + MapColorSchemeDto mapColorScheme; + List _toList() { return [ cameraPosition, @@ -497,6 +525,7 @@ class MapOptionsDto { cameraTargetBounds, padding, mapId, + mapColorScheme, ]; } @@ -522,6 +551,7 @@ class MapOptionsDto { cameraTargetBounds: result[12] as LatLngBoundsDto?, padding: result[13] as MapPaddingDto?, mapId: result[14] as String?, + mapColorScheme: result[15]! as MapColorSchemeDto, ); } @@ -544,13 +574,19 @@ class MapOptionsDto { /// Object containing navigation options used to initialize Google Navigation view. class NavigationViewOptionsDto { - NavigationViewOptionsDto({required this.navigationUIEnabledPreference}); + NavigationViewOptionsDto({ + required this.navigationUIEnabledPreference, + required this.forceNightMode, + }); /// Determines the initial visibility of the navigation UI on map initialization. NavigationUIEnabledPreferenceDto navigationUIEnabledPreference; + /// Controls the navigation night mode for Navigation UI. + NavigationForceNightModeDto forceNightMode; + List _toList() { - return [navigationUIEnabledPreference]; + return [navigationUIEnabledPreference, forceNightMode]; } Object encode() { @@ -562,6 +598,7 @@ class NavigationViewOptionsDto { return NavigationViewOptionsDto( navigationUIEnabledPreference: result[0]! as NavigationUIEnabledPreferenceDto, + forceNightMode: result[1]! as NavigationForceNightModeDto, ); } @@ -2660,186 +2697,192 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is MapTypeDto) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is CameraPerspectiveDto) { + } else if (value is MapColorSchemeDto) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is MarkerEventTypeDto) { + } else if (value is NavigationForceNightModeDto) { buffer.putUint8(133); writeValue(buffer, value.index); - } else if (value is MarkerDragEventTypeDto) { + } else if (value is CameraPerspectiveDto) { buffer.putUint8(134); writeValue(buffer, value.index); - } else if (value is StrokeJointTypeDto) { + } else if (value is MarkerEventTypeDto) { buffer.putUint8(135); writeValue(buffer, value.index); - } else if (value is PatternTypeDto) { + } else if (value is MarkerDragEventTypeDto) { buffer.putUint8(136); writeValue(buffer, value.index); - } else if (value is CameraEventTypeDto) { + } else if (value is StrokeJointTypeDto) { buffer.putUint8(137); writeValue(buffer, value.index); - } else if (value is AlternateRoutesStrategyDto) { + } else if (value is PatternTypeDto) { buffer.putUint8(138); writeValue(buffer, value.index); - } else if (value is RoutingStrategyDto) { + } else if (value is CameraEventTypeDto) { buffer.putUint8(139); writeValue(buffer, value.index); - } else if (value is TravelModeDto) { + } else if (value is AlternateRoutesStrategyDto) { buffer.putUint8(140); writeValue(buffer, value.index); - } else if (value is RouteStatusDto) { + } else if (value is RoutingStrategyDto) { buffer.putUint8(141); writeValue(buffer, value.index); - } else if (value is AudioGuidanceTypeDto) { + } else if (value is TravelModeDto) { buffer.putUint8(142); writeValue(buffer, value.index); - } else if (value is SpeedAlertSeverityDto) { + } else if (value is RouteStatusDto) { buffer.putUint8(143); writeValue(buffer, value.index); - } else if (value is RouteSegmentTrafficDataStatusDto) { + } else if (value is AudioGuidanceTypeDto) { buffer.putUint8(144); writeValue(buffer, value.index); + } else if (value is SpeedAlertSeverityDto) { + buffer.putUint8(145); + writeValue(buffer, value.index); + } else if (value is RouteSegmentTrafficDataStatusDto) { + buffer.putUint8(146); + writeValue(buffer, value.index); } else if (value is RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto) { - buffer.putUint8(145); + buffer.putUint8(147); writeValue(buffer, value.index); } else if (value is ManeuverDto) { - buffer.putUint8(146); + buffer.putUint8(148); writeValue(buffer, value.index); } else if (value is DrivingSideDto) { - buffer.putUint8(147); + buffer.putUint8(149); writeValue(buffer, value.index); } else if (value is NavStateDto) { - buffer.putUint8(148); + buffer.putUint8(150); writeValue(buffer, value.index); } else if (value is LaneShapeDto) { - buffer.putUint8(149); + buffer.putUint8(151); writeValue(buffer, value.index); } else if (value is TaskRemovedBehaviorDto) { - buffer.putUint8(150); + buffer.putUint8(152); writeValue(buffer, value.index); } else if (value is MapOptionsDto) { - buffer.putUint8(151); + buffer.putUint8(153); writeValue(buffer, value.encode()); } else if (value is NavigationViewOptionsDto) { - buffer.putUint8(152); + buffer.putUint8(154); writeValue(buffer, value.encode()); } else if (value is ViewCreationOptionsDto) { - buffer.putUint8(153); + buffer.putUint8(155); writeValue(buffer, value.encode()); } else if (value is CameraPositionDto) { - buffer.putUint8(154); + buffer.putUint8(156); writeValue(buffer, value.encode()); } else if (value is MarkerDto) { - buffer.putUint8(155); + buffer.putUint8(157); writeValue(buffer, value.encode()); } else if (value is MarkerOptionsDto) { - buffer.putUint8(156); + buffer.putUint8(158); writeValue(buffer, value.encode()); } else if (value is ImageDescriptorDto) { - buffer.putUint8(157); + buffer.putUint8(159); writeValue(buffer, value.encode()); } else if (value is InfoWindowDto) { - buffer.putUint8(158); + buffer.putUint8(160); writeValue(buffer, value.encode()); } else if (value is MarkerAnchorDto) { - buffer.putUint8(159); + buffer.putUint8(161); writeValue(buffer, value.encode()); } else if (value is PolygonDto) { - buffer.putUint8(160); + buffer.putUint8(162); writeValue(buffer, value.encode()); } else if (value is PolygonOptionsDto) { - buffer.putUint8(161); + buffer.putUint8(163); writeValue(buffer, value.encode()); } else if (value is PolygonHoleDto) { - buffer.putUint8(162); + buffer.putUint8(164); writeValue(buffer, value.encode()); } else if (value is StyleSpanStrokeStyleDto) { - buffer.putUint8(163); + buffer.putUint8(165); writeValue(buffer, value.encode()); } else if (value is StyleSpanDto) { - buffer.putUint8(164); + buffer.putUint8(166); writeValue(buffer, value.encode()); } else if (value is PolylineDto) { - buffer.putUint8(165); + buffer.putUint8(167); writeValue(buffer, value.encode()); } else if (value is PatternItemDto) { - buffer.putUint8(166); + buffer.putUint8(168); writeValue(buffer, value.encode()); } else if (value is PolylineOptionsDto) { - buffer.putUint8(167); + buffer.putUint8(169); writeValue(buffer, value.encode()); } else if (value is CircleDto) { - buffer.putUint8(168); + buffer.putUint8(170); writeValue(buffer, value.encode()); } else if (value is CircleOptionsDto) { - buffer.putUint8(169); + buffer.putUint8(171); writeValue(buffer, value.encode()); } else if (value is MapPaddingDto) { - buffer.putUint8(170); + buffer.putUint8(172); writeValue(buffer, value.encode()); } else if (value is RouteTokenOptionsDto) { - buffer.putUint8(171); + buffer.putUint8(173); writeValue(buffer, value.encode()); } else if (value is DestinationsDto) { - buffer.putUint8(172); + buffer.putUint8(174); writeValue(buffer, value.encode()); } else if (value is RoutingOptionsDto) { - buffer.putUint8(173); + buffer.putUint8(175); writeValue(buffer, value.encode()); } else if (value is NavigationDisplayOptionsDto) { - buffer.putUint8(174); + buffer.putUint8(176); writeValue(buffer, value.encode()); } else if (value is NavigationWaypointDto) { - buffer.putUint8(175); + buffer.putUint8(177); writeValue(buffer, value.encode()); } else if (value is NavigationTimeAndDistanceDto) { - buffer.putUint8(176); + buffer.putUint8(178); writeValue(buffer, value.encode()); } else if (value is NavigationAudioGuidanceSettingsDto) { - buffer.putUint8(177); + buffer.putUint8(179); writeValue(buffer, value.encode()); } else if (value is SimulationOptionsDto) { - buffer.putUint8(178); + buffer.putUint8(180); writeValue(buffer, value.encode()); } else if (value is LatLngDto) { - buffer.putUint8(179); + buffer.putUint8(181); writeValue(buffer, value.encode()); } else if (value is LatLngBoundsDto) { - buffer.putUint8(180); + buffer.putUint8(182); writeValue(buffer, value.encode()); } else if (value is SpeedingUpdatedEventDto) { - buffer.putUint8(181); + buffer.putUint8(183); writeValue(buffer, value.encode()); } else if (value is GpsAvailabilityChangeEventDto) { - buffer.putUint8(182); + buffer.putUint8(184); writeValue(buffer, value.encode()); } else if (value is SpeedAlertOptionsThresholdPercentageDto) { - buffer.putUint8(183); + buffer.putUint8(185); writeValue(buffer, value.encode()); } else if (value is SpeedAlertOptionsDto) { - buffer.putUint8(184); + buffer.putUint8(186); writeValue(buffer, value.encode()); } else if (value is RouteSegmentTrafficDataRoadStretchRenderingDataDto) { - buffer.putUint8(185); + buffer.putUint8(187); writeValue(buffer, value.encode()); } else if (value is RouteSegmentTrafficDataDto) { - buffer.putUint8(186); + buffer.putUint8(188); writeValue(buffer, value.encode()); } else if (value is RouteSegmentDto) { - buffer.putUint8(187); + buffer.putUint8(189); writeValue(buffer, value.encode()); } else if (value is LaneDirectionDto) { - buffer.putUint8(188); + buffer.putUint8(190); writeValue(buffer, value.encode()); } else if (value is LaneDto) { - buffer.putUint8(189); + buffer.putUint8(191); writeValue(buffer, value.encode()); } else if (value is StepInfoDto) { - buffer.putUint8(190); + buffer.putUint8(192); writeValue(buffer, value.encode()); } else if (value is NavInfoDto) { - buffer.putUint8(191); + buffer.putUint8(193); writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); @@ -2862,151 +2905,157 @@ class _PigeonCodec extends StandardMessageCodec { return value == null ? null : MapTypeDto.values[value]; case 132: final int? value = readValue(buffer) as int?; - return value == null ? null : CameraPerspectiveDto.values[value]; + return value == null ? null : MapColorSchemeDto.values[value]; case 133: final int? value = readValue(buffer) as int?; - return value == null ? null : MarkerEventTypeDto.values[value]; + return value == null ? null : NavigationForceNightModeDto.values[value]; case 134: final int? value = readValue(buffer) as int?; - return value == null ? null : MarkerDragEventTypeDto.values[value]; + return value == null ? null : CameraPerspectiveDto.values[value]; case 135: final int? value = readValue(buffer) as int?; - return value == null ? null : StrokeJointTypeDto.values[value]; + return value == null ? null : MarkerEventTypeDto.values[value]; case 136: final int? value = readValue(buffer) as int?; - return value == null ? null : PatternTypeDto.values[value]; + return value == null ? null : MarkerDragEventTypeDto.values[value]; case 137: final int? value = readValue(buffer) as int?; - return value == null ? null : CameraEventTypeDto.values[value]; + return value == null ? null : StrokeJointTypeDto.values[value]; case 138: final int? value = readValue(buffer) as int?; - return value == null ? null : AlternateRoutesStrategyDto.values[value]; + return value == null ? null : PatternTypeDto.values[value]; case 139: final int? value = readValue(buffer) as int?; - return value == null ? null : RoutingStrategyDto.values[value]; + return value == null ? null : CameraEventTypeDto.values[value]; case 140: final int? value = readValue(buffer) as int?; - return value == null ? null : TravelModeDto.values[value]; + return value == null ? null : AlternateRoutesStrategyDto.values[value]; case 141: final int? value = readValue(buffer) as int?; - return value == null ? null : RouteStatusDto.values[value]; + return value == null ? null : RoutingStrategyDto.values[value]; case 142: final int? value = readValue(buffer) as int?; - return value == null ? null : AudioGuidanceTypeDto.values[value]; + return value == null ? null : TravelModeDto.values[value]; case 143: final int? value = readValue(buffer) as int?; - return value == null ? null : SpeedAlertSeverityDto.values[value]; + return value == null ? null : RouteStatusDto.values[value]; case 144: + final int? value = readValue(buffer) as int?; + return value == null ? null : AudioGuidanceTypeDto.values[value]; + case 145: + final int? value = readValue(buffer) as int?; + return value == null ? null : SpeedAlertSeverityDto.values[value]; + case 146: final int? value = readValue(buffer) as int?; return value == null ? null : RouteSegmentTrafficDataStatusDto.values[value]; - case 145: + case 147: final int? value = readValue(buffer) as int?; return value == null ? null : RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto .values[value]; - case 146: + case 148: final int? value = readValue(buffer) as int?; return value == null ? null : ManeuverDto.values[value]; - case 147: + case 149: final int? value = readValue(buffer) as int?; return value == null ? null : DrivingSideDto.values[value]; - case 148: + case 150: final int? value = readValue(buffer) as int?; return value == null ? null : NavStateDto.values[value]; - case 149: + case 151: final int? value = readValue(buffer) as int?; return value == null ? null : LaneShapeDto.values[value]; - case 150: + case 152: final int? value = readValue(buffer) as int?; return value == null ? null : TaskRemovedBehaviorDto.values[value]; - case 151: + case 153: return MapOptionsDto.decode(readValue(buffer)!); - case 152: + case 154: return NavigationViewOptionsDto.decode(readValue(buffer)!); - case 153: + case 155: return ViewCreationOptionsDto.decode(readValue(buffer)!); - case 154: + case 156: return CameraPositionDto.decode(readValue(buffer)!); - case 155: + case 157: return MarkerDto.decode(readValue(buffer)!); - case 156: + case 158: return MarkerOptionsDto.decode(readValue(buffer)!); - case 157: + case 159: return ImageDescriptorDto.decode(readValue(buffer)!); - case 158: + case 160: return InfoWindowDto.decode(readValue(buffer)!); - case 159: + case 161: return MarkerAnchorDto.decode(readValue(buffer)!); - case 160: + case 162: return PolygonDto.decode(readValue(buffer)!); - case 161: + case 163: return PolygonOptionsDto.decode(readValue(buffer)!); - case 162: + case 164: return PolygonHoleDto.decode(readValue(buffer)!); - case 163: + case 165: return StyleSpanStrokeStyleDto.decode(readValue(buffer)!); - case 164: + case 166: return StyleSpanDto.decode(readValue(buffer)!); - case 165: + case 167: return PolylineDto.decode(readValue(buffer)!); - case 166: + case 168: return PatternItemDto.decode(readValue(buffer)!); - case 167: + case 169: return PolylineOptionsDto.decode(readValue(buffer)!); - case 168: + case 170: return CircleDto.decode(readValue(buffer)!); - case 169: + case 171: return CircleOptionsDto.decode(readValue(buffer)!); - case 170: + case 172: return MapPaddingDto.decode(readValue(buffer)!); - case 171: + case 173: return RouteTokenOptionsDto.decode(readValue(buffer)!); - case 172: + case 174: return DestinationsDto.decode(readValue(buffer)!); - case 173: + case 175: return RoutingOptionsDto.decode(readValue(buffer)!); - case 174: + case 176: return NavigationDisplayOptionsDto.decode(readValue(buffer)!); - case 175: + case 177: return NavigationWaypointDto.decode(readValue(buffer)!); - case 176: + case 178: return NavigationTimeAndDistanceDto.decode(readValue(buffer)!); - case 177: + case 179: return NavigationAudioGuidanceSettingsDto.decode(readValue(buffer)!); - case 178: + case 180: return SimulationOptionsDto.decode(readValue(buffer)!); - case 179: + case 181: return LatLngDto.decode(readValue(buffer)!); - case 180: + case 182: return LatLngBoundsDto.decode(readValue(buffer)!); - case 181: + case 183: return SpeedingUpdatedEventDto.decode(readValue(buffer)!); - case 182: + case 184: return GpsAvailabilityChangeEventDto.decode(readValue(buffer)!); - case 183: + case 185: return SpeedAlertOptionsThresholdPercentageDto.decode( readValue(buffer)!, ); - case 184: + case 186: return SpeedAlertOptionsDto.decode(readValue(buffer)!); - case 185: + case 187: return RouteSegmentTrafficDataRoadStretchRenderingDataDto.decode( readValue(buffer)!, ); - case 186: + case 188: return RouteSegmentTrafficDataDto.decode(readValue(buffer)!); - case 187: + case 189: return RouteSegmentDto.decode(readValue(buffer)!); - case 188: + case 190: return LaneDirectionDto.decode(readValue(buffer)!); - case 189: + case 191: return LaneDto.decode(readValue(buffer)!); - case 190: + case 192: return StepInfoDto.decode(readValue(buffer)!); - case 191: + case 193: return NavInfoDto.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -6122,6 +6171,130 @@ class MapViewApi { return (pigeonVar_replyList[0] as MapPaddingDto?)!; } } + + Future getMapColorScheme(int viewId) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getMapColorScheme$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [viewId], + ); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as MapColorSchemeDto?)!; + } + } + + Future setMapColorScheme( + int viewId, + MapColorSchemeDto mapColorScheme, + ) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setMapColorScheme$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [viewId, mapColorScheme], + ); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } + + Future getForceNightMode(int viewId) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getForceNightMode$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [viewId], + ); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else if (pigeonVar_replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (pigeonVar_replyList[0] as NavigationForceNightModeDto?)!; + } + } + + Future setForceNightMode( + int viewId, + NavigationForceNightModeDto forceNightMode, + ) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setForceNightMode$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [viewId, forceNightMode], + ); + final List? pigeonVar_replyList = + await pigeonVar_sendFuture as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { + throw PlatformException( + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], + ); + } else { + return; + } + } } class ImageRegistryApi { diff --git a/lib/src/types/navigation_view_types.dart b/lib/src/types/navigation_view_types.dart index 8ad6e4da..ed6c819a 100644 --- a/lib/src/types/navigation_view_types.dart +++ b/lib/src/types/navigation_view_types.dart @@ -40,6 +40,39 @@ enum MapType { hybrid, } +/// Map color scheme mode. +/// {@category Navigation View} +/// {@category Map View} +enum MapColorScheme { + /// Follow system or SDK default (automatic). + followSystem, + + /// Force light color scheme. + light, + + /// Force dark color scheme. + dark, +} + +/// Navigation night mode. +/// +/// Controls the navigation UI lighting mode for Navigation views. +/// This affects the color scheme and visibility of navigation UI elements. +/// +/// Android ref: https://developers.google.com/maps/documentation/navigation/android-sdk/reference/com/google/android/libraries/navigation/ForceNightMode +/// iOS ref: https://developers.google.com/maps/documentation/navigation/ios-sdk/reference/objc/Enums/GMSNavigationLightingMode +/// {@category Navigation View} +enum NavigationForceNightMode { + /// Let the SDK automatically determine day or night mode based on time and location. + auto, + + /// Force day mode regardless of time or location. + forceDay, + + /// Force night mode regardless of time or location. + forceNight, +} + /// Represents the camera position in a Google Maps view. /// {@category Navigation View} /// {@category Map View} diff --git a/lib/src/types/view_initialization_options.dart b/lib/src/types/view_initialization_options.dart index 1c14b548..68de8222 100644 --- a/lib/src/types/view_initialization_options.dart +++ b/lib/src/types/view_initialization_options.dart @@ -111,6 +111,7 @@ class MapOptions { this.cameraTargetBounds, this.padding, this.mapId, + this.mapColorScheme = MapColorScheme.followSystem, }) : assert( minZoomPreference == null || maxZoomPreference == null || @@ -214,6 +215,22 @@ class MapOptions { /// Null by default (no map ID). final String? mapId; + /// The map color scheme mode for the map view. + /// + /// Controls whether the map should use light, dark, or system-following color + /// scheme. This setting affects the map tiles and basic map styling. + /// + /// **Important:** For navigation views, this setting only controls the map + /// tile colors when navigation UI is **disabled**. When navigation UI is + /// enabled, use [NavigationViewOptions.forceNightMode] to control both the + /// navigation UI and map tile colors. + /// + /// For map-only views (GoogleMapsMapView), this setting always controls the + /// map tile colors. + /// + /// Defaults to [MapColorScheme.followSystem]. + final MapColorScheme mapColorScheme; + @override String toString() => 'MapOptions(' @@ -231,7 +248,8 @@ class MapOptions { 'zoomControlsEnabled: $zoomControlsEnabled, ' 'cameraTargetBounds: $cameraTargetBounds, ' 'padding: $padding, ' - 'mapId: $mapId' + 'mapId: $mapId, ' + 'mapColorScheme: $mapColorScheme' ')'; } @@ -257,6 +275,7 @@ class NavigationViewOptions { const NavigationViewOptions({ this.navigationUIEnabledPreference = NavigationUIEnabledPreference.automatic, + this.forceNightMode = NavigationForceNightMode.auto, }); /// Determines the initial visibility of the navigation UI on map initialization. @@ -269,9 +288,24 @@ class NavigationViewOptions { /// initially displays a classic map view. final NavigationUIEnabledPreference navigationUIEnabledPreference; + /// Controls the navigation night mode for Navigation UI and map tiles. + /// + /// **When navigation UI is enabled:** This setting controls both the + /// navigation UI elements (turn-by-turn guidance, route preview, etc.) and + /// the map tile colors. The [MapOptions.mapColorScheme] setting is ignored + /// in this case. + /// + /// **When navigation UI is disabled:** This setting has no effect. Use + /// [MapOptions.mapColorScheme] to control the map tile colors instead. + /// + /// Defaults to [NavigationForceNightMode.auto], which lets the SDK automatically + /// determine day or night mode based on time and location. + final NavigationForceNightMode forceNightMode; + @override String toString() => 'NavigationViewOptions(' - 'navigationUIEnabledPreference: $navigationUIEnabledPreference' + 'navigationUIEnabledPreference: $navigationUIEnabledPreference, ' + 'forceNightMode: $forceNightMode' ')'; } diff --git a/pigeons/messages.dart b/pigeons/messages.dart index 3a76be44..a3882f00 100644 --- a/pigeons/messages.dart +++ b/pigeons/messages.dart @@ -54,6 +54,7 @@ class MapOptionsDto { required this.cameraTargetBounds, required this.padding, required this.mapId, + required this.mapColorScheme, }); /// The initial positioning of the camera in the map view. @@ -102,6 +103,9 @@ class MapOptionsDto { /// The map ID for advanced map options eg. cloud-based map styling. /// This value can only be set on map initialization and cannot be changed afterwards. final String? mapId; + + /// The map color scheme mode for the map view. + final MapColorSchemeDto mapColorScheme; } /// Determines the initial visibility of the navigation UI on map initialization. @@ -116,10 +120,16 @@ enum NavigationUIEnabledPreferenceDto { /// Object containing navigation options used to initialize Google Navigation view. class NavigationViewOptionsDto { - NavigationViewOptionsDto({required this.navigationUIEnabledPreference}); + NavigationViewOptionsDto({ + required this.navigationUIEnabledPreference, + required this.forceNightMode, + }); /// Determines the initial visibility of the navigation UI on map initialization. final NavigationUIEnabledPreferenceDto navigationUIEnabledPreference; + + /// Controls the navigation night mode for Navigation UI. + final NavigationForceNightModeDto forceNightMode; } /// A message for creating a new navigation view. @@ -150,6 +160,30 @@ abstract class ViewCreationApi { enum MapTypeDto { none, normal, satellite, terrain, hybrid } +/// Map color scheme mode. +enum MapColorSchemeDto { + /// Follow system or SDK default (automatic). + followSystem, + + /// Force light color scheme. + light, + + /// Force dark color scheme. + dark, +} + +/// Navigation night mode. +enum NavigationForceNightModeDto { + /// Let the SDK automatically determine day or night. + auto, + + /// Force day mode regardless of time or location. + forceDay, + + /// Force night mode regardless of time or location. + forceNight, +} + class CameraPositionDto { CameraPositionDto({ required this.bearing, @@ -576,6 +610,15 @@ abstract class MapViewApi { void enableOnCameraChangedEvents(int viewId); void setPadding(int viewId, MapPaddingDto padding); MapPaddingDto getPadding(int viewId); + + MapColorSchemeDto getMapColorScheme(int viewId); + void setMapColorScheme(int viewId, MapColorSchemeDto mapColorScheme); + + NavigationForceNightModeDto getForceNightMode(int viewId); + void setForceNightMode( + int viewId, + NavigationForceNightModeDto forceNightMode, + ); } @HostApi(dartHostTestHandler: 'TestImageRegistryApi') diff --git a/test/google_navigation_flutter_test.mocks.dart b/test/google_navigation_flutter_test.mocks.dart index 8db4e16e..463692f0 100644 --- a/test/google_navigation_flutter_test.mocks.dart +++ b/test/google_navigation_flutter_test.mocks.dart @@ -1219,6 +1219,38 @@ class MockTestMapViewApi extends _i1.Mock implements _i3.TestMapViewApi { ), ) as _i2.MapPaddingDto); + + @override + _i2.MapColorSchemeDto getMapColorScheme(int? viewId) => + (super.noSuchMethod( + Invocation.method(#getMapColorScheme, [viewId]), + returnValue: _i2.MapColorSchemeDto.followSystem, + ) + as _i2.MapColorSchemeDto); + + @override + void setMapColorScheme(int? viewId, _i2.MapColorSchemeDto? mapColorScheme) => + super.noSuchMethod( + Invocation.method(#setMapColorScheme, [viewId, mapColorScheme]), + returnValueForMissingStub: null, + ); + + @override + _i2.NavigationForceNightModeDto getForceNightMode(int? viewId) => + (super.noSuchMethod( + Invocation.method(#getForceNightMode, [viewId]), + returnValue: _i2.NavigationForceNightModeDto.auto, + ) + as _i2.NavigationForceNightModeDto); + + @override + void setForceNightMode( + int? viewId, + _i2.NavigationForceNightModeDto? forceNightMode, + ) => super.noSuchMethod( + Invocation.method(#setForceNightMode, [viewId, forceNightMode]), + returnValueForMissingStub: null, + ); } /// A class which mocks [TestImageRegistryApi]. diff --git a/test/messages_test.g.dart b/test/messages_test.g.dart index f0f1f17f..a302d2cd 100644 --- a/test/messages_test.g.dart +++ b/test/messages_test.g.dart @@ -40,186 +40,192 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is MapTypeDto) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is CameraPerspectiveDto) { + } else if (value is MapColorSchemeDto) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is MarkerEventTypeDto) { + } else if (value is NavigationForceNightModeDto) { buffer.putUint8(133); writeValue(buffer, value.index); - } else if (value is MarkerDragEventTypeDto) { + } else if (value is CameraPerspectiveDto) { buffer.putUint8(134); writeValue(buffer, value.index); - } else if (value is StrokeJointTypeDto) { + } else if (value is MarkerEventTypeDto) { buffer.putUint8(135); writeValue(buffer, value.index); - } else if (value is PatternTypeDto) { + } else if (value is MarkerDragEventTypeDto) { buffer.putUint8(136); writeValue(buffer, value.index); - } else if (value is CameraEventTypeDto) { + } else if (value is StrokeJointTypeDto) { buffer.putUint8(137); writeValue(buffer, value.index); - } else if (value is AlternateRoutesStrategyDto) { + } else if (value is PatternTypeDto) { buffer.putUint8(138); writeValue(buffer, value.index); - } else if (value is RoutingStrategyDto) { + } else if (value is CameraEventTypeDto) { buffer.putUint8(139); writeValue(buffer, value.index); - } else if (value is TravelModeDto) { + } else if (value is AlternateRoutesStrategyDto) { buffer.putUint8(140); writeValue(buffer, value.index); - } else if (value is RouteStatusDto) { + } else if (value is RoutingStrategyDto) { buffer.putUint8(141); writeValue(buffer, value.index); - } else if (value is AudioGuidanceTypeDto) { + } else if (value is TravelModeDto) { buffer.putUint8(142); writeValue(buffer, value.index); - } else if (value is SpeedAlertSeverityDto) { + } else if (value is RouteStatusDto) { buffer.putUint8(143); writeValue(buffer, value.index); - } else if (value is RouteSegmentTrafficDataStatusDto) { + } else if (value is AudioGuidanceTypeDto) { buffer.putUint8(144); writeValue(buffer, value.index); + } else if (value is SpeedAlertSeverityDto) { + buffer.putUint8(145); + writeValue(buffer, value.index); + } else if (value is RouteSegmentTrafficDataStatusDto) { + buffer.putUint8(146); + writeValue(buffer, value.index); } else if (value is RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto) { - buffer.putUint8(145); + buffer.putUint8(147); writeValue(buffer, value.index); } else if (value is ManeuverDto) { - buffer.putUint8(146); + buffer.putUint8(148); writeValue(buffer, value.index); } else if (value is DrivingSideDto) { - buffer.putUint8(147); + buffer.putUint8(149); writeValue(buffer, value.index); } else if (value is NavStateDto) { - buffer.putUint8(148); + buffer.putUint8(150); writeValue(buffer, value.index); } else if (value is LaneShapeDto) { - buffer.putUint8(149); + buffer.putUint8(151); writeValue(buffer, value.index); } else if (value is TaskRemovedBehaviorDto) { - buffer.putUint8(150); + buffer.putUint8(152); writeValue(buffer, value.index); } else if (value is MapOptionsDto) { - buffer.putUint8(151); + buffer.putUint8(153); writeValue(buffer, value.encode()); } else if (value is NavigationViewOptionsDto) { - buffer.putUint8(152); + buffer.putUint8(154); writeValue(buffer, value.encode()); } else if (value is ViewCreationOptionsDto) { - buffer.putUint8(153); + buffer.putUint8(155); writeValue(buffer, value.encode()); } else if (value is CameraPositionDto) { - buffer.putUint8(154); + buffer.putUint8(156); writeValue(buffer, value.encode()); } else if (value is MarkerDto) { - buffer.putUint8(155); + buffer.putUint8(157); writeValue(buffer, value.encode()); } else if (value is MarkerOptionsDto) { - buffer.putUint8(156); + buffer.putUint8(158); writeValue(buffer, value.encode()); } else if (value is ImageDescriptorDto) { - buffer.putUint8(157); + buffer.putUint8(159); writeValue(buffer, value.encode()); } else if (value is InfoWindowDto) { - buffer.putUint8(158); + buffer.putUint8(160); writeValue(buffer, value.encode()); } else if (value is MarkerAnchorDto) { - buffer.putUint8(159); + buffer.putUint8(161); writeValue(buffer, value.encode()); } else if (value is PolygonDto) { - buffer.putUint8(160); + buffer.putUint8(162); writeValue(buffer, value.encode()); } else if (value is PolygonOptionsDto) { - buffer.putUint8(161); + buffer.putUint8(163); writeValue(buffer, value.encode()); } else if (value is PolygonHoleDto) { - buffer.putUint8(162); + buffer.putUint8(164); writeValue(buffer, value.encode()); } else if (value is StyleSpanStrokeStyleDto) { - buffer.putUint8(163); + buffer.putUint8(165); writeValue(buffer, value.encode()); } else if (value is StyleSpanDto) { - buffer.putUint8(164); + buffer.putUint8(166); writeValue(buffer, value.encode()); } else if (value is PolylineDto) { - buffer.putUint8(165); + buffer.putUint8(167); writeValue(buffer, value.encode()); } else if (value is PatternItemDto) { - buffer.putUint8(166); + buffer.putUint8(168); writeValue(buffer, value.encode()); } else if (value is PolylineOptionsDto) { - buffer.putUint8(167); + buffer.putUint8(169); writeValue(buffer, value.encode()); } else if (value is CircleDto) { - buffer.putUint8(168); + buffer.putUint8(170); writeValue(buffer, value.encode()); } else if (value is CircleOptionsDto) { - buffer.putUint8(169); + buffer.putUint8(171); writeValue(buffer, value.encode()); } else if (value is MapPaddingDto) { - buffer.putUint8(170); + buffer.putUint8(172); writeValue(buffer, value.encode()); } else if (value is RouteTokenOptionsDto) { - buffer.putUint8(171); + buffer.putUint8(173); writeValue(buffer, value.encode()); } else if (value is DestinationsDto) { - buffer.putUint8(172); + buffer.putUint8(174); writeValue(buffer, value.encode()); } else if (value is RoutingOptionsDto) { - buffer.putUint8(173); + buffer.putUint8(175); writeValue(buffer, value.encode()); } else if (value is NavigationDisplayOptionsDto) { - buffer.putUint8(174); + buffer.putUint8(176); writeValue(buffer, value.encode()); } else if (value is NavigationWaypointDto) { - buffer.putUint8(175); + buffer.putUint8(177); writeValue(buffer, value.encode()); } else if (value is NavigationTimeAndDistanceDto) { - buffer.putUint8(176); + buffer.putUint8(178); writeValue(buffer, value.encode()); } else if (value is NavigationAudioGuidanceSettingsDto) { - buffer.putUint8(177); + buffer.putUint8(179); writeValue(buffer, value.encode()); } else if (value is SimulationOptionsDto) { - buffer.putUint8(178); + buffer.putUint8(180); writeValue(buffer, value.encode()); } else if (value is LatLngDto) { - buffer.putUint8(179); + buffer.putUint8(181); writeValue(buffer, value.encode()); } else if (value is LatLngBoundsDto) { - buffer.putUint8(180); + buffer.putUint8(182); writeValue(buffer, value.encode()); } else if (value is SpeedingUpdatedEventDto) { - buffer.putUint8(181); + buffer.putUint8(183); writeValue(buffer, value.encode()); } else if (value is GpsAvailabilityChangeEventDto) { - buffer.putUint8(182); + buffer.putUint8(184); writeValue(buffer, value.encode()); } else if (value is SpeedAlertOptionsThresholdPercentageDto) { - buffer.putUint8(183); + buffer.putUint8(185); writeValue(buffer, value.encode()); } else if (value is SpeedAlertOptionsDto) { - buffer.putUint8(184); + buffer.putUint8(186); writeValue(buffer, value.encode()); } else if (value is RouteSegmentTrafficDataRoadStretchRenderingDataDto) { - buffer.putUint8(185); + buffer.putUint8(187); writeValue(buffer, value.encode()); } else if (value is RouteSegmentTrafficDataDto) { - buffer.putUint8(186); + buffer.putUint8(188); writeValue(buffer, value.encode()); } else if (value is RouteSegmentDto) { - buffer.putUint8(187); + buffer.putUint8(189); writeValue(buffer, value.encode()); } else if (value is LaneDirectionDto) { - buffer.putUint8(188); + buffer.putUint8(190); writeValue(buffer, value.encode()); } else if (value is LaneDto) { - buffer.putUint8(189); + buffer.putUint8(191); writeValue(buffer, value.encode()); } else if (value is StepInfoDto) { - buffer.putUint8(190); + buffer.putUint8(192); writeValue(buffer, value.encode()); } else if (value is NavInfoDto) { - buffer.putUint8(191); + buffer.putUint8(193); writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); @@ -242,151 +248,157 @@ class _PigeonCodec extends StandardMessageCodec { return value == null ? null : MapTypeDto.values[value]; case 132: final int? value = readValue(buffer) as int?; - return value == null ? null : CameraPerspectiveDto.values[value]; + return value == null ? null : MapColorSchemeDto.values[value]; case 133: final int? value = readValue(buffer) as int?; - return value == null ? null : MarkerEventTypeDto.values[value]; + return value == null ? null : NavigationForceNightModeDto.values[value]; case 134: final int? value = readValue(buffer) as int?; - return value == null ? null : MarkerDragEventTypeDto.values[value]; + return value == null ? null : CameraPerspectiveDto.values[value]; case 135: final int? value = readValue(buffer) as int?; - return value == null ? null : StrokeJointTypeDto.values[value]; + return value == null ? null : MarkerEventTypeDto.values[value]; case 136: final int? value = readValue(buffer) as int?; - return value == null ? null : PatternTypeDto.values[value]; + return value == null ? null : MarkerDragEventTypeDto.values[value]; case 137: final int? value = readValue(buffer) as int?; - return value == null ? null : CameraEventTypeDto.values[value]; + return value == null ? null : StrokeJointTypeDto.values[value]; case 138: final int? value = readValue(buffer) as int?; - return value == null ? null : AlternateRoutesStrategyDto.values[value]; + return value == null ? null : PatternTypeDto.values[value]; case 139: final int? value = readValue(buffer) as int?; - return value == null ? null : RoutingStrategyDto.values[value]; + return value == null ? null : CameraEventTypeDto.values[value]; case 140: final int? value = readValue(buffer) as int?; - return value == null ? null : TravelModeDto.values[value]; + return value == null ? null : AlternateRoutesStrategyDto.values[value]; case 141: final int? value = readValue(buffer) as int?; - return value == null ? null : RouteStatusDto.values[value]; + return value == null ? null : RoutingStrategyDto.values[value]; case 142: final int? value = readValue(buffer) as int?; - return value == null ? null : AudioGuidanceTypeDto.values[value]; + return value == null ? null : TravelModeDto.values[value]; case 143: final int? value = readValue(buffer) as int?; - return value == null ? null : SpeedAlertSeverityDto.values[value]; + return value == null ? null : RouteStatusDto.values[value]; case 144: + final int? value = readValue(buffer) as int?; + return value == null ? null : AudioGuidanceTypeDto.values[value]; + case 145: + final int? value = readValue(buffer) as int?; + return value == null ? null : SpeedAlertSeverityDto.values[value]; + case 146: final int? value = readValue(buffer) as int?; return value == null ? null : RouteSegmentTrafficDataStatusDto.values[value]; - case 145: + case 147: final int? value = readValue(buffer) as int?; return value == null ? null : RouteSegmentTrafficDataRoadStretchRenderingDataStyleDto .values[value]; - case 146: + case 148: final int? value = readValue(buffer) as int?; return value == null ? null : ManeuverDto.values[value]; - case 147: + case 149: final int? value = readValue(buffer) as int?; return value == null ? null : DrivingSideDto.values[value]; - case 148: + case 150: final int? value = readValue(buffer) as int?; return value == null ? null : NavStateDto.values[value]; - case 149: + case 151: final int? value = readValue(buffer) as int?; return value == null ? null : LaneShapeDto.values[value]; - case 150: + case 152: final int? value = readValue(buffer) as int?; return value == null ? null : TaskRemovedBehaviorDto.values[value]; - case 151: + case 153: return MapOptionsDto.decode(readValue(buffer)!); - case 152: + case 154: return NavigationViewOptionsDto.decode(readValue(buffer)!); - case 153: + case 155: return ViewCreationOptionsDto.decode(readValue(buffer)!); - case 154: + case 156: return CameraPositionDto.decode(readValue(buffer)!); - case 155: + case 157: return MarkerDto.decode(readValue(buffer)!); - case 156: + case 158: return MarkerOptionsDto.decode(readValue(buffer)!); - case 157: + case 159: return ImageDescriptorDto.decode(readValue(buffer)!); - case 158: + case 160: return InfoWindowDto.decode(readValue(buffer)!); - case 159: + case 161: return MarkerAnchorDto.decode(readValue(buffer)!); - case 160: + case 162: return PolygonDto.decode(readValue(buffer)!); - case 161: + case 163: return PolygonOptionsDto.decode(readValue(buffer)!); - case 162: + case 164: return PolygonHoleDto.decode(readValue(buffer)!); - case 163: + case 165: return StyleSpanStrokeStyleDto.decode(readValue(buffer)!); - case 164: + case 166: return StyleSpanDto.decode(readValue(buffer)!); - case 165: + case 167: return PolylineDto.decode(readValue(buffer)!); - case 166: + case 168: return PatternItemDto.decode(readValue(buffer)!); - case 167: + case 169: return PolylineOptionsDto.decode(readValue(buffer)!); - case 168: + case 170: return CircleDto.decode(readValue(buffer)!); - case 169: + case 171: return CircleOptionsDto.decode(readValue(buffer)!); - case 170: + case 172: return MapPaddingDto.decode(readValue(buffer)!); - case 171: + case 173: return RouteTokenOptionsDto.decode(readValue(buffer)!); - case 172: + case 174: return DestinationsDto.decode(readValue(buffer)!); - case 173: + case 175: return RoutingOptionsDto.decode(readValue(buffer)!); - case 174: + case 176: return NavigationDisplayOptionsDto.decode(readValue(buffer)!); - case 175: + case 177: return NavigationWaypointDto.decode(readValue(buffer)!); - case 176: + case 178: return NavigationTimeAndDistanceDto.decode(readValue(buffer)!); - case 177: + case 179: return NavigationAudioGuidanceSettingsDto.decode(readValue(buffer)!); - case 178: + case 180: return SimulationOptionsDto.decode(readValue(buffer)!); - case 179: + case 181: return LatLngDto.decode(readValue(buffer)!); - case 180: + case 182: return LatLngBoundsDto.decode(readValue(buffer)!); - case 181: + case 183: return SpeedingUpdatedEventDto.decode(readValue(buffer)!); - case 182: + case 184: return GpsAvailabilityChangeEventDto.decode(readValue(buffer)!); - case 183: + case 185: return SpeedAlertOptionsThresholdPercentageDto.decode( readValue(buffer)!, ); - case 184: + case 186: return SpeedAlertOptionsDto.decode(readValue(buffer)!); - case 185: + case 187: return RouteSegmentTrafficDataRoadStretchRenderingDataDto.decode( readValue(buffer)!, ); - case 186: + case 188: return RouteSegmentTrafficDataDto.decode(readValue(buffer)!); - case 187: + case 189: return RouteSegmentDto.decode(readValue(buffer)!); - case 188: + case 190: return LaneDirectionDto.decode(readValue(buffer)!); - case 189: + case 191: return LaneDto.decode(readValue(buffer)!); - case 190: + case 192: return StepInfoDto.decode(readValue(buffer)!); - case 191: + case 193: return NavInfoDto.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -641,6 +653,17 @@ abstract class TestMapViewApi { MapPaddingDto getPadding(int viewId); + MapColorSchemeDto getMapColorScheme(int viewId); + + void setMapColorScheme(int viewId, MapColorSchemeDto mapColorScheme); + + NavigationForceNightModeDto getForceNightMode(int viewId); + + void setForceNightMode( + int viewId, + NavigationForceNightModeDto forceNightMode, + ); + static void setUp( TestMapViewApi? api, { BinaryMessenger? binaryMessenger, @@ -4951,6 +4974,177 @@ abstract class TestMapViewApi { }); } } + { + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getMapColorScheme$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, ( + Object? message, + ) async { + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getMapColorScheme 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.getMapColorScheme was null, expected non-null int.', + ); + try { + final MapColorSchemeDto output = api.getMapColorScheme( + arg_viewId!, + ); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException( + code: 'error', + message: e.toString(), + ), + ); + } + }); + } + } + { + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setMapColorScheme$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler< + Object? + >(pigeonVar_channel, (Object? message) async { + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setMapColorScheme 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.setMapColorScheme was null, expected non-null int.', + ); + final MapColorSchemeDto? arg_mapColorScheme = + (args[1] as MapColorSchemeDto?); + assert( + arg_mapColorScheme != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setMapColorScheme was null, expected non-null MapColorSchemeDto.', + ); + try { + api.setMapColorScheme(arg_viewId!, arg_mapColorScheme!); + 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 + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getForceNightMode$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, ( + Object? message, + ) async { + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.getForceNightMode 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.getForceNightMode was null, expected non-null int.', + ); + try { + final NavigationForceNightModeDto output = api + .getForceNightMode(arg_viewId!); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException( + code: 'error', + message: e.toString(), + ), + ); + } + }); + } + } + { + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setForceNightMode$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler< + Object? + >(pigeonVar_channel, (Object? message) async { + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setForceNightMode 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.setForceNightMode was null, expected non-null int.', + ); + final NavigationForceNightModeDto? arg_forceNightMode = + (args[1] as NavigationForceNightModeDto?); + assert( + arg_forceNightMode != null, + 'Argument for dev.flutter.pigeon.google_navigation_flutter.MapViewApi.setForceNightMode was null, expected non-null NavigationForceNightModeDto.', + ); + try { + api.setForceNightMode(arg_viewId!, arg_forceNightMode!); + return wrapResponse(empty: true); + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString()), + ); + } + }); + } + } } } diff --git a/test/navigation_types_test.dart b/test/navigation_types_test.dart index 22c9f13c..a3786cce 100644 --- a/test/navigation_types_test.dart +++ b/test/navigation_types_test.dart @@ -607,4 +607,80 @@ void main() { expect(lonSpan, 20.0); }); }); + + group('MapColorScheme tests', () { + test('tests MapColorScheme conversion to DTO', () { + expect( + MapColorScheme.followSystem.toDto(), + MapColorSchemeDto.followSystem, + ); + expect(MapColorScheme.light.toDto(), MapColorSchemeDto.light); + expect(MapColorScheme.dark.toDto(), MapColorSchemeDto.dark); + }); + + test('tests MapColorScheme conversion from DTO', () { + expect( + MapColorSchemeDto.followSystem.toMapColorScheme(), + MapColorScheme.followSystem, + ); + expect(MapColorSchemeDto.light.toMapColorScheme(), MapColorScheme.light); + expect(MapColorSchemeDto.dark.toMapColorScheme(), MapColorScheme.dark); + }); + + test('tests MapColorScheme enum values', () { + expect(MapColorScheme.values.length, 3); + expect( + MapColorScheme.values, + containsAll([ + MapColorScheme.followSystem, + MapColorScheme.light, + MapColorScheme.dark, + ]), + ); + }); + }); + + group('NavigationForceNightMode tests', () { + test('tests NavigationForceNightMode conversion to DTO', () { + expect( + NavigationForceNightMode.auto.toDto(), + NavigationForceNightModeDto.auto, + ); + expect( + NavigationForceNightMode.forceDay.toDto(), + NavigationForceNightModeDto.forceDay, + ); + expect( + NavigationForceNightMode.forceNight.toDto(), + NavigationForceNightModeDto.forceNight, + ); + }); + + test('tests NavigationForceNightMode conversion from DTO', () { + expect( + NavigationForceNightModeDto.auto.toNavigationForceNightMode(), + NavigationForceNightMode.auto, + ); + expect( + NavigationForceNightModeDto.forceDay.toNavigationForceNightMode(), + NavigationForceNightMode.forceDay, + ); + expect( + NavigationForceNightModeDto.forceNight.toNavigationForceNightMode(), + NavigationForceNightMode.forceNight, + ); + }); + + test('tests NavigationForceNightMode enum values', () { + expect(NavigationForceNightMode.values.length, 3); + expect( + NavigationForceNightMode.values, + containsAll([ + NavigationForceNightMode.auto, + NavigationForceNightMode.forceDay, + NavigationForceNightMode.forceNight, + ]), + ); + }); + }); } diff --git a/tool/test-ios.sh b/tool/test-ios.sh index a8a84710..ba3767f2 100755 --- a/tool/test-ios.sh +++ b/tool/test-ios.sh @@ -15,7 +15,7 @@ set -e DEVICE_NAME=${TEST_DEVICE:-'iPhone 16 Pro'} # Default to 'iPhone 16 Pro' if no argument is provided -OS_VERSION=${TEST_OS:-'18.5'} # Default to 'iOS 18.5' if no argument is provided +OS_VERSION=${TEST_OS:-'18.6'} # Default to 'iOS 18.6' if no argument is provided # Navigate to the ios directory and run xcodebuild with the provided device name cd ios && xcodebuild test \ From a211741ddb84ae8f43741af5f8a72b4cf1735652 Mon Sep 17 00:00:00 2001 From: Joonas Kerttula Date: Tue, 9 Dec 2025 09:44:05 +0200 Subject: [PATCH 2/2] fix: throw error on convertNavigationForceNightModeToDto for unknown types --- .../main/kotlin/com/google/maps/flutter/navigation/Convert.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 05de8f9b..2af77033 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 @@ -333,9 +333,10 @@ object Convert { */ fun convertNavigationForceNightModeToDto(forceNightMode: Int): NavigationForceNightModeDto { return when (forceNightMode) { + ForceNightMode.AUTO -> NavigationForceNightModeDto.AUTO ForceNightMode.FORCE_DAY -> NavigationForceNightModeDto.FORCE_DAY ForceNightMode.FORCE_NIGHT -> NavigationForceNightModeDto.FORCE_NIGHT - else -> NavigationForceNightModeDto.AUTO + else -> throw FlutterError("convertError", "Unknown ForceNightMode: $forceNightMode") } }