匹配多个概念

时间:2020-03-31 03:55:53

标签: bixby

希望显示我的输入视图,并显示一条随时间变化的消息,并根据另一个变量显示内容。

这是我的输入视图

input-view{
    match{
        userWantToHear(this){
            from-output:getStart //action to get list of selection
        }
    }

    message{
        switch (this){//should be another value which is (timePeriod)
            case ("M"){
                template-macro (morning-template)
            }
            case ("A"){
                template-macro (afternoon-template)
            }
            case ("N"){
                template-macro (night-template)
            }
            default{
                template-macro (normal-template)
            }
        }
    }

    render{
        selection-of (this){ //this should be (userWantToHear)
            where-each (one){
                spoken-summary{ 
                    template ("#{value(one)}")
                }
                cell-card{
                    slot2{
                        content{
                            primary{
                                template ("#{value(one)}")
                            }
                        }
                    }
                }
            }
        }
    }
}

所以我的想法是,创建一个包含两者的结构。

structure (menu) {
  description (__DESCRIPTION__)
  property (timeperiod){
    type (timePeriod)
    min (Required) max (One)
  }

  property (whatuserwant) {
    type (userWantToHear)
    min (Required) max (One)
  }

}

我还创建了一个动作来获取它们。

action (getMenu) {
  type(Search)
    collect{
        input (timeperiod){
            type (timePeriod)
            min (Required) max (One)
            default-init{
                intent{
                    goal: getTime
                }
            }
        }
    input (whatuserwant){
      type (userWantToHear)
      min (Required) max (One)
      default-init{
        intent{
          goal: getStart
        }
      }
    }
    }
  output (menu)
}

input-view的结果将传递到下面的操作中,即userWantToHear

action (getNews) {
    type (Search)
    description (__DESCRIPTION__)
    collect {
        input (whatuserwant){
            type (userWantToHear)
            min (Required) max (One)
            default-init{
                intent{
                    goal: getMenu
                }
            }
        }
    }
    output (newsAudio)
}

所以我想知道输入视图将如何接受结构并访问每个节的内部属性,并取回我想要的输入?目前从我这边来说,它已经可以选择,但是消息不会根据“ timePeriod”改变,我认为它还没有传入输入视图。

1 个答案:

答案 0 :(得分:1)

我认为您的帖子中有两个问题。

  1. 如何呈现不同的视图?答案:使用if-else或switch语句选择模板宏。

  2. 如何访问不在match Type(this)中的概念?答:使用复杂的匹配模式,通过操作将这些概念联系起来。考虑下面的代码块。

  match: IntAge(this) {
    to-input: GetStructPerson (action)
  }
  message {
    template ("Enter age of #{value(action.name)}")
  }

您可以阅读更多内容,并在Bixby Developer Center中下载示例胶囊