Skip to content

Commit 12e4594

Browse files
committed
feat: new APIS with v9
1 parent 9570ed1 commit 12e4594

File tree

3 files changed

+304
-2
lines changed

3 files changed

+304
-2
lines changed

content/ui/sidebar.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default [
7070
{ text: 'SearchBar', link: '/ui/search-bar' },
7171
{ text: 'SegmentedBar', link: '/ui/segmented-bar' },
7272
{ text: 'Slider', link: '/ui/slider' },
73+
{ text: 'SplitView', link: '/ui/split-view' },
7374
{ text: 'Switch', link: '/ui/switch' },
7475
{ text: 'TabView', link: '/ui/tab-view' },
7576
{ text: 'TextField', link: '/ui/text-field' },

content/ui/split-view.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
---
2+
title: SplitView
3+
description: A singular root view component for coordinating up to four column roles (primary, secondary, supplementary, inspector).
4+
contributors:
5+
- NathanWalker
6+
---
7+
8+
`<SplitView>` is an iOS-only container component that gives you a declarative [UISplitViewController](https://developer.apple.com/documentation/uikit/uisplitviewcontroller) and exposes its modern multi-column capabilities to NativeScript apps. It lets you coordinate **up to four** roles:
9+
10+
- **primary** – main navigation or master content
11+
- **secondary** – detail view for the selected item
12+
- **supplementary** – contextual / side content
13+
- **inspector** – tool / inspector pane available on iOS 17+ when the system supports it
14+
15+
Each role is typically provided by a child `<Frame>` so that every column can manage its own navigation stack independently, while still being part of the same split view controller. This mirrors how native iPadOS apps structure complex layouts.
16+
17+
::: tip
18+
It is intended to be used as the singular starting root view for the entire app.
19+
20+
This component is ideal for iPadOS-style apps, admin-style layouts, or any experience where you need a master-detail flow plus an extra contextual pane or inspector.
21+
:::
22+
23+
## Example
24+
25+
### Declarative XML
26+
27+
```xml
28+
<SplitView
29+
displayMode="twoBesideSecondary"
30+
splitBehavior="tile"
31+
preferredPrimaryColumnWidthFraction="0.25"
32+
preferredSupplementaryColumnWidthFraction="0.33"
33+
preferredInspectorColumnWidthFraction="0.20">
34+
35+
<Frame splitRole="primary" defaultPage="pages/master" />
36+
<Frame splitRole="secondary" defaultPage="pages/detail" />
37+
<Frame splitRole="supplementary" defaultPage="pages/context" />
38+
<Frame splitRole="inspector" defaultPage="pages/inspector" />
39+
</SplitView>
40+
```
41+
This configures a 3–4 column layout (depending on OS support) and assigns each role to its own frame.
42+
43+
### Programmatic
44+
45+
```ts
46+
import { SplitView } from '@nativescript/core'
47+
48+
const splitView = new SplitView()
49+
splitView.displayMode = 'twoBesideSecondary'
50+
splitView.splitBehavior = 'tile'
51+
splitView.preferredPrimaryColumnWidthFraction = 0.25
52+
53+
// create frames with splitRole before adding them
54+
```
55+
56+
### With inspector change listener
57+
58+
```ts
59+
splitView.on('inspectorChange', ({ data }) => {
60+
console.log('Inspector visible?', data.showing)
61+
})
62+
```
63+
Fired whenever the inspector column is shown or hidden.
64+
65+
## Concepts
66+
67+
### Roles
68+
69+
SplitView coordinates **roles** rather than arbitrary children. Children declare their intended role:
70+
71+
```xml
72+
<Frame splitRole="primary" />
73+
<Frame splitRole="secondary" />
74+
<Frame splitRole="supplementary" />
75+
<Frame splitRole="inspector" />
76+
```
77+
78+
If a role is omitted, SplitView falls back to the order in which children were added. However, declaring the role is recommended for clarity and for future layout changes.
79+
80+
### Column styles
81+
82+
The underlying controller can operate in *double* or *triple* column styles. SplitView exposes this through a common enum:
83+
84+
- `SplitView.SplitStyle.double`
85+
- `SplitView.SplitStyle.triple`
86+
87+
iOS chooses the right `UISplitViewControllerStyle` for you. On iOS 17+ an inspector column can also be shown. citeturn2view0
88+
89+
## Props
90+
91+
### displayMode
92+
93+
```ts
94+
displayMode:
95+
| 'automatic'
96+
| 'secondaryOnly'
97+
| 'oneBesideSecondary'
98+
| 'oneOverSecondary'
99+
| 'twoBesideSecondary'
100+
| 'twoOverSecondary'
101+
| 'twoDisplaceSecondary'
102+
```
103+
104+
Maps to [UISplitViewController.preferredDisplayMode]. Determines how the primary/supplementary columns relate to the secondary column (beside vs over vs displaced).
105+
106+
### splitBehavior (iOS 14+)
107+
108+
```ts
109+
splitBehavior: 'automatic' | 'tile' | 'overlay' | 'displace'
110+
```
111+
112+
Maps to [UISplitViewController.preferredSplitBehavior](https://developer.apple.com/documentation/uikit/uisplitviewcontroller/preferreddisplaymode). Controls how columns behave when the size class changes (for example overlaying instead of resizing). iOS 14 or newer is required.
113+
114+
### preferredPrimaryColumnWidthFraction
115+
116+
```ts
117+
preferredPrimaryColumnWidthFraction: number // 0..1
118+
```
119+
120+
Fractional width for the primary column (for example `0.25` = 25%).
121+
122+
### preferredSupplementaryColumnWidthFraction
123+
124+
```ts
125+
preferredSupplementaryColumnWidthFraction: number // 0..1
126+
```
127+
128+
Used in triple-column style to reserve width for the supplementary column.
129+
130+
### preferredInspectorColumnWidthFraction
131+
132+
```ts
133+
preferredInspectorColumnWidthFraction: number // 0..1
134+
```
135+
136+
Width fraction for the inspector column, applied only when the platform supports the inspector role (iOS 17+). On earlier versions this is safely ignored.
137+
138+
### inspectorShowing (readonly)
139+
140+
```ts
141+
inspectorShowing: boolean
142+
```
143+
144+
Current visibility state of the inspector column. Helpful to sync UI buttons with the actual split view state.
145+
146+
## Static members
147+
148+
### SplitView.getInstance()
149+
150+
```ts
151+
const active = SplitView.getInstance()
152+
```
153+
154+
Returns the last created SplitView instance, or `null` if none exists. This is a convenience for apps that only ever use a single SplitView and want to access it imperatively (for example, from a service).
155+
156+
### SplitView.SplitStyle
157+
158+
```ts
159+
const { SplitStyle } = SplitView
160+
```
161+
162+
Common enum representing double vs triple column styles. The iOS implementation maps this to the proper `UISplitViewController` style.
163+
164+
## Methods
165+
166+
### showPrimary() / hidePrimary()
167+
168+
```ts
169+
splitView.showPrimary()
170+
splitView.hidePrimary()
171+
```
172+
173+
Shows or hides the primary column. Useful on compact width or when presenting master-detail flows modally.
174+
175+
### showSecondary() / hideSecondary()
176+
177+
```ts
178+
splitView.showSecondary()
179+
splitView.hideSecondary()
180+
```
181+
182+
Controls the visibility of the secondary column.
183+
184+
### showSupplementary()
185+
186+
```ts
187+
splitView.showSupplementary()
188+
```
189+
190+
Ensures the supplementary column is visible when the display mode allows it. Hiding is typically handled automatically by the display mode.
191+
192+
### showInspector() / hideInspector()
193+
194+
```ts
195+
splitView.showInspector()
196+
splitView.hideInspector()
197+
```
198+
199+
Toggles the inspector column (iOS 17+). Calls are no-ops on platforms/versions where inspector is not available.
200+
201+
### onSecondaryViewCollapsed(secondaryVC, primaryVC)
202+
203+
Lifecycle hook invoked when the system collapses the secondary onto the primary (for example, when moving to a compact size). Override in subclasses or listen at the NativeScript level to adjust your UI.
204+
205+
## Events
206+
207+
### inspectorChange
208+
209+
```ts
210+
splitView.on('inspectorChange', (args) => {
211+
console.log('Inspector visible?', args.data.showing)
212+
})
213+
```
214+
215+
Emitted whenever the inspector column changes visibility. Payload contains a `data.showing: boolean`.
216+
217+
## Platform notes
218+
219+
- **Platform**: iOS only (backed by `UISplitViewController`).
220+
- **splitBehavior**: requires iOS 14+.
221+
- **Inspector**: requires iOS 17+. On earlier versions the property is ignored and inspector-related methods are safe no-ops.
222+
223+
## Native component
224+
225+
- iOS: [`UISplitViewController`](https://developer.apple.com/documentation/uikit/uisplitviewcontroller)

content/ui/tab-view.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
---
22
title: TabView
3-
description: UI component for grouping content into tabs and let users switch between them.
3+
description: UI component for grouping content into tabs and letting users switch between them.
44
contributors:
55
- rigor789
66
- Ombuweb
7+
- NathanWalker
78
---
89

910
`<TabView>` is a UI component that shows content grouped into tabs and lets users switch between them.
1011

12+
As of NativeScript 9, on **iOS 26+**, TabView now supports:
13+
- an **optional bottom accessory view** (`iosBottomAccessory`) that sits just above the tab bar and participates in layout, and
14+
- a **configurable tab bar minimize behavior** (`iosTabBarMinimizeBehavior`) so you can control how/when the tab bar hides when scrolling.
15+
1116
<DeviceFrame type="ios">
1217
<img src="../assets/images/screenshots/ios/TabView.png"/>
1318
</DeviceFrame>
@@ -130,7 +135,7 @@ Sets the underline color of the tabs. **Android only.**
130135

131136
```css
132137
.tab-view {
133-
android-selected-tab-highlight-color:: #3d5a80;
138+
android-selected-tab-highlight-color: #3d5a80;
134139
}
135140
```
136141

@@ -160,6 +165,38 @@ Defaults to `automatic`.
160165

161166
See [UIImage.RenderingMode](https://developer.apple.com/documentation/uikit/uiimage/renderingmode).
162167

168+
### iosBottomAccessory
169+
170+
```ts
171+
iosBottomAccessory: View // iOS 26+ only
172+
```
173+
174+
Assigns a bottom accessory view that is rendered *above* the iOS tab bar, inside the TabView's layout. This is useful for mini players, status bars, or context-sensitive actions that should stay attached to the tab bar. On platforms below iOS 26 this property is ignored.
175+
176+
Notes:
177+
- Give it an explicit `height` or style it with CSS so the TabView can measure it.
178+
- It participates in layout pass fixes added in this release so it will resize alongside safe areas.
179+
- On Android this is ignored.
180+
181+
### iosTabBarMinimizeBehavior
182+
183+
```ts
184+
iosTabBarMinimizeBehavior:
185+
| 'automatic'
186+
| 'never'
187+
| 'onScrollDown'
188+
| 'onScrollUp'
189+
```
190+
191+
Controls how the iOS tab bar minimizes/hides in response to scrolling. This mirrors the iOS 26 tab bar behavior on `UITabBarController`.
192+
193+
- `automatic` – system chooses; good default.
194+
- `never` – keep the tab bar always visible.
195+
- `onScrollDown` – hide the tab bar when scrolling down.
196+
- `onScrollUp` – show the tab bar when scrolling up.
197+
198+
Ignored on iOS < 26 and on Android.
199+
163200
### ...Inherited
164201

165202
For additional inherited properties, refer to the [API Reference](/api/class/TabView).
@@ -211,6 +248,45 @@ on('selectedIndexChanged', (args: EventData) => {
211248

212249
Emitted when the selected tab changes.
213250

251+
## Platform specific notes
252+
253+
### iOS 26+ bottom accessory
254+
255+
On iOS 26+ you can attach any NativeScript view as a bottom accessory, such as a mini player, quick actions, or a context bar. On earlier iOS versions and on Android this is ignored safely.
256+
257+
```xml
258+
<TabView
259+
id="mainTabs"
260+
selectedIndex="0"
261+
iosTabBarMinimizeBehavior="automatic"
262+
iosBottomAccessory="
263+
<StackLayout
264+
height='44'
265+
backgroundColor='#1c1c1e'
266+
orientation='horizontal'
267+
horizontalAlignment='stretch'>
268+
<Label text='Now playing…' color='white' verticalAlignment='center' marginLeft='12' />
269+
</StackLayout>
270+
">
271+
<TabViewItem title="Library">
272+
<Label text="Your library" />
273+
</TabViewItem>
274+
<TabViewItem title="Search">
275+
<Label text="Search" />
276+
</TabViewItem>
277+
</TabView>
278+
```
279+
280+
You can also set the accessory from code if you need to build it dynamically:
281+
282+
```ts
283+
const tabView = page.getViewById('mainTabs') as TabView
284+
const accessory = new StackLayout()
285+
accessory.height = 44
286+
accessory.backgroundColor = '#1c1c1e'
287+
tabView.iosBottomAccessory = accessory
288+
```
289+
214290
## Native component
215291

216292
- Android: [`androidx.viewpager.widget.ViewPager`](https://developer.android.com/reference/androidx/viewpager/widget/ViewPager)

0 commit comments

Comments
 (0)