Files
grechka62 97c06317da Use state_id_variable value instead of cached state id
commit_hash:40c91b0c9b3debc7077c775e078017f1d8471b65
2026-03-23 22:20:10 +03:00

280 lines
8.1 KiB
JSON

{
"description": "State variable value is synchronized with state changes by actions.",
"platforms": [
"android",
"ios",
"web"
],
"div_data": {
"templates": {
"gallery_item": {
"type": "container",
"orientation": "vertical",
"width": {
"type": "fixed",
"value": 150
},
"height": {
"type": "fixed",
"value": 200
},
"border": {
"corner_radius": 8,
"stroke": {
"color": "#CCCCCC",
"width": 1
}
},
"paddings": {
"left": 12,
"top": 12,
"right": 12,
"bottom": 12
},
"margins": {
"left": 8,
"right": 8
},
"items": [
{
"type": "state",
"$id": "item_state_id",
"state_id_variable": "state",
"default_state_id": "off",
"states": [
{
"state_id": "off",
"div": {
"type": "text",
"text": "OFF",
"font_size": 16,
"text_alignment_horizontal": "center",
"text_alignment_vertical": "center",
"width": {
"type": "match_parent"
},
"height": {
"type": "fixed",
"value": 60
},
"background": [
{
"type": "solid",
"color": "#E74C3C"
}
]
}
},
{
"state_id": "on",
"div": {
"type": "text",
"text": "ON",
"font_size": 16,
"text_alignment_horizontal": "center",
"text_alignment_vertical": "center",
"width": {
"type": "match_parent"
},
"height": {
"type": "fixed",
"value": 60
},
"background": [
{
"type": "solid",
"color": "#2ECC71"
}
]
}
}
]
},
{
"type": "text",
"$text": "item_label_text",
"font_size": 14,
"text_color": "#666666",
"text_alignment_horizontal": "center",
"margins": {
"top": 8
}
}
]
}
},
"card": {
"log_id": "state_preservation_test",
"variables": [
{
"name": "state",
"type": "string",
"value": "off"
},
{
"name": "title",
"type": "string",
"value": "Initial state - all states in gallery are Off"
}
],
"states": [
{
"state_id": 0,
"div": {
"type": "container",
"orientation": "vertical",
"items": [
{
"type": "text",
"text": "@{title}",
"font_size": 16,
"paddings": {
"left": 20,
"top": 20,
"right": 20,
"bottom": 20
},
"text_alignment_horizontal": "center"
},
{
"type": "gallery",
"id": "test_gallery",
"orientation": "horizontal",
"item_spacing": 0,
"height": {
"type": "fixed",
"value": 200
},
"items": [
{
"type": "gallery_item",
"item_state_id": "item1_state",
"item_label_text": "Item 1"
},
{
"type": "gallery_item",
"item_state_id": "item2_state",
"item_label_text": "Item 2"
},
{
"type": "gallery_item",
"item_state_id": "item3_state",
"item_label_text": "Item 3"
},
{
"type": "gallery_item",
"item_state_id": "item4_state",
"item_label_text": "Item 4"
},
{
"type": "gallery_item",
"item_state_id": "item5_state",
"item_label_text": "Item 5"
},
{
"type": "gallery_item",
"item_state_id": "item6_state",
"item_label_text": "Item 6"
},
{
"type": "gallery_item",
"item_state_id": "item7_state",
"item_label_text": "Item 7"
},
{
"type": "gallery_item",
"item_state_id": "item8_state",
"item_label_text": "Item 8"
},
{
"type": "gallery_item",
"item_state_id": "item9_state",
"item_label_text": "Item 9"
},
{
"type": "gallery_item",
"item_state_id": "item10_state",
"item_label_text": "Item 10"
},
{
"type": "gallery_item",
"item_state_id": "item11_state",
"item_label_text": "Item 11"
},
{
"type": "gallery_item",
"item_state_id": "item12_state",
"item_label_text": "Item 12"
},
{
"type": "gallery_item",
"item_state_id": "item13_state",
"item_label_text": "Item 13"
},
{
"type": "gallery_item",
"item_state_id": "item14_state",
"item_label_text": "Item 14"
},
{
"type": "gallery_item",
"item_state_id": "item15_state",
"item_label_text": "Item 15"
},
{
"type": "gallery_item",
"item_state_id": "item16_state",
"item_label_text": "Item 16"
},
{
"type": "gallery_item",
"item_state_id": "item17_state",
"item_label_text": "Item 17"
},
{
"type": "gallery_item",
"item_state_id": "item18_state",
"item_label_text": "Item 18"
},
{
"type": "gallery_item",
"item_state_id": "item19_state",
"item_label_text": "Item 19"
},
{
"type": "gallery_item",
"item_state_id": "item20_state",
"item_label_text": "Item 20"
}
]
}
]
}
}
]
}
},
"steps": [
{
"div_actions": [
{
"url": "div-action://set_state?state_id=0/item20_state/on",
"log_id": "turn_on_item20"
},
{
"log_id": "change_title",
"url": "div-action://set_variable?name=title&value=State%20of%20item%2020%20changed%20by%20action%20-%20all%20states%20are%20On"
}
]
},
{
"div_actions": [
{
"url": "div-action://scroll_to_end?id=test_gallery&animated=false",
"log_id": "scroll_to_end"
}
]
}
]
}