-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(ios): SplitView UI component #10942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c5cef21
feat(ios): SplitView
NathanWalker a4194f2
Merge remote-tracking branch 'origin/main' into feat/split-view
NathanWalker ffcd442
feat(ios): SplitView component
NathanWalker 058a116
chore: cleanup
NathanWalker ddf82bf
ref: removed unneeded weak refs from delegates
CatchABus 33db120
ref: use a common delegate as default and animation
CatchABus 0bd09f3
chore: cleanup
NathanWalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,8 @@ | ||
| <Frame defaultPage="main-page"> | ||
| </Frame> | ||
|
|
||
| <!-- Test SplitView | ||
| Must be root component of the app to work properly | ||
| --> | ||
| <!-- <Frame defaultPage="split-view/split-view-root"> | ||
| </Frame> --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| import { Application } from '@nativescript/core'; | ||
| import { Application, SplitView } from '@nativescript/core'; | ||
|
|
||
| Application.run({ moduleName: 'app-root' }); | ||
| // Application.run({ moduleName: 'app-root' }); | ||
|
|
||
| SplitView.SplitStyle = 'triple'; | ||
| Application.run({ moduleName: 'split-view/split-view-root' }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { Observable, EventData, Page, SplitView, ItemEventData } from '@nativescript/core'; | ||
| import { getItemCallbacks } from './split-view-root'; | ||
| let page: Page; | ||
|
|
||
| export function navigatingTo(args: EventData) { | ||
| page = <Page>args.object; | ||
| page.bindingContext = new SplitViewPrimaryModel(); | ||
| } | ||
|
|
||
| export class SplitViewPrimaryModel extends Observable { | ||
| items: string[] = []; | ||
|
|
||
| constructor() { | ||
| super(); | ||
| this.items = Array.from({ length: 20 }, (_, i) => `Item ${i + 1}`); | ||
| } | ||
|
|
||
| onItemTap(args: ItemEventData) { | ||
| console.log('args.index', args.index); | ||
| SplitView.getInstance()?.showSecondary(); | ||
| getItemCallbacks().forEach((callback) => callback(this.items[args.index])); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page"> | ||
| <ActionBar title="Primary View" class="action-bar" iosLargeTitle="true"></ActionBar> | ||
|
|
||
| <!-- Primary column (master) --> | ||
| <GridLayout rows="auto,*"> | ||
| <!-- <Label text="Primary" marginBottom="12" marginLeft="8" fontSize="22" fontWeight="bold" /> --> | ||
| <ListView row="1" items="{{ items }}" itemTap="{{ onItemTap }}" backgroundColor="white"> | ||
| <ListView.itemTemplate> | ||
| <GridLayout padding="12"> | ||
| <Label text="{{ $value }}" fontSize="18" /> | ||
| </GridLayout> | ||
| </ListView.itemTemplate> | ||
| </ListView> | ||
| </GridLayout> | ||
|
|
||
| </Page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { Observable, EventData, Page } from '@nativescript/core'; | ||
| let page: Page; | ||
|
|
||
| export function navigatingTo(args: EventData) { | ||
| page = <Page>args.object; | ||
| page.bindingContext = new SplitViewModel(); | ||
| } | ||
|
|
||
| export class SplitViewModel extends Observable {} | ||
|
|
||
| let itemCallbacks: Array<(item: any) => void> = []; | ||
| export function setItemCallbacks(changeItem: Array<(item: any) => void>) { | ||
| itemCallbacks.push(...changeItem); | ||
| } | ||
| export function getItemCallbacks() { | ||
| return itemCallbacks; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| <SplitView xmlns="http://schemas.nativescript.org/tns.xsd" displayMode="twoBesideSecondary" splitBehavior="tile" preferredPrimaryColumnWidthFraction="0.25" preferredSupplementaryColumnWidthFraction="0.33" | ||
| preferredInspectorColumnWidthFraction="0.20"> | ||
| <Frame splitRole="primary" defaultPage="split-view/split-view-primary"> | ||
|
|
||
| </Frame> | ||
|
|
||
| <Frame splitRole="secondary" defaultPage="split-view/split-view-secondary"> | ||
|
|
||
| </Frame> | ||
|
|
||
| <Frame splitRole="supplementary" defaultPage="split-view/split-view-supplement"> | ||
|
|
||
| </Frame> | ||
|
|
||
| <Frame splitRole="inspector" defaultPage="pages/list-page-sticky"> | ||
|
|
||
| </Frame> | ||
|
|
||
| </SplitView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { Observable, EventData, Page, SplitView } from '@nativescript/core'; | ||
| import { setItemCallbacks } from './split-view-root'; | ||
| let page: Page; | ||
|
|
||
| export function navigatingTo(args: EventData) { | ||
| page = <Page>args.object; | ||
| page.bindingContext = new SplitViewSecondaryModel(); | ||
| } | ||
|
|
||
| export class SplitViewSecondaryModel extends Observable { | ||
| selectedItem = `Select an item from Primary.`; | ||
| showInspectorButton = false; | ||
|
|
||
| constructor() { | ||
| super(); | ||
| setItemCallbacks([this.changeItem.bind(this)]); | ||
| SplitView.getInstance().on('inspectorChange', (args: any) => { | ||
| console.log('inspectorChange', args.data?.showing); | ||
| this.showInspectorButton = !args.data?.showing; | ||
| this.notifyPropertyChange('showInspectorButton', this.showInspectorButton); | ||
| }); | ||
| } | ||
| toggle() { | ||
| SplitView.getInstance()?.showPrimary(); | ||
| } | ||
|
|
||
| toggleInspector() { | ||
| SplitView.getInstance()?.showInspector(); | ||
| } | ||
|
|
||
| changeItem(item: any) { | ||
| this.selectedItem = item; | ||
| this.notifyPropertyChange('selectedItem', item); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page"> | ||
| <ActionBar title="Secondary View" class="action-bar"> | ||
| </ActionBar> | ||
| <!-- Secondary column (detail) --> | ||
| <StackLayout class="p-16"> | ||
| <Label text="Secondary" marginBottom="12" fontSize="22" fontWeight="bold" /> | ||
| <Label text="{{ selectedItem }}" textWrap="true" tap="{{toggle}}" /> | ||
| <Label text="Show Inspector" tap="{{toggleInspector}}" class="m-t-10 font-weight-bold" visibility="{{ showInspectorButton ? 'visible' : 'collapsed' }}" /> | ||
| </StackLayout> | ||
|
|
||
| </Page> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { Observable, EventData, Page, SplitView } from '@nativescript/core'; | ||
| import { setItemCallbacks } from './split-view-root'; | ||
| let page: Page; | ||
|
|
||
| export function navigatingTo(args: EventData) { | ||
| page = <Page>args.object; | ||
| page.bindingContext = new SplitViewSupplementaryModel(); | ||
| } | ||
|
|
||
| export class SplitViewSupplementaryModel extends Observable { | ||
| selectedItem = `Supplementary - Select an item.`; | ||
| constructor() { | ||
| super(); | ||
| setItemCallbacks([this.changeItem.bind(this)]); | ||
| } | ||
| toggle() { | ||
| SplitView.getInstance()?.showPrimary(); | ||
| } | ||
|
|
||
| changeItem(item: any) { | ||
| this.selectedItem = item; | ||
| this.notifyPropertyChange('selectedItem', item); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page"> | ||
| <ActionBar title="Supplementary View" class="action-bar"> | ||
| </ActionBar> | ||
| <!-- Supplementary column (detail) --> | ||
| <StackLayout class="p-16"> | ||
| <Label text="Supplementary" marginBottom="12" fontSize="22" fontWeight="bold" /> | ||
| <Label text="{{ selectedItem }}" textWrap="true" tap="{{toggle}}" /> | ||
| </StackLayout> | ||
|
|
||
| </Page> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.