Skip to content

Commit 104e23e

Browse files
committed
feat: SplitView phase 1
1 parent 3fcd215 commit 104e23e

File tree

9 files changed

+131
-1
lines changed

9 files changed

+131
-1
lines changed

apps/nativescript-demo-ng/src/app/app.routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Routes } from '@angular/router';
22
import { ItemDetailComponent } from './item/item-detail.component';
33
import { ItemsComponent } from './item/items.component';
44
import { ListViewStickyComponent } from './list-view-sticky/list-view-sticky.component';
5+
import { SPLIT_VIEW_ROUTES } from './split-view-demo/split-view.routes';
56
// import { HomeComponent } from './home/home.component';
67
// import { BootGuardService } from './boot-guard.service';
78

@@ -15,6 +16,10 @@ export const routes: Routes = [
1516
path: 'list-view-sticky',
1617
component: ListViewStickyComponent,
1718
},
19+
{
20+
path: 'split-view-demo',
21+
children: SPLIT_VIEW_ROUTES,
22+
},
1823

1924
/**
2025
* Test tab named outlets
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<ActionBar title="SplitView Demo"></ActionBar>
2+
3+
<GridLayout rows="*, *" columns="*">
4+
<SplitView
5+
row="0"
6+
displayMode="twoBesideSecondary"
7+
splitBehavior="tile"
8+
preferredPrimaryColumnWidthFraction="0.25"
9+
preferredSupplementaryColumnWidthFraction="0.33"
10+
preferredInspectorColumnWidthFraction="0.2"
11+
>
12+
<page-router-outlet name="primary"></page-router-outlet>
13+
<page-router-outlet name="secondary"></page-router-outlet>
14+
<page-router-outlet name="supplementary"></page-router-outlet>
15+
<page-router-outlet name="inspector"></page-router-outlet>
16+
</SplitView>
17+
</GridLayout>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';
3+
4+
@Component({
5+
selector: 'ns-split-view-demo',
6+
templateUrl: './split-view-demo.component.html',
7+
imports: [NativeScriptCommonModule, NativeScriptRouterModule],
8+
standalone: true,
9+
schemas: [NO_ERRORS_SCHEMA],
10+
})
11+
export class SplitViewDemoComponent {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptCommonModule } from '@nativescript/angular';
3+
4+
@Component({
5+
selector: 'ns-split-view-inspector',
6+
template: `<GridLayout rows="auto,*" class="p-16">
7+
<Label row="0" text="Inspector" class="h2 mb-8"></Label>
8+
<Label row="1" text="This is the inspector column." class="text-center"></Label>
9+
</GridLayout>`,
10+
standalone: true,
11+
imports: [NativeScriptCommonModule],
12+
schemas: [NO_ERRORS_SCHEMA],
13+
})
14+
export class SplitViewInspectorComponent {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptCommonModule } from '@nativescript/angular';
3+
4+
@Component({
5+
selector: 'ns-split-view-primary',
6+
template: `<GridLayout rows="auto,*" class="p-16">
7+
<Label row="0" text="Primary" class="h2 mb-8"></Label>
8+
<Label row="1" text="This is the primary column." class="text-center"></Label>
9+
</GridLayout>`,
10+
standalone: true,
11+
imports: [NativeScriptCommonModule],
12+
schemas: [NO_ERRORS_SCHEMA],
13+
})
14+
export class SplitViewPrimaryComponent {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptCommonModule } from '@nativescript/angular';
3+
4+
@Component({
5+
selector: 'ns-split-view-secondary',
6+
template: `<GridLayout rows="auto,*" class="p-16">
7+
<Label row="0" text="Secondary" class="h2 mb-8"></Label>
8+
<Label row="1" text="This is the secondary column." class="text-center"></Label>
9+
</GridLayout>`,
10+
standalone: true,
11+
imports: [NativeScriptCommonModule],
12+
schemas: [NO_ERRORS_SCHEMA],
13+
})
14+
export class SplitViewSecondaryComponent {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptCommonModule } from '@nativescript/angular';
3+
4+
@Component({
5+
selector: 'ns-split-view-supplementary',
6+
template: `<GridLayout rows="auto,*" class="p-16">
7+
<Label row="0" text="Supplementary" class="h2 mb-8"></Label>
8+
<Label row="1" text="This is the supplementary column." class="text-center"></Label>
9+
</GridLayout>`,
10+
standalone: true,
11+
imports: [NativeScriptCommonModule],
12+
schemas: [NO_ERRORS_SCHEMA],
13+
})
14+
export class SplitViewSupplementaryComponent {}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Routes } from '@angular/router';
2+
import { SplitViewDemoComponent } from './split-view-demo.component';
3+
import { SplitViewPrimaryComponent } from './split-view-primary.component';
4+
import { SplitViewSecondaryComponent } from './split-view-secondary.component';
5+
import { SplitViewSupplementaryComponent } from './split-view-supplementary.component';
6+
import { SplitViewInspectorComponent } from './split-view-inspector.component';
7+
8+
export const SPLIT_VIEW_ROUTES: Routes = [
9+
{
10+
path: '',
11+
component: SplitViewDemoComponent,
12+
children: [
13+
{
14+
path: '',
15+
redirectTo: '/split-view-demo/(primary:primary//secondary:secondary//supplementary:supplementary//inspector:inspector)',
16+
pathMatch: 'full',
17+
},
18+
{
19+
path: 'primary',
20+
component: SplitViewPrimaryComponent,
21+
outlet: 'primary',
22+
},
23+
{
24+
path: 'secondary',
25+
component: SplitViewSecondaryComponent,
26+
outlet: 'secondary',
27+
},
28+
{
29+
path: 'supplementary',
30+
component: SplitViewSupplementaryComponent,
31+
outlet: 'supplementary',
32+
},
33+
{
34+
path: 'inspector',
35+
component: SplitViewInspectorComponent,
36+
outlet: 'inspector',
37+
},
38+
],
39+
},
40+
];

packages/angular/src/lib/element-registry/common-views.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AbsoluteLayout, ActivityIndicator, Button, ContentView, DatePicker, DockLayout, FlexboxLayout, FormattedString, Frame, GridLayout, HtmlView, Image, Label, ListPicker, ListView, Page, Placeholder, Progress, ProxyViewContainer, Repeater, RootLayout, ScrollView, SearchBar, SegmentedBar, SegmentedBarItem, Slider, Span, StackLayout, Switch, TabView, TextField, TextView, TimePicker, WebView, WrapLayout } from '@nativescript/core';
1+
import { AbsoluteLayout, ActivityIndicator, Button, ContentView, DatePicker, DockLayout, FlexboxLayout, FormattedString, Frame, GridLayout, HtmlView, Image, Label, ListPicker, ListView, Page, Placeholder, Progress, ProxyViewContainer, Repeater, RootLayout, ScrollView, SearchBar, SegmentedBar, SegmentedBarItem, Slider, Span, SplitView, StackLayout, Switch, TabView, TextField, TextView, TimePicker, WebView, WrapLayout } from '@nativescript/core';
22
import { formattedStringMeta, frameMeta, textBaseMeta } from './metas';
33
import { registerElement } from './registry';
44

@@ -33,6 +33,7 @@ export function registerNativeScriptViewComponents() {
3333
registerElement('SegmentedBar', () => SegmentedBar);
3434
registerElement('SegmentedBarItem', () => SegmentedBarItem);
3535
registerElement('Slider', () => Slider);
36+
registerElement('SplitView', () => SplitView);
3637
registerElement('StackLayout', () => StackLayout);
3738
registerElement('FlexboxLayout', () => FlexboxLayout);
3839
registerElement('Switch', () => Switch);

0 commit comments

Comments
 (0)