Input-view selection-of not working correctly - bixby

I am trying to display a list of profiles for the user and have the hands-free navigation enabled. Whenever I use selection-of in render, the view does not get rendered correctly.
I have tried putting the layout into a layout-macro before, but I get the same result, so I would prefer to have the view in just one file.
input-view {
match: Profile (profile) {
from-output: GetProfiles
}
message {
template ("These are the list of profiles under your account.")
}
render {
if (size(profile) > 1) {
selection-of (profile) {
navigation-mode {
read-many {
page-size (size(profile))
list-summary ("There are #{size(profile)} profiles.")
page-content{
underflow-statement (These are the first set)
page-selection-question (Do you want to select one of these?)
item-selection-question (Which one would you like?)
overflow-statement (That's all I have)
overflow-question (What would you like to do?)
}
}
}
where-each (item) {
title-card {
title-area {
halign (Start)
slot1 {
single-line {
text {
style (Detail_L_Soft)
value ("Account: #{value(item.acctName)}")
}
}
}
slot2 {
single-line {
text {
style (Detail_M_Soft)
value ("Web property: #{value(item.webName)}")
}
}
}
slot3 {
single-line {
text {
style (Title_S)
value ("Profile: #{value(item.viewName)}")
}
}
}
}
}
}
}
}
}
}
The message and layout seem to not get used, but instead displays the list like this:
Here are sixteen profiles.
2.0.3-teamname.capsule.Profile
2.0.3-teamname.capsule.Profile
2.0.3-teamname.capsule.Profile
2.0.3-teamname.capsule.Profile
2.0.3-teamname.capsule.Profile
2.0.3-teamname.capsule.Profile
2.0.3-teamname.capsule.Profile
2.0.3-teamname.capsule.Profile
2.0.3-teamname.capsule.Profile
2.0.3-teamname.capsule.Profile

Are you sure this input view is the one matching the moment?
Here are sixteen profiles.
... makes it sound like you're on a result moment.
Try converting this to a result-view.

GetProfiles sounds like it retrieves a bunch of Profiles which makes it a result-view. If the intent is to select from the output of this function, this function should feed into a computed-input that is part of an Action.

Related

How to show .overlay with search results full width

var navbody: some View {
NavigationView {
ZStack {
somedarkcolorhere
List(searchModel.suggestions ?? [], rowContent: { text in
NavigationLink(destination: MediaSearchResultsView(searchText: text)) {
Text(text)
}
})
.overlay(SearchMediaHintsResultsScreen(searchModel: searchModel))
.searchable(text: $searchModel.searchText
// https://stackoverflow.com/questions/69668266/searchable-modifier-not-displaying-search-bar-below-navigation-bar-title
/* uncomment for search field to be shown initially and ever.
On iPad running 16.1 search field does show initially.
On iphone running 15.6.1 navigationTitle shows and search field
initially does not
*/
// , placement: .navigationBarDrawer(displayMode: .always)
)
.navigationTitle("v1_what_are_we_searching_for".localized)
}
.onChange(of: searchModel.searchText) { _ in
searchModel.processChangeOfSearchText()
}
.preference(key: ErrorPreferenceKey.self, value: observableError)
.sheet(isPresented: $observableError.showingError) {
ErrorView(error: observableError)
}
}
}
How to show .overlay with search results full width of the window?
currently it has gaps on the left and right
It is hard to see from just the code you have shown.
The List has default styling that includes some padding round the edges. You could try using a ForEach, or change the list style with a listStyle(.plain) modifier.
Does your overlay view also have a frame set to occupy the available space, such as .frame(maxWidth: .infinity)?
It may be due to the List default ListStyle of .insetGrouped. Try using .plain
Or try adding another view to the top layer of the ZStack that is only there when you want to show the overlay, so that it doesn't block List tap gestures, but can use the full View bounds to show the overlay.
i.e.
ZStack {
somedarkcolorhere
List { }
if showOverlay { Overlay }
}

How to remove the margin in section in bixby

This is a situation where sectioning is absolutely necessary.
I want to remove the margin between sections.
how do i do?
testview.view.bxb ↓
layout{
section{
content{
compound-card{
content{
paragraph{
value("testtesttesttesttesttesttesttesttest")
}
paragraph{
value("testtesttesttesttesttesttesttesttest")
}
}
}
}
}
section{
content{
compound-card{
content{
paragraph{
value("testtesttesttesttesttesttesttesttest")
}
paragraph{
value("testtesttesttesttesttesttesttesttest")
}
}
}
}
}
}
image ↓
[Problem]
testtesttesttesttesttesttesttesttest
testtesttesttesttesttesttesttesttest
testtesttesttesttesttesttesttesttest
testtesttesttesttesttesttesttesttest
[i want]
testtesttesttesttesttesttesttesttest
testtesttesttesttesttesttesttesttest
testtesttesttesttesttesttesttesttest
testtesttesttesttesttesttesttesttest
help would be appreciated.
The additional space between two sections is not removable. It is there by design to split two different sections.
However, in your code, there is no need to do different section, as I would demo later
use new line "\n" in the paragraph value
use different paragraph in the same section
I would also recommend watch this tutorial to learn more about different component in Bixby result-view.
result-view {
match: StructB (this)
message: template ("Sample view")
render {
// assume always single item, demo purpose only
layout {
section {
content {
paragraph {
value: template ("#{value(this.aaa)}\n#{value(this.bbb)}\n#{value(this.ccc)}\n#{value(this.ddd)}")
}
paragraph {
value: template ("I can do more here")
}
}
}
}
}
}
There is no need for compound card as well, here is the result. Please take note the additional space between two paragraphs.
Here is the content of StructB for your reference

how to provide different result view for new user

How do I provide a different result-view message or layout for a new user?
In this case, I want the view to be different depending on whether the user is a new user as shown in the UserData concept, whose values I compute in the action GetAltBrainsData.
I have given UserData the feature profile-stored.
result-view {
match: AltBrainsData (this)
{
from-output: GetAltBrainsData (getaltbrainsdata)
}
message {
//here is where i want to check if UserData.newuser = true and vary the answer
//if (userdata.newuser) {template("hello new user")} else ...
if (size(this) > 1) {
template ("I found #{(size(this))} AltBrains")
}
else-if (size(this) == 1 ) {
template ("") {speech ("#{value(this.name)}")}
}
else {template ("No AltBrains matched the search.")}
}
render {
// if UserData.newuser = true then welcome layout
but the result-view still doesn't seem to be aware of UserData.The IDE complains that it is an illegal expression in userdata.newuser
Try if (getaltbrainsdata.userdata.newuser), or whatever you had named the UserData as in your action's model.
Another way to approach this is to access it with a match pattern like
result-view {
match: AltBrainsData (this)
{
from-output: GetAltBrainsData (getaltbrainsdata) {
from-input: UserData (userData)
}
...

How can I let the user give NL input when showing them an input-view?

I have a capsule that calculates something based on user input. The user needs to tell my capsule an originating country (FromCountryConcept), destination country (ToCountryConcept), and a text (LetterContentConcept). Since the country concepts are enum, the input-view for those are simple selection-of. For the input-view for the text I use a textarea. All of the code is below and available on github in this repository: SendLetter-Bixby
When the user uses the Bixby Views to give the required input to Bixby everything works as expected.
How can I let the user provide input to the shown input-view using (spoken or typed) NL input?
My action SendLetter.model.bxb looks like this:
action (SendLetter) {
description (Sends a Letter from one country to another and calculates the cost based on the letter content length.)
type (Calculation)
collect {
input (fromCountry) {
type (FromCountryConcept)
min (Required)
max (One)
default-init {
intent {
goal: FromCountryConcept
value-set: FromCountryConcept {
FromCountryConcept(Germany)
FromCountryConcept(South Korea)
FromCountryConcept(USA)
FromCountryConcept(Spain)
FromCountryConcept(Austria)
FromCountryConcept(France)
}
}
}
}
input (toCountry) {
type (ToCountryConcept)
min (Required)
max (One)
default-init {
intent {
goal: ToCountryConcept
value-set: ToCountryConcept {
ToCountryConcept(Austria)
ToCountryConcept(South Korea)
ToCountryConcept(USA)
ToCountryConcept(Spain)
ToCountryConcept(Germany)
ToCountryConcept(France)
}
}
}
}
input (letterContent) {
type (LetterContentConcept)
min (Required)
max (One)
}
}
output (SendLetterResponseConcept)
}
The input-view for the country concepts FromCountry_Input.view.bxb looks like this (ToCountry_Input.view.bxb is equivalent):
input-view {
match: FromCountryConcept(this)
message {
template ("Select the country this letter will be sent from")
}
render {
selection-of (this) {
where-each (fromCountry) {
// default-layout used
}
}
}
}
The input-view for the text I want the user to be able to input is in LetterContent_Input.view.bxb:
input-view {
match: LetterContentConcept(this)
message {
template ("Write the content of the letter.")
}
render {
form {
on-submit {
goal: LetterContentConcept
value {
viv.core.FormElement(letterContent)
}
}
elements {
textarea {
id (letterContent)
label ("Letter Content")
type (LetterContentConcept)
value ("#{value(this)}")
}
}
}
}
}
You're at a prompting moment, so you need to add prompt training.
This will allow the user to use NL to respond to your prompt.
In the training tab, it looks like this:
https://bixbydevelopers.com/dev/docs/dev-guide/developers/training.intro-training#add-training-examples-for-prompts

How to prevent duplicate action execution in Bixby?

I want to implement a capsule that does a calculation if the user provides the full input necessary for the calculation or asks the user for the necessary input if the user doesn't provide the full input with the very first request. Everything works if the user provides the full request. If the user doesn't provide the full request but Bixby needs more information, I run into some strange behavior where the Calculation is being called more than once and Bixby takes the necessary information for the Calculation from a result of another Calculation, it looks like in the debug graph.
To easier demonstrate my problem I've extended the dice sample capsule capsule-sample-dice and added numSides and numDice to the RollResultConcept, so that I can access the number of dice and sides in the result.
RollResult.model.bxb now looks like this:
structure (RollResultConcept) {
description (The result object produced by the RollDice action.)
property (sum) {
type (SumConcept)
min (Required)
max (One)
}
property (roll) {
description (The list of results for each dice roll.)
type (RollConcept)
min (Required)
max (Many)
}
// The two properties below have been added
property (numSides) {
description (The number of sides that the dice of this roll have.)
type (NumSidesConcept)
min (Required)
max (One)
}
property (numDice) {
description (The number of dice in this roll.)
type (NumDiceConcept)
min (Required)
max (One)
}
}
I've also added single-lines in RollResult.view.bxb so that the number of sides and dice are being shown to the user after a roll.
RollResult.view.bxb:
result-view {
match {
RollResultConcept (rollResult)
}
render {
layout {
section {
content {
single-line {
text {
style (Detail_M)
value ("Sum: #{value(rollResult.sum)}")
}
}
single-line {
text {
style (Detail_M)
value ("Rolls: #{value(rollResult.roll)}")
}
}
// The two single-line below have been added
single-line {
text {
style (Detail_M)
value ("Dice: #{value(rollResult.numDice)}")
}
}
single-line {
text {
style (Detail_M)
value ("Sides: #{value(rollResult.numSides)}")
}
}
}
}
}
}
}
Edit: I forgot to add the code that I changed in RollDice.js, see below:
RollDice.js
// RollDice
// Rolls a dice given a number of sides and a number of dice
// Main entry point
module.exports.function = function rollDice(numDice, numSides) {
var sum = 0;
var result = [];
for (var i = 0; i < numDice; i++) {
var roll = Math.ceil(Math.random() * numSides);
result.push(roll);
sum += roll;
}
// RollResult
return {
sum: sum, // required Sum
roll: result, // required list Roll
numSides: numSides, // required for numSides
numDice: numDice // required for numDice
}
}
End Edit
In the Simulator I now run the following query
intent {
goal: RollDice
value: NumDiceConcept(2)
}
which is missing the required NumSidesConcept.
Debug view shows the following graph, with NumSidesConcept missing (as expected).
I now run the following query in the simulator
intent {
goal: RollDice
value: NumDiceConcept(2)
value: NumSidesConcept(6)
}
which results in the following Graph in Debug view:
and it looks like to me that the Calculation is being done twice in order to get to the Result. I've already tried giving the feature { transient } to the models, but that didn't change anything. Can anybody tell me what's happening here? Am I not allowed to use the same primitive models in an output because they will be used by Bixby when trying to execute an action?
I tried modifying the code as you have but was unable to run the intent (successfully).
BEGIN EDIT
I added the additional lines in RollDice.js and was able to see the plan that you are seeing.
The reason for the double execution is that you ran the intents consecutively and Bixby derived the value of the NumSidesConcept that you did NOT specify in the first intent, from the second intent, and executed the first intent.
You can verify the above by providing a different set of values to NumSidesConcept and NumDiceConcept in each of the intents.
If you had given enough time between these two intents, then the result would be different. In your scenario, the first intent was waiting on a NumSidesConcept to be available, and as soon as the Planner found it (from the result of the second intent), the execution went through.
How can you avoid this? Make sure that you have an input-view for each of the inputs so Bixby can prompt the user for any values that did not come through the NL (or Aligned NL).
END EDIT
Here is another approach that will NOT require changing the RollResultConcept AND will work according to your expectations (of accessing the number of dice and sides in the result-view)
result-view {
match: RollResultConcept (rollResult) {
from-output: RollDice(action)
}
render {
layout {
section {
content {
single-line {
text {
style (Detail_M)
value ("Sum: #{value(rollResult.sum)}")
}
}
single-line {
text {
style (Detail_M)
value ("Rolls: #{value(rollResult.roll)}")
}
}
// The two single-line below have been added
single-line {
text {
style (Detail_M)
value ("Dice: #{value(action.numDice)}")
}
}
single-line {
text {
style (Detail_M)
value ("Sides: #{value(action.numSides)}")
}
}
}
}
}
}
}
Give it a shot and let us know if it works!

Resources