Adds an AppBar on your app.
Properties
These are the setter and getter properties for the addAppBar Component.
Example - Basic AppBar
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "Top,Center", 1, 1)
this.apb = ui.addAppBar(this.main, "My App", "", 1)
this.btn = ui.addButton(this.main, "Button")
this.btn.margins = 0.1
}
}
from hybrid import ui
def OnStart():
main = ui.addLayout("main", "Linear", "Top,Center", 1, 1)
apb = ui.addAppBar(main, "My App", "", 1)
btn = ui.addButton(main, "Button")
btn.margins = 0.1
Example - Fixed appbar with drawer
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter", 1, 1)
this.apb = ui.addAppBar(this.main, "My app", "Menu,Fixed", 1)
this.apb.setOnMenu( this.showDrawer )
this.drawLay = ui.addLayout(null, "Linear", "Top")
this.drawer = ui.addDrawer(this.drawLay, "left")
let lst = [
["folder", "Folders"],
["music_note", "Audios"],
["photo", "Photos"]
]
this.lstMenu = ui.addList(this.drawLay, lst, "Icon", 1 )
this.lstMenu.label = "Main navigation"
this.lstMenu.setOnTouch( this.onTouch )
}
showDrawer()
{
this.drawer.show()
}
onTouch( title )
{
this.apb.text = title
this.drawer.hide()
}
}
from hybrid import ui
def OnStart():
global drawer, apb
main = ui.addLayout("main", "Linear", "VCenter", 1, 1)
apb = ui.addAppBar(main, "My app", "Menu,Fixed", 1)
apb.setOnMenu( showDrawer )
drawLay = ui.addLayout(None, "Linear", "Top")
drawer = ui.addDrawer(drawLay, "left")
lst = [
["folder", "Folders"],
["music_note", "Audios"],
["photo", "Photos"]
]
lstMenu = ui.addList(drawLay, lst, "Icon", 1 )
lstMenu.label = "Main navigation"
lstMenu.setOnTouch( onTouch )
def showDrawer():
drawer.show()
def onTouch(title, body, icon, index, event):
apb.text = title
drawer.hide()
Example - Appbar with actions
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "Top,Center", 1, 1)
this.apb = ui.addAppBar(this.main, "My App", "Menu,Primary")
this.apb.setOnMenu( this.showDrawer )
this.btn1 = ui.addButton(this.apb.layout, "mail", "icon")
this.btn1.setOnTouch(() => { ui.showPopup("Messages", "Bottom") })
this.btn2 = ui.addButton(this.apb.layout, "person", "icon")
this.btn2.setOnTouch(() => { ui.showPopup("Account", "Bottom") })
this.btn3 = ui.addButton(this.apb.layout, "more_vert", "icon")
this.btn3.setOnTouch(() => { ui.showPopup("More options", "Bottom") })
this.drawLay = ui.addLayout(null, "Linear", "Top")
this.drawer = ui.addDrawer(this.drawLay, "left")
let lst = [
["folder", "Folders"],
["music_note", "Audios"],
["photo", "Photos"]
]
this.lstMenu = ui.addList(this.drawLay, lst, "Icon", 1 )
this.lstMenu.label = "Main navigation"
this.lstMenu.setOnTouch( this.onTouch )
}
showDrawer()
{
this.drawer.show()
}
onTouch( title )
{
this.apb.text = title
this.drawer.hide()
}
}
from hybrid import ui
def OnStart():
global drawer, apb
main = ui.addLayout("main", "Linear", "Top,Center", 1, 1)
apb = ui.addAppBar(main, "My App", "Menu,Primary")
apb.setOnMenu( showDrawer )
btn1 = ui.addButton(apb.layout, "mail", "icon")
btn1.setOnTouch(lambda event: ui.showPopup("Messages", "Bottom"))
btn2 = ui.addButton(apb.layout, "person", "icon")
btn2.setOnTouch(lambda event: ui.showPopup("Account", "Bottom"))
btn3 = ui.addButton(apb.layout, "more_vert", "icon")
btn3.setOnTouch(lambda event: ui.showPopup("More options", "Bottom"))
drawLay = ui.addLayout(None, "Linear", "Top")
drawer = ui.addDrawer(drawLay, "left")
lst = [
["folder", "Folders"],
["music_note", "Audios"],
["photo", "Photos"]
]
lstMenu = ui.addList(drawLay, lst, "Icon", 1 )
lstMenu.label = "Main navigation"
lstMenu.setOnTouch( onTouch )
def showDrawer():
drawer.show()
def onTouch(title, body, icon, index, event):
apb.text = title
drawer.hide()
Example - Appbar with search field
class Main extends App
{
onStart()
{
this.main = ui.addLayout( "main", "Linear", "Top", 1, 1 )
this.apb = ui.addAppBar( this.main, "My app", "Default" )
this.tfd = ui.addTextField(this.apb.layout, "", "Search,Outlined,Small")
this.tfd.placeholder = "Search"
this.tfd.hide()
this.searchBtn = ui.addButton(this.apb.layout, "search", "icon")
this.searchBtn.setOnTouch( this.showSearchField )
}
showSearchField()
{
if(this.searchBtn.text == "search")
{
this.tfd.show()
this.searchBtn.text = "close"
}
else
{
this.tfd.hide()
this.searchBtn.text = "search"
}
}
}
from hybrid import ui
def OnStart():
global tfd, searchBtn
main = ui.addLayout("main", "Linear", "Top", 1, 1)
apb = ui.addAppBar(main, "My app", "Default")
tfd = ui.addTextField(apb.layout, "", "Search,Outlined,Small")
tfd.placeholder = "Search"
tfd.hide()
searchBtn = ui.addButton(apb.layout, "search", "icon")
searchBtn.setOnTouch( showSearchField )
def showSearchField(event):
if searchBtn.text == "search":
tfd.show()
searchBtn.text = "close"
else:
tfd.hide()
searchBtn.text = "search"
Methods
The following methods are available on the AppBar object:
Boolean: Sets or returns the disabled state of the control.
Boolean: Returns whether the control is visible or not.
Boolean: Sets or returns whether the appbar has menu button.
Number: Fraction of the screen width. [0-1]
Number: Fraction of the screen height. [0-1]
Number: The time in milliseconds.
Number: The z-index. A negative value behaves like `sendBackward` method.
Number: The z-index. A positve value behaves like `bringForward` method.
Number: Border-left thickness in pixels.
Number: Top-left corner radius.
Number: Top-right corner radius.
Number: Bottom-left corner radius.
Number: Bottom-right corner radius.
Number: Fraction of the parent width.
Number: Fraction of the parent height.
Number: Fraction of the component width.
Number: Fraction of the component height. [0-1]
Number: Fraction of the component width. [0-1]
Number: Fraction of the parent width. [0-1]
Number: The x-scale of the component.Values less than `0` is smaller than the normal. While values greater than `1` is greater than the normal.
Number: The y-scale of the component. Values less than `1` is smaller than the normal. While vaues greater than `1` is greater than the normal.
Number: Fraction of the parent height. [0-1]
Number: Returns the absolute height of the control in pixels.
Number: Returns the absolute distance of the control from the left in pixels.
Number: Returns the absolute distance of the control from the top in pixels.
Number: Returns the absolute width of the control in pixels.
Number: Sets or returns the border thickness in pixels.
Number: Sets or returns the corner radius of the accordion panel. You can also pass an array of the form [tl, tr, bl, br]. See setCornerRadius for customization.
Number: Sets or returns the height of the control as a fraction of the parent control.
Number: Returns the distance of the control from the left.
Number: Sets or returns the opacity of the control.
Number: Sets or returns the angle of rotation in degrees.
Number: Sets or returns the font size of the title text.
Number: Returns the distance of the control from the top.
Number: Sets or returns the width of the control as a fraction of the parent control.
String: “The title text of the appbar”
String: comma “,” separated: “one or a combination of the following:
`Menu` : Adds a menu icon on the left
`Primary` `Secondary` `Transparent` `Inherit` `Default` : Adds a color
`Absolute` `Static` `Fixed` `Relative` : Adds a positioning”
String: “The type of animation. Here are the available values
`bounce` `flash` `pulse` `rubberBand` `shakeX` `shakeY` `headShake` `swing` `tada` `wobble` `jello` `heartBeat`
`Back Entrances `backInDown` `backInLeft` `backInRight` `backInUp`
`Back Exits `backOutDown` `backOutLeft` `backOutRight` `backOutUp`
`Bouncing Entrances `bounceIn` `bounceInDown` `bounceInLeft` `bounceInRight` `bounceInUp`
`Bouncing exits `bounceOut` `bounceOutDown` `bounceOutLeft` `bounceOutRight` `bounceOutUp`
`Fading entrances `fadeIn` `fadeInDown` `fadeInDownBig` `fadeInLeft` `fadeInLeftBig` `fadeInRight` `fadeInRightBig` `fadeInUp` `fadeInUpBig` `fadeInTopLeft` `fadeInTopRight` `fadeInBottomLeft` `fadeInBottomRight`
`Fading exits `fadeOut` `fadeOutDown` `fadeOutDownBig` `fadeOutLeft` `fadeOutLeftBig` `fadeOutRight` `fadeOutRightBig` `fadeOutUp` `fadeOutUpBig` `fadeOutTopLeft` `fadeOutTopRight` `fadeOutBottomRight` `fadeOutBottomLeft`
`Flippers `flip` `flipInX` `flipInY` `flipOutX` `flipOutY`
`Lightspeed `lightSpeedInRight` `lightSpeedInLeft` `lightSpeedOutRight` `lightSpeedOutLeft`
`Rotating Entrances `rotateIn` `rotateInDownLeft` `rotateInDownRight` `rotateInUpLeft` `rotateInUpRight`
`Rotating Exits `rotateOut` `rotateOutDownLeft` `rotateOutDownRight` `rotateOutUpLeft` `rotateOutUpRight`
`Specials `hinge` `jackInTheBox` `rollIn` `rollOut`
`Zooming Entrances `zoomIn` `zoomInDown` `zoomInLeft` `zoomInRight` `zoomInUp`
`Zooming Exits `zoomOut` `zoomOutDown` `zoomOutLeft` `zoomOutRight` `zoomOutUp`
`Sliding Entrances `slideInDown` `slideInLeft` `slideInRight` `slideInUp`
`Sliding Exits `slideOutDown` `slideOutLeft` `slideOutRight` `slideOutUp`.”
String: “The mode of the measurements. Values can be `px` or `%`”
String: “Border color in hexadecimal form `#rrggbb`”
String: “Border-styles. Values can be `dotted` `dashed` `solid` `double` `groove` `ridge` `inset` and `outset`. Default is `solid`”
String: “Unit. Values are `px` `rem` or `%`.”
String: “`px` or `%`”
String: “The size thickness mode. Can be `px`”
String: “Unit of measurement. Can be `px` or `%` or any css unit of measurement.”
String: A hexadecimal color of the form #rrggbb
String: The path to your image file.
String: Sets or returns the border color. Color is in hexadecimal form #rrggbb
String: Sets or returns the border style. Values can be dotted, dashed, solid, double, groove, ridge, inset and outset. Default is solid.
String: Sets or returns the theme color of the AppBar. Values can be Default Primary Secondary Transparent Inherit
String: Sets or returns the relative path to the font-family use.
String: Sets or returns the icon of the menu button.
String: Sets or returns the options of the control.
String: Sets or return the AppBar title text
String: Sets or returns the hexadecimal color of the appbar title.
String: Sets or returns the variant of the title text. Values can be h1 h2 h3 h4 h5 or h6
String: Returns the type of the control.
String: Sets or returns the visibility of the control.
Object: The parent layout where to add the AppBar
Object: The layout where to add controls
Object: The pointer event object.
Object: The click event object.
Object: Returns the parent layout control.
Object: Returns the position of the control. The returned object has left top right and bottom props.
List: Sets or returns the margin of the control. Works on controls with Linear parent only. You can also pass a number to set equal margins for all sides.
List: Sets or returns the padding of the control. You can also pass a number to set equal padding for all sides.
function()
apb.addLayout
Adds a layout for additional controls at the right of the appbar
apb.animate
Animate the component
apb.bringForward
Bring this component forward by a given z-index
apb.destroy
Destroy the component
apb.getPosition
Returns the position of the component. The return object is of the form `{ left, top, right, bottom
apb.gone
Destroy the component
apb.hide
Hide the component
apb.sendBackward
Bring this component backward by a given z-index
apb.setBorder
Sets the border line for the component container
apb.setCornerRadius
Sets the corner radius of the appbar
apb.setMargins
Sets the margin of the component
apb.setOnContextMenu
Adds a callback function on right click
apb.setOnMenu
Sets a function to be called when the user clicks the menu
apb.setOnTouch
Adds a callback handler when the component is touch
apb.setPadding
Sets the padding component container
apb.setPosition
Sets the position of the component relative to its parent dimensions
apb.setScale
Sets the x and y scaling of the component
apb.setSize
Sets the size of the component
apb.show
Show the component
Layout:'Returns the right layout of the appbar where you can add controls.'