在Bixby中,是否有任何方法可以按特定顺序在图像选择器中显示图像或按图像名称对图像进行排序?

时间:2019-06-25 05:10:55

标签: bixby bixbystudio

我正在尝试向用户显示少量图像,以供他们选择任何图像,并且希望图像按特定顺序排列或根据其名称进行排序。但是每次选择屏幕加载图像时,图像似乎都是随机的。

这是我传递图像的方式:

  default-init {
    intent {
      goal: Image
      value: Image {
        url: viv.core.Url("/images/img1.png")
      }
      value: Image {
        url: viv.core.Url("/images/img2.png")
      }
      value: Image {
        url: viv.core.Url("/images/img3.png")
      }
      value: Image {
        url: viv.core.Url("/images/img4.png")
      }
      value: Image {
        url: viv.core.Url("/images/img5.png")
      }
      value: Image {
        url: viv.core.Url("/images/img6.png")
      }
    }
  }

这是输入视图:

  input-view {
    match: Image (this) {
      to-input: SelectImage 
    }

    message {
       template (Choose any image?)
    }

    render {
      image-picker (this) {
        size (Medium)
    }
  }
}    

我希望它们以给定的顺序显示或根据它们的名称进行排序(在这种情况下是相同的)。我该怎么办?

1 个答案:

答案 0 :(得分:2)

如果您在操作模型中列出值,则该值没有任何顺序,并且是随机的。

一个简单的解决方案是创建一个没有输入的单独动作,并在默认init中使用该动作。然后在链接的JS函数中,返回一个图像对象数组。显示顺序将是数组索引顺序。

更改default-init部分

    default-init {
    intent {
      goal: GetDefaultImage
    }

添加操作GetDefaultImage

action(GetDefaultImage) {
  type(Search) 
  output(Image)
}

链接的JS文件(将其链接到端点文件中)

module.exports.function = function getDefaultImage () {
  var result = []
  // result should be in the format of result[0].url = 'imageUrl1'
  //                                   result[1].url = 'imageUrl2'
  return result;
}