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
Related
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 }
}
I had a question regarding plurals in dialog.
Let's say I have a structure
structure (MyStructure) {
property (MyConcept) {
type {EnumConcept} max (Many)
}
}
And a Value dialog for it:
dialog (Value) {
match: MyConcept(this)
if (this == 'ABC') {
switch(plural(this)) {
case (One) { template("single1") }
default { template ("plural1") }
}
}
if (this == 'DEF') {
switch(plural(this)) {
case (One) { template("single2") }
default { template ("plural2") }
}
}
}
By using
Code:
#{value(myStructure.myConcept.plural('Many'))}
I am able to get "plural1" or "plural2" when myStructure has below values and size of myConcept is 1:
myStructure = [
{ myConcept: ABC },
{ myConcept: ABC },
{ myConcept: ABC },
{ myConcept: ABC }
]
When size of myConcept is 2 and myStructure has below values,
myStructure = [
{ myConcept: ABC },
{ myConcept: ABC },
{ myConcept: DEF },
{ myConcept: DEF }
]
using the Code:
#{value(myStructure.myConcept.plural('Many'))}
is giving NLG as
"single1 and single2"
What I want in the NLG:
"plural1 and plural2"
Can someone please help us in giving proper plural NLG for each element of the unique "myConcept" present in the list of "myStructure"?
What I want is to apply plurality to each individual value of an array.
size(myStructure.myConcept) = 2.
I want to apply plural to both the values of myConcept.
I do not think in dialogs we have an for-each kind of thing available.
It's a little hard to tell what's going on in the code above. If this answer isn't helpful, consider sharing the full source code somewhere for live debugging.
You can try something like
#{value(myStructure.myConcept.plural(plural(myStructure.myConcept))}
The docs has an example like:
#{concept(restaurantStyle.plural(plural(restaurant)))}
Source: https://bixbydevelopers.com/dev/docs/reference/ref-topics/el-ref#node-evaluation-functions in the plural(node) section.
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.
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
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!