AdmiralSwiftUI Controls ToolBar - admiral-team/admiralui-ios GitHub Wiki

Overview

ToolBar - A control that displays one or more buttons vertically or horizontally. ToolBar can be vertical or horizontal. To create a horizontal or vertical ToolBar, you must specify type in the initializer ToolBarItem - A model that represents an item which can be placed in the toolbar.

To configure the current button style for a view hierarchy, use the buttonStyle(_:) modifier. You can create buttons in two styles: (default, additional) by specifying style in init CirclePageControlStyle:.

Code

@State private var toolbarType: ToolBarType = .vertical
@State private var selectedIndex: Int
private var items: [ToolBarItem] = [
 ToolBarItem(
            title: "Pay",
            image: Image("Your image"),
            badgeStyle: .value(3))
]

ToolBar(
         items: $sliceItemArray,
         type: $toolbarType,
         selectedIndex: $selectedIndex,
         onTap: { index in
             print(index)
         }
)

You can create a button with ToolBar specifying the following parameters in init:

- items - array Items of ToolBar (ToolBarItem)
- type - type of ToolBar items horizontal or vertical, vertical by default
- onTap - the callback action by tapping the button
- isSelectable - defines ToolBar item behavior on tap: highllight or select

You can create a ToolBarItem by specifying the following parameters in the initializer

 - name - text for ToolBarItem
 - image - image for ToolBarItem
 - badgeStyle - сan be either empty or value (Int)
 - type - this parameter is responsible for the display style: `default`, error, success, attention
 - isEnabled - this parameter is responsible for enable or disable ToolBarItem

Live Example

To run live demo with ToolBar open Xcode and run project with Example target. Then in the main page open Page -> ToolBar:

Contribution

You can help us to find bugs or ask us to add features.

  • To start issue please use ready-made templates.
  • To make changes to the repository, you need to create a fork of the project, make changes to the code and create a pull request in our project. You can read more about this in the Github documentation.