UI Components
Frame
UI component for displaying and navigating between Pages.
<Frame>
is a UI component used to display and navigate between Pages. A NativeScript app can have multiple Frames, or none - most apps will have at least a single Frame often set as the the root view (or inside a RootLayout).
Examples β
A single root Frame β
This example shows a single root frame that navigates to the main-page
by default, and allows the user to navigate further within this frame (spanning the full-screen).
<!-- app-root -->
<FramedefaultPage="main-page"/>
A global menu bar and a Frame β
This example shows an always visible menu bar stacked above a Frame that allows the user to navigate further.
<GridLayoutrows="auto, *">
<Labelrow="0"text="Example Menu Bar"/>
<ContentViewrow="1">
<FramedefaultPage="mainPage"/>
</ContentView>
</GridLayout>
Note
We have wrapped the Frame inside a ContentView because on iOS a frame always spans the full height of it's parent container, so we wouldn't be able to resize it without the additional ContentView.
Multiple root Frames β
This pseudo example shows two Frames side-by-side, the frame on the left represents a list of conversations, and the Frame on the right represents the details of the currently selected conversation.
The idea of using a Frame on the left is to allow navigating to a different Page while keeping the conversation-details open on the right.
<GridLayoutcolumns="300, *">
<ContentViewcol="0">
<FramedefaultPage="conversation-list" />
</ContentView>
<ContentViewcol="1">
<FramedefaultPage="conversation-details" />
</ContentView>
</GridLayout>
Note
This is a simplified example to convey the possibilities, in a real app implementation there would be nuances specific to the app.
Props β
actionBarVisibility β
actionBarVisibility: 'auto'|'always'|'never'
Used to control the visibility the Navigation Bar in iOS and the ActionBar in Android for all Pages within this Frame.
animated β
animated: boolean
Gets or sets if navigation transitions within this Frame should be animated.
backStack β
backStack: BackstackEntry[]
Readonly list of backstack entries.
See BackstackEntry.
currentEntry β
currentEntry: NavigationEntry
Readonly. The current NavigationEntry the Frame is navigated to.
See NavigationEntry.
currentPage β
currentPage: Page
Readonly. The current Page the Frame is navigated to.
See Page.
transition β
transition: NavigationTransition
Gets or sets the default navigation transition for this Frame.
See NavigationTransition.
defaultAnimatedNavigation β
defaultAnimatedNavigation: boolean
Static. Gets or sets if navigation transitions should be animated globally.
defaultTransition β
defaultTransition: NavigationTransition
Static. Gets or sets the default NavigationTransition for all frames across the app.
See NavigationTransition.
...Inherited β
For additional inherited properties, refer to the API Reference.
Methods β
canGoBack() β
canGoBack(): boolean
Returns wether or not this Frame can navigate back (there are entries in the backstack).
goBack() β
goBack(to?: BackstackEntry): void
Navigates to the previous entry (or to
) in the backstack.
See BackstackEntry.
navigate() β
navigate(pageModuleName: string): void
// or
navigate(create: () => Page): void
// or
navigate(entry: NavigationEntry): void
Navigates to a Page.
See Frame.navigate Reference, Page, NavigationEntry.
getFrameById() β
getFrameById(id: string): Frame
Static. Returns a Frame by it's id
if found.
See Frame.
topmost() β
topmost(): Frame
Static. Returns the topmost frame.
See Frame.
Events β
navigatingTo β
on('navigatingTo', (args:NavigationData) => {
constframe= args.object asFrame
constentry= args.entry asBackstackEntry
constpage= entry.resolvedPage asPage
})
Emitted when the Frame is navigating to a new Page.
navigatedTo β
on('navigatedTo', (args:NavigationData) => {
constframe= args.object asFrame
constentry= args.entry asBackstackEntry
constpage= entry.resolvedPage asPage
})
Emitted when the Frame has navigated to a new Page.
NavigationTransition Interface β
See NavigationTransition API Reference.
name β
name: string
A named transition name. Available transitions:
curl
(same ascurlUp
) (iOS only)curlUp
(iOS only)curlDown
(iOS only)explode
(Android only)fade
flip
(same asflipRight
)flipRight
flipLeft
slide
(same asslideLeft
)slideLeft
slideRight
slideTop
slideBottom
instance β
instance: Transition
This property allows you to define a custom transition instance
See Transition.
duration β
duration: number
The duration of the transition in milliseconds
curve β
curve: CoreTypes.AnimationCurve
Sets the transition animation curve.
Alternatively, you can pass an instance of type UIViewAnimationCurve for iOS or android.animation.TimeInterpolator for Android.
NavigationEntry Interface β
See NavigationEntry API Reference.
moduleName β
moduleName: string
The name of the Page module to navigate to (eg. pages/details-page
given a pages/details-page.xml
exists).
create() β
create: () => View
A function called to create the Page (View instance) to be navigated to.
Example
functioncreate() {
constpage=newPage()
constactionBar=newActionBar()
actionBar.title ='Example Page'
page.actionBar = actionBar
conststackLayout=newStackLayout()
stackLayout.backgroundColor ='#65adf1'
page.content = stackLayout
return page
}
context β
context: any
An object used to pass data to the navigated to Page.
transition β
transition: string | NavigationTransition
The transition name, or a NavigationTransition to use when navigating.
See NavigationTransition.
transitionAndroid β
transitionAndroid: string | NavigationTransition
Overrides the transition property when navigating on Android.
See NavigationTransition.
transitioniOS β
transitioniOS: string | NavigationTransition
Overrides the transition property when navigating on iOS.
See NavigationTransition.
backstackVisible β
backstackVisible: boolean
If set to true
, it records the navigation in the backstack.
If set to false
, it navigates without affecting the backstack. Once navigated away from the Page, it will get disposed and the user can't navigate back to it (via the back button).
clearHistory β
clearHistory: boolean
If set to true
, it clears the navigation history backstack.
Native component β
- Android:
org.nativescript.widgets.ContentLayout
- iOS:
UINavigationController
- Previous
- Navigation Components
- Next
- Page
- Examples
- Props
- Methods
- Events
- NavigationTransition Interface
- NavigationEntry Interface
- Native component
Contributors
Last updated: