如何显示 Bixby 确认视图?

How do you get a Bixby confirmation view to show up?

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

我有一个名为 Evaluate 的操作和一个自动从用户个人资料中提取的地址输入。我想在 运行 Evaluate 之前确认这个地址,以防用户想使用不同的地址

这是我所做的:

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

import (viv.common) {
      as (common)
      version (3.30.0)
    }

2) 将 confirm/by 语句添加到评估操作中:

confirm {
    by (common.Confirmation)
  }

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
            }
        }
    }
}

我希望这样做,但我想我还遗漏了其他东西。有什么想法吗?

我一直在研究这个,我的猜测是 它不适用于 Calculation 操作(或 Constructor 操作),您需要一个交易操作,基于confirmation-view documentation中的以下句子:

There must be a corresponding transactional action asking for confirmation with the confirm key.

看看样品胶囊capsule-sample-bank。提交传输会提示用户进行确认。他们使用两个确认提示:

  • 第一个是在评估 CreateTransfer 之前提示用户确认并生成 Transfer 模型。这就是您要找的人。
  • 第二个是使用 transaction-support 和一个 match { 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

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