Bixby Developer Center

References

layout-macro-def

optionalvalue required

Defines the layout-macro.

Note

This key will be deprecated in a future release. You should switch to using generic macro and macro-def keys instead to create layout macros. For more information, see Reusing Content with Macros.

Note

Currently, we do not support returning multiple components from a layout-macro. If you want to have multiple components, for example multiple section components, you have to return a full layout.

If you want to define multiple components within a macro, you must use a macro instead.

You can define multiple layout-macro-def definitions within a single *.layout.bxb file or separate each layout-macro-def in its own *.layout.bxb file. These files must be placed in the appropriate locale-specific resources folder.

Note

You cannot have a macro with the same ID if the macro is defined in the same resource folder. For example, if you have a macro with the ID "this-test-macro" in the bixby-mobile-en-US target, you cannot have another different macro with the same name in that target.

However, if the macro's target is in a higher level resource folder, the more specific target will override the more general target. For example, say you have a macro in bixby-mobile-en and another macro in bixby-mobile-en-US, both with the ID "this-test-macro". The macro in the bixby-mobile-en-US target will render for the bixby-mobile-en-US target, but the bixby-mobile-en macro will render for the bixby-mobile-en-GB target.

Macros with the same ID but in different targets (for example, bixby-mobile-ko-KR and bixby-mobile-en-US) are allowed and are encouraged, especially when localizing or handling development for multiple devices.

Note

Be aware of which components you are adding to your layouts and layout macros, because different components are available under different views. If you call a layout or layout macro in a view and that layout specifies a component that the view does not support, Bixby Developer Studio will throw an error. Similarly, you should consider which layout macros are being called within a layout itself. The same layout macro invoked in one component might not be valid if used within a different component, as the list of supported child components could differ.

You can read the Designing with Bixby Views Design Guide and the Building Bixby Views (UI) Developers' Guide to check if your layout is using the correct components for that moment and that view.

Examples

These examples are pulled from the example.SpaceResorts sample capsule.

layout-macro-def (habitat-pod-summary) {
params {
param (habitatPod) {
type (HabitatPod)
min (Required) max (One)
}
}
content {
cell-card {
slot2 {
content {
primary {
template ("#{value(habitatPod.name)}")
}
}
}
slot3 {
label {
value ("#{value(habitatPod.price)}")
}
}
}
}
}

View eb6c995 on GitHub

layout-macro-def (order-details) {
params {
param (order) {
type (Order)
min (Required) max (One)
}
}
content {
section {
title {macro (Details)}
content {
input-cell {
label {
macro (NumberOfAstronauts)
}
value {
template ("[#{value(order.item.numberOfAstronauts)}]")
}
on-click {
intent {
goal: MakeReservation
route: UpdateOrder
route: GetNumberOfAstronauts
}
}
}
input-cell {
label { macro (Dates)}
value ("[#{value(order.item.dateInterval)}]")
on-click {
intent {
goal: MakeReservation
route: UpdateOrder
route: GetDateInterval
}
}
}
compound-card {
content {
single-line {
text {
value { macro (Package)}
style (Detail_M_Soft)
}
}
cell-area {
slot2 {
content {
primary ("[#{value(order.item.pod.name)}]")
}
}
slot3 {
label {
value ("[#{value(order.item.pod.price)}]")
}
}
}
}
on-click {
intent {
goal: MakeReservation
route: UpdateOrder
route: GetPod
}
}
}
}
}
}
}

View eb6c995 on GitHub

Child Keys

content
required
Layout container that holds informational content
params
optional
List of parameters to be defined in the layout-macro-def