"form" 和 "layout" 可以一起用于渲染输入视图吗?
Can "form" and "layout" be used together in rendering an input-view?
我想在输入表单上方布置一些文本,但我无法弄清楚如何让 Bixby 接受它们作为渲染的子项。这可能吗?错误消息抱怨渲染的内容既是空的又是多基数(?)。
render {
layout { section { content { paragraph { value ("Each AltBrain tracks a particular topic and prepares news, facts, images, and social media for you to review. What would you like this AltBrain to track?")}}
}
}
form {
elements {
text-input {
id (comments)
type (Comments)
label (Example: The Witcher on Netflix.)
max-length (72)
value ("#{raw(comments)}")
}
}
on-submit {
goal: Comments
value: viv.core.FormElement(comments)
}
submit-button (Next)
}
}
简单的回答:form
不能和layout
一起使用,后面的会不可达。
更难的问题,我什么时候在输入视图中使用layout
?
检查以下代码作为示例。当操作中所需输入只有 1 个有效值时,它用于提供额外的 selection/confirm 步骤。
render {
if (size(this)==1) {
layout {
section {
content {
title-area {
slot1 {
text ("You sure are #{value(this)} years old?")
}
}
}
}
select-button-text ("confirm")
}
}
else-if (size(this)>1) {
selection-of (this) {
where-each (item) {
title-card {
title-area {
slot1 {
text ("Select #{value(item)}")
}
}
}
}
}
}
else {
form {
elements {
number-input {
id (that)
label (Age)
type (IntAge)
}
}
on-submit {
goal: IntAge
value: viv.core.FormElement(that)
}
}
}
}
如果只有1个值,视图是这样的(这里需要select-button-text
)。确保动作模型,此输入有 prompt-behavior (AlwaysSelection)
我想在输入表单上方布置一些文本,但我无法弄清楚如何让 Bixby 接受它们作为渲染的子项。这可能吗?错误消息抱怨渲染的内容既是空的又是多基数(?)。
render {
layout { section { content { paragraph { value ("Each AltBrain tracks a particular topic and prepares news, facts, images, and social media for you to review. What would you like this AltBrain to track?")}}
}
}
form {
elements {
text-input {
id (comments)
type (Comments)
label (Example: The Witcher on Netflix.)
max-length (72)
value ("#{raw(comments)}")
}
}
on-submit {
goal: Comments
value: viv.core.FormElement(comments)
}
submit-button (Next)
}
}
简单的回答:form
不能和layout
一起使用,后面的会不可达。
更难的问题,我什么时候在输入视图中使用layout
?
检查以下代码作为示例。当操作中所需输入只有 1 个有效值时,它用于提供额外的 selection/confirm 步骤。
render {
if (size(this)==1) {
layout {
section {
content {
title-area {
slot1 {
text ("You sure are #{value(this)} years old?")
}
}
}
}
select-button-text ("confirm")
}
}
else-if (size(this)>1) {
selection-of (this) {
where-each (item) {
title-card {
title-area {
slot1 {
text ("Select #{value(item)}")
}
}
}
}
}
}
else {
form {
elements {
number-input {
id (that)
label (Age)
type (IntAge)
}
}
on-submit {
goal: IntAge
value: viv.core.FormElement(that)
}
}
}
}
如果只有1个值,视图是这样的(这里需要select-button-text
)。确保动作模型,此输入有 prompt-behavior (AlwaysSelection)