diff --git a/content/ui/action-bar.md b/content/ui/action-bar.md new file mode 100644 index 00000000..5c1da22b --- /dev/null +++ b/content/ui/action-bar.md @@ -0,0 +1,664 @@ +--- +title: ActionBar +--- + + +The ActionBar is NativeScript’s abstraction over the Android [ActionBar](https://developer.android.com/training/appbar/) and iOS [NavigationBar](https://developer.apple.com/design/human-interface-guidelines/ios/bars/navigation-bars/). It represents a toolbar at the top of the activity window, and can have a title, application-level navigation, as well as other custom interactive items. + + +## Simple ActionBar with title + + + +```html + +``` + + + + + +## ActionBar with custom title component + + + +```xml + + + + + +``` + + + +## ActionBar with ActionItem + +The `` component supports the platform-specific position and systemIcon for iOS and Android. + +### Positioning ActionItem + +- Android sets position via `android.position`: + + - `actionBar`: Puts the item in the ActionBar. Action item can be rendered both as text or icon. + - `popup`: Puts the item in the options menu. Items will be rendered as text. + - `actionBarIfRoom`: Puts the item in the ActionBar if there is room for it. Otherwise, puts it in the options menu. + +- iOS sets position via ios.position: + + - `left`: Puts the item on the left side of the ActionBar. + - `right`: Puts the item on the right side of the ActionBar. + + + + +```html + + + + + + +``` + + +## ActionBar with NavigationButton + +`` is a UI component that provides an abstraction for the Android navigation button and the iOS back button. + + + +```html + + + +``` + + + +:::tip Platform specific behavior + +**iOS Specific** + +On iOS the default text of the navigation button is the title of the previous page and the back button is used explicitly for navigation. +It navigates to the previous page and does not allow overriding this behavior. +If you need to place a custom button on the left side of the `` (e.g., to show a Drawer button), you can use an `` with `ios.position="left"`. + +**Android Specific** + +On Android, you can't add text inside the navigation button. +You can use the icon property to set an image (e.g., `~/images/nav-image.png` or `res:\\ic_nav`). +You can use `android.systemIcon` to set one of the system icons available in Android. +In this case, there is no default behaviour for NavigationButton tap event, and we should set the callback function, which will be executed. +::: + +## Setting an app icon for Android in ActionBar + + + +```html + +``` + + + + +## Styling ActionBar + +To style the ``, you can use only `background-color` and `color` properties. Alternatively, you can use [@nativescript/tailwind](https://docs.nativescript.org/plugins/tailwindcss.html) and use the default styles for each different theme. The icon property of `ActionItem` can use Icon Fonts with the `font://` prefix. By setting up this prefix, a new image will be generated, which will be set as an ``'s icon resource. While using this functionality, we need to specify the font-size, which will calculate the size of the generated image base on the device's dpi. + + + + + + + + + + + + + +```html + + + + + + + + + + + +