From e76cdca4732b054946344d3a80a7e3cbdef522ea Mon Sep 17 00:00:00 2001 From: Peng Liu Date: Mon, 9 Dec 2024 22:45:38 +0800 Subject: [PATCH] Update glnative to v11.9.0-rc.1 and add precipitations API and example. (#2874) --- CHANGELOG.md | 14 +- LICENSE.md | 2 +- app/src/main/AndroidManifest.xml | 12 + .../examples/style/PrecipitationActivity.kt | 78 ++ .../res/layout/activity_precipitations.xml | 35 + .../main/res/values/example_descriptions.xml | 1 + app/src/main/res/values/example_titles.xml | 1 + compose-app/src/main/AndroidManifest.xml | 10 + .../examples/style/PrecipitationsActivity.kt | 155 +++ .../main/res/values/example_descriptions.xml | 1 + .../src/main/res/values/example_titles.xml | 1 + extension-compose/api/Release/metalava.txt | 159 ++- extension-compose/api/extension-compose.api | 152 ++- .../maps/extension/compose/style/Style.kt | 10 + .../extension/compose/style/StyleState.kt | 18 + .../compose/style/internal/MapStyleNode.kt | 34 + .../style/precipitations/RainStateApplier.kt | 159 +++ .../style/precipitations/SnowStateApplier.kt | 155 +++ .../precipitations/generated/RainState.kt | 472 +++++++++ .../precipitations/generated/SnowState.kt | 472 +++++++++ .../style/standard/BaseStandardStyleState.kt | 16 + .../ExperimentalStandardStyleState.kt | 18 +- .../maps/testapp/style/BaseStyleTest.kt | 15 + .../precipitations/generated/RainTest.kt | 419 ++++++++ .../precipitations/generated/SnowTest.kt | 419 ++++++++ extension-style/api/Release/metalava.txt | 256 +++++ extension-style/api/extension-style.api | 226 ++++ .../extension/style/StyleExtensionImpl.kt | 46 +- .../style/precipitations/generated/Rain.kt | 989 ++++++++++++++++++ .../style/precipitations/generated/RainExt.kt | 39 + .../style/precipitations/generated/Snow.kt | 989 ++++++++++++++++++ .../style/precipitations/generated/SnowExt.kt | 39 + .../maps/extension/style/types/TypeDSLs.kt | 22 +- .../precipitations/generated/RainTest.kt | 946 +++++++++++++++++ .../precipitations/generated/SnowTest.kt | 946 +++++++++++++++++ gradle/libs.versions.toml | 4 +- .../main/java/com/mapbox/maps/MapboxMap.kt | 2 + sdk-base/api/Release/metalava.txt | 18 + sdk-base/api/sdk-base.api | 16 + .../com/mapbox/maps/MapboxStyleManager.kt | 90 ++ .../maps/extension/style/StyleContract.kt | 38 + 41 files changed, 7478 insertions(+), 16 deletions(-) create mode 100644 app/src/main/java/com/mapbox/maps/testapp/examples/style/PrecipitationActivity.kt create mode 100644 app/src/main/res/layout/activity_precipitations.xml create mode 100644 compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/style/PrecipitationsActivity.kt create mode 100644 extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/RainStateApplier.kt create mode 100644 extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/SnowStateApplier.kt create mode 100644 extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/generated/RainState.kt create mode 100644 extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/generated/SnowState.kt create mode 100644 extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/precipitations/generated/RainTest.kt create mode 100644 extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/precipitations/generated/SnowTest.kt create mode 100644 extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/Rain.kt create mode 100644 extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/RainExt.kt create mode 100644 extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/Snow.kt create mode 100644 extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/SnowExt.kt create mode 100644 extension-style/src/test/java/com/mapbox/maps/extension/style/precipitations/generated/RainTest.kt create mode 100644 extension-style/src/test/java/com/mapbox/maps/extension/style/precipitations/generated/SnowTest.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 38c3344244..9ee3b9f830 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,20 @@ Mapbox welcomes participation and contributions from everyone. # 11.9.0-rc.1 - +## Features ✨ and improvements 🏁 * Add `toHsla` expression. +* Introduce experimental `Snow` and `Rain` APIs to show the snow or rain effect on the map. +* [compose] Introduce experimental `SnowState` and `RainState` APIs to show the snow or rain effect on the map. + +## Bug fixes 🐞 +* Improve character spacing for text offsets. +* Fixed crash on Android API level < 26. +* Do not load vector icons for client-provided sprites. +* Fall back to the feature's original ID when promoteId is an object and the source layer is not specified as a key in the object. +* Fixed crash caused by a repeated command buffer commit call. + +## Dependencies +* Update gl-native to v11.9.0-rc.1 and common to v24.9.0-rc.1. # 11.8.1 December 03, 2024 ## Bug fixes 🐞 diff --git a/LICENSE.md b/LICENSE.md index 255d9d4766..c051fe2e6d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -482,7 +482,7 @@ License: [The Apache Software License, Version 2.0](http://www.apache.org/licens =========================================================================== -### MapboxCoreMaps,11.10.0-beta.1,Mapbox ToS,Mapbox,https://www.mapbox.com/ +### MapboxCoreMaps,11.9.0-rc.1,Mapbox ToS,Mapbox,https://www.mapbox.com/ ``` Mapbox Core Maps version 11.0 diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2264ad7710..1653e0a51d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1414,5 +1414,17 @@ android:name="android.support.PARENT_ACTIVITY" android:value=".ExampleOverviewActivity" /> + + + + diff --git a/app/src/main/java/com/mapbox/maps/testapp/examples/style/PrecipitationActivity.kt b/app/src/main/java/com/mapbox/maps/testapp/examples/style/PrecipitationActivity.kt new file mode 100644 index 0000000000..5cfc907fb4 --- /dev/null +++ b/app/src/main/java/com/mapbox/maps/testapp/examples/style/PrecipitationActivity.kt @@ -0,0 +1,78 @@ +package com.mapbox.maps.testapp.examples.style + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.mapbox.geojson.Point +import com.mapbox.maps.CameraOptions +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.Style +import com.mapbox.maps.extension.style.precipitations.generated.rain +import com.mapbox.maps.extension.style.precipitations.generated.removeRain +import com.mapbox.maps.extension.style.precipitations.generated.removeSnow +import com.mapbox.maps.extension.style.precipitations.generated.setRain +import com.mapbox.maps.extension.style.precipitations.generated.setSnow +import com.mapbox.maps.extension.style.precipitations.generated.snow +import com.mapbox.maps.extension.style.style +import com.mapbox.maps.testapp.databinding.ActivityPrecipitationsBinding + +/** + * Showcase snow and rain effect. + */ +@OptIn(MapboxExperimental::class) +class PrecipitationActivity : AppCompatActivity() { + + private var isSnowing: Boolean = true + private var isRaining: Boolean = true + private val rain = rain { + intensity(0.6) + opacity(0.5) + vignette(0.5) + } + private val snow = snow { + intensity(0.6) + opacity(0.5) + vignette(0.5) + } + private lateinit var binding: ActivityPrecipitationsBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityPrecipitationsBinding.inflate(layoutInflater) + setContentView(binding.root) + val mapboxMap = binding.mapView.mapboxMap + mapboxMap.setCamera( + CameraOptions.Builder() + .center(Point.fromLngLat(24.943849, 60.171924)) + .bearing(-17.6) + .pitch(45.0) + .zoom(16.0) + .build() + ) + + mapboxMap.loadStyle( + style(Style.STANDARD) { + +snow + +rain + } + ) + + // change snow intensity on fab click + binding.toggleSnow.setOnClickListener { + isSnowing = !isSnowing + if (isSnowing) { + mapboxMap.setSnow(snow) + } else { + mapboxMap.removeSnow() + } + } + + binding.toggleRain.setOnClickListener { + isRaining = !isRaining + if (isRaining) { + mapboxMap.setRain(rain) + } else { + mapboxMap.removeRain() + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_precipitations.xml b/app/src/main/res/layout/activity_precipitations.xml new file mode 100644 index 0000000000..ecc0f430b9 --- /dev/null +++ b/app/src/main/res/layout/activity_precipitations.xml @@ -0,0 +1,35 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/example_descriptions.xml b/app/src/main/res/values/example_descriptions.xml index e58d26546d..e8e957269f 100644 --- a/app/src/main/res/values/example_descriptions.xml +++ b/app/src/main/res/values/example_descriptions.xml @@ -110,4 +110,5 @@ Showcase the usage of clip layer. Showcase of the Standard Style interactions. Animate 3D location puck on the map + Showcase rain and snow effects. diff --git a/app/src/main/res/values/example_titles.xml b/app/src/main/res/values/example_titles.xml index 8c5b66465e..9e4512bac7 100644 --- a/app/src/main/res/values/example_titles.xml +++ b/app/src/main/res/values/example_titles.xml @@ -112,4 +112,5 @@ Clip layer example Standard Style interactions Location component model animation + Precipitations example diff --git a/compose-app/src/main/AndroidManifest.xml b/compose-app/src/main/AndroidManifest.xml index a07bbc798c..a8111c6306 100644 --- a/compose-app/src/main/AndroidManifest.xml +++ b/compose-app/src/main/AndroidManifest.xml @@ -307,6 +307,16 @@ android:name="@string/category" android:value="@string/category_styles" /> + + + \ No newline at end of file diff --git a/compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/style/PrecipitationsActivity.kt b/compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/style/PrecipitationsActivity.kt new file mode 100644 index 0000000000..0b371a65e5 --- /dev/null +++ b/compose-app/src/main/java/com/mapbox/maps/compose/testapp/examples/style/PrecipitationsActivity.kt @@ -0,0 +1,155 @@ +package com.mapbox.maps.compose.testapp.examples.style + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.FloatingActionButton +import androidx.compose.material.Text +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.Style +import com.mapbox.maps.compose.testapp.ExampleScaffold +import com.mapbox.maps.compose.testapp.examples.utils.CityLocations +import com.mapbox.maps.compose.testapp.ui.theme.MapboxMapComposeTheme +import com.mapbox.maps.extension.compose.MapboxMap +import com.mapbox.maps.extension.compose.animation.viewport.rememberMapViewportState +import com.mapbox.maps.extension.compose.style.DoubleValue +import com.mapbox.maps.extension.compose.style.MapStyle +import com.mapbox.maps.extension.compose.style.precipitations.generated.RainState +import com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState +import com.mapbox.maps.extension.compose.style.precipitations.generated.rememberRainState +import com.mapbox.maps.extension.compose.style.precipitations.generated.rememberSnowState +import com.mapbox.maps.extension.compose.style.rememberStyleState + +/** + * Example to showcase usage of [RainState] and [SnowState]. + */ +@OptIn(MapboxExperimental::class) +public class PrecipitationsActivity : ComponentActivity() { + + /** + * Describes the heaviness of precipitation. + */ + public sealed class PrecipitationState( + public val intensity: Double, + public val density: Double, + public val opacity: Double, + public val text: String + ) { + public object None : PrecipitationState(intensity = 0.0, density = 0.0, opacity = 0.0, text = "no") + + public object Light : PrecipitationState(intensity = 0.2, density = 0.2, opacity = 0.3, text = "light") + + public object Medium : PrecipitationState(intensity = 0.6, density = 0.6, opacity = 0.5, text = "medium") + + public object Heavy : PrecipitationState(intensity = 1.0, density = 1.0, opacity = 0.8, text = "heavy") + + public fun toggleNext(): PrecipitationState { + return when (this) { + Heavy -> None + None -> Light + Light -> Medium + Medium -> Heavy + } + } + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setContent { + var snowPrecipitationState: PrecipitationState by remember { + mutableStateOf(PrecipitationState.Light) + } + + var rainPrecipitationState: PrecipitationState by remember { + mutableStateOf(PrecipitationState.Light) + } + + val mapViewportState = rememberMapViewportState { + setCameraOptions { + zoom(ZOOM) + pitch(PITCH) + bearing(BEARING) + center(CityLocations.HELSINKI) + } + } + + val rainState = rememberRainState().also { + it.opacity = DoubleValue(rainPrecipitationState.opacity) + it.intensity = DoubleValue(rainPrecipitationState.intensity) + it.density = DoubleValue(rainPrecipitationState.density) + } + + val snowState = rememberSnowState().also { + it.opacity = DoubleValue(snowPrecipitationState.opacity) + it.intensity = DoubleValue(snowPrecipitationState.intensity) + it.density = DoubleValue(snowPrecipitationState.density) + } + + MapboxMapComposeTheme { + ExampleScaffold( + floatingActionButton = { + Column { + FloatingActionButton( + modifier = Modifier.padding(bottom = 10.dp), + onClick = { + rainPrecipitationState = rainPrecipitationState.toggleNext() + }, + shape = RoundedCornerShape(16.dp), + ) { + Text( + modifier = Modifier.padding(10.dp), + text = "${rainPrecipitationState.text} rain" + ) + } + FloatingActionButton( + modifier = Modifier.padding(bottom = 10.dp), + onClick = { + snowPrecipitationState = snowPrecipitationState.toggleNext() + }, + shape = RoundedCornerShape(16.dp), + ) { + Text( + modifier = Modifier.padding(10.dp), + text = "${snowPrecipitationState.text} snow" + ) + } + } + } + ) { + MapboxMap( + Modifier.fillMaxSize(), + mapViewportState = mapViewportState, + style = { + MapStyle( + style = Style.STANDARD, + styleState = rememberStyleState().apply { + this.rainState = + if (rainPrecipitationState == PrecipitationState.None) RainState.DISABLED else rainState + this.snowState = + if (snowPrecipitationState == PrecipitationState.None) SnowState.DISABLED else snowState + } + ) + } + ) + } + } + } + } + + private companion object { + private const val ZOOM: Double = 16.0 + private const val PITCH: Double = 40.0 + private const val BEARING: Double = 70.0 + } +} \ No newline at end of file diff --git a/compose-app/src/main/res/values/example_descriptions.xml b/compose-app/src/main/res/values/example_descriptions.xml index 820578872a..af6772b6aa 100644 --- a/compose-app/src/main/res/values/example_descriptions.xml +++ b/compose-app/src/main/res/values/example_descriptions.xml @@ -27,4 +27,5 @@ Showcase usage of Standard style Showcase the usage of clip layer. Showcase the interactions. + Showcase the rain and snow effects. \ No newline at end of file diff --git a/compose-app/src/main/res/values/example_titles.xml b/compose-app/src/main/res/values/example_titles.xml index 38c379d575..cd8b0ef305 100644 --- a/compose-app/src/main/res/values/example_titles.xml +++ b/compose-app/src/main/res/values/example_titles.xml @@ -27,4 +27,5 @@ Standard style Clip layer example Interactions example + Precipitations example diff --git a/extension-compose/api/Release/metalava.txt b/extension-compose/api/Release/metalava.txt index aea236be79..f8cd2eeea6 100644 --- a/extension-compose/api/Release/metalava.txt +++ b/extension-compose/api/Release/metalava.txt @@ -1297,6 +1297,8 @@ package com.mapbox.maps.extension.compose.style { method public com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState getAtmosphereState(); method public com.mapbox.maps.extension.compose.style.lights.LightsState getLightsState(); method public com.mapbox.maps.extension.compose.style.projection.generated.Projection getProjection(); + method public com.mapbox.maps.extension.compose.style.precipitations.generated.RainState getRainState(); + method public com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState getSnowState(); method public com.mapbox.maps.extension.compose.style.StyleImportsConfig getStyleImportsConfig(); method public com.mapbox.maps.extension.compose.style.interactions.StyleInteractionsState getStyleInteractionsState(); method public com.mapbox.maps.TransitionOptions getStyleTransition(); @@ -1304,6 +1306,8 @@ package com.mapbox.maps.extension.compose.style { method public void setAtmosphereState(com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState); method public void setLightsState(com.mapbox.maps.extension.compose.style.lights.LightsState); method public void setProjection(com.mapbox.maps.extension.compose.style.projection.generated.Projection); + method public void setRainState(com.mapbox.maps.extension.compose.style.precipitations.generated.RainState); + method public void setSnowState(com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState); method public void setStyleImportsConfig(com.mapbox.maps.extension.compose.style.StyleImportsConfig); method public void setStyleInteractionsState(com.mapbox.maps.extension.compose.style.interactions.StyleInteractionsState); method public void setStyleTransition(com.mapbox.maps.TransitionOptions); @@ -1311,6 +1315,8 @@ package com.mapbox.maps.extension.compose.style { property public final com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState atmosphereState; property public final com.mapbox.maps.extension.compose.style.lights.LightsState lightsState; property public final com.mapbox.maps.extension.compose.style.projection.generated.Projection projection; + property public final com.mapbox.maps.extension.compose.style.precipitations.generated.RainState rainState; + property public final com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState snowState; property public final com.mapbox.maps.extension.compose.style.StyleImportsConfig styleImportsConfig; property public final com.mapbox.maps.extension.compose.style.interactions.StyleInteractionsState styleInteractionsState; property public final com.mapbox.maps.TransitionOptions styleTransition; @@ -3838,6 +3844,151 @@ package com.mapbox.maps.extension.compose.style.lights.generated { } +package com.mapbox.maps.extension.compose.style.precipitations { + + public final class RainStateApplierKt { + } + +} + +package com.mapbox.maps.extension.compose.style.precipitations.generated { + + @androidx.compose.runtime.Stable @com.mapbox.maps.MapboxExperimental public final class RainState { + ctor public RainState(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getCenterThinning(); + method public com.mapbox.maps.extension.compose.style.Transition getCenterThinningTransition(); + method public com.mapbox.maps.extension.compose.style.ColorValue getColor(); + method public com.mapbox.maps.extension.compose.style.Transition getColorTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getDensity(); + method public com.mapbox.maps.extension.compose.style.Transition getDensityTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleListValue getDirection(); + method public com.mapbox.maps.extension.compose.style.Transition getDirectionTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getIntensity(); + method public com.mapbox.maps.extension.compose.style.Transition getIntensityTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getOpacity(); + method public com.mapbox.maps.extension.compose.style.Transition getOpacityTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getVignette(); + method public com.mapbox.maps.extension.compose.style.Transition getVignetteTransition(); + method public void setCenterThinning(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setCenterThinningTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setColor(com.mapbox.maps.extension.compose.style.ColorValue); + method public void setColorTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setDensity(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setDensityTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setDirection(com.mapbox.maps.extension.compose.style.DoubleListValue); + method public void setDirectionTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setIntensity(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setIntensityTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setOpacity(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setOpacityTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setVignette(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setVignetteTransition(com.mapbox.maps.extension.compose.style.Transition); + property public final com.mapbox.maps.extension.compose.style.DoubleValue centerThinning; + property public final com.mapbox.maps.extension.compose.style.Transition centerThinningTransition; + property public final com.mapbox.maps.extension.compose.style.ColorValue color; + property public final com.mapbox.maps.extension.compose.style.Transition colorTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleValue density; + property public final com.mapbox.maps.extension.compose.style.Transition densityTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleListValue direction; + property public final com.mapbox.maps.extension.compose.style.Transition directionTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleValue intensity; + property public final com.mapbox.maps.extension.compose.style.Transition intensityTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleValue opacity; + property public final com.mapbox.maps.extension.compose.style.Transition opacityTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleValue vignette; + property public final com.mapbox.maps.extension.compose.style.Transition vignetteTransition; + field public static final com.mapbox.maps.extension.compose.style.precipitations.generated.RainState.Companion Companion; + field public static final com.mapbox.maps.extension.compose.style.precipitations.generated.RainState DISABLED; + } + + public static final class RainState.Companion { + method public androidx.compose.runtime.saveable.Saver getSaver(); + property public final androidx.compose.runtime.saveable.Saver Saver; + } + + @kotlinx.parcelize.Parcelize @kotlinx.parcelize.TypeParceler public static final class RainState.Holder implements android.os.Parcelable { + method public java.util.Map component1(); + method public boolean component2(); + method public com.mapbox.maps.extension.compose.style.precipitations.generated.RainState.Holder copy(java.util.Map savedProperties, boolean enabled); + method public boolean getEnabled(); + method public java.util.Map getSavedProperties(); + property public final boolean enabled; + property public final java.util.Map savedProperties; + } + + public final class RainStateKt { + method @androidx.compose.runtime.Composable @com.mapbox.maps.MapboxExperimental public static inline com.mapbox.maps.extension.compose.style.precipitations.generated.RainState rememberRainState(String? key = null, kotlin.jvm.functions.Function1 init = {}); + } + + @androidx.compose.runtime.Stable @com.mapbox.maps.MapboxExperimental public final class SnowState { + ctor public SnowState(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getCenterThinning(); + method public com.mapbox.maps.extension.compose.style.Transition getCenterThinningTransition(); + method public com.mapbox.maps.extension.compose.style.ColorValue getColor(); + method public com.mapbox.maps.extension.compose.style.Transition getColorTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getDensity(); + method public com.mapbox.maps.extension.compose.style.Transition getDensityTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleListValue getDirection(); + method public com.mapbox.maps.extension.compose.style.Transition getDirectionTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getIntensity(); + method public com.mapbox.maps.extension.compose.style.Transition getIntensityTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getOpacity(); + method public com.mapbox.maps.extension.compose.style.Transition getOpacityTransition(); + method public com.mapbox.maps.extension.compose.style.DoubleValue getVignette(); + method public com.mapbox.maps.extension.compose.style.Transition getVignetteTransition(); + method public void setCenterThinning(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setCenterThinningTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setColor(com.mapbox.maps.extension.compose.style.ColorValue); + method public void setColorTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setDensity(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setDensityTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setDirection(com.mapbox.maps.extension.compose.style.DoubleListValue); + method public void setDirectionTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setIntensity(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setIntensityTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setOpacity(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setOpacityTransition(com.mapbox.maps.extension.compose.style.Transition); + method public void setVignette(com.mapbox.maps.extension.compose.style.DoubleValue); + method public void setVignetteTransition(com.mapbox.maps.extension.compose.style.Transition); + property public final com.mapbox.maps.extension.compose.style.DoubleValue centerThinning; + property public final com.mapbox.maps.extension.compose.style.Transition centerThinningTransition; + property public final com.mapbox.maps.extension.compose.style.ColorValue color; + property public final com.mapbox.maps.extension.compose.style.Transition colorTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleValue density; + property public final com.mapbox.maps.extension.compose.style.Transition densityTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleListValue direction; + property public final com.mapbox.maps.extension.compose.style.Transition directionTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleValue intensity; + property public final com.mapbox.maps.extension.compose.style.Transition intensityTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleValue opacity; + property public final com.mapbox.maps.extension.compose.style.Transition opacityTransition; + property public final com.mapbox.maps.extension.compose.style.DoubleValue vignette; + property public final com.mapbox.maps.extension.compose.style.Transition vignetteTransition; + field public static final com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState.Companion Companion; + field public static final com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState DISABLED; + } + + public static final class SnowState.Companion { + method public androidx.compose.runtime.saveable.Saver getSaver(); + property public final androidx.compose.runtime.saveable.Saver Saver; + } + + @kotlinx.parcelize.Parcelize @kotlinx.parcelize.TypeParceler public static final class SnowState.Holder implements android.os.Parcelable { + method public java.util.Map component1(); + method public boolean component2(); + method public com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState.Holder copy(java.util.Map savedProperties, boolean enabled); + method public boolean getEnabled(); + method public java.util.Map getSavedProperties(); + property public final boolean enabled; + property public final java.util.Map savedProperties; + } + + public final class SnowStateKt { + method @androidx.compose.runtime.Composable @com.mapbox.maps.MapboxExperimental public static inline com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState rememberSnowState(String? key = null, kotlin.jvm.functions.Function1 init = {}); + } + +} + package com.mapbox.maps.extension.compose.style.projection.generated { @androidx.compose.runtime.Immutable public final class Projection { @@ -4317,20 +4468,26 @@ package com.mapbox.maps.extension.compose.style.sources.generated { package com.mapbox.maps.extension.compose.style.standard { @androidx.compose.runtime.Stable @com.mapbox.maps.MapboxExperimental public class BaseStandardStyleState { - ctor protected BaseStandardStyleState(com.mapbox.maps.extension.compose.style.projection.generated.Projection initialProjection, com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState initialAtmosphereState, com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState initialTerrainState = com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState.INITIAL, com.mapbox.maps.extension.compose.style.lights.LightsState initialLightsState = com.mapbox.maps.extension.compose.style.lights.LightsState.INITIAL, com.mapbox.maps.TransitionOptions initialStyleTransition); + ctor protected BaseStandardStyleState(com.mapbox.maps.extension.compose.style.projection.generated.Projection initialProjection, com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState initialAtmosphereState, com.mapbox.maps.extension.compose.style.precipitations.generated.RainState initialRainState, com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState initialSnowState, com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState initialTerrainState = com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState.INITIAL, com.mapbox.maps.extension.compose.style.lights.LightsState initialLightsState = com.mapbox.maps.extension.compose.style.lights.LightsState.INITIAL, com.mapbox.maps.TransitionOptions initialStyleTransition); method public final com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState getAtmosphereState(); method public final com.mapbox.maps.extension.compose.style.lights.LightsState getLightsState(); method public final com.mapbox.maps.extension.compose.style.projection.generated.Projection getProjection(); + method public final com.mapbox.maps.extension.compose.style.precipitations.generated.RainState getRainState(); + method public final com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState getSnowState(); method public final com.mapbox.maps.TransitionOptions getStyleTransition(); method public final com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState getTerrainState(); method public final void setAtmosphereState(com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState); method public final void setLightsState(com.mapbox.maps.extension.compose.style.lights.LightsState); method public final void setProjection(com.mapbox.maps.extension.compose.style.projection.generated.Projection); + method public final void setRainState(com.mapbox.maps.extension.compose.style.precipitations.generated.RainState); + method public final void setSnowState(com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState); method public final void setStyleTransition(com.mapbox.maps.TransitionOptions); method public final void setTerrainState(com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState); property public final com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState atmosphereState; property public final com.mapbox.maps.extension.compose.style.lights.LightsState lightsState; property public final com.mapbox.maps.extension.compose.style.projection.generated.Projection projection; + property public final com.mapbox.maps.extension.compose.style.precipitations.generated.RainState rainState; + property public final com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState snowState; property public final com.mapbox.maps.TransitionOptions styleTransition; property public final com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState terrainState; } diff --git a/extension-compose/api/extension-compose.api b/extension-compose/api/extension-compose.api index b6b587c695..97d7b9a74f 100644 --- a/extension-compose/api/extension-compose.api +++ b/extension-compose/api/extension-compose.api @@ -1102,6 +1102,8 @@ public final class com/mapbox/maps/extension/compose/style/StyleState { public final fun getAtmosphereState ()Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState; public final fun getLightsState ()Lcom/mapbox/maps/extension/compose/style/lights/LightsState; public final fun getProjection ()Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection; + public final fun getRainState ()Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState; + public final fun getSnowState ()Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState; public final fun getStyleImportsConfig ()Lcom/mapbox/maps/extension/compose/style/StyleImportsConfig; public final fun getStyleInteractionsState ()Lcom/mapbox/maps/extension/compose/style/interactions/StyleInteractionsState; public final fun getStyleTransition ()Lcom/mapbox/maps/TransitionOptions; @@ -1109,6 +1111,8 @@ public final class com/mapbox/maps/extension/compose/style/StyleState { public final fun setAtmosphereState (Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;)V public final fun setLightsState (Lcom/mapbox/maps/extension/compose/style/lights/LightsState;)V public final fun setProjection (Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;)V + public final fun setRainState (Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState;)V + public final fun setSnowState (Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState;)V public final fun setStyleImportsConfig (Lcom/mapbox/maps/extension/compose/style/StyleImportsConfig;)V public final fun setStyleInteractionsState (Lcom/mapbox/maps/extension/compose/style/interactions/StyleInteractionsState;)V public final fun setStyleTransition (Lcom/mapbox/maps/TransitionOptions;)V @@ -3250,6 +3254,146 @@ public final class com/mapbox/maps/extension/compose/style/lights/generated/Flat public static final fun rememberFlatLightState (Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)Lcom/mapbox/maps/extension/compose/style/lights/generated/FlatLightState; } +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/RainState { + public static final field Companion Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState$Companion; + public static final field DISABLED Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState; + public fun ()V + public synthetic fun (Lcom/mapbox/maps/extension/compose/style/precipitations/RainStateApplier;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/ColorValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleListValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun equals (Ljava/lang/Object;)Z + public final fun getCenterThinning ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getCenterThinningTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getColor ()Lcom/mapbox/maps/extension/compose/style/ColorValue; + public final fun getColorTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getDensity ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getDensityTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getDirection ()Lcom/mapbox/maps/extension/compose/style/DoubleListValue; + public final fun getDirectionTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getIntensity ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getIntensityTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getOpacity ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getOpacityTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getVignette ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getVignetteTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public fun hashCode ()I + public final fun setCenterThinning (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setCenterThinningTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setColor (Lcom/mapbox/maps/extension/compose/style/ColorValue;)V + public final fun setColorTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setDensity (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setDensityTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setDirection (Lcom/mapbox/maps/extension/compose/style/DoubleListValue;)V + public final fun setDirectionTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setIntensity (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setIntensityTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setOpacity (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setOpacityTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setVignette (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setVignetteTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public fun toString ()Ljava/lang/String; +} + +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/RainState$Companion { + public final fun getSaver ()Landroidx/compose/runtime/saveable/Saver; +} + +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/RainState$Holder : android/os/Parcelable { + public static final field $stable I + public static final field CREATOR Landroid/os/Parcelable$Creator; + public final fun component1 ()Ljava/util/Map; + public final fun component2 ()Z + public final fun copy (Ljava/util/Map;Z)Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState$Holder; + public static synthetic fun copy$default (Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState$Holder;Ljava/util/Map;ZILjava/lang/Object;)Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState$Holder; + public fun describeContents ()I + public fun equals (Ljava/lang/Object;)Z + public final fun getEnabled ()Z + public final fun getSavedProperties ()Ljava/util/Map; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; + public fun writeToParcel (Landroid/os/Parcel;I)V +} + +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/RainState$Holder$Creator : android/os/Parcelable$Creator { + public fun ()V + public final fun createFromParcel (Landroid/os/Parcel;)Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState$Holder; + public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object; + public final fun newArray (I)[Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState$Holder; + public synthetic fun newArray (I)[Ljava/lang/Object; +} + +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/RainStateKt { + public static final fun rememberRainState (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState; +} + +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/SnowState { + public static final field Companion Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState$Companion; + public static final field DISABLED Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState; + public fun ()V + public synthetic fun (Lcom/mapbox/maps/extension/compose/style/precipitations/SnowStateApplier;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/ColorValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleListValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lcom/mapbox/maps/extension/compose/style/DoubleValue;Lcom/mapbox/maps/extension/compose/style/Transition;Lkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun equals (Ljava/lang/Object;)Z + public final fun getCenterThinning ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getCenterThinningTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getColor ()Lcom/mapbox/maps/extension/compose/style/ColorValue; + public final fun getColorTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getDensity ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getDensityTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getDirection ()Lcom/mapbox/maps/extension/compose/style/DoubleListValue; + public final fun getDirectionTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getIntensity ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getIntensityTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getOpacity ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getOpacityTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public final fun getVignette ()Lcom/mapbox/maps/extension/compose/style/DoubleValue; + public final fun getVignetteTransition ()Lcom/mapbox/maps/extension/compose/style/Transition; + public fun hashCode ()I + public final fun setCenterThinning (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setCenterThinningTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setColor (Lcom/mapbox/maps/extension/compose/style/ColorValue;)V + public final fun setColorTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setDensity (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setDensityTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setDirection (Lcom/mapbox/maps/extension/compose/style/DoubleListValue;)V + public final fun setDirectionTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setIntensity (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setIntensityTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setOpacity (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setOpacityTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public final fun setVignette (Lcom/mapbox/maps/extension/compose/style/DoubleValue;)V + public final fun setVignetteTransition (Lcom/mapbox/maps/extension/compose/style/Transition;)V + public fun toString ()Ljava/lang/String; +} + +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/SnowState$Companion { + public final fun getSaver ()Landroidx/compose/runtime/saveable/Saver; +} + +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/SnowState$Holder : android/os/Parcelable { + public static final field $stable I + public static final field CREATOR Landroid/os/Parcelable$Creator; + public final fun component1 ()Ljava/util/Map; + public final fun component2 ()Z + public final fun copy (Ljava/util/Map;Z)Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState$Holder; + public static synthetic fun copy$default (Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState$Holder;Ljava/util/Map;ZILjava/lang/Object;)Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState$Holder; + public fun describeContents ()I + public fun equals (Ljava/lang/Object;)Z + public final fun getEnabled ()Z + public final fun getSavedProperties ()Ljava/util/Map; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; + public fun writeToParcel (Landroid/os/Parcel;I)V +} + +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/SnowState$Holder$Creator : android/os/Parcelable$Creator { + public fun ()V + public final fun createFromParcel (Landroid/os/Parcel;)Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState$Holder; + public synthetic fun createFromParcel (Landroid/os/Parcel;)Ljava/lang/Object; + public final fun newArray (I)[Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState$Holder; + public synthetic fun newArray (I)[Ljava/lang/Object; +} + +public final class com/mapbox/maps/extension/compose/style/precipitations/generated/SnowStateKt { + public static final fun rememberSnowState (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Landroidx/compose/runtime/Composer;II)Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState; +} + public final class com/mapbox/maps/extension/compose/style/projection/generated/Projection { public static final field Companion Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection$Companion; public static final field DEFAULT Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection; @@ -3689,16 +3833,20 @@ public final class com/mapbox/maps/extension/compose/style/sources/generated/Vec } public class com/mapbox/maps/extension/compose/style/standard/BaseStandardStyleState { - protected fun (Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState;Lcom/mapbox/maps/extension/compose/style/lights/LightsState;Lcom/mapbox/maps/TransitionOptions;)V - public synthetic fun (Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState;Lcom/mapbox/maps/extension/compose/style/lights/LightsState;Lcom/mapbox/maps/TransitionOptions;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + protected fun (Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState;Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState;Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState;Lcom/mapbox/maps/extension/compose/style/lights/LightsState;Lcom/mapbox/maps/TransitionOptions;)V + public synthetic fun (Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState;Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState;Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState;Lcom/mapbox/maps/extension/compose/style/lights/LightsState;Lcom/mapbox/maps/TransitionOptions;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun getAtmosphereState ()Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState; public final fun getLightsState ()Lcom/mapbox/maps/extension/compose/style/lights/LightsState; public final fun getProjection ()Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection; + public final fun getRainState ()Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState; + public final fun getSnowState ()Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState; public final fun getStyleTransition ()Lcom/mapbox/maps/TransitionOptions; public final fun getTerrainState ()Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState; public final fun setAtmosphereState (Lcom/mapbox/maps/extension/compose/style/atmosphere/generated/AtmosphereState;)V public final fun setLightsState (Lcom/mapbox/maps/extension/compose/style/lights/LightsState;)V public final fun setProjection (Lcom/mapbox/maps/extension/compose/style/projection/generated/Projection;)V + public final fun setRainState (Lcom/mapbox/maps/extension/compose/style/precipitations/generated/RainState;)V + public final fun setSnowState (Lcom/mapbox/maps/extension/compose/style/precipitations/generated/SnowState;)V public final fun setStyleTransition (Lcom/mapbox/maps/TransitionOptions;)V public final fun setTerrainState (Lcom/mapbox/maps/extension/compose/style/terrain/generated/TerrainState;)V } diff --git a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/Style.kt b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/Style.kt index 419a7ad4cc..86652a900c 100644 --- a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/Style.kt +++ b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/Style.kt @@ -329,6 +329,8 @@ public fun GenericStyle( mapboxMap = mapApplier.mapView.mapboxMap, projection = styleState.projection, atmosphereState = styleState.atmosphereState, + rainState = styleState.rainState, + snowState = styleState.snowState, terrainState = styleState.terrainState, ) }, @@ -339,6 +341,12 @@ public fun GenericStyle( update(styleState.atmosphereState) { updateAtmosphere(styleState.atmosphereState) } + update(styleState.rainState) { + updateRain(styleState.rainState) + } + update(styleState.snowState) { + updateSnow(styleState.snowState) + } update(styleState.terrainState) { updateTerrain(styleState.terrainState) } @@ -348,6 +356,8 @@ public fun GenericStyle( } ) { styleState.atmosphereState.UpdateProperties() + styleState.rainState.UpdateProperties() + styleState.snowState.UpdateProperties() styleState.terrainState.UpdateProperties() styleState.lightsState.BindToMap(mapboxMap = mapApplier.mapView.mapboxMap) val styleImportsScope = remember { diff --git a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/StyleState.kt b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/StyleState.kt index d9f69f8742..2a97aadb96 100644 --- a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/StyleState.kt +++ b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/StyleState.kt @@ -11,6 +11,8 @@ import com.mapbox.maps.TransitionOptions import com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState import com.mapbox.maps.extension.compose.style.interactions.StyleInteractionsState import com.mapbox.maps.extension.compose.style.lights.LightsState +import com.mapbox.maps.extension.compose.style.precipitations.generated.RainState +import com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState import com.mapbox.maps.extension.compose.style.projection.generated.Projection import com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState import com.mapbox.maps.extension.style.utils.transition @@ -39,6 +41,8 @@ public class StyleState internal constructor( initialStyleInteractionsState: StyleInteractionsState, initialProjection: Projection, initialAtmosphereState: AtmosphereState, + initialRainState: RainState, + initialSnowState: SnowState, initialTerrainState: TerrainState = TerrainState.INITIAL, initialLightsState: LightsState = LightsState.INITIAL, initialStyleTransition: TransitionOptions, @@ -51,6 +55,8 @@ public class StyleState internal constructor( initialStyleInteractionsState = StyleInteractionsState(), initialProjection = Projection.INITIAL, initialAtmosphereState = AtmosphereState(), + initialRainState = RainState(), + initialSnowState = SnowState(), initialTerrainState = TerrainState.INITIAL, initialLightsState = LightsState.INITIAL, initialStyleTransition = transition { } @@ -79,6 +85,18 @@ public class StyleState internal constructor( */ public var atmosphereState: AtmosphereState by mutableStateOf(initialAtmosphereState) + /** + * The snow effect to be set to the map. By default, no changes to the current snow. + */ + @MapboxExperimental + public var snowState: SnowState by mutableStateOf(initialSnowState) + + /** + * The rain effect to be set to the map. By default, no changes to the current rain. + */ + @MapboxExperimental + public var rainState: RainState by mutableStateOf(initialRainState) + /** * The terrain to be set to the map. Defaults to initial state meaning no custom terrain is added, default value is taken from [style] definition. */ diff --git a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/internal/MapStyleNode.kt b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/internal/MapStyleNode.kt index 172811e1b9..1408462316 100644 --- a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/internal/MapStyleNode.kt +++ b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/internal/MapStyleNode.kt @@ -1,6 +1,7 @@ package com.mapbox.maps.extension.compose.style.internal import android.util.Log +import com.mapbox.maps.MapboxExperimental import com.mapbox.maps.MapboxMap import com.mapbox.maps.StyleDataLoaded import com.mapbox.maps.StyleDataLoadedType @@ -8,6 +9,8 @@ import com.mapbox.maps.TransitionOptions import com.mapbox.maps.coroutine.styleDataLoadedEvents import com.mapbox.maps.extension.compose.internal.MapNode import com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState +import com.mapbox.maps.extension.compose.style.precipitations.generated.RainState +import com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState import com.mapbox.maps.extension.compose.style.projection.generated.Projection import com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState import com.mapbox.maps.logD @@ -24,11 +27,14 @@ import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.shareIn import kotlinx.coroutines.launch +@OptIn(MapboxExperimental::class) internal class MapStyleNode( val style: String, val mapboxMap: MapboxMap, private val projection: Projection, var atmosphereState: AtmosphereState, + var rainState: RainState, + var snowState: SnowState, var terrainState: TerrainState, ) : MapNode() { @@ -67,6 +73,8 @@ internal class MapStyleNode( updateStyle(style) updateProjection(projection) updateAtmosphere(atmosphereState) + updateRain(rainState) + updateSnow(snowState) updateTerrain(terrainState) } @@ -91,6 +99,8 @@ internal class MapStyleNode( override fun onClear() { super.onClear() atmosphereState.applier.detach() + rainState.applier.detach() + snowState.applier.detach() terrainState.applier.detach() children.forEach { it.onClear() } } @@ -137,6 +147,30 @@ internal class MapStyleNode( } } + internal fun updateRain(rainState: RainState) { + // we have to detach (in a sense of cancelling property collector jobs) the previous state + // before attaching the new state; otherwise the jobs will be duplicated + this.rainState.applier.detach() + this.rainState = rainState + coroutineScope.launch { + styleDataLoaded.collect { + rainState.applier.attachTo(mapboxMap) + } + } + } + + internal fun updateSnow(snowState: SnowState) { + // we have to detach (in a sense of cancelling property collector jobs) the previous state + // before attaching the new state; otherwise the jobs will be duplicated + this.snowState.applier.detach() + this.snowState = snowState + coroutineScope.launch { + styleDataLoaded.collect { + snowState.applier.attachTo(mapboxMap) + } + } + } + internal fun updateTerrain(terrainState: TerrainState) { val previousTerrainState = this.terrainState this.terrainState = terrainState diff --git a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/RainStateApplier.kt b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/RainStateApplier.kt new file mode 100644 index 0000000000..c9f2ee0ee6 --- /dev/null +++ b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/RainStateApplier.kt @@ -0,0 +1,159 @@ +package com.mapbox.maps.extension.compose.style.precipitations + +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.MapboxMap +import com.mapbox.maps.extension.style.precipitations.generated.removeRain +import com.mapbox.maps.logD +import com.mapbox.maps.logE +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.launch +import java.util.Objects + +/** + * A [MutableStateFlow] to keep the latest value for the Property + */ +internal typealias PropertyValueFlow = MutableStateFlow + +@MapboxExperimental +internal class RainStateApplier internal constructor( + initialProperties: Map, + private val coroutineScope: CoroutineScope = CoroutineScope( + Dispatchers.Main.immediate + SupervisorJob() + CoroutineName( + "RainStateScope" + ) + ), + internal val enabled: Boolean +) { + private var propertiesUpdateJobs: MutableList = mutableListOf() + private var rainSet = false + + /** + * A shared flow to keep track of each property own flow ([PropertyValueFlow]). + * Every time a new [Pair] is emitted in this flow we will start collecting its flow + * ([PropertyValueFlow]), see [startCollectingPropertyFlows]. + */ + private val propertiesFlowsToCollect = + MutableSharedFlow>(replay = Channel.UNLIMITED) + + init { + initialProperties.forEach { + setProperty(it.key, it.value) + } + } + + internal fun attachTo(mapboxMap: MapboxMap) { + if (!enabled) { + mapboxMap.removeRain() + return + } + val replayCache = propertiesFlowsToCollect.replayCache + if (replayCache.isNotEmpty()) { + logD(TAG, "Adding rain: $this") + mapboxMap.setStyleRain( + properties = Value( + hashMapOf().also { map -> + // Get the most recent list of properties and their values + map.putAll(replayCache.associate { it.first to it.second.value }) + logD(TAG, "Setting all properties in one go: $map") + } + ), + ).onError { + logE(TAG, "Failed to add rain: $it") + }.onValue { + logD(TAG, "Added rain: $this") + rainSet = true + } + } + startCollectingPropertyFlows(mapboxMap) + } + + private fun startCollectingPropertyFlows(mapboxMap: MapboxMap) { + val collectNewPropertiesJob = coroutineScope.launch { + propertiesFlowsToCollect.collect { (name: String, valueFlow: PropertyValueFlow) -> + val updatePropertyJob = coroutineScope.launch { + valueFlow.collect { value -> + logD(TAG, "settingProperty: name=$name, value=$value ...") + mapboxMap.setStyleRainProperty(name, value) + .onError { error -> + // handle the use case of changing rain e.g. for Standard style + // and explicitly adding it so that applying property could take effect + if (!rainSet) { + mapboxMap.setStyleRain(Value.valueOf(hashMapOf())).onValue { + rainSet = true + mapboxMap.setStyleRainProperty(name, value).onError { + logE(TAG, "Failed to set rain property $name as $value: $error") + }.onValue { + logD(TAG, "settingProperty: name=$name, value=$value executed") + } + }.onError { + logE(TAG, "Failed to set rain with no properties, error = $it") + logE(TAG, "settingProperty: name=$name, value=$value ignored") + } + } else { + logE(TAG, "Failed to set rain property $name as $value: $error") + } + }.onValue { + logD(TAG, "settingProperty: name=$name, value=$value executed") + } + } + } + propertiesUpdateJobs.add(updatePropertyJob) + } + } + propertiesUpdateJobs.add(collectNewPropertiesJob) + } + + internal fun detach() { + // Stop any collect job that changes the source properties + propertiesUpdateJobs.forEach(Job::cancel) + propertiesUpdateJobs.clear() + } + + internal fun setProperty(name: String, value: Value) { + logD(TAG, "setProperty() called with: name = $name, value = $value") + val setOfFlows = propertiesFlowsToCollect.replayCache + val currentFlow: Pair>? = setOfFlows.firstOrNull { + it.first == name + } + if (currentFlow != null) { + currentFlow.second.value = value + } else { + logD(TAG, "setProperty: emitting new property to listen to: $name") + // Add the new property to the set of property flows we want to collect + propertiesFlowsToCollect.tryEmit(name to MutableStateFlow(value)) + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as RainStateApplier + + val thisProperties = + propertiesFlowsToCollect.replayCache.associate { it.first to it.second.value } + val otherProperties = + other.propertiesFlowsToCollect.replayCache.associate { it.first to it.second.value } + if (thisProperties != otherProperties) return false + + return rainSet == other.rainSet + } + + override fun hashCode(): Int { + val thisProperties = + propertiesFlowsToCollect.replayCache.associate { it.first to it.second.value } + return Objects.hash(rainSet, thisProperties) + } + + private companion object { + private const val TAG = "RainStateApplier" + } +} \ No newline at end of file diff --git a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/SnowStateApplier.kt b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/SnowStateApplier.kt new file mode 100644 index 0000000000..2888014b68 --- /dev/null +++ b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/SnowStateApplier.kt @@ -0,0 +1,155 @@ +package com.mapbox.maps.extension.compose.style.precipitations + +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.MapboxMap +import com.mapbox.maps.extension.style.precipitations.generated.removeSnow +import com.mapbox.maps.logD +import com.mapbox.maps.logE +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.launch +import java.util.Objects + +@MapboxExperimental +internal class SnowStateApplier internal constructor( + initialProperties: Map, + private val coroutineScope: CoroutineScope = CoroutineScope( + Dispatchers.Main.immediate + SupervisorJob() + CoroutineName( + "SnowStateScope" + ) + ), + internal val enabled: Boolean +) { + private var propertiesUpdateJobs: MutableList = mutableListOf() + private var snowSet = false + + /** + * A shared flow to keep track of each property own flow ([PropertyValueFlow]). + * Every time a new [Pair] is emitted in this flow we will start collecting its flow + * ([PropertyValueFlow]), see [startCollectingPropertyFlows]. + */ + private val propertiesFlowsToCollect = + MutableSharedFlow>(replay = Channel.UNLIMITED) + + init { + initialProperties.forEach { + setProperty(it.key, it.value) + } + } + + internal fun attachTo(mapboxMap: MapboxMap) { + if (!enabled) { + mapboxMap.removeSnow() + return + } + + val replayCache = propertiesFlowsToCollect.replayCache + if (replayCache.isNotEmpty()) { + logD(TAG, "Adding snow: $this") + mapboxMap.setStyleSnow( + properties = Value( + hashMapOf().also { map -> + // Get the most recent list of properties and their values + map.putAll(replayCache.associate { it.first to it.second.value }) + logD(TAG, "Setting all properties in one go: $map") + } + ), + ).onError { + logE(TAG, "Failed to add snow: $it") + }.onValue { + logD(TAG, "Added snow: $this") + snowSet = true + } + } + startCollectingPropertyFlows(mapboxMap) + } + + private fun startCollectingPropertyFlows(mapboxMap: MapboxMap) { + val collectNewPropertiesJob = coroutineScope.launch { + propertiesFlowsToCollect.collect { (name: String, valueFlow: PropertyValueFlow) -> + val updatePropertyJob = coroutineScope.launch { + valueFlow.collect { value -> + logD(TAG, "settingProperty: name=$name, value=$value ...") + mapboxMap.setStyleSnowProperty(name, value) + .onError { error -> + // handle the use case of changing snow e.g. for Standard style + // and explicitly adding it so that applying property could take effect + if (!snowSet) { + mapboxMap.setStyleSnow(Value.valueOf(hashMapOf())).onValue { + snowSet = true + mapboxMap.setStyleSnowProperty(name, value).onError { + logE(TAG, "Failed to set snow property $name as $value: $error") + }.onValue { + logD(TAG, "settingProperty: name=$name, value=$value executed") + } + }.onError { + logE(TAG, "Failed to set snow with no properties, error = $it") + logE(TAG, "settingProperty: name=$name, value=$value ignored") + } + } else { + logE(TAG, "Failed to set snow property $name as $value: $error") + } + }.onValue { + logD(TAG, "settingProperty: name=$name, value=$value executed") + } + } + } + propertiesUpdateJobs.add(updatePropertyJob) + } + } + propertiesUpdateJobs.add(collectNewPropertiesJob) + } + + internal fun detach() { + // Stop any collect job that changes the source properties + propertiesUpdateJobs.forEach(Job::cancel) + propertiesUpdateJobs.clear() + } + + internal fun setProperty(name: String, value: Value) { + logD(TAG, "setProperty() called with: name = $name, value = $value") + val setOfFlows = propertiesFlowsToCollect.replayCache + val currentFlow: Pair>? = setOfFlows.firstOrNull { + it.first == name + } + if (currentFlow != null) { + currentFlow.second.value = value + } else { + logD(TAG, "setProperty: emitting new property to listen to: $name") + // Add the new property to the set of property flows we want to collect + propertiesFlowsToCollect.tryEmit(name to MutableStateFlow(value)) + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as SnowStateApplier + + val thisProperties = + propertiesFlowsToCollect.replayCache.associate { it.first to it.second.value } + val otherProperties = + other.propertiesFlowsToCollect.replayCache.associate { it.first to it.second.value } + if (thisProperties != otherProperties) return false + + return snowSet == other.snowSet + } + + override fun hashCode(): Int { + val thisProperties = + propertiesFlowsToCollect.replayCache.associate { it.first to it.second.value } + return Objects.hash(snowSet, thisProperties) + } + + private companion object { + private const val TAG = "SnowStateApplier" + } +} \ No newline at end of file diff --git a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/generated/RainState.kt b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/generated/RainState.kt new file mode 100644 index 0000000000..78b6d6f0ef --- /dev/null +++ b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/generated/RainState.kt @@ -0,0 +1,472 @@ +// This file is generated. + +package com.mapbox.maps.extension.compose.style.precipitations.generated + +import android.os.Parcelable +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.Stable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.Saver +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.extension.compose.style.ColorValue +import com.mapbox.maps.extension.compose.style.DoubleListValue +import com.mapbox.maps.extension.compose.style.DoubleValue +import com.mapbox.maps.extension.compose.style.Transition +import com.mapbox.maps.extension.compose.style.internal.ValueParceler +import com.mapbox.maps.extension.compose.style.precipitations.RainStateApplier +import kotlinx.parcelize.Parcelize +import kotlinx.parcelize.TypeParceler +import java.util.Objects + +/** + * Create and [rememberSaveable] a [RainState] using [RainState.Saver]. + * [init] will be called when the [RainState] is first created to configure its + * initial state. + * + * @param key An optional key to be used as a key for the saved value. If not provided we use the + * automatically generated by the Compose runtime which is unique for the every exact code location + * in the composition tree. + * @param init A function initialise this [RainState]. + */ +@Composable +@MapboxExperimental +public inline fun rememberRainState( + key: String? = null, + crossinline init: RainState.() -> Unit = {} +): RainState = rememberSaveable(key = key, saver = RainState.Saver) { + RainState().apply(init) +} + +/** + * The Rain effects applied to the style. + */ +@Stable +@MapboxExperimental +public class RainState private constructor( + internal val applier: RainStateApplier, + centerThinning: DoubleValue, + centerThinningTransition: Transition, + color: ColorValue, + colorTransition: Transition, + density: DoubleValue, + densityTransition: Transition, + direction: DoubleListValue, + directionTransition: Transition, + intensity: DoubleValue, + intensityTransition: Transition, + opacity: DoubleValue, + opacityTransition: Transition, + vignette: DoubleValue, + vignetteTransition: Transition, +) { + public constructor() : this(enabled = true) + + private constructor(enabled: Boolean) : this( + RainStateApplier(emptyMap(), enabled = enabled), + DoubleValue.INITIAL, + Transition.INITIAL, + ColorValue.INITIAL, + Transition.INITIAL, + DoubleValue.INITIAL, + Transition.INITIAL, + DoubleListValue.INITIAL, + Transition.INITIAL, + DoubleValue.INITIAL, + Transition.INITIAL, + DoubleValue.INITIAL, + Transition.INITIAL, + DoubleValue.INITIAL, + Transition.INITIAL, + ) + + private val centerThinningState: MutableState = mutableStateOf(centerThinning) + + /** + * Thinning factor of rain particles from center. 0 - no thinning. 1 - maximal central area + * thinning. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var centerThinning: DoubleValue by centerThinningState + + @Composable + private fun UpdateCenterThinning() { + centerThinningState.value.apply { + if (notInitial) { + applier.setProperty("centerThinning", value) + } + } + } + private val centerThinningTransitionState: MutableState = mutableStateOf(centerThinningTransition) + + /** + * Defines the transition of [centerThinning]. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var centerThinningTransition: Transition by centerThinningTransitionState + + @Composable + private fun UpdateCenterThinningTransition() { + centerThinningTransitionState.value.apply { + if (notInitial) { + applier.setProperty("centerThinning-transition", value) + } + } + } + private val colorState: MutableState = mutableStateOf(color) + + /** + * + * Default value: "#ffffff". + */ + @MapboxExperimental + public var color: ColorValue by colorState + + @Composable + private fun UpdateColor() { + colorState.value.apply { + if (notInitial) { + applier.setProperty("color", value) + } + } + } + private val colorTransitionState: MutableState = mutableStateOf(colorTransition) + + /** + * Defines the transition of [color]. + * Default value: "#ffffff". + */ + @MapboxExperimental + public var colorTransition: Transition by colorTransitionState + + @Composable + private fun UpdateColorTransition() { + colorTransitionState.value.apply { + if (notInitial) { + applier.setProperty("color-transition", value) + } + } + } + private val densityState: MutableState = mutableStateOf(density) + + /** + * Rain particles density. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var density: DoubleValue by densityState + + @Composable + private fun UpdateDensity() { + densityState.value.apply { + if (notInitial) { + applier.setProperty("density", value) + } + } + } + private val densityTransitionState: MutableState = mutableStateOf(densityTransition) + + /** + * Defines the transition of [density]. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var densityTransition: Transition by densityTransitionState + + @Composable + private fun UpdateDensityTransition() { + densityTransitionState.value.apply { + if (notInitial) { + applier.setProperty("density-transition", value) + } + } + } + private val directionState: MutableState = mutableStateOf(direction) + + /** + * Main rain particles direction. Heading & pitch + * Default value: [0,80]. Value range: [0, 360] + */ + @MapboxExperimental + public var direction: DoubleListValue by directionState + + @Composable + private fun UpdateDirection() { + directionState.value.apply { + if (notInitial) { + applier.setProperty("direction", value) + } + } + } + private val directionTransitionState: MutableState = mutableStateOf(directionTransition) + + /** + * Defines the transition of [direction]. + * Default value: [0,80]. Value range: [0, 360] + */ + @MapboxExperimental + public var directionTransition: Transition by directionTransitionState + + @Composable + private fun UpdateDirectionTransition() { + directionTransitionState.value.apply { + if (notInitial) { + applier.setProperty("direction-transition", value) + } + } + } + private val intensityState: MutableState = mutableStateOf(intensity) + + /** + * Rain particles movement factor. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var intensity: DoubleValue by intensityState + + @Composable + private fun UpdateIntensity() { + intensityState.value.apply { + if (notInitial) { + applier.setProperty("intensity", value) + } + } + } + private val intensityTransitionState: MutableState = mutableStateOf(intensityTransition) + + /** + * Defines the transition of [intensity]. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var intensityTransition: Transition by intensityTransitionState + + @Composable + private fun UpdateIntensityTransition() { + intensityTransitionState.value.apply { + if (notInitial) { + applier.setProperty("intensity-transition", value) + } + } + } + private val opacityState: MutableState = mutableStateOf(opacity) + + /** + * Rain particles opacity. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var opacity: DoubleValue by opacityState + + @Composable + private fun UpdateOpacity() { + opacityState.value.apply { + if (notInitial) { + applier.setProperty("opacity", value) + } + } + } + private val opacityTransitionState: MutableState = mutableStateOf(opacityTransition) + + /** + * Defines the transition of [opacity]. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var opacityTransition: Transition by opacityTransitionState + + @Composable + private fun UpdateOpacityTransition() { + opacityTransitionState.value.apply { + if (notInitial) { + applier.setProperty("opacity-transition", value) + } + } + } + private val vignetteState: MutableState = mutableStateOf(vignette) + + /** + * Rain vignette screen-space effect. + * Default value: 0. Value range: [0, 1] + */ + @MapboxExperimental + public var vignette: DoubleValue by vignetteState + + @Composable + private fun UpdateVignette() { + vignetteState.value.apply { + if (notInitial) { + applier.setProperty("vignette", value) + } + } + } + private val vignetteTransitionState: MutableState = mutableStateOf(vignetteTransition) + + /** + * Defines the transition of [vignette]. + * Default value: 0. Value range: [0, 1] + */ + @MapboxExperimental + public var vignetteTransition: Transition by vignetteTransitionState + + @Composable + private fun UpdateVignetteTransition() { + vignetteTransitionState.value.apply { + if (notInitial) { + applier.setProperty("vignette-transition", value) + } + } + } + + @Composable + internal fun UpdateProperties() { + UpdateCenterThinning() + UpdateCenterThinningTransition() + UpdateColor() + UpdateColorTransition() + UpdateDensity() + UpdateDensityTransition() + UpdateDirection() + UpdateDirectionTransition() + UpdateIntensity() + UpdateIntensityTransition() + UpdateOpacity() + UpdateOpacityTransition() + UpdateVignette() + UpdateVignetteTransition() + } + + private fun getProperties(): Map = + listOfNotNull( + ("centerThinning" to centerThinning.value).takeIf { centerThinning.notInitial }, + ("centerThinning-transition" to centerThinningTransition.value).takeIf { centerThinningTransition.notInitial }, + ("color" to color.value).takeIf { color.notInitial }, + ("color-transition" to colorTransition.value).takeIf { colorTransition.notInitial }, + ("density" to density.value).takeIf { density.notInitial }, + ("density-transition" to densityTransition.value).takeIf { densityTransition.notInitial }, + ("direction" to direction.value).takeIf { direction.notInitial }, + ("direction-transition" to directionTransition.value).takeIf { directionTransition.notInitial }, + ("intensity" to intensity.value).takeIf { intensity.notInitial }, + ("intensity-transition" to intensityTransition.value).takeIf { intensityTransition.notInitial }, + ("opacity" to opacity.value).takeIf { opacity.notInitial }, + ("opacity-transition" to opacityTransition.value).takeIf { opacityTransition.notInitial }, + ("vignette" to vignette.value).takeIf { vignette.notInitial }, + ("vignette-transition" to vignetteTransition.value).takeIf { vignetteTransition.notInitial }, + ).toMap() + + /** + * See [Any.equals] + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as RainState + + if (applier != other.applier) return false + if (centerThinning != other.centerThinning) return false + if (centerThinningTransition != other.centerThinningTransition) return false + if (color != other.color) return false + if (colorTransition != other.colorTransition) return false + if (density != other.density) return false + if (densityTransition != other.densityTransition) return false + if (direction != other.direction) return false + if (directionTransition != other.directionTransition) return false + if (intensity != other.intensity) return false + if (intensityTransition != other.intensityTransition) return false + if (opacity != other.opacity) return false + if (opacityTransition != other.opacityTransition) return false + if (vignette != other.vignette) return false + if (vignetteTransition != other.vignetteTransition) return false + + return true + } + + /** + * See [Any.hashCode] + */ + override fun hashCode(): Int = Objects.hash( + applier, + centerThinning, + centerThinningTransition, + color, + colorTransition, + density, + densityTransition, + direction, + directionTransition, + intensity, + intensityTransition, + opacity, + opacityTransition, + vignette, + vignetteTransition, + ) + + /** + * Returns a string representation of the object. + */ + override fun toString(): String = + "RainState(centerThinning=$centerThinning, centerThinningTransition=$centerThinningTransition, color=$color, colorTransition=$colorTransition, density=$density, densityTransition=$densityTransition, direction=$direction, directionTransition=$directionTransition, intensity=$intensity, intensityTransition=$intensityTransition, opacity=$opacity, opacityTransition=$opacityTransition, vignette=$vignette, vignetteTransition=$vignetteTransition)" + + /** + * Rain Holder class to be used within [Saver]. + */ + @Parcelize + @TypeParceler + public data class Holder internal constructor( + /** + * Saved properties. + * Note that we use a generic [Map] to be able to evolve this class without breaking changes. + */ + val savedProperties: Map, + /** + * Indicating if the RainState is enabled. + */ + val enabled: Boolean + ) : Parcelable + + /** + * Public companion object. + */ + public companion object { + /** + * The default saver implementation for [RainState] + */ + public val Saver: Saver = Saver( + save = { Holder(it.getProperties(), it.applier.enabled) }, + restore = { holder -> + RainState( + RainStateApplier(holder.savedProperties, enabled = holder.enabled), + centerThinning = holder.savedProperties["centerThinning"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + centerThinningTransition = holder.savedProperties["centerThinning-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + color = holder.savedProperties["color"]?.let { ColorValue(it) } ?: ColorValue.INITIAL, + colorTransition = holder.savedProperties["color-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + density = holder.savedProperties["density"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + densityTransition = holder.savedProperties["density-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + direction = holder.savedProperties["direction"]?.let { DoubleListValue(it) } ?: DoubleListValue.INITIAL, + directionTransition = holder.savedProperties["direction-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + intensity = holder.savedProperties["intensity"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + intensityTransition = holder.savedProperties["intensity-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + opacity = holder.savedProperties["opacity"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + opacityTransition = holder.savedProperties["opacity-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + vignette = holder.savedProperties["vignette"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + vignetteTransition = holder.savedProperties["vignette-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + ) + } + ) + + /** + * Disabled value for [RainState], setting disabled will result in removing rain effect. + */ + @JvmField + public val DISABLED: RainState = RainState(enabled = false) + } +} +// End of generated file. \ No newline at end of file diff --git a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/generated/SnowState.kt b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/generated/SnowState.kt new file mode 100644 index 0000000000..4c0d9d53f8 --- /dev/null +++ b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/precipitations/generated/SnowState.kt @@ -0,0 +1,472 @@ +// This file is generated. + +package com.mapbox.maps.extension.compose.style.precipitations.generated + +import android.os.Parcelable +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.Stable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.saveable.Saver +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.extension.compose.style.ColorValue +import com.mapbox.maps.extension.compose.style.DoubleListValue +import com.mapbox.maps.extension.compose.style.DoubleValue +import com.mapbox.maps.extension.compose.style.Transition +import com.mapbox.maps.extension.compose.style.internal.ValueParceler +import com.mapbox.maps.extension.compose.style.precipitations.SnowStateApplier +import kotlinx.parcelize.Parcelize +import kotlinx.parcelize.TypeParceler +import java.util.Objects + +/** + * Create and [rememberSaveable] a [SnowState] using [SnowState.Saver]. + * [init] will be called when the [SnowState] is first created to configure its + * initial state. + * + * @param key An optional key to be used as a key for the saved value. If not provided we use the + * automatically generated by the Compose runtime which is unique for the every exact code location + * in the composition tree. + * @param init A function initialise this [SnowState]. + */ +@Composable +@MapboxExperimental +public inline fun rememberSnowState( + key: String? = null, + crossinline init: SnowState.() -> Unit = {} +): SnowState = rememberSaveable(key = key, saver = SnowState.Saver) { + SnowState().apply(init) +} + +/** + * The Snow effects applied to the style. + */ +@Stable +@MapboxExperimental +public class SnowState private constructor( + internal val applier: SnowStateApplier, + centerThinning: DoubleValue, + centerThinningTransition: Transition, + color: ColorValue, + colorTransition: Transition, + density: DoubleValue, + densityTransition: Transition, + direction: DoubleListValue, + directionTransition: Transition, + intensity: DoubleValue, + intensityTransition: Transition, + opacity: DoubleValue, + opacityTransition: Transition, + vignette: DoubleValue, + vignetteTransition: Transition, +) { + public constructor() : this(enabled = true) + + private constructor(enabled: Boolean) : this( + SnowStateApplier(emptyMap(), enabled = enabled), + DoubleValue.INITIAL, + Transition.INITIAL, + ColorValue.INITIAL, + Transition.INITIAL, + DoubleValue.INITIAL, + Transition.INITIAL, + DoubleListValue.INITIAL, + Transition.INITIAL, + DoubleValue.INITIAL, + Transition.INITIAL, + DoubleValue.INITIAL, + Transition.INITIAL, + DoubleValue.INITIAL, + Transition.INITIAL, + ) + + private val centerThinningState: MutableState = mutableStateOf(centerThinning) + + /** + * Thinning factor of snow particles from center. 0 - no thinning. 1 - maximal central area + * thinning. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var centerThinning: DoubleValue by centerThinningState + + @Composable + private fun UpdateCenterThinning() { + centerThinningState.value.apply { + if (notInitial) { + applier.setProperty("centerThinning", value) + } + } + } + private val centerThinningTransitionState: MutableState = mutableStateOf(centerThinningTransition) + + /** + * Defines the transition of [centerThinning]. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var centerThinningTransition: Transition by centerThinningTransitionState + + @Composable + private fun UpdateCenterThinningTransition() { + centerThinningTransitionState.value.apply { + if (notInitial) { + applier.setProperty("centerThinning-transition", value) + } + } + } + private val colorState: MutableState = mutableStateOf(color) + + /** + * Snow particles color. + * Default value: "#ffffff". + */ + @MapboxExperimental + public var color: ColorValue by colorState + + @Composable + private fun UpdateColor() { + colorState.value.apply { + if (notInitial) { + applier.setProperty("color", value) + } + } + } + private val colorTransitionState: MutableState = mutableStateOf(colorTransition) + + /** + * Defines the transition of [color]. + * Default value: "#ffffff". + */ + @MapboxExperimental + public var colorTransition: Transition by colorTransitionState + + @Composable + private fun UpdateColorTransition() { + colorTransitionState.value.apply { + if (notInitial) { + applier.setProperty("color-transition", value) + } + } + } + private val densityState: MutableState = mutableStateOf(density) + + /** + * Snow particles density. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var density: DoubleValue by densityState + + @Composable + private fun UpdateDensity() { + densityState.value.apply { + if (notInitial) { + applier.setProperty("density", value) + } + } + } + private val densityTransitionState: MutableState = mutableStateOf(densityTransition) + + /** + * Defines the transition of [density]. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var densityTransition: Transition by densityTransitionState + + @Composable + private fun UpdateDensityTransition() { + densityTransitionState.value.apply { + if (notInitial) { + applier.setProperty("density-transition", value) + } + } + } + private val directionState: MutableState = mutableStateOf(direction) + + /** + * Main snow particles direction. Heading & pitch + * Default value: [0,90]. Value range: [0, 360] + */ + @MapboxExperimental + public var direction: DoubleListValue by directionState + + @Composable + private fun UpdateDirection() { + directionState.value.apply { + if (notInitial) { + applier.setProperty("direction", value) + } + } + } + private val directionTransitionState: MutableState = mutableStateOf(directionTransition) + + /** + * Defines the transition of [direction]. + * Default value: [0,90]. Value range: [0, 360] + */ + @MapboxExperimental + public var directionTransition: Transition by directionTransitionState + + @Composable + private fun UpdateDirectionTransition() { + directionTransitionState.value.apply { + if (notInitial) { + applier.setProperty("direction-transition", value) + } + } + } + private val intensityState: MutableState = mutableStateOf(intensity) + + /** + * Snow particles movement factor. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var intensity: DoubleValue by intensityState + + @Composable + private fun UpdateIntensity() { + intensityState.value.apply { + if (notInitial) { + applier.setProperty("intensity", value) + } + } + } + private val intensityTransitionState: MutableState = mutableStateOf(intensityTransition) + + /** + * Defines the transition of [intensity]. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var intensityTransition: Transition by intensityTransitionState + + @Composable + private fun UpdateIntensityTransition() { + intensityTransitionState.value.apply { + if (notInitial) { + applier.setProperty("intensity-transition", value) + } + } + } + private val opacityState: MutableState = mutableStateOf(opacity) + + /** + * Snow particles opacity. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var opacity: DoubleValue by opacityState + + @Composable + private fun UpdateOpacity() { + opacityState.value.apply { + if (notInitial) { + applier.setProperty("opacity", value) + } + } + } + private val opacityTransitionState: MutableState = mutableStateOf(opacityTransition) + + /** + * Defines the transition of [opacity]. + * Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + public var opacityTransition: Transition by opacityTransitionState + + @Composable + private fun UpdateOpacityTransition() { + opacityTransitionState.value.apply { + if (notInitial) { + applier.setProperty("opacity-transition", value) + } + } + } + private val vignetteState: MutableState = mutableStateOf(vignette) + + /** + * Snow vignette screen-space effect. + * Default value: 0. Value range: [0, 1] + */ + @MapboxExperimental + public var vignette: DoubleValue by vignetteState + + @Composable + private fun UpdateVignette() { + vignetteState.value.apply { + if (notInitial) { + applier.setProperty("vignette", value) + } + } + } + private val vignetteTransitionState: MutableState = mutableStateOf(vignetteTransition) + + /** + * Defines the transition of [vignette]. + * Default value: 0. Value range: [0, 1] + */ + @MapboxExperimental + public var vignetteTransition: Transition by vignetteTransitionState + + @Composable + private fun UpdateVignetteTransition() { + vignetteTransitionState.value.apply { + if (notInitial) { + applier.setProperty("vignette-transition", value) + } + } + } + + @Composable + internal fun UpdateProperties() { + UpdateCenterThinning() + UpdateCenterThinningTransition() + UpdateColor() + UpdateColorTransition() + UpdateDensity() + UpdateDensityTransition() + UpdateDirection() + UpdateDirectionTransition() + UpdateIntensity() + UpdateIntensityTransition() + UpdateOpacity() + UpdateOpacityTransition() + UpdateVignette() + UpdateVignetteTransition() + } + + private fun getProperties(): Map = + listOfNotNull( + ("centerThinning" to centerThinning.value).takeIf { centerThinning.notInitial }, + ("centerThinning-transition" to centerThinningTransition.value).takeIf { centerThinningTransition.notInitial }, + ("color" to color.value).takeIf { color.notInitial }, + ("color-transition" to colorTransition.value).takeIf { colorTransition.notInitial }, + ("density" to density.value).takeIf { density.notInitial }, + ("density-transition" to densityTransition.value).takeIf { densityTransition.notInitial }, + ("direction" to direction.value).takeIf { direction.notInitial }, + ("direction-transition" to directionTransition.value).takeIf { directionTransition.notInitial }, + ("intensity" to intensity.value).takeIf { intensity.notInitial }, + ("intensity-transition" to intensityTransition.value).takeIf { intensityTransition.notInitial }, + ("opacity" to opacity.value).takeIf { opacity.notInitial }, + ("opacity-transition" to opacityTransition.value).takeIf { opacityTransition.notInitial }, + ("vignette" to vignette.value).takeIf { vignette.notInitial }, + ("vignette-transition" to vignetteTransition.value).takeIf { vignetteTransition.notInitial }, + ).toMap() + + /** + * See [Any.equals] + */ + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as SnowState + + if (applier != other.applier) return false + if (centerThinning != other.centerThinning) return false + if (centerThinningTransition != other.centerThinningTransition) return false + if (color != other.color) return false + if (colorTransition != other.colorTransition) return false + if (density != other.density) return false + if (densityTransition != other.densityTransition) return false + if (direction != other.direction) return false + if (directionTransition != other.directionTransition) return false + if (intensity != other.intensity) return false + if (intensityTransition != other.intensityTransition) return false + if (opacity != other.opacity) return false + if (opacityTransition != other.opacityTransition) return false + if (vignette != other.vignette) return false + if (vignetteTransition != other.vignetteTransition) return false + + return true + } + + /** + * See [Any.hashCode] + */ + override fun hashCode(): Int = Objects.hash( + applier, + centerThinning, + centerThinningTransition, + color, + colorTransition, + density, + densityTransition, + direction, + directionTransition, + intensity, + intensityTransition, + opacity, + opacityTransition, + vignette, + vignetteTransition, + ) + + /** + * Returns a string representation of the object. + */ + override fun toString(): String = + "SnowState(centerThinning=$centerThinning, centerThinningTransition=$centerThinningTransition, color=$color, colorTransition=$colorTransition, density=$density, densityTransition=$densityTransition, direction=$direction, directionTransition=$directionTransition, intensity=$intensity, intensityTransition=$intensityTransition, opacity=$opacity, opacityTransition=$opacityTransition, vignette=$vignette, vignetteTransition=$vignetteTransition)" + + /** + * Snow Holder class to be used within [Saver]. + */ + @Parcelize + @TypeParceler + public data class Holder internal constructor( + /** + * Saved properties. + * Note that we use a generic [Map] to be able to evolve this class without breaking changes. + */ + val savedProperties: Map, + /** + * Indicating if the SnowState is enabled. + */ + val enabled: Boolean + ) : Parcelable + + /** + * Public companion object. + */ + public companion object { + /** + * The default saver implementation for [SnowState] + */ + public val Saver: Saver = Saver( + save = { Holder(it.getProperties(), it.applier.enabled) }, + restore = { holder -> + SnowState( + SnowStateApplier(holder.savedProperties, enabled = holder.enabled), + centerThinning = holder.savedProperties["centerThinning"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + centerThinningTransition = holder.savedProperties["centerThinning-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + color = holder.savedProperties["color"]?.let { ColorValue(it) } ?: ColorValue.INITIAL, + colorTransition = holder.savedProperties["color-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + density = holder.savedProperties["density"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + densityTransition = holder.savedProperties["density-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + direction = holder.savedProperties["direction"]?.let { DoubleListValue(it) } ?: DoubleListValue.INITIAL, + directionTransition = holder.savedProperties["direction-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + intensity = holder.savedProperties["intensity"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + intensityTransition = holder.savedProperties["intensity-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + opacity = holder.savedProperties["opacity"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + opacityTransition = holder.savedProperties["opacity-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + vignette = holder.savedProperties["vignette"]?.let { DoubleValue(it) } ?: DoubleValue.INITIAL, + vignetteTransition = holder.savedProperties["vignette-transition"]?.let { Transition(it) } ?: Transition.INITIAL, + ) + } + ) + + /** + * Disabled value for [SnowState], setting disabled will result in removing snow effect. + */ + @JvmField + public val DISABLED: SnowState = SnowState(enabled = false) + } +} +// End of generated file. \ No newline at end of file diff --git a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/standard/BaseStandardStyleState.kt b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/standard/BaseStandardStyleState.kt index 9292536fd6..1d90ee85ae 100644 --- a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/standard/BaseStandardStyleState.kt +++ b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/standard/BaseStandardStyleState.kt @@ -8,6 +8,8 @@ import com.mapbox.maps.MapboxExperimental import com.mapbox.maps.TransitionOptions import com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState import com.mapbox.maps.extension.compose.style.lights.LightsState +import com.mapbox.maps.extension.compose.style.precipitations.generated.RainState +import com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState import com.mapbox.maps.extension.compose.style.projection.generated.Projection import com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState @@ -19,6 +21,8 @@ import com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState public open class BaseStandardStyleState protected constructor( initialProjection: Projection, initialAtmosphereState: AtmosphereState, + initialRainState: RainState, + initialSnowState: SnowState, initialTerrainState: TerrainState = TerrainState.INITIAL, initialLightsState: LightsState = LightsState.INITIAL, initialStyleTransition: TransitionOptions, @@ -33,6 +37,18 @@ public open class BaseStandardStyleState protected constructor( */ public var atmosphereState: AtmosphereState by mutableStateOf(initialAtmosphereState) + /** + * The snow effect to be set to the map. By default, no changes to the current snow. + */ + @MapboxExperimental + public var snowState: SnowState by mutableStateOf(initialSnowState) + + /** + * The rain effect to be set to the map. By default, no changes to the current rain. + */ + @MapboxExperimental + public var rainState: RainState by mutableStateOf(initialRainState) + /** * The terrain to be set to the map. Defaults to initial state meaning no custom terrain is added, default value is taken from Standard style definition. */ diff --git a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/standard/ExperimentalStandardStyleState.kt b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/standard/ExperimentalStandardStyleState.kt index 485b16dfec..0cf159fa78 100644 --- a/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/standard/ExperimentalStandardStyleState.kt +++ b/extension-compose/src/main/java/com/mapbox/maps/extension/compose/style/standard/ExperimentalStandardStyleState.kt @@ -11,6 +11,8 @@ import com.mapbox.maps.TransitionOptions import com.mapbox.maps.extension.compose.style.atmosphere.generated.AtmosphereState import com.mapbox.maps.extension.compose.style.interactions.StyleInteractionsState import com.mapbox.maps.extension.compose.style.lights.LightsState +import com.mapbox.maps.extension.compose.style.precipitations.generated.RainState +import com.mapbox.maps.extension.compose.style.precipitations.generated.SnowState import com.mapbox.maps.extension.compose.style.projection.generated.Projection import com.mapbox.maps.extension.compose.style.standard.generated.StandardStyleInteractionsState import com.mapbox.maps.extension.compose.style.terrain.generated.TerrainState @@ -40,16 +42,20 @@ public class ExperimentalStandardStyleState internal constructor( initialStyleInteractionsState: StandardStyleInteractionsState, initialProjection: Projection, initialAtmosphereState: AtmosphereState, + initialRainState: RainState, + initialSnowState: SnowState, initialTerrainState: TerrainState = TerrainState.INITIAL, initialLightsState: LightsState = LightsState.INITIAL, initialStyleTransition: TransitionOptions, initialConfigurationState: StandardStyleConfigurationState, ) : BaseStandardStyleState( - initialProjection, - initialAtmosphereState, - initialTerrainState, - initialLightsState, - initialStyleTransition, + initialProjection = initialProjection, + initialAtmosphereState = initialAtmosphereState, + initialRainState = initialRainState, + initialSnowState = initialSnowState, + initialTerrainState = initialTerrainState, + initialLightsState = initialLightsState, + initialStyleTransition = initialStyleTransition, ) { /** * Construct a default [ExperimentalStandardStyleState]. @@ -58,6 +64,8 @@ public class ExperimentalStandardStyleState internal constructor( initialStyleInteractionsState = StandardStyleInteractionsState(), initialProjection = Projection.INITIAL, initialAtmosphereState = AtmosphereState(), + initialRainState = RainState(), + initialSnowState = SnowState(), initialTerrainState = TerrainState.INITIAL, initialLightsState = LightsState.INITIAL, initialStyleTransition = transition { }, diff --git a/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/BaseStyleTest.kt b/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/BaseStyleTest.kt index f932630156..3b84894d69 100644 --- a/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/BaseStyleTest.kt +++ b/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/BaseStyleTest.kt @@ -6,6 +6,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.LargeTest import androidx.test.platform.app.InstrumentationRegistry import com.mapbox.maps.MapView +import com.mapbox.maps.MapboxExperimental import com.mapbox.maps.MapboxMap import com.mapbox.maps.Style import com.mapbox.maps.extension.style.StyleContract @@ -19,6 +20,10 @@ import com.mapbox.maps.extension.style.light.generated.DirectionalLight import com.mapbox.maps.extension.style.light.generated.FlatLight import com.mapbox.maps.extension.style.light.getLight import com.mapbox.maps.extension.style.light.setLight +import com.mapbox.maps.extension.style.precipitations.generated.Rain +import com.mapbox.maps.extension.style.precipitations.generated.Snow +import com.mapbox.maps.extension.style.precipitations.generated.setRain +import com.mapbox.maps.extension.style.precipitations.generated.setSnow import com.mapbox.maps.extension.style.sources.addSource import com.mapbox.maps.extension.style.terrain.generated.setTerrain import org.junit.After @@ -109,6 +114,16 @@ abstract class BaseStyleTest { style.setLight(ambientLight, directionalLight) } + @OptIn(MapboxExperimental::class) + fun setupSnow(snow: Snow) { + style.setSnow(snow) + } + + @OptIn(MapboxExperimental::class) + fun setupRain(rain: Rain) { + style.setRain(rain) + } + fun getLayer(id: String): Layer? { return style.getLayer(id) } diff --git a/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/precipitations/generated/RainTest.kt b/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/precipitations/generated/RainTest.kt new file mode 100644 index 0000000000..f940a0c51e --- /dev/null +++ b/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/precipitations/generated/RainTest.kt @@ -0,0 +1,419 @@ +// This file is generated. + +package com.mapbox.maps.testapp.style.precipitations.generated + +import android.graphics.Color +import androidx.test.annotation.UiThreadTest +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.extension.style.expressions.dsl.generated.literal +import com.mapbox.maps.extension.style.expressions.dsl.generated.rgba +import com.mapbox.maps.extension.style.precipitations.generated.rain +import com.mapbox.maps.extension.style.types.transitionOptions +import com.mapbox.maps.testapp.style.BaseStyleTest +import org.junit.Assert.assertEquals +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Basic smoke tests for Rain + */ +@OptIn(MapboxExperimental::class) +@RunWith(AndroidJUnit4::class) +class RainTest : BaseStyleTest() { + + @Test + @UiThreadTest + fun centerThinningTest() { + val rain = rain { + centerThinning(1.0) + } + setupRain(rain) + assertEquals(1.0, rain.centerThinning!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun centerThinningAsExpressionTest() { + val expression = literal(1.0) + + val rain = rain { + centerThinning(expression) + } + setupRain(rain) + assertEquals(1.0, rain.centerThinningAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun centerThinningTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + centerThinningTransition(transition) + } + setupRain(rain) + assertEquals(transition, rain.centerThinningTransition) + } + + @Test + @UiThreadTest + fun centerThinningTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + centerThinningTransition { + duration(100) + delay(200) + } + } + setupRain(rain) + assertEquals(transition, rain.centerThinningTransition) + } + + @Test + @UiThreadTest + fun colorAsColorIntTest() { + val rain = rain { + color(Color.CYAN) + } + setupRain(rain) + assertEquals(Color.CYAN, rain.colorAsColorInt) + } + + @Test + @UiThreadTest + fun colorTest() { + val rain = rain { + color("rgba(0, 0, 0, 1)") + } + setupRain(rain) + assertEquals("rgba(0, 0, 0, 1)", rain.color) + } + + // Add Expression Test + @Test + @UiThreadTest + fun colorAsExpressionTest() { + val expression = rgba { + literal(0.0) + literal(0.0) + literal(0.0) + literal(1.0) + } + + val rain = rain { + color(expression) + } + setupRain(rain) + assertEquals(expression.toString(), rain.colorAsExpression.toString()) + } + + @Test + @UiThreadTest + fun colorTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + colorTransition(transition) + } + setupRain(rain) + assertEquals(transition, rain.colorTransition) + } + + @Test + @UiThreadTest + fun colorTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + colorTransition { + duration(100) + delay(200) + } + } + setupRain(rain) + assertEquals(transition, rain.colorTransition) + } + + @Test + @UiThreadTest + fun densityTest() { + val rain = rain { + density(1.0) + } + setupRain(rain) + assertEquals(1.0, rain.density!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun densityAsExpressionTest() { + val expression = literal(1.0) + + val rain = rain { + density(expression) + } + setupRain(rain) + assertEquals(1.0, rain.densityAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun densityTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + densityTransition(transition) + } + setupRain(rain) + assertEquals(transition, rain.densityTransition) + } + + @Test + @UiThreadTest + fun densityTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + densityTransition { + duration(100) + delay(200) + } + } + setupRain(rain) + assertEquals(transition, rain.densityTransition) + } + + @Test + @UiThreadTest + fun directionTest() { + val rain = rain { + direction(listOf(0.0, 1.0)) + } + setupRain(rain) + assertEquals(listOf(0.0, 1.0), rain.direction) + } + + // Add Expression Test + @Test + @UiThreadTest + fun directionAsExpressionTest() { + val expression = literal(listOf(0.0, 1.0)) + + val rain = rain { + direction(expression) + } + setupRain(rain) + assertEquals(expression.toString(), rain.directionAsExpression.toString()) + } + + @Test + @UiThreadTest + fun directionTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + directionTransition(transition) + } + setupRain(rain) + assertEquals(transition, rain.directionTransition) + } + + @Test + @UiThreadTest + fun directionTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + directionTransition { + duration(100) + delay(200) + } + } + setupRain(rain) + assertEquals(transition, rain.directionTransition) + } + + @Test + @UiThreadTest + fun intensityTest() { + val rain = rain { + intensity(1.0) + } + setupRain(rain) + assertEquals(1.0, rain.intensity!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun intensityAsExpressionTest() { + val expression = literal(1.0) + + val rain = rain { + intensity(expression) + } + setupRain(rain) + assertEquals(1.0, rain.intensityAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun intensityTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + intensityTransition(transition) + } + setupRain(rain) + assertEquals(transition, rain.intensityTransition) + } + + @Test + @UiThreadTest + fun intensityTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + intensityTransition { + duration(100) + delay(200) + } + } + setupRain(rain) + assertEquals(transition, rain.intensityTransition) + } + + @Test + @UiThreadTest + fun opacityTest() { + val rain = rain { + opacity(1.0) + } + setupRain(rain) + assertEquals(1.0, rain.opacity!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun opacityAsExpressionTest() { + val expression = literal(1.0) + + val rain = rain { + opacity(expression) + } + setupRain(rain) + assertEquals(1.0, rain.opacityAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun opacityTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + opacityTransition(transition) + } + setupRain(rain) + assertEquals(transition, rain.opacityTransition) + } + + @Test + @UiThreadTest + fun opacityTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + opacityTransition { + duration(100) + delay(200) + } + } + setupRain(rain) + assertEquals(transition, rain.opacityTransition) + } + + @Test + @UiThreadTest + fun vignetteTest() { + val rain = rain { + vignette(1.0) + } + setupRain(rain) + assertEquals(1.0, rain.vignette!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun vignetteAsExpressionTest() { + val expression = literal(1.0) + + val rain = rain { + vignette(expression) + } + setupRain(rain) + assertEquals(1.0, rain.vignetteAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun vignetteTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + vignetteTransition(transition) + } + setupRain(rain) + assertEquals(transition, rain.vignetteTransition) + } + + @Test + @UiThreadTest + fun vignetteTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val rain = rain { + vignetteTransition { + duration(100) + delay(200) + } + } + setupRain(rain) + assertEquals(transition, rain.vignetteTransition) + } +} + +// End of generated file. \ No newline at end of file diff --git a/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/precipitations/generated/SnowTest.kt b/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/precipitations/generated/SnowTest.kt new file mode 100644 index 0000000000..474e1fa1bb --- /dev/null +++ b/extension-style-app/src/androidTest/java/com/mapbox/maps/testapp/style/precipitations/generated/SnowTest.kt @@ -0,0 +1,419 @@ +// This file is generated. + +package com.mapbox.maps.testapp.style.precipitations.generated + +import android.graphics.Color +import androidx.test.annotation.UiThreadTest +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.extension.style.expressions.dsl.generated.literal +import com.mapbox.maps.extension.style.expressions.dsl.generated.rgba +import com.mapbox.maps.extension.style.precipitations.generated.snow +import com.mapbox.maps.extension.style.types.transitionOptions +import com.mapbox.maps.testapp.style.BaseStyleTest +import org.junit.Assert.assertEquals +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Basic smoke tests for Snow + */ +@OptIn(MapboxExperimental::class) +@RunWith(AndroidJUnit4::class) +class SnowTest : BaseStyleTest() { + + @Test + @UiThreadTest + fun centerThinningTest() { + val snow = snow { + centerThinning(1.0) + } + setupSnow(snow) + assertEquals(1.0, snow.centerThinning!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun centerThinningAsExpressionTest() { + val expression = literal(1.0) + + val snow = snow { + centerThinning(expression) + } + setupSnow(snow) + assertEquals(1.0, snow.centerThinningAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun centerThinningTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + centerThinningTransition(transition) + } + setupSnow(snow) + assertEquals(transition, snow.centerThinningTransition) + } + + @Test + @UiThreadTest + fun centerThinningTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + centerThinningTransition { + duration(100) + delay(200) + } + } + setupSnow(snow) + assertEquals(transition, snow.centerThinningTransition) + } + + @Test + @UiThreadTest + fun colorAsColorIntTest() { + val snow = snow { + color(Color.CYAN) + } + setupSnow(snow) + assertEquals(Color.CYAN, snow.colorAsColorInt) + } + + @Test + @UiThreadTest + fun colorTest() { + val snow = snow { + color("rgba(0, 0, 0, 1)") + } + setupSnow(snow) + assertEquals("rgba(0, 0, 0, 1)", snow.color) + } + + // Add Expression Test + @Test + @UiThreadTest + fun colorAsExpressionTest() { + val expression = rgba { + literal(0.0) + literal(0.0) + literal(0.0) + literal(1.0) + } + + val snow = snow { + color(expression) + } + setupSnow(snow) + assertEquals(expression.toString(), snow.colorAsExpression.toString()) + } + + @Test + @UiThreadTest + fun colorTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + colorTransition(transition) + } + setupSnow(snow) + assertEquals(transition, snow.colorTransition) + } + + @Test + @UiThreadTest + fun colorTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + colorTransition { + duration(100) + delay(200) + } + } + setupSnow(snow) + assertEquals(transition, snow.colorTransition) + } + + @Test + @UiThreadTest + fun densityTest() { + val snow = snow { + density(1.0) + } + setupSnow(snow) + assertEquals(1.0, snow.density!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun densityAsExpressionTest() { + val expression = literal(1.0) + + val snow = snow { + density(expression) + } + setupSnow(snow) + assertEquals(1.0, snow.densityAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun densityTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + densityTransition(transition) + } + setupSnow(snow) + assertEquals(transition, snow.densityTransition) + } + + @Test + @UiThreadTest + fun densityTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + densityTransition { + duration(100) + delay(200) + } + } + setupSnow(snow) + assertEquals(transition, snow.densityTransition) + } + + @Test + @UiThreadTest + fun directionTest() { + val snow = snow { + direction(listOf(0.0, 1.0)) + } + setupSnow(snow) + assertEquals(listOf(0.0, 1.0), snow.direction) + } + + // Add Expression Test + @Test + @UiThreadTest + fun directionAsExpressionTest() { + val expression = literal(listOf(0.0, 1.0)) + + val snow = snow { + direction(expression) + } + setupSnow(snow) + assertEquals(expression.toString(), snow.directionAsExpression.toString()) + } + + @Test + @UiThreadTest + fun directionTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + directionTransition(transition) + } + setupSnow(snow) + assertEquals(transition, snow.directionTransition) + } + + @Test + @UiThreadTest + fun directionTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + directionTransition { + duration(100) + delay(200) + } + } + setupSnow(snow) + assertEquals(transition, snow.directionTransition) + } + + @Test + @UiThreadTest + fun intensityTest() { + val snow = snow { + intensity(1.0) + } + setupSnow(snow) + assertEquals(1.0, snow.intensity!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun intensityAsExpressionTest() { + val expression = literal(1.0) + + val snow = snow { + intensity(expression) + } + setupSnow(snow) + assertEquals(1.0, snow.intensityAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun intensityTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + intensityTransition(transition) + } + setupSnow(snow) + assertEquals(transition, snow.intensityTransition) + } + + @Test + @UiThreadTest + fun intensityTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + intensityTransition { + duration(100) + delay(200) + } + } + setupSnow(snow) + assertEquals(transition, snow.intensityTransition) + } + + @Test + @UiThreadTest + fun opacityTest() { + val snow = snow { + opacity(1.0) + } + setupSnow(snow) + assertEquals(1.0, snow.opacity!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun opacityAsExpressionTest() { + val expression = literal(1.0) + + val snow = snow { + opacity(expression) + } + setupSnow(snow) + assertEquals(1.0, snow.opacityAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun opacityTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + opacityTransition(transition) + } + setupSnow(snow) + assertEquals(transition, snow.opacityTransition) + } + + @Test + @UiThreadTest + fun opacityTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + opacityTransition { + duration(100) + delay(200) + } + } + setupSnow(snow) + assertEquals(transition, snow.opacityTransition) + } + + @Test + @UiThreadTest + fun vignetteTest() { + val snow = snow { + vignette(1.0) + } + setupSnow(snow) + assertEquals(1.0, snow.vignette!!, 1E-5) + } + + // Add Expression Test + @Test + @UiThreadTest + fun vignetteAsExpressionTest() { + val expression = literal(1.0) + + val snow = snow { + vignette(expression) + } + setupSnow(snow) + assertEquals(1.0, snow.vignetteAsExpression?.contents as Double, 1E-5) + } + + @Test + @UiThreadTest + fun vignetteTransitionTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + vignetteTransition(transition) + } + setupSnow(snow) + assertEquals(transition, snow.vignetteTransition) + } + + @Test + @UiThreadTest + fun vignetteTransitionSetDslTest() { + val transition = transitionOptions { + duration(100) + delay(200) + } + val snow = snow { + vignetteTransition { + duration(100) + delay(200) + } + } + setupSnow(snow) + assertEquals(transition, snow.vignetteTransition) + } +} + +// End of generated file. \ No newline at end of file diff --git a/extension-style/api/Release/metalava.txt b/extension-style/api/Release/metalava.txt index d2d2f90005..5b5cd42749 100644 --- a/extension-style/api/Release/metalava.txt +++ b/extension-style/api/Release/metalava.txt @@ -9,6 +9,8 @@ package com.mapbox.maps.extension.style { method public java.util.List> getLayers(); method public java.util.List getModels(); method public com.mapbox.maps.extension.style.projection.generated.Projection? getProjection(); + method public com.mapbox.maps.extension.style.StyleContract.StyleRainExtension? getRain(); + method public com.mapbox.maps.extension.style.StyleContract.StyleSnowExtension? getSnow(); method public java.util.List getSources(); method public String getStyle(); method public com.mapbox.maps.extension.style.terrain.generated.Terrain? getTerrain(); @@ -20,6 +22,8 @@ package com.mapbox.maps.extension.style { property public java.util.List> layers; property public java.util.List models; property public com.mapbox.maps.extension.style.projection.generated.Projection? projection; + property public com.mapbox.maps.extension.style.StyleContract.StyleRainExtension? rain; + property public com.mapbox.maps.extension.style.StyleContract.StyleSnowExtension? snow; property public java.util.List sources; property public String style; property public com.mapbox.maps.extension.style.terrain.generated.Terrain? terrain; @@ -44,6 +48,8 @@ package com.mapbox.maps.extension.style { method public operator void setLight(com.mapbox.maps.extension.style.light.generated.FlatLight); method public operator void setLight(com.mapbox.maps.extension.style.light.DynamicLight); method public operator void setProjection(com.mapbox.maps.extension.style.projection.generated.Projection); + method public operator void setRain(com.mapbox.maps.extension.style.precipitations.generated.Rain); + method public operator void setSnow(com.mapbox.maps.extension.style.precipitations.generated.Snow); method public operator void setTerrain(com.mapbox.maps.extension.style.terrain.generated.Terrain); method public operator void setTransition(com.mapbox.maps.TransitionOptions); property public final String style; @@ -6300,6 +6306,250 @@ package com.mapbox.maps.extension.style.model { } +package com.mapbox.maps.extension.style.precipitations.generated { + + @UiThread @com.mapbox.maps.MapboxExperimental public final class Rain implements com.mapbox.maps.extension.style.precipitations.generated.RainDslReceiver com.mapbox.maps.extension.style.StyleContract.StyleRainExtension { + ctor public Rain(); + method public void bindTo(com.mapbox.maps.MapboxStyleManager delegate); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain centerThinning(double centerThinning); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain centerThinning(com.mapbox.maps.extension.style.expressions.generated.Expression centerThinning); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain centerThinningTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain centerThinningTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain color(@ColorInt int color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain color(String color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain color(com.mapbox.maps.extension.style.expressions.generated.Expression color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain colorTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain colorTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain density(double density); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain density(com.mapbox.maps.extension.style.expressions.generated.Expression density); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain densityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain densityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain direction(java.util.List direction); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain direction(com.mapbox.maps.extension.style.expressions.generated.Expression direction); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain directionTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain directionTransition(kotlin.jvm.functions.Function1 block); + method public Double? getCenterThinning(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getCenterThinningAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getCenterThinningTransition(); + method public String? getColor(); + method @ColorInt public Integer? getColorAsColorInt(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getColorAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getColorTransition(); + method public Double? getDensity(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getDensityAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getDensityTransition(); + method public java.util.List? getDirection(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getDirectionAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getDirectionTransition(); + method public Double? getIntensity(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getIntensityAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getIntensityTransition(); + method public Double? getOpacity(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getOpacityAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getOpacityTransition(); + method public Double? getVignette(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getVignetteAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getVignetteTransition(); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain intensity(double intensity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain intensity(com.mapbox.maps.extension.style.expressions.generated.Expression intensity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain intensityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain intensityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain opacity(double opacity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain opacity(com.mapbox.maps.extension.style.expressions.generated.Expression opacity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain opacityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain opacityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain vignette(double vignette); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain vignette(com.mapbox.maps.extension.style.expressions.generated.Expression vignette); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain vignetteTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain vignetteTransition(kotlin.jvm.functions.Function1 block); + property public final Double? centerThinning; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? centerThinningAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? centerThinningTransition; + property public final String? color; + property @ColorInt public final Integer? colorAsColorInt; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? colorAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? colorTransition; + property public final Double? density; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? densityAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? densityTransition; + property public final java.util.List? direction; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? directionAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? directionTransition; + property public final Double? intensity; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? intensityAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? intensityTransition; + property public final Double? opacity; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? opacityAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? opacityTransition; + property public final Double? vignette; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? vignetteAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? vignetteTransition; + } + + @com.mapbox.maps.MapboxExperimental @com.mapbox.maps.extension.style.types.RainDsl public interface RainDslReceiver { + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain centerThinning(double centerThinning = 1.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain centerThinning(com.mapbox.maps.extension.style.expressions.generated.Expression centerThinning); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain centerThinningTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain centerThinningTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain color(@ColorInt int color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain color(String color = "#ffffff"); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain color(com.mapbox.maps.extension.style.expressions.generated.Expression color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain colorTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain colorTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain density(double density = 1.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain density(com.mapbox.maps.extension.style.expressions.generated.Expression density); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain densityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain densityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain direction(java.util.List direction = listOf(0.0, 80.0)); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain direction(com.mapbox.maps.extension.style.expressions.generated.Expression direction); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain directionTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain directionTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain intensity(double intensity = 1.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain intensity(com.mapbox.maps.extension.style.expressions.generated.Expression intensity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain intensityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain intensityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain opacity(double opacity = 1.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain opacity(com.mapbox.maps.extension.style.expressions.generated.Expression opacity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain opacityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain opacityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain vignette(double vignette = 0.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain vignette(com.mapbox.maps.extension.style.expressions.generated.Expression vignette); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain vignetteTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Rain vignetteTransition(kotlin.jvm.functions.Function1 block); + } + + public final class RainKt { + method @com.mapbox.maps.MapboxExperimental public static com.mapbox.maps.extension.style.precipitations.generated.Rain rain(kotlin.jvm.functions.Function1 block); + } + + public final class RainUtils { + method @com.mapbox.maps.MapboxExperimental public static com.mapbox.maps.extension.style.precipitations.generated.Rain getRain(com.mapbox.maps.MapboxStyleManager); + method @com.mapbox.maps.MapboxExperimental public static void removeRain(com.mapbox.maps.MapboxStyleManager); + method @com.mapbox.maps.MapboxExperimental public static void setRain(com.mapbox.maps.MapboxStyleManager, com.mapbox.maps.extension.style.StyleContract.StyleRainExtension rain); + } + + @UiThread @com.mapbox.maps.MapboxExperimental public final class Snow implements com.mapbox.maps.extension.style.precipitations.generated.SnowDslReceiver com.mapbox.maps.extension.style.StyleContract.StyleSnowExtension { + ctor public Snow(); + method public void bindTo(com.mapbox.maps.MapboxStyleManager delegate); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow centerThinning(double centerThinning); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow centerThinning(com.mapbox.maps.extension.style.expressions.generated.Expression centerThinning); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow centerThinningTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow centerThinningTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow color(@ColorInt int color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow color(String color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow color(com.mapbox.maps.extension.style.expressions.generated.Expression color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow colorTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow colorTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow density(double density); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow density(com.mapbox.maps.extension.style.expressions.generated.Expression density); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow densityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow densityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow direction(java.util.List direction); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow direction(com.mapbox.maps.extension.style.expressions.generated.Expression direction); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow directionTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow directionTransition(kotlin.jvm.functions.Function1 block); + method public Double? getCenterThinning(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getCenterThinningAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getCenterThinningTransition(); + method public String? getColor(); + method @ColorInt public Integer? getColorAsColorInt(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getColorAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getColorTransition(); + method public Double? getDensity(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getDensityAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getDensityTransition(); + method public java.util.List? getDirection(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getDirectionAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getDirectionTransition(); + method public Double? getIntensity(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getIntensityAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getIntensityTransition(); + method public Double? getOpacity(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getOpacityAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getOpacityTransition(); + method public Double? getVignette(); + method public com.mapbox.maps.extension.style.expressions.generated.Expression? getVignetteAsExpression(); + method public com.mapbox.maps.extension.style.types.StyleTransition? getVignetteTransition(); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow intensity(double intensity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow intensity(com.mapbox.maps.extension.style.expressions.generated.Expression intensity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow intensityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow intensityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow opacity(double opacity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow opacity(com.mapbox.maps.extension.style.expressions.generated.Expression opacity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow opacityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow opacityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow vignette(double vignette); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow vignette(com.mapbox.maps.extension.style.expressions.generated.Expression vignette); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow vignetteTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow vignetteTransition(kotlin.jvm.functions.Function1 block); + property public final Double? centerThinning; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? centerThinningAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? centerThinningTransition; + property public final String? color; + property @ColorInt public final Integer? colorAsColorInt; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? colorAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? colorTransition; + property public final Double? density; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? densityAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? densityTransition; + property public final java.util.List? direction; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? directionAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? directionTransition; + property public final Double? intensity; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? intensityAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? intensityTransition; + property public final Double? opacity; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? opacityAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? opacityTransition; + property public final Double? vignette; + property public final com.mapbox.maps.extension.style.expressions.generated.Expression? vignetteAsExpression; + property public final com.mapbox.maps.extension.style.types.StyleTransition? vignetteTransition; + } + + @com.mapbox.maps.MapboxExperimental @com.mapbox.maps.extension.style.types.SnowDsl public interface SnowDslReceiver { + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow centerThinning(double centerThinning = 1.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow centerThinning(com.mapbox.maps.extension.style.expressions.generated.Expression centerThinning); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow centerThinningTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow centerThinningTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow color(@ColorInt int color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow color(String color = "#ffffff"); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow color(com.mapbox.maps.extension.style.expressions.generated.Expression color); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow colorTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow colorTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow density(double density = 1.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow density(com.mapbox.maps.extension.style.expressions.generated.Expression density); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow densityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow densityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow direction(java.util.List direction = listOf(0.0, 90.0)); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow direction(com.mapbox.maps.extension.style.expressions.generated.Expression direction); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow directionTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow directionTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow intensity(double intensity = 1.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow intensity(com.mapbox.maps.extension.style.expressions.generated.Expression intensity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow intensityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow intensityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow opacity(double opacity = 1.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow opacity(com.mapbox.maps.extension.style.expressions.generated.Expression opacity); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow opacityTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow opacityTransition(kotlin.jvm.functions.Function1 block); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow vignette(double vignette = 0.0); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow vignette(com.mapbox.maps.extension.style.expressions.generated.Expression vignette); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow vignetteTransition(com.mapbox.maps.extension.style.types.StyleTransition options); + method @com.mapbox.maps.MapboxExperimental public com.mapbox.maps.extension.style.precipitations.generated.Snow vignetteTransition(kotlin.jvm.functions.Function1 block); + } + + public final class SnowKt { + method @com.mapbox.maps.MapboxExperimental public static com.mapbox.maps.extension.style.precipitations.generated.Snow snow(kotlin.jvm.functions.Function1 block); + } + + public final class SnowUtils { + method @com.mapbox.maps.MapboxExperimental public static com.mapbox.maps.extension.style.precipitations.generated.Snow getSnow(com.mapbox.maps.MapboxStyleManager); + method @com.mapbox.maps.MapboxExperimental public static void removeSnow(com.mapbox.maps.MapboxStyleManager); + method @com.mapbox.maps.MapboxExperimental public static void setSnow(com.mapbox.maps.MapboxStyleManager, com.mapbox.maps.extension.style.StyleContract.StyleSnowExtension snow); + } + +} + package com.mapbox.maps.extension.style.projection.generated { @UiThread public final class Projection implements com.mapbox.maps.extension.style.StyleContract.StyleProjectionExtension { @@ -7041,6 +7291,12 @@ package com.mapbox.maps.extension.style.types { public static final class PromoteId.Companion { } + @com.mapbox.maps.MapboxExperimental @kotlin.DslMarker public @interface RainDsl { + } + + @com.mapbox.maps.MapboxExperimental @kotlin.DslMarker public @interface SnowDsl { + } + @kotlin.DslMarker public @interface SourceDsl { } diff --git a/extension-style/api/extension-style.api b/extension-style/api/extension-style.api index b410e0250d..3fa12cbf16 100644 --- a/extension-style/api/extension-style.api +++ b/extension-style/api/extension-style.api @@ -9,6 +9,8 @@ public final class com/mapbox/maps/extension/style/StyleExtensionImpl : com/mapb public fun getModels ()Ljava/util/List; public synthetic fun getProjection ()Lcom/mapbox/maps/extension/style/StyleContract$StyleProjectionExtension; public fun getProjection ()Lcom/mapbox/maps/extension/style/projection/generated/Projection; + public fun getRain ()Lcom/mapbox/maps/extension/style/StyleContract$StyleRainExtension; + public fun getSnow ()Lcom/mapbox/maps/extension/style/StyleContract$StyleSnowExtension; public fun getSources ()Ljava/util/List; public fun getStyle ()Ljava/lang/String; public synthetic fun getTerrain ()Lcom/mapbox/maps/extension/style/StyleContract$StyleTerrainExtension; @@ -35,6 +37,8 @@ public final class com/mapbox/maps/extension/style/StyleExtensionImpl$Builder { public final fun setLight (Lcom/mapbox/maps/extension/style/light/DynamicLight;)V public final fun setLight (Lcom/mapbox/maps/extension/style/light/generated/FlatLight;)V public final fun setProjection (Lcom/mapbox/maps/extension/style/projection/generated/Projection;)V + public final fun setRain (Lcom/mapbox/maps/extension/style/precipitations/generated/Rain;)V + public final fun setSnow (Lcom/mapbox/maps/extension/style/precipitations/generated/Snow;)V public final fun setTerrain (Lcom/mapbox/maps/extension/style/terrain/generated/Terrain;)V public final fun setTransition (Lcom/mapbox/maps/TransitionOptions;)V } @@ -5301,6 +5305,222 @@ public final class com/mapbox/maps/extension/style/model/ModelUtils { public static final fun model (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/model/ModelExtensionImpl; } +public final class com/mapbox/maps/extension/style/precipitations/generated/Rain : com/mapbox/maps/extension/style/StyleContract$StyleRainExtension, com/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver { + public fun ()V + public fun bindTo (Lcom/mapbox/maps/MapboxStyleManager;)V + public fun centerThinning (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun centerThinning (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun centerThinningTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun centerThinningTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun color (I)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun color (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun color (Ljava/lang/String;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun colorTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun colorTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun density (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun density (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun densityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun densityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun direction (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun direction (Ljava/util/List;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun directionTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun directionTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public final fun getCenterThinning ()Ljava/lang/Double; + public final fun getCenterThinningAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getCenterThinningTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getColor ()Ljava/lang/String; + public final fun getColorAsColorInt ()Ljava/lang/Integer; + public final fun getColorAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getColorTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getDensity ()Ljava/lang/Double; + public final fun getDensityAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getDensityTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getDirection ()Ljava/util/List; + public final fun getDirectionAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getDirectionTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getIntensity ()Ljava/lang/Double; + public final fun getIntensityAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getIntensityTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getOpacity ()Ljava/lang/Double; + public final fun getOpacityAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getOpacityTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getVignette ()Ljava/lang/Double; + public final fun getVignetteAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getVignetteTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public fun intensity (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun intensity (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun intensityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun intensityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun opacity (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun opacity (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun opacityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun opacityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun vignette (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun vignette (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun vignetteTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public fun vignetteTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; +} + +public abstract interface class com/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver { + public abstract fun centerThinning (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun centerThinning (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun centerThinningTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun centerThinningTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun color (I)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun color (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun color (Ljava/lang/String;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun colorTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun colorTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun density (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun density (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun densityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun densityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun direction (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun direction (Ljava/util/List;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun directionTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun directionTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun intensity (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun intensity (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun intensityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun intensityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun opacity (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun opacity (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun opacityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun opacityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun vignette (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun vignette (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun vignetteTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public abstract fun vignetteTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; +} + +public final class com/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver$DefaultImpls { + public static synthetic fun centerThinning$default (Lcom/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public static synthetic fun color$default (Lcom/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver;Ljava/lang/String;ILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public static synthetic fun density$default (Lcom/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public static synthetic fun direction$default (Lcom/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver;Ljava/util/List;ILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public static synthetic fun intensity$default (Lcom/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public static synthetic fun opacity$default (Lcom/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public static synthetic fun vignette$default (Lcom/mapbox/maps/extension/style/precipitations/generated/RainDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; +} + +public final class com/mapbox/maps/extension/style/precipitations/generated/RainKt { + public static final fun rain (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; +} + +public final class com/mapbox/maps/extension/style/precipitations/generated/RainUtils { + public static final fun getRain (Lcom/mapbox/maps/MapboxStyleManager;)Lcom/mapbox/maps/extension/style/precipitations/generated/Rain; + public static final fun removeRain (Lcom/mapbox/maps/MapboxStyleManager;)V + public static final fun setRain (Lcom/mapbox/maps/MapboxStyleManager;Lcom/mapbox/maps/extension/style/StyleContract$StyleRainExtension;)V +} + +public final class com/mapbox/maps/extension/style/precipitations/generated/Snow : com/mapbox/maps/extension/style/StyleContract$StyleSnowExtension, com/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver { + public fun ()V + public fun bindTo (Lcom/mapbox/maps/MapboxStyleManager;)V + public fun centerThinning (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun centerThinning (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun centerThinningTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun centerThinningTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun color (I)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun color (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun color (Ljava/lang/String;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun colorTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun colorTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun density (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun density (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun densityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun densityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun direction (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun direction (Ljava/util/List;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun directionTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun directionTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public final fun getCenterThinning ()Ljava/lang/Double; + public final fun getCenterThinningAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getCenterThinningTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getColor ()Ljava/lang/String; + public final fun getColorAsColorInt ()Ljava/lang/Integer; + public final fun getColorAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getColorTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getDensity ()Ljava/lang/Double; + public final fun getDensityAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getDensityTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getDirection ()Ljava/util/List; + public final fun getDirectionAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getDirectionTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getIntensity ()Ljava/lang/Double; + public final fun getIntensityAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getIntensityTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getOpacity ()Ljava/lang/Double; + public final fun getOpacityAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getOpacityTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public final fun getVignette ()Ljava/lang/Double; + public final fun getVignetteAsExpression ()Lcom/mapbox/maps/extension/style/expressions/generated/Expression; + public final fun getVignetteTransition ()Lcom/mapbox/maps/extension/style/types/StyleTransition; + public fun intensity (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun intensity (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun intensityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun intensityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun opacity (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun opacity (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun opacityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun opacityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun vignette (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun vignette (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun vignetteTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public fun vignetteTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; +} + +public abstract interface class com/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver { + public abstract fun centerThinning (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun centerThinning (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun centerThinningTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun centerThinningTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun color (I)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun color (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun color (Ljava/lang/String;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun colorTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun colorTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun density (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun density (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun densityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun densityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun direction (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun direction (Ljava/util/List;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun directionTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun directionTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun intensity (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun intensity (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun intensityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun intensityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun opacity (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun opacity (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun opacityTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun opacityTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun vignette (D)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun vignette (Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun vignetteTransition (Lcom/mapbox/maps/extension/style/types/StyleTransition;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public abstract fun vignetteTransition (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; +} + +public final class com/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver$DefaultImpls { + public static synthetic fun centerThinning$default (Lcom/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public static synthetic fun color$default (Lcom/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver;Ljava/lang/String;ILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public static synthetic fun density$default (Lcom/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public static synthetic fun direction$default (Lcom/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver;Ljava/util/List;ILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public static synthetic fun intensity$default (Lcom/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public static synthetic fun opacity$default (Lcom/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public static synthetic fun vignette$default (Lcom/mapbox/maps/extension/style/precipitations/generated/SnowDslReceiver;DILjava/lang/Object;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; +} + +public final class com/mapbox/maps/extension/style/precipitations/generated/SnowKt { + public static final fun snow (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; +} + +public final class com/mapbox/maps/extension/style/precipitations/generated/SnowUtils { + public static final fun getSnow (Lcom/mapbox/maps/MapboxStyleManager;)Lcom/mapbox/maps/extension/style/precipitations/generated/Snow; + public static final fun removeSnow (Lcom/mapbox/maps/MapboxStyleManager;)V + public static final fun setSnow (Lcom/mapbox/maps/MapboxStyleManager;Lcom/mapbox/maps/extension/style/StyleContract$StyleSnowExtension;)V +} + public final class com/mapbox/maps/extension/style/projection/generated/Projection : com/mapbox/maps/extension/style/StyleContract$StyleProjectionExtension { public fun (Lcom/mapbox/maps/extension/style/layers/properties/generated/ProjectionName;)V public fun bindTo (Lcom/mapbox/maps/MapboxStyleManager;)V @@ -6036,6 +6256,12 @@ public final class com/mapbox/maps/extension/style/types/PromoteId { public final class com/mapbox/maps/extension/style/types/PromoteId$Companion { } +public abstract interface annotation class com/mapbox/maps/extension/style/types/RainDsl : java/lang/annotation/Annotation { +} + +public abstract interface annotation class com/mapbox/maps/extension/style/types/SnowDsl : java/lang/annotation/Annotation { +} + public abstract interface annotation class com/mapbox/maps/extension/style/types/SourceDsl : java/lang/annotation/Annotation { } diff --git a/extension-style/src/main/java/com/mapbox/maps/extension/style/StyleExtensionImpl.kt b/extension-style/src/main/java/com/mapbox/maps/extension/style/StyleExtensionImpl.kt index 326264e1bb..b83bd34e39 100644 --- a/extension-style/src/main/java/com/mapbox/maps/extension/style/StyleExtensionImpl.kt +++ b/extension-style/src/main/java/com/mapbox/maps/extension/style/StyleExtensionImpl.kt @@ -4,19 +4,21 @@ import android.opengl.GLES20 import com.mapbox.maps.LayerPosition import com.mapbox.maps.MapboxExperimental import com.mapbox.maps.TransitionOptions -import com.mapbox.maps.extension.style.StyleExtensionImpl.* +import com.mapbox.maps.extension.style.StyleExtensionImpl.Builder import com.mapbox.maps.extension.style.atmosphere.generated.Atmosphere import com.mapbox.maps.extension.style.image.ImageExtensionImpl import com.mapbox.maps.extension.style.image.ImageNinePatchExtensionImpl -import com.mapbox.maps.extension.style.layers.* +import com.mapbox.maps.extension.style.layers.Layer import com.mapbox.maps.extension.style.layers.properties.generated.ProjectionName import com.mapbox.maps.extension.style.light.DynamicLight import com.mapbox.maps.extension.style.light.generated.AmbientLight import com.mapbox.maps.extension.style.light.generated.DirectionalLight import com.mapbox.maps.extension.style.light.generated.FlatLight import com.mapbox.maps.extension.style.model.ModelExtensionImpl +import com.mapbox.maps.extension.style.precipitations.generated.Rain +import com.mapbox.maps.extension.style.precipitations.generated.Snow import com.mapbox.maps.extension.style.projection.generated.Projection -import com.mapbox.maps.extension.style.sources.* +import com.mapbox.maps.extension.style.sources.Source import com.mapbox.maps.extension.style.terrain.generated.Terrain import com.mapbox.maps.extension.style.utils.StyleTelemetryEvents @@ -83,6 +85,18 @@ class StyleExtensionImpl private constructor( */ override val transition: TransitionOptions? = builder.transition + /** + * The rain effect of the style. + */ + @MapboxExperimental + override val rain: StyleContract.StyleRainExtension? = builder.rain + + /** + * The snow effect of the style. + */ + @MapboxExperimental + override val snow: StyleContract.StyleSnowExtension? = builder.snow + /** * The builder for style extension. */ @@ -104,6 +118,10 @@ class StyleExtensionImpl private constructor( internal var atmosphere: Atmosphere? = null internal var projection: Projection? = null internal var transition: TransitionOptions? = null + @OptIn(MapboxExperimental::class) + internal var snow: Snow? = null + @OptIn(MapboxExperimental::class) + internal var rain: Rain? = null /** * Extension function for [Layer] to overload Unary operations. @@ -197,6 +215,28 @@ class StyleExtensionImpl private constructor( transition = this } + /** + * Extension function for [Snow] to overload Unary operations. + * + * Apply +[Snow] will add specific snow effect to the [StyleExtensionImpl]. + */ + @OptIn(MapboxExperimental::class) + @JvmName("setSnow") + operator fun Snow.unaryPlus() { + snow = this + } + + /** + * Extension function for [Rain] to overload Unary operations. + * + * Apply +[Rain] will add specific snow effect to the [StyleExtensionImpl]. + */ + @OptIn(MapboxExperimental::class) + @JvmName("setRain") + operator fun Rain.unaryPlus() { + rain = this + } + /** * Extension function for [ImageExtensionImpl] to overload Unary operations. * diff --git a/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/Rain.kt b/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/Rain.kt new file mode 100644 index 0000000000..4f40048727 --- /dev/null +++ b/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/Rain.kt @@ -0,0 +1,989 @@ +// This file is generated. +package com.mapbox.maps.extension.style.precipitations.generated + +import android.util.Log +import androidx.annotation.ColorInt +import androidx.annotation.UiThread +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.MapboxStyleException +import com.mapbox.maps.MapboxStyleManager +import com.mapbox.maps.extension.style.StyleContract +import com.mapbox.maps.extension.style.expressions.generated.Expression +import com.mapbox.maps.extension.style.layers.properties.PropertyValue +import com.mapbox.maps.extension.style.types.RainDsl +import com.mapbox.maps.extension.style.types.StyleTransition +import com.mapbox.maps.extension.style.utils.ColorUtils.colorIntToRgbaExpression +import com.mapbox.maps.extension.style.utils.ColorUtils.rgbaExpressionToColorInt +import com.mapbox.maps.extension.style.utils.ColorUtils.rgbaExpressionToColorString +import com.mapbox.maps.extension.style.utils.unwrap + +/** + * The experimental Rain API to render rain effect on the map. + */ +@UiThread +@MapboxExperimental +class Rain : RainDslReceiver, StyleContract.StyleRainExtension { + internal var delegate: MapboxStyleManager? = null + private val properties = HashMap>() + + /** + * Thinning factor of rain particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + val centerThinning: Double? + /** + * Thinning factor of rain particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @return centerThinning as Double + */ + get() { + return getPropertyValue("centerThinning") + } + + /** + * Thinning factor of rain particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @param centerThinning as Double + */ + @MapboxExperimental + override fun centerThinning(centerThinning: Double): Rain = apply { + setProperty(PropertyValue("centerThinning", centerThinning)) + } + + /** + * CenterThinning property transition options. + */ + @MapboxExperimental + val centerThinningTransition: StyleTransition? + /** + * Get the CenterThinning property transition options. + * + * @return transition options for centerThinning + */ + get() { + return getTransitionProperty("centerThinning-transition") + } + + /** + * Set the CenterThinning property transition options. + * + * @param options transition options for centerThinning + */ + @MapboxExperimental + override fun centerThinningTransition(options: StyleTransition): Rain = apply { + val propertyValue = PropertyValue("centerThinning-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [centerThinningTransition]. + */ + @MapboxExperimental + override fun centerThinningTransition(block: StyleTransition.Builder.() -> Unit): Rain = apply { + centerThinningTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Thinning factor of rain particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * This is an Expression representation of "centerThinning". + */ + @MapboxExperimental + val centerThinningAsExpression: Expression? + /** + * Thinning factor of rain particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * Get the centerThinning property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("centerThinning")?.let { + return it + } + centerThinning?.let { + return Expression.literal(it) + } + return null + } + /** + * Thinning factor of rain particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @param centerThinning value of centerThinning as Expression + */ + @MapboxExperimental + override fun centerThinning(centerThinning: Expression): Rain = apply { + val propertyValue = PropertyValue("centerThinning", centerThinning) + setProperty(propertyValue) + } + /** + * Default value: "#ffffff". + */ + @MapboxExperimental + val colorAsColorInt: Int? + /** + * Default value: "#ffffff". + * + * @return color as int + */ + @ColorInt + get() { + colorAsExpression?.let { + return rgbaExpressionToColorInt(it) + } + return null + } + /** + * Default value: "#ffffff". + * + * @param color as int + */ + @MapboxExperimental + override fun color(@ColorInt color: Int): Rain = apply { + val propertyValue = PropertyValue("color", colorIntToRgbaExpression(color)) + setProperty(propertyValue) + } + /** + * Default value: "#ffffff". + */ + @MapboxExperimental + val color: String? + /** + * Default value: "#ffffff". + * + * @return color as String + */ + get() { + colorAsExpression?.let { + return rgbaExpressionToColorString(it) + } + return null + } + + /** + * Default value: "#ffffff". + * + * @param color as String + */ + @MapboxExperimental + override fun color(color: String): Rain = apply { + setProperty(PropertyValue("color", color)) + } + + /** + * Color property transition options. + */ + @MapboxExperimental + val colorTransition: StyleTransition? + /** + * Get the Color property transition options. + * + * @return transition options for color + */ + get() { + return getTransitionProperty("color-transition") + } + + /** + * Set the Color property transition options. + * + * @param options transition options for color + */ + @MapboxExperimental + override fun colorTransition(options: StyleTransition): Rain = apply { + val propertyValue = PropertyValue("color-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [colorTransition]. + */ + @MapboxExperimental + override fun colorTransition(block: StyleTransition.Builder.() -> Unit): Rain = apply { + colorTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Default value: "#ffffff". + * + * This is an Expression representation of "color". + */ + @MapboxExperimental + val colorAsExpression: Expression? + /** + * Default value: "#ffffff". + * + * Get the color property as an Expression + * + * @return String + */ + get() { + getPropertyValue("color")?.let { + return it + } + return null + } + /** + * Default value: "#ffffff". + * + * @param color value of color as Expression + */ + @MapboxExperimental + override fun color(color: Expression): Rain = apply { + val propertyValue = PropertyValue("color", color) + setProperty(propertyValue) + } + /** + * Rain particles density. Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + val density: Double? + /** + * Rain particles density. Default value: 1. Value range: [0, 1] + * + * @return density as Double + */ + get() { + return getPropertyValue("density") + } + + /** + * Rain particles density. Default value: 1. Value range: [0, 1] + * + * @param density as Double + */ + @MapboxExperimental + override fun density(density: Double): Rain = apply { + setProperty(PropertyValue("density", density)) + } + + /** + * Density property transition options. + */ + @MapboxExperimental + val densityTransition: StyleTransition? + /** + * Get the Density property transition options. + * + * @return transition options for density + */ + get() { + return getTransitionProperty("density-transition") + } + + /** + * Set the Density property transition options. + * + * @param options transition options for density + */ + @MapboxExperimental + override fun densityTransition(options: StyleTransition): Rain = apply { + val propertyValue = PropertyValue("density-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [densityTransition]. + */ + @MapboxExperimental + override fun densityTransition(block: StyleTransition.Builder.() -> Unit): Rain = apply { + densityTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Rain particles density. Default value: 1. Value range: [0, 1] + * + * This is an Expression representation of "density". + */ + @MapboxExperimental + val densityAsExpression: Expression? + /** + * Rain particles density. Default value: 1. Value range: [0, 1] + * + * Get the density property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("density")?.let { + return it + } + density?.let { + return Expression.literal(it) + } + return null + } + /** + * Rain particles density. Default value: 1. Value range: [0, 1] + * + * @param density value of density as Expression + */ + @MapboxExperimental + override fun density(density: Expression): Rain = apply { + val propertyValue = PropertyValue("density", density) + setProperty(propertyValue) + } + /** + * Main rain particles direction. Heading & pitch Default value: [0,80]. Value range: [0, 360] + */ + @MapboxExperimental + val direction: List? + /** + * Main rain particles direction. Heading & pitch Default value: [0,80]. Value range: [0, 360] + * + * @return direction as List + */ + get() { + return getPropertyValue("direction") + } + + /** + * Main rain particles direction. Heading & pitch Default value: [0,80]. Value range: [0, 360] + * + * @param direction as List + */ + @MapboxExperimental + override fun direction(direction: List): Rain = apply { + setProperty(PropertyValue("direction", direction)) + } + + /** + * Direction property transition options. + */ + @MapboxExperimental + val directionTransition: StyleTransition? + /** + * Get the Direction property transition options. + * + * @return transition options for direction + */ + get() { + return getTransitionProperty("direction-transition") + } + + /** + * Set the Direction property transition options. + * + * @param options transition options for direction + */ + @MapboxExperimental + override fun directionTransition(options: StyleTransition): Rain = apply { + val propertyValue = PropertyValue("direction-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [directionTransition]. + */ + @MapboxExperimental + override fun directionTransition(block: StyleTransition.Builder.() -> Unit): Rain = apply { + directionTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Main rain particles direction. Heading & pitch Default value: [0,80]. Value range: [0, 360] + * + * This is an Expression representation of "direction". + */ + @MapboxExperimental + val directionAsExpression: Expression? + /** + * Main rain particles direction. Heading & pitch Default value: [0,80]. Value range: [0, 360] + * + * Get the direction property as an Expression + * + * @return List + */ + get() { + getPropertyValue("direction")?.let { + return it + } + direction?.let { + return Expression.literal(it) + } + return null + } + /** + * Main rain particles direction. Heading & pitch Default value: [0,80]. Value range: [0, 360] + * + * @param direction value of direction as Expression + */ + @MapboxExperimental + override fun direction(direction: Expression): Rain = apply { + val propertyValue = PropertyValue("direction", direction) + setProperty(propertyValue) + } + /** + * Rain particles movement factor. Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + val intensity: Double? + /** + * Rain particles movement factor. Default value: 1. Value range: [0, 1] + * + * @return intensity as Double + */ + get() { + return getPropertyValue("intensity") + } + + /** + * Rain particles movement factor. Default value: 1. Value range: [0, 1] + * + * @param intensity as Double + */ + @MapboxExperimental + override fun intensity(intensity: Double): Rain = apply { + setProperty(PropertyValue("intensity", intensity)) + } + + /** + * Intensity property transition options. + */ + @MapboxExperimental + val intensityTransition: StyleTransition? + /** + * Get the Intensity property transition options. + * + * @return transition options for intensity + */ + get() { + return getTransitionProperty("intensity-transition") + } + + /** + * Set the Intensity property transition options. + * + * @param options transition options for intensity + */ + @MapboxExperimental + override fun intensityTransition(options: StyleTransition): Rain = apply { + val propertyValue = PropertyValue("intensity-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [intensityTransition]. + */ + @MapboxExperimental + override fun intensityTransition(block: StyleTransition.Builder.() -> Unit): Rain = apply { + intensityTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Rain particles movement factor. Default value: 1. Value range: [0, 1] + * + * This is an Expression representation of "intensity". + */ + @MapboxExperimental + val intensityAsExpression: Expression? + /** + * Rain particles movement factor. Default value: 1. Value range: [0, 1] + * + * Get the intensity property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("intensity")?.let { + return it + } + intensity?.let { + return Expression.literal(it) + } + return null + } + /** + * Rain particles movement factor. Default value: 1. Value range: [0, 1] + * + * @param intensity value of intensity as Expression + */ + @MapboxExperimental + override fun intensity(intensity: Expression): Rain = apply { + val propertyValue = PropertyValue("intensity", intensity) + setProperty(propertyValue) + } + /** + * Rain particles opacity. Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + val opacity: Double? + /** + * Rain particles opacity. Default value: 1. Value range: [0, 1] + * + * @return opacity as Double + */ + get() { + return getPropertyValue("opacity") + } + + /** + * Rain particles opacity. Default value: 1. Value range: [0, 1] + * + * @param opacity as Double + */ + @MapboxExperimental + override fun opacity(opacity: Double): Rain = apply { + setProperty(PropertyValue("opacity", opacity)) + } + + /** + * Opacity property transition options. + */ + @MapboxExperimental + val opacityTransition: StyleTransition? + /** + * Get the Opacity property transition options. + * + * @return transition options for opacity + */ + get() { + return getTransitionProperty("opacity-transition") + } + + /** + * Set the Opacity property transition options. + * + * @param options transition options for opacity + */ + @MapboxExperimental + override fun opacityTransition(options: StyleTransition): Rain = apply { + val propertyValue = PropertyValue("opacity-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [opacityTransition]. + */ + @MapboxExperimental + override fun opacityTransition(block: StyleTransition.Builder.() -> Unit): Rain = apply { + opacityTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Rain particles opacity. Default value: 1. Value range: [0, 1] + * + * This is an Expression representation of "opacity". + */ + @MapboxExperimental + val opacityAsExpression: Expression? + /** + * Rain particles opacity. Default value: 1. Value range: [0, 1] + * + * Get the opacity property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("opacity")?.let { + return it + } + opacity?.let { + return Expression.literal(it) + } + return null + } + /** + * Rain particles opacity. Default value: 1. Value range: [0, 1] + * + * @param opacity value of opacity as Expression + */ + @MapboxExperimental + override fun opacity(opacity: Expression): Rain = apply { + val propertyValue = PropertyValue("opacity", opacity) + setProperty(propertyValue) + } + /** + * Rain vignette screen-space effect. Default value: 0. Value range: [0, 1] + */ + @MapboxExperimental + val vignette: Double? + /** + * Rain vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @return vignette as Double + */ + get() { + return getPropertyValue("vignette") + } + + /** + * Rain vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @param vignette as Double + */ + @MapboxExperimental + override fun vignette(vignette: Double): Rain = apply { + setProperty(PropertyValue("vignette", vignette)) + } + + /** + * Vignette property transition options. + */ + @MapboxExperimental + val vignetteTransition: StyleTransition? + /** + * Get the Vignette property transition options. + * + * @return transition options for vignette + */ + get() { + return getTransitionProperty("vignette-transition") + } + + /** + * Set the Vignette property transition options. + * + * @param options transition options for vignette + */ + @MapboxExperimental + override fun vignetteTransition(options: StyleTransition): Rain = apply { + val propertyValue = PropertyValue("vignette-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [vignetteTransition]. + */ + @MapboxExperimental + override fun vignetteTransition(block: StyleTransition.Builder.() -> Unit): Rain = apply { + vignetteTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Rain vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * This is an Expression representation of "vignette". + */ + @MapboxExperimental + val vignetteAsExpression: Expression? + /** + * Rain vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * Get the vignette property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("vignette")?.let { + return it + } + vignette?.let { + return Expression.literal(it) + } + return null + } + /** + * Rain vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @param vignette value of vignette as Expression + */ + @MapboxExperimental + override fun vignette(vignette: Expression): Rain = apply { + val propertyValue = PropertyValue("vignette", vignette) + setProperty(propertyValue) + } + + /** + * Bind rain to the map controller. + * + * @param delegate The map controller + */ + override fun bindTo(delegate: MapboxStyleManager) { + this.delegate = delegate + val rainParams = HashMap() + + properties.forEach { + rainParams[it.key] = it.value.value + } + val expected = delegate.setStyleRain(Value(rainParams)) + expected.error?.let { + throw MapboxStyleException("Set rain failed: $it") + } + } + + private fun setProperty(property: PropertyValue<*>) { + properties[property.propertyName] = property + updateProperty(property) + } + + private fun updateProperty(propertyValue: PropertyValue<*>) { + val expected = delegate?.setStyleRainProperty( + propertyValue.propertyName, + propertyValue.value + ) + expected?.error?.let { + throw MapboxStyleException("Set rain property failed: $it") + } + } + + private inline fun getPropertyValue(propertyName: String): T? { + delegate?.let { + return try { + it.getStyleRainProperty(propertyName).unwrap() + } catch (e: RuntimeException) { + Log.e(TAG, "Get rain property failed: ${e.message}") + Log.e(TAG, it.getStyleRainProperty(propertyName).toString()) + null + } + } + throw MapboxStyleException("Get property $propertyName failed: rain is not added to style yet.") + } + + private fun getTransitionProperty(transitionName: String): StyleTransition? { + delegate?.let { + return try { + @Suppress("UNCHECKED_CAST") + val styleLayerProperty = + it.getStyleRainProperty(transitionName).value.contents as HashMap + val duration = styleLayerProperty["duration"]?.contents as Long + val delay = styleLayerProperty["delay"]?.contents as Long + StyleTransition.Builder().delay(delay).duration(duration).build() + } catch (e: RuntimeException) { + Log.e(TAG, "Get rain property failed: ${e.message}") + Log.e(TAG, it.getStyleRainProperty(transitionName).toString()) + null + } + } + throw MapboxStyleException("Get property $transitionName failed: rain is not added to style yet.") + } + + /** + * Static variables and methods. + */ + private companion object { + private const val TAG = "Mbgl-Rain" + } +} + +/** + * This Interface contains all the functions that will be exposed to Koltin DSL. + * + * Separated the DSL receiver class to this interface to avoid IDE code suggestion for + * property getters. + */ +@RainDsl +@MapboxExperimental +interface RainDslReceiver { + /** + * Thinning factor of rain particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @param centerThinning as Double + */ + @MapboxExperimental + fun centerThinning(centerThinning: Double = 1.0): Rain + + /** + * Thinning factor of rain particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @param centerThinning value of centerThinning as Expression + */ + @MapboxExperimental + fun centerThinning(centerThinning: Expression): Rain + + /** + * Set the CenterThinning property transition options. + * + * @param options transition options for centerThinning + */ + @MapboxExperimental + fun centerThinningTransition(options: StyleTransition): Rain + + /** + * DSL for [centerThinningTransition]. + */ + @MapboxExperimental + fun centerThinningTransition(block: StyleTransition.Builder.() -> Unit): Rain + /** + * Default value: "#ffffff". + * + * @param color as int + */ + @MapboxExperimental + fun color(@ColorInt color: Int): Rain + /** + * Default value: "#ffffff". + * + * @param color as String + */ + @MapboxExperimental + fun color(color: String = "#ffffff"): Rain + + /** + * Default value: "#ffffff". + * + * @param color value of color as Expression + */ + @MapboxExperimental + fun color(color: Expression): Rain + + /** + * Set the Color property transition options. + * + * @param options transition options for color + */ + @MapboxExperimental + fun colorTransition(options: StyleTransition): Rain + + /** + * DSL for [colorTransition]. + */ + @MapboxExperimental + fun colorTransition(block: StyleTransition.Builder.() -> Unit): Rain + /** + * Rain particles density. Default value: 1. Value range: [0, 1] + * + * @param density as Double + */ + @MapboxExperimental + fun density(density: Double = 1.0): Rain + + /** + * Rain particles density. Default value: 1. Value range: [0, 1] + * + * @param density value of density as Expression + */ + @MapboxExperimental + fun density(density: Expression): Rain + + /** + * Set the Density property transition options. + * + * @param options transition options for density + */ + @MapboxExperimental + fun densityTransition(options: StyleTransition): Rain + + /** + * DSL for [densityTransition]. + */ + @MapboxExperimental + fun densityTransition(block: StyleTransition.Builder.() -> Unit): Rain + /** + * Main rain particles direction. Heading & pitch Default value: [0,80]. Value range: [0, 360] + * + * @param direction as List + */ + @MapboxExperimental + fun direction(direction: List = listOf(0.0, 80.0)): Rain + + /** + * Main rain particles direction. Heading & pitch Default value: [0,80]. Value range: [0, 360] + * + * @param direction value of direction as Expression + */ + @MapboxExperimental + fun direction(direction: Expression): Rain + + /** + * Set the Direction property transition options. + * + * @param options transition options for direction + */ + @MapboxExperimental + fun directionTransition(options: StyleTransition): Rain + + /** + * DSL for [directionTransition]. + */ + @MapboxExperimental + fun directionTransition(block: StyleTransition.Builder.() -> Unit): Rain + /** + * Rain particles movement factor. Default value: 1. Value range: [0, 1] + * + * @param intensity as Double + */ + @MapboxExperimental + fun intensity(intensity: Double = 1.0): Rain + + /** + * Rain particles movement factor. Default value: 1. Value range: [0, 1] + * + * @param intensity value of intensity as Expression + */ + @MapboxExperimental + fun intensity(intensity: Expression): Rain + + /** + * Set the Intensity property transition options. + * + * @param options transition options for intensity + */ + @MapboxExperimental + fun intensityTransition(options: StyleTransition): Rain + + /** + * DSL for [intensityTransition]. + */ + @MapboxExperimental + fun intensityTransition(block: StyleTransition.Builder.() -> Unit): Rain + /** + * Rain particles opacity. Default value: 1. Value range: [0, 1] + * + * @param opacity as Double + */ + @MapboxExperimental + fun opacity(opacity: Double = 1.0): Rain + + /** + * Rain particles opacity. Default value: 1. Value range: [0, 1] + * + * @param opacity value of opacity as Expression + */ + @MapboxExperimental + fun opacity(opacity: Expression): Rain + + /** + * Set the Opacity property transition options. + * + * @param options transition options for opacity + */ + @MapboxExperimental + fun opacityTransition(options: StyleTransition): Rain + + /** + * DSL for [opacityTransition]. + */ + @MapboxExperimental + fun opacityTransition(block: StyleTransition.Builder.() -> Unit): Rain + /** + * Rain vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @param vignette as Double + */ + @MapboxExperimental + fun vignette(vignette: Double = 0.0): Rain + + /** + * Rain vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @param vignette value of vignette as Expression + */ + @MapboxExperimental + fun vignette(vignette: Expression): Rain + + /** + * Set the Vignette property transition options. + * + * @param options transition options for vignette + */ + @MapboxExperimental + fun vignetteTransition(options: StyleTransition): Rain + + /** + * DSL for [vignetteTransition]. + */ + @MapboxExperimental + fun vignetteTransition(block: StyleTransition.Builder.() -> Unit): Rain +} + +/** + * DSL function for creating [Rain] instance. + */ +@MapboxExperimental +fun rain(block: RainDslReceiver.() -> Unit): Rain { + return Rain().apply(block) +} + +// End of generated file. \ No newline at end of file diff --git a/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/RainExt.kt b/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/RainExt.kt new file mode 100644 index 0000000000..2bf18e1231 --- /dev/null +++ b/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/RainExt.kt @@ -0,0 +1,39 @@ +// This file is generated. +@file:JvmName("RainUtils") + +package com.mapbox.maps.extension.style.precipitations.generated + +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.MapboxStyleManager +import com.mapbox.maps.extension.style.StyleContract + +/** + * Extension function to get the Rain provided by the Style Extension. + * + * @return Rain + */ +@MapboxExperimental +fun MapboxStyleManager.getRain(): Rain { + return Rain().also { it.delegate = this } +} + +/** + * Extension function to set the Rain provided by the Style Extension to the Style. + * + * @param rain The rain to be set + */ +@MapboxExperimental +fun MapboxStyleManager.setRain(rain: StyleContract.StyleRainExtension) { + rain.bindTo(this) +} + +/** + * Removes rain from style if it was set. + */ +@MapboxExperimental +fun MapboxStyleManager.removeRain() { + setStyleRain(Value.nullValue()) +} + +// End of generated file. \ No newline at end of file diff --git a/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/Snow.kt b/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/Snow.kt new file mode 100644 index 0000000000..56accc130d --- /dev/null +++ b/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/Snow.kt @@ -0,0 +1,989 @@ +// This file is generated. +package com.mapbox.maps.extension.style.precipitations.generated + +import android.util.Log +import androidx.annotation.ColorInt +import androidx.annotation.UiThread +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.MapboxStyleException +import com.mapbox.maps.MapboxStyleManager +import com.mapbox.maps.extension.style.StyleContract +import com.mapbox.maps.extension.style.expressions.generated.Expression +import com.mapbox.maps.extension.style.layers.properties.PropertyValue +import com.mapbox.maps.extension.style.types.SnowDsl +import com.mapbox.maps.extension.style.types.StyleTransition +import com.mapbox.maps.extension.style.utils.ColorUtils.colorIntToRgbaExpression +import com.mapbox.maps.extension.style.utils.ColorUtils.rgbaExpressionToColorInt +import com.mapbox.maps.extension.style.utils.ColorUtils.rgbaExpressionToColorString +import com.mapbox.maps.extension.style.utils.unwrap + +/** + * The experimental Snow API to render snow effect on the map. + */ +@UiThread +@MapboxExperimental +class Snow : SnowDslReceiver, StyleContract.StyleSnowExtension { + internal var delegate: MapboxStyleManager? = null + private val properties = HashMap>() + + /** + * Thinning factor of snow particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + val centerThinning: Double? + /** + * Thinning factor of snow particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @return centerThinning as Double + */ + get() { + return getPropertyValue("centerThinning") + } + + /** + * Thinning factor of snow particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @param centerThinning as Double + */ + @MapboxExperimental + override fun centerThinning(centerThinning: Double): Snow = apply { + setProperty(PropertyValue("centerThinning", centerThinning)) + } + + /** + * CenterThinning property transition options. + */ + @MapboxExperimental + val centerThinningTransition: StyleTransition? + /** + * Get the CenterThinning property transition options. + * + * @return transition options for centerThinning + */ + get() { + return getTransitionProperty("centerThinning-transition") + } + + /** + * Set the CenterThinning property transition options. + * + * @param options transition options for centerThinning + */ + @MapboxExperimental + override fun centerThinningTransition(options: StyleTransition): Snow = apply { + val propertyValue = PropertyValue("centerThinning-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [centerThinningTransition]. + */ + @MapboxExperimental + override fun centerThinningTransition(block: StyleTransition.Builder.() -> Unit): Snow = apply { + centerThinningTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Thinning factor of snow particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * This is an Expression representation of "centerThinning". + */ + @MapboxExperimental + val centerThinningAsExpression: Expression? + /** + * Thinning factor of snow particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * Get the centerThinning property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("centerThinning")?.let { + return it + } + centerThinning?.let { + return Expression.literal(it) + } + return null + } + /** + * Thinning factor of snow particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @param centerThinning value of centerThinning as Expression + */ + @MapboxExperimental + override fun centerThinning(centerThinning: Expression): Snow = apply { + val propertyValue = PropertyValue("centerThinning", centerThinning) + setProperty(propertyValue) + } + /** + * Snow particles color. Default value: "#ffffff". + */ + @MapboxExperimental + val colorAsColorInt: Int? + /** + * Snow particles color. Default value: "#ffffff". + * + * @return color as int + */ + @ColorInt + get() { + colorAsExpression?.let { + return rgbaExpressionToColorInt(it) + } + return null + } + /** + * Snow particles color. Default value: "#ffffff". + * + * @param color as int + */ + @MapboxExperimental + override fun color(@ColorInt color: Int): Snow = apply { + val propertyValue = PropertyValue("color", colorIntToRgbaExpression(color)) + setProperty(propertyValue) + } + /** + * Snow particles color. Default value: "#ffffff". + */ + @MapboxExperimental + val color: String? + /** + * Snow particles color. Default value: "#ffffff". + * + * @return color as String + */ + get() { + colorAsExpression?.let { + return rgbaExpressionToColorString(it) + } + return null + } + + /** + * Snow particles color. Default value: "#ffffff". + * + * @param color as String + */ + @MapboxExperimental + override fun color(color: String): Snow = apply { + setProperty(PropertyValue("color", color)) + } + + /** + * Color property transition options. + */ + @MapboxExperimental + val colorTransition: StyleTransition? + /** + * Get the Color property transition options. + * + * @return transition options for color + */ + get() { + return getTransitionProperty("color-transition") + } + + /** + * Set the Color property transition options. + * + * @param options transition options for color + */ + @MapboxExperimental + override fun colorTransition(options: StyleTransition): Snow = apply { + val propertyValue = PropertyValue("color-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [colorTransition]. + */ + @MapboxExperimental + override fun colorTransition(block: StyleTransition.Builder.() -> Unit): Snow = apply { + colorTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Snow particles color. Default value: "#ffffff". + * + * This is an Expression representation of "color". + */ + @MapboxExperimental + val colorAsExpression: Expression? + /** + * Snow particles color. Default value: "#ffffff". + * + * Get the color property as an Expression + * + * @return String + */ + get() { + getPropertyValue("color")?.let { + return it + } + return null + } + /** + * Snow particles color. Default value: "#ffffff". + * + * @param color value of color as Expression + */ + @MapboxExperimental + override fun color(color: Expression): Snow = apply { + val propertyValue = PropertyValue("color", color) + setProperty(propertyValue) + } + /** + * Snow particles density. Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + val density: Double? + /** + * Snow particles density. Default value: 1. Value range: [0, 1] + * + * @return density as Double + */ + get() { + return getPropertyValue("density") + } + + /** + * Snow particles density. Default value: 1. Value range: [0, 1] + * + * @param density as Double + */ + @MapboxExperimental + override fun density(density: Double): Snow = apply { + setProperty(PropertyValue("density", density)) + } + + /** + * Density property transition options. + */ + @MapboxExperimental + val densityTransition: StyleTransition? + /** + * Get the Density property transition options. + * + * @return transition options for density + */ + get() { + return getTransitionProperty("density-transition") + } + + /** + * Set the Density property transition options. + * + * @param options transition options for density + */ + @MapboxExperimental + override fun densityTransition(options: StyleTransition): Snow = apply { + val propertyValue = PropertyValue("density-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [densityTransition]. + */ + @MapboxExperimental + override fun densityTransition(block: StyleTransition.Builder.() -> Unit): Snow = apply { + densityTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Snow particles density. Default value: 1. Value range: [0, 1] + * + * This is an Expression representation of "density". + */ + @MapboxExperimental + val densityAsExpression: Expression? + /** + * Snow particles density. Default value: 1. Value range: [0, 1] + * + * Get the density property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("density")?.let { + return it + } + density?.let { + return Expression.literal(it) + } + return null + } + /** + * Snow particles density. Default value: 1. Value range: [0, 1] + * + * @param density value of density as Expression + */ + @MapboxExperimental + override fun density(density: Expression): Snow = apply { + val propertyValue = PropertyValue("density", density) + setProperty(propertyValue) + } + /** + * Main snow particles direction. Heading & pitch Default value: [0,90]. Value range: [0, 360] + */ + @MapboxExperimental + val direction: List? + /** + * Main snow particles direction. Heading & pitch Default value: [0,90]. Value range: [0, 360] + * + * @return direction as List + */ + get() { + return getPropertyValue("direction") + } + + /** + * Main snow particles direction. Heading & pitch Default value: [0,90]. Value range: [0, 360] + * + * @param direction as List + */ + @MapboxExperimental + override fun direction(direction: List): Snow = apply { + setProperty(PropertyValue("direction", direction)) + } + + /** + * Direction property transition options. + */ + @MapboxExperimental + val directionTransition: StyleTransition? + /** + * Get the Direction property transition options. + * + * @return transition options for direction + */ + get() { + return getTransitionProperty("direction-transition") + } + + /** + * Set the Direction property transition options. + * + * @param options transition options for direction + */ + @MapboxExperimental + override fun directionTransition(options: StyleTransition): Snow = apply { + val propertyValue = PropertyValue("direction-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [directionTransition]. + */ + @MapboxExperimental + override fun directionTransition(block: StyleTransition.Builder.() -> Unit): Snow = apply { + directionTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Main snow particles direction. Heading & pitch Default value: [0,90]. Value range: [0, 360] + * + * This is an Expression representation of "direction". + */ + @MapboxExperimental + val directionAsExpression: Expression? + /** + * Main snow particles direction. Heading & pitch Default value: [0,90]. Value range: [0, 360] + * + * Get the direction property as an Expression + * + * @return List + */ + get() { + getPropertyValue("direction")?.let { + return it + } + direction?.let { + return Expression.literal(it) + } + return null + } + /** + * Main snow particles direction. Heading & pitch Default value: [0,90]. Value range: [0, 360] + * + * @param direction value of direction as Expression + */ + @MapboxExperimental + override fun direction(direction: Expression): Snow = apply { + val propertyValue = PropertyValue("direction", direction) + setProperty(propertyValue) + } + /** + * Snow particles movement factor. Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + val intensity: Double? + /** + * Snow particles movement factor. Default value: 1. Value range: [0, 1] + * + * @return intensity as Double + */ + get() { + return getPropertyValue("intensity") + } + + /** + * Snow particles movement factor. Default value: 1. Value range: [0, 1] + * + * @param intensity as Double + */ + @MapboxExperimental + override fun intensity(intensity: Double): Snow = apply { + setProperty(PropertyValue("intensity", intensity)) + } + + /** + * Intensity property transition options. + */ + @MapboxExperimental + val intensityTransition: StyleTransition? + /** + * Get the Intensity property transition options. + * + * @return transition options for intensity + */ + get() { + return getTransitionProperty("intensity-transition") + } + + /** + * Set the Intensity property transition options. + * + * @param options transition options for intensity + */ + @MapboxExperimental + override fun intensityTransition(options: StyleTransition): Snow = apply { + val propertyValue = PropertyValue("intensity-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [intensityTransition]. + */ + @MapboxExperimental + override fun intensityTransition(block: StyleTransition.Builder.() -> Unit): Snow = apply { + intensityTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Snow particles movement factor. Default value: 1. Value range: [0, 1] + * + * This is an Expression representation of "intensity". + */ + @MapboxExperimental + val intensityAsExpression: Expression? + /** + * Snow particles movement factor. Default value: 1. Value range: [0, 1] + * + * Get the intensity property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("intensity")?.let { + return it + } + intensity?.let { + return Expression.literal(it) + } + return null + } + /** + * Snow particles movement factor. Default value: 1. Value range: [0, 1] + * + * @param intensity value of intensity as Expression + */ + @MapboxExperimental + override fun intensity(intensity: Expression): Snow = apply { + val propertyValue = PropertyValue("intensity", intensity) + setProperty(propertyValue) + } + /** + * Snow particles opacity. Default value: 1. Value range: [0, 1] + */ + @MapboxExperimental + val opacity: Double? + /** + * Snow particles opacity. Default value: 1. Value range: [0, 1] + * + * @return opacity as Double + */ + get() { + return getPropertyValue("opacity") + } + + /** + * Snow particles opacity. Default value: 1. Value range: [0, 1] + * + * @param opacity as Double + */ + @MapboxExperimental + override fun opacity(opacity: Double): Snow = apply { + setProperty(PropertyValue("opacity", opacity)) + } + + /** + * Opacity property transition options. + */ + @MapboxExperimental + val opacityTransition: StyleTransition? + /** + * Get the Opacity property transition options. + * + * @return transition options for opacity + */ + get() { + return getTransitionProperty("opacity-transition") + } + + /** + * Set the Opacity property transition options. + * + * @param options transition options for opacity + */ + @MapboxExperimental + override fun opacityTransition(options: StyleTransition): Snow = apply { + val propertyValue = PropertyValue("opacity-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [opacityTransition]. + */ + @MapboxExperimental + override fun opacityTransition(block: StyleTransition.Builder.() -> Unit): Snow = apply { + opacityTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Snow particles opacity. Default value: 1. Value range: [0, 1] + * + * This is an Expression representation of "opacity". + */ + @MapboxExperimental + val opacityAsExpression: Expression? + /** + * Snow particles opacity. Default value: 1. Value range: [0, 1] + * + * Get the opacity property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("opacity")?.let { + return it + } + opacity?.let { + return Expression.literal(it) + } + return null + } + /** + * Snow particles opacity. Default value: 1. Value range: [0, 1] + * + * @param opacity value of opacity as Expression + */ + @MapboxExperimental + override fun opacity(opacity: Expression): Snow = apply { + val propertyValue = PropertyValue("opacity", opacity) + setProperty(propertyValue) + } + /** + * Snow vignette screen-space effect. Default value: 0. Value range: [0, 1] + */ + @MapboxExperimental + val vignette: Double? + /** + * Snow vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @return vignette as Double + */ + get() { + return getPropertyValue("vignette") + } + + /** + * Snow vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @param vignette as Double + */ + @MapboxExperimental + override fun vignette(vignette: Double): Snow = apply { + setProperty(PropertyValue("vignette", vignette)) + } + + /** + * Vignette property transition options. + */ + @MapboxExperimental + val vignetteTransition: StyleTransition? + /** + * Get the Vignette property transition options. + * + * @return transition options for vignette + */ + get() { + return getTransitionProperty("vignette-transition") + } + + /** + * Set the Vignette property transition options. + * + * @param options transition options for vignette + */ + @MapboxExperimental + override fun vignetteTransition(options: StyleTransition): Snow = apply { + val propertyValue = PropertyValue("vignette-transition", options) + setProperty(propertyValue) + } + + /** + * DSL for [vignetteTransition]. + */ + @MapboxExperimental + override fun vignetteTransition(block: StyleTransition.Builder.() -> Unit): Snow = apply { + vignetteTransition(StyleTransition.Builder().apply(block).build()) + } + + /** + * Snow vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * This is an Expression representation of "vignette". + */ + @MapboxExperimental + val vignetteAsExpression: Expression? + /** + * Snow vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * Get the vignette property as an Expression + * + * @return Double + */ + get() { + getPropertyValue("vignette")?.let { + return it + } + vignette?.let { + return Expression.literal(it) + } + return null + } + /** + * Snow vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @param vignette value of vignette as Expression + */ + @MapboxExperimental + override fun vignette(vignette: Expression): Snow = apply { + val propertyValue = PropertyValue("vignette", vignette) + setProperty(propertyValue) + } + + /** + * Bind snow to the map controller. + * + * @param delegate The map controller + */ + override fun bindTo(delegate: MapboxStyleManager) { + this.delegate = delegate + val snowParams = HashMap() + + properties.forEach { + snowParams[it.key] = it.value.value + } + val expected = delegate.setStyleSnow(Value(snowParams)) + expected.error?.let { + throw MapboxStyleException("Set snow failed: $it") + } + } + + private fun setProperty(property: PropertyValue<*>) { + properties[property.propertyName] = property + updateProperty(property) + } + + private fun updateProperty(propertyValue: PropertyValue<*>) { + val expected = delegate?.setStyleSnowProperty( + propertyValue.propertyName, + propertyValue.value + ) + expected?.error?.let { + throw MapboxStyleException("Set snow property failed: $it") + } + } + + private inline fun getPropertyValue(propertyName: String): T? { + delegate?.let { + return try { + it.getStyleSnowProperty(propertyName).unwrap() + } catch (e: RuntimeException) { + Log.e(TAG, "Get snow property failed: ${e.message}") + Log.e(TAG, it.getStyleSnowProperty(propertyName).toString()) + null + } + } + throw MapboxStyleException("Get property $propertyName failed: snow is not added to style yet.") + } + + private fun getTransitionProperty(transitionName: String): StyleTransition? { + delegate?.let { + return try { + @Suppress("UNCHECKED_CAST") + val styleLayerProperty = + it.getStyleSnowProperty(transitionName).value.contents as HashMap + val duration = styleLayerProperty["duration"]?.contents as Long + val delay = styleLayerProperty["delay"]?.contents as Long + StyleTransition.Builder().delay(delay).duration(duration).build() + } catch (e: RuntimeException) { + Log.e(TAG, "Get snow property failed: ${e.message}") + Log.e(TAG, it.getStyleSnowProperty(transitionName).toString()) + null + } + } + throw MapboxStyleException("Get property $transitionName failed: snow is not added to style yet.") + } + + /** + * Static variables and methods. + */ + private companion object { + private const val TAG = "Mbgl-Snow" + } +} + +/** + * This Interface contains all the functions that will be exposed to Koltin DSL. + * + * Separated the DSL receiver class to this interface to avoid IDE code suggestion for + * property getters. + */ +@SnowDsl +@MapboxExperimental +interface SnowDslReceiver { + /** + * Thinning factor of snow particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @param centerThinning as Double + */ + @MapboxExperimental + fun centerThinning(centerThinning: Double = 1.0): Snow + + /** + * Thinning factor of snow particles from center. 0 - no thinning. 1 - maximal central area thinning. Default value: 1. Value range: [0, 1] + * + * @param centerThinning value of centerThinning as Expression + */ + @MapboxExperimental + fun centerThinning(centerThinning: Expression): Snow + + /** + * Set the CenterThinning property transition options. + * + * @param options transition options for centerThinning + */ + @MapboxExperimental + fun centerThinningTransition(options: StyleTransition): Snow + + /** + * DSL for [centerThinningTransition]. + */ + @MapboxExperimental + fun centerThinningTransition(block: StyleTransition.Builder.() -> Unit): Snow + /** + * Snow particles color. Default value: "#ffffff". + * + * @param color as int + */ + @MapboxExperimental + fun color(@ColorInt color: Int): Snow + /** + * Snow particles color. Default value: "#ffffff". + * + * @param color as String + */ + @MapboxExperimental + fun color(color: String = "#ffffff"): Snow + + /** + * Snow particles color. Default value: "#ffffff". + * + * @param color value of color as Expression + */ + @MapboxExperimental + fun color(color: Expression): Snow + + /** + * Set the Color property transition options. + * + * @param options transition options for color + */ + @MapboxExperimental + fun colorTransition(options: StyleTransition): Snow + + /** + * DSL for [colorTransition]. + */ + @MapboxExperimental + fun colorTransition(block: StyleTransition.Builder.() -> Unit): Snow + /** + * Snow particles density. Default value: 1. Value range: [0, 1] + * + * @param density as Double + */ + @MapboxExperimental + fun density(density: Double = 1.0): Snow + + /** + * Snow particles density. Default value: 1. Value range: [0, 1] + * + * @param density value of density as Expression + */ + @MapboxExperimental + fun density(density: Expression): Snow + + /** + * Set the Density property transition options. + * + * @param options transition options for density + */ + @MapboxExperimental + fun densityTransition(options: StyleTransition): Snow + + /** + * DSL for [densityTransition]. + */ + @MapboxExperimental + fun densityTransition(block: StyleTransition.Builder.() -> Unit): Snow + /** + * Main snow particles direction. Heading & pitch Default value: [0,90]. Value range: [0, 360] + * + * @param direction as List + */ + @MapboxExperimental + fun direction(direction: List = listOf(0.0, 90.0)): Snow + + /** + * Main snow particles direction. Heading & pitch Default value: [0,90]. Value range: [0, 360] + * + * @param direction value of direction as Expression + */ + @MapboxExperimental + fun direction(direction: Expression): Snow + + /** + * Set the Direction property transition options. + * + * @param options transition options for direction + */ + @MapboxExperimental + fun directionTransition(options: StyleTransition): Snow + + /** + * DSL for [directionTransition]. + */ + @MapboxExperimental + fun directionTransition(block: StyleTransition.Builder.() -> Unit): Snow + /** + * Snow particles movement factor. Default value: 1. Value range: [0, 1] + * + * @param intensity as Double + */ + @MapboxExperimental + fun intensity(intensity: Double = 1.0): Snow + + /** + * Snow particles movement factor. Default value: 1. Value range: [0, 1] + * + * @param intensity value of intensity as Expression + */ + @MapboxExperimental + fun intensity(intensity: Expression): Snow + + /** + * Set the Intensity property transition options. + * + * @param options transition options for intensity + */ + @MapboxExperimental + fun intensityTransition(options: StyleTransition): Snow + + /** + * DSL for [intensityTransition]. + */ + @MapboxExperimental + fun intensityTransition(block: StyleTransition.Builder.() -> Unit): Snow + /** + * Snow particles opacity. Default value: 1. Value range: [0, 1] + * + * @param opacity as Double + */ + @MapboxExperimental + fun opacity(opacity: Double = 1.0): Snow + + /** + * Snow particles opacity. Default value: 1. Value range: [0, 1] + * + * @param opacity value of opacity as Expression + */ + @MapboxExperimental + fun opacity(opacity: Expression): Snow + + /** + * Set the Opacity property transition options. + * + * @param options transition options for opacity + */ + @MapboxExperimental + fun opacityTransition(options: StyleTransition): Snow + + /** + * DSL for [opacityTransition]. + */ + @MapboxExperimental + fun opacityTransition(block: StyleTransition.Builder.() -> Unit): Snow + /** + * Snow vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @param vignette as Double + */ + @MapboxExperimental + fun vignette(vignette: Double = 0.0): Snow + + /** + * Snow vignette screen-space effect. Default value: 0. Value range: [0, 1] + * + * @param vignette value of vignette as Expression + */ + @MapboxExperimental + fun vignette(vignette: Expression): Snow + + /** + * Set the Vignette property transition options. + * + * @param options transition options for vignette + */ + @MapboxExperimental + fun vignetteTransition(options: StyleTransition): Snow + + /** + * DSL for [vignetteTransition]. + */ + @MapboxExperimental + fun vignetteTransition(block: StyleTransition.Builder.() -> Unit): Snow +} + +/** + * DSL function for creating [Snow] instance. + */ +@MapboxExperimental +fun snow(block: SnowDslReceiver.() -> Unit): Snow { + return Snow().apply(block) +} + +// End of generated file. \ No newline at end of file diff --git a/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/SnowExt.kt b/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/SnowExt.kt new file mode 100644 index 0000000000..28b48b8bd2 --- /dev/null +++ b/extension-style/src/main/java/com/mapbox/maps/extension/style/precipitations/generated/SnowExt.kt @@ -0,0 +1,39 @@ +// This file is generated. +@file:JvmName("SnowUtils") + +package com.mapbox.maps.extension.style.precipitations.generated + +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.MapboxStyleManager +import com.mapbox.maps.extension.style.StyleContract + +/** + * Extension function to get the Snow provided by the Style Extension. + * + * @return Snow + */ +@MapboxExperimental +fun MapboxStyleManager.getSnow(): Snow { + return Snow().also { it.delegate = this } +} + +/** + * Extension function to set the Snow provided by the Style Extension to the Style. + * + * @param snow The snow to be set + */ +@MapboxExperimental +fun MapboxStyleManager.setSnow(snow: StyleContract.StyleSnowExtension) { + snow.bindTo(this) +} + +/** + * Removes snow from style if it was set. + */ +@MapboxExperimental +fun MapboxStyleManager.removeSnow() { + setStyleSnow(Value.nullValue()) +} + +// End of generated file. \ No newline at end of file diff --git a/extension-style/src/main/java/com/mapbox/maps/extension/style/types/TypeDSLs.kt b/extension-style/src/main/java/com/mapbox/maps/extension/style/types/TypeDSLs.kt index 7d3c560b79..ccf7844dc6 100644 --- a/extension-style/src/main/java/com/mapbox/maps/extension/style/types/TypeDSLs.kt +++ b/extension-style/src/main/java/com/mapbox/maps/extension/style/types/TypeDSLs.kt @@ -1,5 +1,7 @@ package com.mapbox.maps.extension.style.types +import com.mapbox.maps.MapboxExperimental + /** * Dsl marker for Light. * @@ -46,4 +48,22 @@ annotation class TerrainDsl * Controls the scope of the Atmosphere Dsl. */ @DslMarker -annotation class AtmosphereDsl \ No newline at end of file +annotation class AtmosphereDsl + +/** + * Dsl marker for Snow. + * + * Controls the scope of the Snow Dsl. + */ +@DslMarker +@MapboxExperimental +annotation class SnowDsl + +/** + * Dsl marker for Rain. + * + * Controls the scope of the Rain Dsl. + */ +@DslMarker +@MapboxExperimental +annotation class RainDsl \ No newline at end of file diff --git a/extension-style/src/test/java/com/mapbox/maps/extension/style/precipitations/generated/RainTest.kt b/extension-style/src/test/java/com/mapbox/maps/extension/style/precipitations/generated/RainTest.kt new file mode 100644 index 0000000000..ecf312c27d --- /dev/null +++ b/extension-style/src/test/java/com/mapbox/maps/extension/style/precipitations/generated/RainTest.kt @@ -0,0 +1,946 @@ +// This file is generated. +package com.mapbox.maps.extension.style.precipitations.generated + +import android.graphics.Color +import com.mapbox.bindgen.Expected +import com.mapbox.bindgen.None +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.MapboxStyleManager +import com.mapbox.maps.StylePropertyValue +import com.mapbox.maps.StylePropertyValueKind +import com.mapbox.maps.extension.style.expressions.dsl.generated.rgba +import com.mapbox.maps.extension.style.types.transitionOptions +import com.mapbox.maps.extension.style.utils.TypeUtils +import io.mockk.* +import org.junit.After +import org.junit.Assert.* +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner + +@RunWith(RobolectricTestRunner::class) +@OptIn(MapboxExperimental::class) +class RainTest { + private val style = mockk(relaxUnitFun = true, relaxed = true) + private val styleProperty = mockk() + private val expected = mockk>(relaxUnitFun = true, relaxed = true) + private val valueSlot = slot() + + @Before + fun prepareTest() { + every { style.getStyleRainProperty(any()) } returns styleProperty + every { styleProperty.kind } returns StylePropertyValueKind.CONSTANT + every { style.setStyleRainProperty(any(), any()) } returns expected + every { style.setStyleRain(any()) } returns expected + every { expected.error } returns null + } + + @After + fun cleanup() { + clearAllMocks() + } + + @Test + fun centerThinningSet() { + val rain = rain { + centerThinning(1.0) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("centerThinning=1.0")) + } + + @Test + fun centerThinningSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.centerThinning(1.0) + verify { style.setStyleRainProperty("centerThinning", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun centerThinningGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0.toString(), rain.centerThinning!!.toString()) + verify { style.getStyleRainProperty("centerThinning") } + } + + // Expression Tests + + @Test + fun centerThinningAsExpressionGetNull() { + val rain = rain { } + rain.bindTo(style) + assertEquals(null, rain.centerThinningAsExpression) + verify { style.getStyleRainProperty("centerThinning") } + } + + @Test + fun centerThinningAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0, rain.centerThinningAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, rain.centerThinning!!, 1E-5) + verify { style.getStyleRainProperty("centerThinning") } + } + + @Test + fun centerThinningTransitionSet() { + val rain = rain { + centerThinningTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("centerThinning-transition={duration=100, delay=200}")) + } + + @Test + fun centerThinningTransitionSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.centerThinningTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleRainProperty("centerThinning-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun centerThinningTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(transition.toValue().toString(), rain.centerThinningTransition!!.toValue().toString()) + verify { style.getStyleRainProperty("centerThinning-transition") } + } + + @Test + fun centerThinningTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(null, rain.centerThinningTransition) + verify { style.getStyleRainProperty("centerThinning-transition") } + } + + @Test(expected = RuntimeException::class) + fun centerThinningTransitionGetException() { + val rain = rain {} + rain.centerThinningTransition + } + + @Test + fun centerThinningTransitionSetDsl() { + val rain = rain { + centerThinningTransition { + duration(100) + delay(200) + } + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("centerThinning-transition={duration=100, delay=200}")) + } + @Test + fun colorAsColorIntSet() { + val rain = rain { + color(Color.CYAN) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertEquals("{color=[rgba, 0, 255, 255, 1.0]}", valueSlot.captured.toString()) + } + + @Test + fun colorAsColorIntSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.color(Color.CYAN) + verify { style.setStyleRainProperty("color", capture(valueSlot)) } + assertEquals("[rgba, 0, 255, 255, 1.0]", valueSlot.captured.toString()) + } + + @Test + fun colorAsColorIntGet() { + val expression = rgba { + literal(255) + literal(0) + literal(0) + literal(1.0) + } + every { styleProperty.kind } returns StylePropertyValueKind.EXPRESSION + every { styleProperty.value } returns expression + + val rain = rain {} + rain.bindTo(style) + assertEquals(Color.RED, rain.colorAsColorInt!!) + verify { style.getStyleRainProperty("color") } + } + + @Test + fun colorSet() { + val rain = rain { + color("rgba(0, 0, 0, 1)") + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("color=rgba(0, 0, 0, 1)")) + } + + @Test + fun colorSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.color("rgba(0, 0, 0, 1)") + verify { style.setStyleRainProperty("color", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("rgba(0, 0, 0, 1)")) + } + + @Test + fun colorGet() { + val expression = rgba { + literal(0) + literal(0) + literal(0) + literal(1.0) + } + every { styleProperty.kind } returns StylePropertyValueKind.EXPRESSION + every { styleProperty.value } returns expression + + val rain = rain { } + rain.bindTo(style) + assertEquals("rgba(0, 0, 0, 1)".toString(), rain.color!!.toString()) + verify { style.getStyleRainProperty("color") } + } + + // Expression Tests + + @Test + fun colorAsExpressionGetNull() { + val rain = rain { } + rain.bindTo(style) + assertEquals(null, rain.colorAsExpression) + verify { style.getStyleRainProperty("color") } + } + + @Test + fun colorAsExpressionGetFromLiteral() { + val expression = rgba { + literal(0) + literal(0) + literal(0) + literal(1.0) + } + every { styleProperty.kind } returns StylePropertyValueKind.EXPRESSION + every { styleProperty.value } returns expression + + val rain = rain { + color(expression) + } + rain.bindTo(style) + assertEquals(expression.toString(), rain.colorAsExpression.toString()) + assertEquals("rgba(0, 0, 0, 1)", rain.color) + assertEquals(Color.BLACK, rain.colorAsColorInt) + verify { style.getStyleRainProperty("color") } + } + + @Test + fun colorTransitionSet() { + val rain = rain { + colorTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("color-transition={duration=100, delay=200}")) + } + + @Test + fun colorTransitionSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.colorTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleRainProperty("color-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun colorTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(transition.toValue().toString(), rain.colorTransition!!.toValue().toString()) + verify { style.getStyleRainProperty("color-transition") } + } + + @Test + fun colorTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(null, rain.colorTransition) + verify { style.getStyleRainProperty("color-transition") } + } + + @Test(expected = RuntimeException::class) + fun colorTransitionGetException() { + val rain = rain {} + rain.colorTransition + } + + @Test + fun colorTransitionSetDsl() { + val rain = rain { + colorTransition { + duration(100) + delay(200) + } + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("color-transition={duration=100, delay=200}")) + } + @Test + fun densitySet() { + val rain = rain { + density(1.0) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("density=1.0")) + } + + @Test + fun densitySetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.density(1.0) + verify { style.setStyleRainProperty("density", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun densityGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0.toString(), rain.density!!.toString()) + verify { style.getStyleRainProperty("density") } + } + + // Expression Tests + + @Test + fun densityAsExpressionGetNull() { + val rain = rain { } + rain.bindTo(style) + assertEquals(null, rain.densityAsExpression) + verify { style.getStyleRainProperty("density") } + } + + @Test + fun densityAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0, rain.densityAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, rain.density!!, 1E-5) + verify { style.getStyleRainProperty("density") } + } + + @Test + fun densityTransitionSet() { + val rain = rain { + densityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("density-transition={duration=100, delay=200}")) + } + + @Test + fun densityTransitionSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.densityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleRainProperty("density-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun densityTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(transition.toValue().toString(), rain.densityTransition!!.toValue().toString()) + verify { style.getStyleRainProperty("density-transition") } + } + + @Test + fun densityTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(null, rain.densityTransition) + verify { style.getStyleRainProperty("density-transition") } + } + + @Test(expected = RuntimeException::class) + fun densityTransitionGetException() { + val rain = rain {} + rain.densityTransition + } + + @Test + fun densityTransitionSetDsl() { + val rain = rain { + densityTransition { + duration(100) + delay(200) + } + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("density-transition={duration=100, delay=200}")) + } + @Test + fun directionSet() { + val rain = rain { + direction(listOf(0.0, 1.0)) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("direction=[0.0, 1.0]")) + } + + @Test + fun directionSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.direction(listOf(0.0, 1.0)) + verify { style.setStyleRainProperty("direction", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("[0.0, 1.0]")) + } + + @Test + fun directionGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(listOf(0.0, 1.0)) + + val rain = rain { } + rain.bindTo(style) + assertEquals(listOf(0.0, 1.0).toString(), rain.direction!!.toString()) + verify { style.getStyleRainProperty("direction") } + } + + // Expression Tests + + @Test + fun directionAsExpressionGetNull() { + val rain = rain { } + rain.bindTo(style) + assertEquals(null, rain.directionAsExpression) + verify { style.getStyleRainProperty("direction") } + } + + @Test + fun directionAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(listOf(0.0, 1.0)) + val rain = rain { } + rain.bindTo(style) + assertEquals("[literal, [0.0, 1.0]]", rain.directionAsExpression.toString()) + assertEquals(listOf(0.0, 1.0), rain.direction) + verify { style.getStyleRainProperty("direction") } + } + + @Test + fun directionTransitionSet() { + val rain = rain { + directionTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("direction-transition={duration=100, delay=200}")) + } + + @Test + fun directionTransitionSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.directionTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleRainProperty("direction-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun directionTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(transition.toValue().toString(), rain.directionTransition!!.toValue().toString()) + verify { style.getStyleRainProperty("direction-transition") } + } + + @Test + fun directionTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(null, rain.directionTransition) + verify { style.getStyleRainProperty("direction-transition") } + } + + @Test(expected = RuntimeException::class) + fun directionTransitionGetException() { + val rain = rain {} + rain.directionTransition + } + + @Test + fun directionTransitionSetDsl() { + val rain = rain { + directionTransition { + duration(100) + delay(200) + } + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("direction-transition={duration=100, delay=200}")) + } + @Test + fun intensitySet() { + val rain = rain { + intensity(1.0) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("intensity=1.0")) + } + + @Test + fun intensitySetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.intensity(1.0) + verify { style.setStyleRainProperty("intensity", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun intensityGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0.toString(), rain.intensity!!.toString()) + verify { style.getStyleRainProperty("intensity") } + } + + // Expression Tests + + @Test + fun intensityAsExpressionGetNull() { + val rain = rain { } + rain.bindTo(style) + assertEquals(null, rain.intensityAsExpression) + verify { style.getStyleRainProperty("intensity") } + } + + @Test + fun intensityAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0, rain.intensityAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, rain.intensity!!, 1E-5) + verify { style.getStyleRainProperty("intensity") } + } + + @Test + fun intensityTransitionSet() { + val rain = rain { + intensityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("intensity-transition={duration=100, delay=200}")) + } + + @Test + fun intensityTransitionSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.intensityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleRainProperty("intensity-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun intensityTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(transition.toValue().toString(), rain.intensityTransition!!.toValue().toString()) + verify { style.getStyleRainProperty("intensity-transition") } + } + + @Test + fun intensityTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(null, rain.intensityTransition) + verify { style.getStyleRainProperty("intensity-transition") } + } + + @Test(expected = RuntimeException::class) + fun intensityTransitionGetException() { + val rain = rain {} + rain.intensityTransition + } + + @Test + fun intensityTransitionSetDsl() { + val rain = rain { + intensityTransition { + duration(100) + delay(200) + } + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("intensity-transition={duration=100, delay=200}")) + } + @Test + fun opacitySet() { + val rain = rain { + opacity(1.0) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("opacity=1.0")) + } + + @Test + fun opacitySetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.opacity(1.0) + verify { style.setStyleRainProperty("opacity", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun opacityGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0.toString(), rain.opacity!!.toString()) + verify { style.getStyleRainProperty("opacity") } + } + + // Expression Tests + + @Test + fun opacityAsExpressionGetNull() { + val rain = rain { } + rain.bindTo(style) + assertEquals(null, rain.opacityAsExpression) + verify { style.getStyleRainProperty("opacity") } + } + + @Test + fun opacityAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0, rain.opacityAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, rain.opacity!!, 1E-5) + verify { style.getStyleRainProperty("opacity") } + } + + @Test + fun opacityTransitionSet() { + val rain = rain { + opacityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("opacity-transition={duration=100, delay=200}")) + } + + @Test + fun opacityTransitionSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.opacityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleRainProperty("opacity-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun opacityTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(transition.toValue().toString(), rain.opacityTransition!!.toValue().toString()) + verify { style.getStyleRainProperty("opacity-transition") } + } + + @Test + fun opacityTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(null, rain.opacityTransition) + verify { style.getStyleRainProperty("opacity-transition") } + } + + @Test(expected = RuntimeException::class) + fun opacityTransitionGetException() { + val rain = rain {} + rain.opacityTransition + } + + @Test + fun opacityTransitionSetDsl() { + val rain = rain { + opacityTransition { + duration(100) + delay(200) + } + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("opacity-transition={duration=100, delay=200}")) + } + @Test + fun vignetteSet() { + val rain = rain { + vignette(1.0) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("vignette=1.0")) + } + + @Test + fun vignetteSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.vignette(1.0) + verify { style.setStyleRainProperty("vignette", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun vignetteGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0.toString(), rain.vignette!!.toString()) + verify { style.getStyleRainProperty("vignette") } + } + + // Expression Tests + + @Test + fun vignetteAsExpressionGetNull() { + val rain = rain { } + rain.bindTo(style) + assertEquals(null, rain.vignetteAsExpression) + verify { style.getStyleRainProperty("vignette") } + } + + @Test + fun vignetteAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val rain = rain { } + rain.bindTo(style) + assertEquals(1.0, rain.vignetteAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, rain.vignette!!, 1E-5) + verify { style.getStyleRainProperty("vignette") } + } + + @Test + fun vignetteTransitionSet() { + val rain = rain { + vignetteTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("vignette-transition={duration=100, delay=200}")) + } + + @Test + fun vignetteTransitionSetAfterInitialization() { + val rain = rain { } + rain.bindTo(style) + rain.vignetteTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleRainProperty("vignette-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun vignetteTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(transition.toValue().toString(), rain.vignetteTransition!!.toValue().toString()) + verify { style.getStyleRainProperty("vignette-transition") } + } + + @Test + fun vignetteTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val rain = rain {} + rain.bindTo(style) + assertEquals(null, rain.vignetteTransition) + verify { style.getStyleRainProperty("vignette-transition") } + } + + @Test(expected = RuntimeException::class) + fun vignetteTransitionGetException() { + val rain = rain {} + rain.vignetteTransition + } + + @Test + fun vignetteTransitionSetDsl() { + val rain = rain { + vignetteTransition { + duration(100) + delay(200) + } + } + rain.bindTo(style) + verify { style.setStyleRain(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("vignette-transition={duration=100, delay=200}")) + } + + @Test + fun getRainTest() { + assertNotNull(style.getRain()) + verify(exactly = 0) { style.setStyleRain(any()) } + } + + @Test + fun removeRainTest() { + style.removeRain() + verify { style.setStyleRain(Value.nullValue()) } + } +} + +// End of generated file. \ No newline at end of file diff --git a/extension-style/src/test/java/com/mapbox/maps/extension/style/precipitations/generated/SnowTest.kt b/extension-style/src/test/java/com/mapbox/maps/extension/style/precipitations/generated/SnowTest.kt new file mode 100644 index 0000000000..8bc4a2237f --- /dev/null +++ b/extension-style/src/test/java/com/mapbox/maps/extension/style/precipitations/generated/SnowTest.kt @@ -0,0 +1,946 @@ +// This file is generated. +package com.mapbox.maps.extension.style.precipitations.generated + +import android.graphics.Color +import com.mapbox.bindgen.Expected +import com.mapbox.bindgen.None +import com.mapbox.bindgen.Value +import com.mapbox.maps.MapboxExperimental +import com.mapbox.maps.MapboxStyleManager +import com.mapbox.maps.StylePropertyValue +import com.mapbox.maps.StylePropertyValueKind +import com.mapbox.maps.extension.style.expressions.dsl.generated.rgba +import com.mapbox.maps.extension.style.types.transitionOptions +import com.mapbox.maps.extension.style.utils.TypeUtils +import io.mockk.* +import org.junit.After +import org.junit.Assert.* +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner + +@RunWith(RobolectricTestRunner::class) +@OptIn(MapboxExperimental::class) +class SnowTest { + private val style = mockk(relaxUnitFun = true, relaxed = true) + private val styleProperty = mockk() + private val expected = mockk>(relaxUnitFun = true, relaxed = true) + private val valueSlot = slot() + + @Before + fun prepareTest() { + every { style.getStyleSnowProperty(any()) } returns styleProperty + every { styleProperty.kind } returns StylePropertyValueKind.CONSTANT + every { style.setStyleSnowProperty(any(), any()) } returns expected + every { style.setStyleSnow(any()) } returns expected + every { expected.error } returns null + } + + @After + fun cleanup() { + clearAllMocks() + } + + @Test + fun centerThinningSet() { + val snow = snow { + centerThinning(1.0) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("centerThinning=1.0")) + } + + @Test + fun centerThinningSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.centerThinning(1.0) + verify { style.setStyleSnowProperty("centerThinning", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun centerThinningGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0.toString(), snow.centerThinning!!.toString()) + verify { style.getStyleSnowProperty("centerThinning") } + } + + // Expression Tests + + @Test + fun centerThinningAsExpressionGetNull() { + val snow = snow { } + snow.bindTo(style) + assertEquals(null, snow.centerThinningAsExpression) + verify { style.getStyleSnowProperty("centerThinning") } + } + + @Test + fun centerThinningAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0, snow.centerThinningAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, snow.centerThinning!!, 1E-5) + verify { style.getStyleSnowProperty("centerThinning") } + } + + @Test + fun centerThinningTransitionSet() { + val snow = snow { + centerThinningTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("centerThinning-transition={duration=100, delay=200}")) + } + + @Test + fun centerThinningTransitionSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.centerThinningTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleSnowProperty("centerThinning-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun centerThinningTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(transition.toValue().toString(), snow.centerThinningTransition!!.toValue().toString()) + verify { style.getStyleSnowProperty("centerThinning-transition") } + } + + @Test + fun centerThinningTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(null, snow.centerThinningTransition) + verify { style.getStyleSnowProperty("centerThinning-transition") } + } + + @Test(expected = RuntimeException::class) + fun centerThinningTransitionGetException() { + val snow = snow {} + snow.centerThinningTransition + } + + @Test + fun centerThinningTransitionSetDsl() { + val snow = snow { + centerThinningTransition { + duration(100) + delay(200) + } + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("centerThinning-transition={duration=100, delay=200}")) + } + @Test + fun colorAsColorIntSet() { + val snow = snow { + color(Color.CYAN) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertEquals("{color=[rgba, 0, 255, 255, 1.0]}", valueSlot.captured.toString()) + } + + @Test + fun colorAsColorIntSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.color(Color.CYAN) + verify { style.setStyleSnowProperty("color", capture(valueSlot)) } + assertEquals("[rgba, 0, 255, 255, 1.0]", valueSlot.captured.toString()) + } + + @Test + fun colorAsColorIntGet() { + val expression = rgba { + literal(255) + literal(0) + literal(0) + literal(1.0) + } + every { styleProperty.kind } returns StylePropertyValueKind.EXPRESSION + every { styleProperty.value } returns expression + + val snow = snow {} + snow.bindTo(style) + assertEquals(Color.RED, snow.colorAsColorInt!!) + verify { style.getStyleSnowProperty("color") } + } + + @Test + fun colorSet() { + val snow = snow { + color("rgba(0, 0, 0, 1)") + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("color=rgba(0, 0, 0, 1)")) + } + + @Test + fun colorSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.color("rgba(0, 0, 0, 1)") + verify { style.setStyleSnowProperty("color", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("rgba(0, 0, 0, 1)")) + } + + @Test + fun colorGet() { + val expression = rgba { + literal(0) + literal(0) + literal(0) + literal(1.0) + } + every { styleProperty.kind } returns StylePropertyValueKind.EXPRESSION + every { styleProperty.value } returns expression + + val snow = snow { } + snow.bindTo(style) + assertEquals("rgba(0, 0, 0, 1)".toString(), snow.color!!.toString()) + verify { style.getStyleSnowProperty("color") } + } + + // Expression Tests + + @Test + fun colorAsExpressionGetNull() { + val snow = snow { } + snow.bindTo(style) + assertEquals(null, snow.colorAsExpression) + verify { style.getStyleSnowProperty("color") } + } + + @Test + fun colorAsExpressionGetFromLiteral() { + val expression = rgba { + literal(0) + literal(0) + literal(0) + literal(1.0) + } + every { styleProperty.kind } returns StylePropertyValueKind.EXPRESSION + every { styleProperty.value } returns expression + + val snow = snow { + color(expression) + } + snow.bindTo(style) + assertEquals(expression.toString(), snow.colorAsExpression.toString()) + assertEquals("rgba(0, 0, 0, 1)", snow.color) + assertEquals(Color.BLACK, snow.colorAsColorInt) + verify { style.getStyleSnowProperty("color") } + } + + @Test + fun colorTransitionSet() { + val snow = snow { + colorTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("color-transition={duration=100, delay=200}")) + } + + @Test + fun colorTransitionSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.colorTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleSnowProperty("color-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun colorTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(transition.toValue().toString(), snow.colorTransition!!.toValue().toString()) + verify { style.getStyleSnowProperty("color-transition") } + } + + @Test + fun colorTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(null, snow.colorTransition) + verify { style.getStyleSnowProperty("color-transition") } + } + + @Test(expected = RuntimeException::class) + fun colorTransitionGetException() { + val snow = snow {} + snow.colorTransition + } + + @Test + fun colorTransitionSetDsl() { + val snow = snow { + colorTransition { + duration(100) + delay(200) + } + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("color-transition={duration=100, delay=200}")) + } + @Test + fun densitySet() { + val snow = snow { + density(1.0) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("density=1.0")) + } + + @Test + fun densitySetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.density(1.0) + verify { style.setStyleSnowProperty("density", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun densityGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0.toString(), snow.density!!.toString()) + verify { style.getStyleSnowProperty("density") } + } + + // Expression Tests + + @Test + fun densityAsExpressionGetNull() { + val snow = snow { } + snow.bindTo(style) + assertEquals(null, snow.densityAsExpression) + verify { style.getStyleSnowProperty("density") } + } + + @Test + fun densityAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0, snow.densityAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, snow.density!!, 1E-5) + verify { style.getStyleSnowProperty("density") } + } + + @Test + fun densityTransitionSet() { + val snow = snow { + densityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("density-transition={duration=100, delay=200}")) + } + + @Test + fun densityTransitionSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.densityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleSnowProperty("density-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun densityTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(transition.toValue().toString(), snow.densityTransition!!.toValue().toString()) + verify { style.getStyleSnowProperty("density-transition") } + } + + @Test + fun densityTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(null, snow.densityTransition) + verify { style.getStyleSnowProperty("density-transition") } + } + + @Test(expected = RuntimeException::class) + fun densityTransitionGetException() { + val snow = snow {} + snow.densityTransition + } + + @Test + fun densityTransitionSetDsl() { + val snow = snow { + densityTransition { + duration(100) + delay(200) + } + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("density-transition={duration=100, delay=200}")) + } + @Test + fun directionSet() { + val snow = snow { + direction(listOf(0.0, 1.0)) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("direction=[0.0, 1.0]")) + } + + @Test + fun directionSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.direction(listOf(0.0, 1.0)) + verify { style.setStyleSnowProperty("direction", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("[0.0, 1.0]")) + } + + @Test + fun directionGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(listOf(0.0, 1.0)) + + val snow = snow { } + snow.bindTo(style) + assertEquals(listOf(0.0, 1.0).toString(), snow.direction!!.toString()) + verify { style.getStyleSnowProperty("direction") } + } + + // Expression Tests + + @Test + fun directionAsExpressionGetNull() { + val snow = snow { } + snow.bindTo(style) + assertEquals(null, snow.directionAsExpression) + verify { style.getStyleSnowProperty("direction") } + } + + @Test + fun directionAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(listOf(0.0, 1.0)) + val snow = snow { } + snow.bindTo(style) + assertEquals("[literal, [0.0, 1.0]]", snow.directionAsExpression.toString()) + assertEquals(listOf(0.0, 1.0), snow.direction) + verify { style.getStyleSnowProperty("direction") } + } + + @Test + fun directionTransitionSet() { + val snow = snow { + directionTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("direction-transition={duration=100, delay=200}")) + } + + @Test + fun directionTransitionSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.directionTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleSnowProperty("direction-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun directionTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(transition.toValue().toString(), snow.directionTransition!!.toValue().toString()) + verify { style.getStyleSnowProperty("direction-transition") } + } + + @Test + fun directionTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(null, snow.directionTransition) + verify { style.getStyleSnowProperty("direction-transition") } + } + + @Test(expected = RuntimeException::class) + fun directionTransitionGetException() { + val snow = snow {} + snow.directionTransition + } + + @Test + fun directionTransitionSetDsl() { + val snow = snow { + directionTransition { + duration(100) + delay(200) + } + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("direction-transition={duration=100, delay=200}")) + } + @Test + fun intensitySet() { + val snow = snow { + intensity(1.0) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("intensity=1.0")) + } + + @Test + fun intensitySetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.intensity(1.0) + verify { style.setStyleSnowProperty("intensity", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun intensityGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0.toString(), snow.intensity!!.toString()) + verify { style.getStyleSnowProperty("intensity") } + } + + // Expression Tests + + @Test + fun intensityAsExpressionGetNull() { + val snow = snow { } + snow.bindTo(style) + assertEquals(null, snow.intensityAsExpression) + verify { style.getStyleSnowProperty("intensity") } + } + + @Test + fun intensityAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0, snow.intensityAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, snow.intensity!!, 1E-5) + verify { style.getStyleSnowProperty("intensity") } + } + + @Test + fun intensityTransitionSet() { + val snow = snow { + intensityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("intensity-transition={duration=100, delay=200}")) + } + + @Test + fun intensityTransitionSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.intensityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleSnowProperty("intensity-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun intensityTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(transition.toValue().toString(), snow.intensityTransition!!.toValue().toString()) + verify { style.getStyleSnowProperty("intensity-transition") } + } + + @Test + fun intensityTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(null, snow.intensityTransition) + verify { style.getStyleSnowProperty("intensity-transition") } + } + + @Test(expected = RuntimeException::class) + fun intensityTransitionGetException() { + val snow = snow {} + snow.intensityTransition + } + + @Test + fun intensityTransitionSetDsl() { + val snow = snow { + intensityTransition { + duration(100) + delay(200) + } + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("intensity-transition={duration=100, delay=200}")) + } + @Test + fun opacitySet() { + val snow = snow { + opacity(1.0) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("opacity=1.0")) + } + + @Test + fun opacitySetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.opacity(1.0) + verify { style.setStyleSnowProperty("opacity", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun opacityGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0.toString(), snow.opacity!!.toString()) + verify { style.getStyleSnowProperty("opacity") } + } + + // Expression Tests + + @Test + fun opacityAsExpressionGetNull() { + val snow = snow { } + snow.bindTo(style) + assertEquals(null, snow.opacityAsExpression) + verify { style.getStyleSnowProperty("opacity") } + } + + @Test + fun opacityAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0, snow.opacityAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, snow.opacity!!, 1E-5) + verify { style.getStyleSnowProperty("opacity") } + } + + @Test + fun opacityTransitionSet() { + val snow = snow { + opacityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("opacity-transition={duration=100, delay=200}")) + } + + @Test + fun opacityTransitionSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.opacityTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleSnowProperty("opacity-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun opacityTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(transition.toValue().toString(), snow.opacityTransition!!.toValue().toString()) + verify { style.getStyleSnowProperty("opacity-transition") } + } + + @Test + fun opacityTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(null, snow.opacityTransition) + verify { style.getStyleSnowProperty("opacity-transition") } + } + + @Test(expected = RuntimeException::class) + fun opacityTransitionGetException() { + val snow = snow {} + snow.opacityTransition + } + + @Test + fun opacityTransitionSetDsl() { + val snow = snow { + opacityTransition { + duration(100) + delay(200) + } + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("opacity-transition={duration=100, delay=200}")) + } + @Test + fun vignetteSet() { + val snow = snow { + vignette(1.0) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("vignette=1.0")) + } + + @Test + fun vignetteSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.vignette(1.0) + verify { style.setStyleSnowProperty("vignette", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("1.0")) + } + + @Test + fun vignetteGet() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0.toString(), snow.vignette!!.toString()) + verify { style.getStyleSnowProperty("vignette") } + } + + // Expression Tests + + @Test + fun vignetteAsExpressionGetNull() { + val snow = snow { } + snow.bindTo(style) + assertEquals(null, snow.vignetteAsExpression) + verify { style.getStyleSnowProperty("vignette") } + } + + @Test + fun vignetteAsExpressionGetFromLiteral() { + every { styleProperty.value } returns TypeUtils.wrapToValue(1.0) + val snow = snow { } + snow.bindTo(style) + assertEquals(1.0, snow.vignetteAsExpression?.contents as Double, 1E-5) + assertEquals(1.0, snow.vignette!!, 1E-5) + verify { style.getStyleSnowProperty("vignette") } + } + + @Test + fun vignetteTransitionSet() { + val snow = snow { + vignetteTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("vignette-transition={duration=100, delay=200}")) + } + + @Test + fun vignetteTransitionSetAfterInitialization() { + val snow = snow { } + snow.bindTo(style) + snow.vignetteTransition( + transitionOptions { + duration(100) + delay(200) + } + ) + verify { style.setStyleSnowProperty("vignette-transition", capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("{duration=100, delay=200}")) + } + + @Test + fun vignetteTransitionGet() { + val transition = transitionOptions { + duration(100) + delay(200) + } + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(transition.toValue().toString(), snow.vignetteTransition!!.toValue().toString()) + verify { style.getStyleSnowProperty("vignette-transition") } + } + + @Test + fun vignetteTransitionGetNull() { + val transition = "wrong type" + every { styleProperty.value } returns TypeUtils.wrapToValue(transition) + val snow = snow {} + snow.bindTo(style) + assertEquals(null, snow.vignetteTransition) + verify { style.getStyleSnowProperty("vignette-transition") } + } + + @Test(expected = RuntimeException::class) + fun vignetteTransitionGetException() { + val snow = snow {} + snow.vignetteTransition + } + + @Test + fun vignetteTransitionSetDsl() { + val snow = snow { + vignetteTransition { + duration(100) + delay(200) + } + } + snow.bindTo(style) + verify { style.setStyleSnow(capture(valueSlot)) } + assertTrue(valueSlot.captured.toString().contains("vignette-transition={duration=100, delay=200}")) + } + + @Test + fun getSnowTest() { + assertNotNull(style.getSnow()) + verify(exactly = 0) { style.setStyleSnow(any()) } + } + + @Test + fun removeSnowTest() { + style.removeSnow() + verify { style.setStyleSnow(Value.nullValue()) } + } +} + +// End of generated file. \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6eac515154..dc2379ef4f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -35,8 +35,8 @@ japicmp = "0.4.1" # Dependencies # GlNative and Common are used by the convention plugin -mapboxGlNative = "11.10.0-SNAPSHOT-12-03--10-49.git-b51ed89" -mapboxCommon = "24.10.0-SNAPSHOT-12-03--10-49.git-b51ed89" +mapboxGlNative = "11.9.0-rc.1" +mapboxCommon = "24.9.0-rc.1" mapboxBase = "0.11.0" mapboxGestures = "0.8.0" diff --git a/maps-sdk/src/main/java/com/mapbox/maps/MapboxMap.kt b/maps-sdk/src/main/java/com/mapbox/maps/MapboxMap.kt index 78a0868474..5c4840e499 100644 --- a/maps-sdk/src/main/java/com/mapbox/maps/MapboxMap.kt +++ b/maps-sdk/src/main/java/com/mapbox/maps/MapboxMap.kt @@ -412,6 +412,8 @@ class MapboxMap : styleExtension.atmosphere?.bindTo(style) styleExtension.projection?.bindTo(style) styleExtension.transition?.let(style::setStyleTransition) + styleExtension.rain?.bindTo(style) + styleExtension.snow?.bindTo(style) }, styleDataSourcesLoadedListener = { style -> styleExtension.sources.forEach { diff --git a/sdk-base/api/Release/metalava.txt b/sdk-base/api/Release/metalava.txt index 7b6ca194a6..8593f3f614 100644 --- a/sdk-base/api/Release/metalava.txt +++ b/sdk-base/api/Release/metalava.txt @@ -176,7 +176,9 @@ package com.mapbox.maps { method @CallSuper @MainThread public java.util.List getStyleLights(); method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public final com.mapbox.maps.StyleManager getStyleManager(); method @CallSuper @MainThread public com.mapbox.maps.StylePropertyValue getStyleProjectionProperty(String property); + method @CallSuper @MainThread @com.mapbox.maps.MapboxExperimental public final com.mapbox.maps.StylePropertyValue getStyleRainProperty(String property); method @CallSuper @MainThread public java.util.List getStyleSlots(); + method @CallSuper @MainThread @com.mapbox.maps.MapboxExperimental public final com.mapbox.maps.StylePropertyValue getStyleSnowProperty(String property); method @CallSuper @MainThread public com.mapbox.bindgen.Expected getStyleSourceProperties(String sourceId); method @CallSuper @MainThread public com.mapbox.maps.StylePropertyValue getStyleSourceProperty(String sourceId, String property); method @CallSuper @MainThread public java.util.List getStyleSources(); @@ -212,6 +214,10 @@ package com.mapbox.maps { method @CallSuper @MainThread public com.mapbox.bindgen.Expected setStyleLights(com.mapbox.bindgen.Value lights); method @CallSuper @MainThread public com.mapbox.bindgen.Expected setStyleProjection(com.mapbox.bindgen.Value properties); method @CallSuper @MainThread public com.mapbox.bindgen.Expected setStyleProjectionProperty(String property, com.mapbox.bindgen.Value value); + method @CallSuper @MainThread @com.mapbox.maps.MapboxExperimental public final com.mapbox.bindgen.Expected setStyleRain(com.mapbox.bindgen.Value properties); + method @CallSuper @MainThread @com.mapbox.maps.MapboxExperimental public final com.mapbox.bindgen.Expected setStyleRainProperty(String property, com.mapbox.bindgen.Value value); + method @CallSuper @MainThread @com.mapbox.maps.MapboxExperimental public com.mapbox.bindgen.Expected setStyleSnow(com.mapbox.bindgen.Value properties); + method @CallSuper @MainThread @com.mapbox.maps.MapboxExperimental public com.mapbox.bindgen.Expected setStyleSnowProperty(String property, com.mapbox.bindgen.Value value); method @CallSuper @MainThread public com.mapbox.bindgen.Expected setStyleSourceProperties(String sourceId, com.mapbox.bindgen.Value properties); method @CallSuper @MainThread public com.mapbox.bindgen.Expected setStyleSourceProperty(String sourceId, String property, com.mapbox.bindgen.Value value); method @CallSuper @MainThread public com.mapbox.bindgen.Expected setStyleTerrain(com.mapbox.bindgen.Value properties); @@ -674,6 +680,8 @@ package com.mapbox.maps.extension.style { method public java.util.List> getLayers(); method public java.util.List getModels(); method public com.mapbox.maps.extension.style.StyleContract.StyleProjectionExtension? getProjection(); + method public com.mapbox.maps.extension.style.StyleContract.StyleRainExtension? getRain(); + method public com.mapbox.maps.extension.style.StyleContract.StyleSnowExtension? getSnow(); method public java.util.List getSources(); method public String getStyle(); method public com.mapbox.maps.extension.style.StyleContract.StyleTerrainExtension? getTerrain(); @@ -685,6 +693,8 @@ package com.mapbox.maps.extension.style { property public abstract java.util.List> layers; property public abstract java.util.List models; property public abstract com.mapbox.maps.extension.style.StyleContract.StyleProjectionExtension? projection; + property public abstract com.mapbox.maps.extension.style.StyleContract.StyleRainExtension? rain; + property public abstract com.mapbox.maps.extension.style.StyleContract.StyleSnowExtension? snow; property public abstract java.util.List sources; property public abstract String style; property public abstract com.mapbox.maps.extension.style.StyleContract.StyleTerrainExtension? terrain; @@ -711,6 +721,14 @@ package com.mapbox.maps.extension.style { method public void bindTo(com.mapbox.maps.MapboxStyleManager delegate); } + @com.mapbox.maps.MapboxExperimental public static fun interface StyleContract.StyleRainExtension { + method public void bindTo(com.mapbox.maps.MapboxStyleManager delegate); + } + + @com.mapbox.maps.MapboxExperimental public static fun interface StyleContract.StyleSnowExtension { + method public void bindTo(com.mapbox.maps.MapboxStyleManager delegate); + } + public static fun interface StyleContract.StyleSourceExtension { method public void bindTo(com.mapbox.maps.MapboxStyleManager delegate); } diff --git a/sdk-base/api/sdk-base.api b/sdk-base/api/sdk-base.api index 3835f4ca95..b4e8e68b27 100644 --- a/sdk-base/api/sdk-base.api +++ b/sdk-base/api/sdk-base.api @@ -197,7 +197,9 @@ public class com/mapbox/maps/MapboxStyleManager { public fun getStyleLights ()Ljava/util/List; public final fun getStyleManager ()Lcom/mapbox/maps/StyleManager; public fun getStyleProjectionProperty (Ljava/lang/String;)Lcom/mapbox/maps/StylePropertyValue; + public final fun getStyleRainProperty (Ljava/lang/String;)Lcom/mapbox/maps/StylePropertyValue; public fun getStyleSlots ()Ljava/util/List; + public final fun getStyleSnowProperty (Ljava/lang/String;)Lcom/mapbox/maps/StylePropertyValue; public fun getStyleSourceProperties (Ljava/lang/String;)Lcom/mapbox/bindgen/Expected; public fun getStyleSourceProperty (Ljava/lang/String;Ljava/lang/String;)Lcom/mapbox/maps/StylePropertyValue; public fun getStyleSources ()Ljava/util/List; @@ -233,6 +235,10 @@ public class com/mapbox/maps/MapboxStyleManager { public fun setStyleLights (Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; public fun setStyleProjection (Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; public fun setStyleProjectionProperty (Ljava/lang/String;Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; + public final fun setStyleRain (Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; + public final fun setStyleRainProperty (Ljava/lang/String;Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; + public fun setStyleSnow (Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; + public fun setStyleSnowProperty (Ljava/lang/String;Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; public fun setStyleSourceProperties (Ljava/lang/String;Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; public fun setStyleSourceProperty (Ljava/lang/String;Ljava/lang/String;Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; public fun setStyleTerrain (Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected; @@ -682,6 +688,8 @@ public abstract interface class com/mapbox/maps/extension/style/StyleContract$St public abstract fun getLayers ()Ljava/util/List; public abstract fun getModels ()Ljava/util/List; public abstract fun getProjection ()Lcom/mapbox/maps/extension/style/StyleContract$StyleProjectionExtension; + public abstract fun getRain ()Lcom/mapbox/maps/extension/style/StyleContract$StyleRainExtension; + public abstract fun getSnow ()Lcom/mapbox/maps/extension/style/StyleContract$StyleSnowExtension; public abstract fun getSources ()Ljava/util/List; public abstract fun getStyle ()Ljava/lang/String; public abstract fun getTerrain ()Lcom/mapbox/maps/extension/style/StyleContract$StyleTerrainExtension; @@ -712,6 +720,14 @@ public abstract interface class com/mapbox/maps/extension/style/StyleContract$St public abstract fun bindTo (Lcom/mapbox/maps/MapboxStyleManager;)V } +public abstract interface class com/mapbox/maps/extension/style/StyleContract$StyleRainExtension { + public abstract fun bindTo (Lcom/mapbox/maps/MapboxStyleManager;)V +} + +public abstract interface class com/mapbox/maps/extension/style/StyleContract$StyleSnowExtension { + public abstract fun bindTo (Lcom/mapbox/maps/MapboxStyleManager;)V +} + public abstract interface class com/mapbox/maps/extension/style/StyleContract$StyleSourceExtension { public abstract fun bindTo (Lcom/mapbox/maps/MapboxStyleManager;)V } diff --git a/sdk-base/src/main/java/com/mapbox/maps/MapboxStyleManager.kt b/sdk-base/src/main/java/com/mapbox/maps/MapboxStyleManager.kt index 78cd9a2828..657301814b 100644 --- a/sdk-base/src/main/java/com/mapbox/maps/MapboxStyleManager.kt +++ b/sdk-base/src/main/java/com/mapbox/maps/MapboxStyleManager.kt @@ -906,6 +906,96 @@ open class MapboxStyleManager @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX) return styleManager.setStyleAtmosphereProperty(property, value) } + /** + * Experimental. Sets the style global snow properties. + * + * @param properties A map of style snow properties values, with their names as a key. + * + * @return A string describing an error if the operation was not successful, empty otherwise. + */ + @CallSuper + @MainThread + @MapboxExperimental + open fun setStyleSnow(properties: Value): Expected { + ThreadChecker.throwIfNotMainThread() + return styleManager.setStyleSnow(properties) + } + + /** + * Gets the value of a style snow property. + * + * @param property The style snow property name. + * @return The style snow property value. + */ + @MainThread + @CallSuper + @MapboxExperimental + fun getStyleSnowProperty(property: String): StylePropertyValue { + ThreadChecker.throwIfNotMainThread() + return styleManager.getStyleSnowProperty(property) + } + + /** + * Experimental. Sets the style global snow property. + * + * @param property the property name + * @param value the property value + * + * @return A string describing an error if the operation was not successful, empty otherwise. + */ + @CallSuper + @MainThread + @MapboxExperimental + open fun setStyleSnowProperty(property: String, value: Value): Expected { + ThreadChecker.throwIfNotMainThread() + return styleManager.setStyleSnowProperty(property, value) + } + + /** + * Experimental. Sets the style global rain properties. + * + * @param properties A map of style rain properties values, with their names as a key. + * + * @return A string describing an error if the operation was not successful, empty otherwise. + */ + @MainThread + @CallSuper + @MapboxExperimental + fun setStyleRain(properties: Value): Expected { + ThreadChecker.throwIfNotMainThread() + return styleManager.setStyleRain(properties) + } + + /** + * Gets the value of a style rain property. + * + * @param property The style rain property name. + * @return The style rain property value. + */ + @MainThread + @CallSuper + @MapboxExperimental + fun getStyleRainProperty(property: String): StylePropertyValue { + ThreadChecker.throwIfNotMainThread() + return styleManager.getStyleRainProperty(property) + } + + /** + * Experimental. Sets the style global rain property. + * + * @param property the property name + * @param value the property value + * + * @return A string describing an error if the operation was not successful, empty otherwise. + */ + @MainThread + @CallSuper + @MapboxExperimental + fun setStyleRainProperty(property: String, value: Value): Expected { + ThreadChecker.throwIfNotMainThread() + return styleManager.setStyleRainProperty(property, value) + } + /** * Sets the style global [terrain](https://docs.mapbox.com/mapbox-gl-js/style-spec/#terrain) properties. * diff --git a/sdk-base/src/main/java/com/mapbox/maps/extension/style/StyleContract.kt b/sdk-base/src/main/java/com/mapbox/maps/extension/style/StyleContract.kt index 4b02eebbd5..aabf938b37 100644 --- a/sdk-base/src/main/java/com/mapbox/maps/extension/style/StyleContract.kt +++ b/sdk-base/src/main/java/com/mapbox/maps/extension/style/StyleContract.kt @@ -68,6 +68,18 @@ interface StyleContract { * Transition options applied when loading the style. */ val transition: TransitionOptions? + + /** + * The rain precipitation of the style. + */ + @MapboxExperimental + val rain: StyleRainExtension? + + /** + * The snow precipitation of the style. + */ + @MapboxExperimental + val snow: StyleSnowExtension? } /** @@ -167,4 +179,30 @@ interface StyleContract { */ fun bindTo(delegate: MapboxStyleManager) } + + /** + * Define the interfaces for the Snow plugin. + */ + @MapboxExperimental + fun interface StyleSnowExtension { + /** + * Bind the snow to the Style. + * + * @param delegate The style delegate + */ + fun bindTo(delegate: MapboxStyleManager) + } + + /** + * Define the interfaces for the Rain plugin. + */ + @MapboxExperimental + fun interface StyleRainExtension { + /** + * Bind the rain to the Style. + * + * @param delegate The style delegate + */ + fun bindTo(delegate: MapboxStyleManager) + } } \ No newline at end of file