如何显示Bixby确认视图?

big*_*gus 3 bixby

我花了很长时间浏览文档,但是在执行操作之前无法获得确认视图。向胶囊添加确认视图的步骤是什么?

我有一个名为的操作Evaluate和一个地址输入,该地址输入会自动从用户的个人资料中提取。我想在运行前确认此地址Evaluate,以防用户想要使用其他地址

这是我所做的:

1)在capsule.bxb中导入viv.common:

import (viv.common) {
      as (common)
      version (3.30.0)
    }
Run Code Online (Sandbox Code Playgroud)

2)在确认动作中添加确认/声明:

confirm {
    by (common.Confirmation)
  }
Run Code Online (Sandbox Code Playgroud)

3)添加一个将与评估动作匹配的确认视图:

confirmation-view {
    match: common.Confirmation {
      confirming {Evaluate (action) }
    }
    mode (PositiveEmphasis)
    message ("Is this the correct address?")

    render {
      layout {
        section {
          content{
            paragraph {
              style (Title_XS)
              value {
                template (
                "#{value(action.address)}}?"
                )
              }
            }
          }
        }
      }
    }
    confirm-options {        
        label ("Yes")
    }
    abort-options {
        label ("Try another Address")
        on-abort {
            intent {
              goal: InputAddress
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望这样做可以,但是我想我还缺少其他东西。有任何想法吗?

Ber*_*mpl 6

我一直在研究这个问题,我的猜测是它不适用于一个Calculation动作(或一个Constructor动作),您需要基于确认视图文档中以下语句的事务动作

必须有一个相应的交易操作,要求使用确认键进行确认。

看一下样品囊胶囊-样品库。进行传输会提示用户进行确认。他们使用两个确认提示:

  • 在提示用户确认之前进行第一个操作,然后进行评估CreateTransfer并生成Transfer模型。这是您要寻找的那个。
  • 使用transaction-supportmatch { Transfer }来完成第二个匹配,以匹配第一个的输出,并CommitTransfer在用户确认后开始新的意图。

文件夹结构中的相关文件为:

+-- models/
|  +-- actions/
|  |  +-- CreateTransfer.model.bxb
+-- resources/
|  +-- base/
|  |  +-- dialog/
|  |  |  +-- CreateTransfer_Confirmation.dialog.bxb
|  |  |  +-- Transfer_Result.dialog.bxb
|  |  +-- transactions/
|  |  |  +-- precommit.transaction.bxb
|  |  +-- views/
|  |  |  +-- CreateTransfer_Confirmation.view.bxb
Run Code Online (Sandbox Code Playgroud)

也许Bixby开发人员团队的人可以扩展这个答案。我看不出为什么不能对Calculation动作使用确认的原因。

  • 好答案!此外,您可以查看https://github.com/bixbydevelopers/capsule-sample-shirt示例。它具有通过单击操作建模的Confirmation.view.bxb。不同的操作类型是帮助Bixby在内部计划路由。计算是简单的计算。 (2认同)