mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
Fixed DivKitKMP setVariable
commit_hash:121c60585aa2a79d538762803d699fd50f910bd0
This commit is contained in:
@@ -63,14 +63,16 @@ extension [String: Any] {
|
||||
fileprivate var divVariables: [DivVariableName: DivVariableValue] {
|
||||
compactMapValues {
|
||||
switch $0 {
|
||||
case let value as Bool:
|
||||
DivVariableValue.bool(value)
|
||||
case let value as NSNumber where CFGetTypeID(value) == CFBooleanGetTypeID():
|
||||
DivVariableValue.bool(value.boolValue)
|
||||
case let value as String:
|
||||
DivVariableValue.string(value)
|
||||
case let value as Double:
|
||||
DivVariableValue.number(value)
|
||||
case let value as Int:
|
||||
DivVariableValue.integer(value)
|
||||
case let value as Bool:
|
||||
DivVariableValue.bool(value)
|
||||
case let value as Color:
|
||||
DivVariableValue.color(value)
|
||||
case let value as URL:
|
||||
|
||||
+15
-6
@@ -1,6 +1,7 @@
|
||||
package com.yandex.divkit.multiplaform.sample
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.systemBars
|
||||
@@ -8,6 +9,7 @@ import androidx.compose.foundation.layout.windowInsetsPadding
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.yandex.divkit.multiplatform.DivKit
|
||||
@@ -18,7 +20,12 @@ import com.yandex.divkit.multiplatform.dependencies.ErrorReporter
|
||||
@Composable
|
||||
internal fun MainScreen() {
|
||||
DivKit(dependencies) {
|
||||
val isDarkTheme = isSystemInDarkTheme()
|
||||
var globalVar by variable(name = "global_var", value = "<initial>")
|
||||
var isDarkThemeVar by variable(name = "is_dark_theme", value = isDarkTheme)
|
||||
LaunchedEffect(isDarkTheme) {
|
||||
isDarkThemeVar = isDarkTheme
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.fillMaxSize().windowInsetsPadding(WindowInsets.systemBars),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
@@ -77,7 +84,7 @@ private val jsonString = """
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "@{color.background}"
|
||||
"color": "@{is_dark_theme ? '#000' : '#FFF'}"
|
||||
}
|
||||
],
|
||||
"border": {
|
||||
@@ -121,6 +128,7 @@ private val jsonString = """
|
||||
{
|
||||
"type": "text",
|
||||
"${'$'}text": "author",
|
||||
"text_color": "@{is_dark_theme ? '#FFF' : '#000'}",
|
||||
"font_size": 18,
|
||||
"ranges": [
|
||||
{
|
||||
@@ -214,14 +222,14 @@ private val jsonString = """
|
||||
"top": 20
|
||||
},
|
||||
"font_size": 20,
|
||||
"text_color": "#FFF",
|
||||
"text_color": "@{is_dark_theme ? '#000' : '#FFF'}",
|
||||
"border": {
|
||||
"corner_radius": 12
|
||||
},
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#4267B2"
|
||||
"color": "@{is_dark_theme ? '#FFF' : '#000'}"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
@@ -250,14 +258,14 @@ private val jsonString = """
|
||||
"top": 20
|
||||
},
|
||||
"font_size": 20,
|
||||
"text_color": "#FFF",
|
||||
"text_color": "@{is_dark_theme ? '#000' : '#FFF'}",
|
||||
"border": {
|
||||
"corner_radius": 12
|
||||
},
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "#4267B2"
|
||||
"color": "@{is_dark_theme ? '#FFF' : '#000'}"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -329,7 +337,7 @@ private val jsonString = """
|
||||
"background": [
|
||||
{
|
||||
"type": "solid",
|
||||
"color": "@{color.background}"
|
||||
"color": "@{is_dark_theme ? '#000' : '#FFF'}"
|
||||
}
|
||||
],
|
||||
"border": {
|
||||
@@ -365,6 +373,7 @@ private val jsonString = """
|
||||
{
|
||||
"type": "text",
|
||||
"text": "by @rive_app",
|
||||
"text_color": "@{is_dark_theme ? '#FFF' : '#000'}",
|
||||
"font_size": 18,
|
||||
"ranges": [
|
||||
{
|
||||
|
||||
@@ -15,16 +15,16 @@ PODS:
|
||||
- DivKitKMP (32.35.0):
|
||||
- DivKit (= 32.35.0)
|
||||
- DivKitExtensions (= 32.35.0)
|
||||
- VGSL (7.17.0):
|
||||
- VGSLFundamentals (= 7.17.0)
|
||||
- VGSLNetworking (= 7.17.0)
|
||||
- VGSLUI (= 7.17.0)
|
||||
- VGSLFundamentals (7.17.0)
|
||||
- VGSLNetworking (7.17.0):
|
||||
- VGSLFundamentals (= 7.17.0)
|
||||
- VGSLUI (= 7.17.0)
|
||||
- VGSLUI (7.17.0):
|
||||
- VGSLFundamentals (= 7.17.0)
|
||||
- VGSL (7.19.0):
|
||||
- VGSLFundamentals (= 7.19.0)
|
||||
- VGSLNetworking (= 7.19.0)
|
||||
- VGSLUI (= 7.19.0)
|
||||
- VGSLFundamentals (7.19.0)
|
||||
- VGSLNetworking (7.19.0):
|
||||
- VGSLFundamentals (= 7.19.0)
|
||||
- VGSLUI (= 7.19.0)
|
||||
- VGSLUI (7.19.0):
|
||||
- VGSLFundamentals (= 7.19.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- DivKitKMP (from `../../divkit-multiplatform/DivKitKMP`)
|
||||
@@ -52,10 +52,10 @@ SPEC CHECKSUMS:
|
||||
DivKit_Serialization: c15fa9eb3878dda9710a30a19a395e61a9d2e118
|
||||
DivKitExtensions: 2dd13f295a717e0e4de3810b69c8865f90125195
|
||||
DivKitKMP: 83316de3342542a9a6a2f49d5bcb8e46d73cdfae
|
||||
VGSL: 6696dd84229c7d3ce8ad9b940e89bbd199e2b12d
|
||||
VGSLFundamentals: 5bd45cb6e0b594902aa9f8927402b4d787460bc7
|
||||
VGSLNetworking: 4301c663201314d27357078ec8df9dccc631ec62
|
||||
VGSLUI: 6cf73663cc3e9fcc808c095f065eb84555a5cd52
|
||||
VGSL: 75984a3b526265aa3a231ca69f17807079f97c7e
|
||||
VGSLFundamentals: 3d10d98d88fe1094415b1bf8f473f99f44d4ed2c
|
||||
VGSLNetworking: 9454665ea5a91f2af656ce4cec064b7292c02d5f
|
||||
VGSLUI: 11d1a11dbe0b11777eb9f2a73d22508490ccb6de
|
||||
|
||||
PODFILE CHECKSUM: d6a16f2757fae6a8b9bc890d8f61fa4cd1dabc22
|
||||
|
||||
|
||||
Reference in New Issue
Block a user