forked from NativeScript/nativescript-sdk-examples-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
578 additions
and
215 deletions.
There are no files selected for viewing
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions
5
app/ns-ui-widgets-category/bottom-navigation/basics/article.md
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
app/ns-ui-widgets-category/bottom-navigation/basics/basics-page.js
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
app/ns-ui-widgets-category/bottom-navigation/basics/basics-page.xml
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
app/ns-ui-widgets-category/bottom-navigation/basics/basics-ts-page.ts
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
app/ns-ui-widgets-category/bottom-navigation/basics/basics-ts-page.xml
This file was deleted.
Oops, something went wrong.
16 changes: 9 additions & 7 deletions
16
app/ns-ui-widgets-category/bottom-navigation/bottom-navigation-page.js
This file contains 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
6 changes: 6 additions & 0 deletions
6
app/ns-ui-widgets-category/bottom-navigation/events/article.md
This file contains 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,6 @@ | ||
- `selectedIndexChanged` - Event used to track the tabs interaction though the change of `selectedIndex` property of `BottomNavigation` component. The event data is of type `SelectedIndexChangedEventData` extends `EventData` with two new properties: | ||
- `oldIndex` - Provides the old selected index. | ||
- `newIndwex` - Provides the new selected index. | ||
|
||
<snippet id='bottom-navigation-events-js'/> | ||
<snippet id='bottom-navigation-events-tsc'/> |
27 changes: 27 additions & 0 deletions
27
app/ns-ui-widgets-category/bottom-navigation/events/events-page.js
This file contains 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,27 @@ | ||
const fromObject = require("tns-core-modules/data/observable").fromObject; | ||
|
||
exports.onNavigatingTo = (args) => { | ||
const page = args.object; | ||
const vm = fromObject({ | ||
selectedIndex: 1 | ||
}); | ||
|
||
page.bindingContext = vm; | ||
}; | ||
|
||
// >> bottom-navigation-events-js | ||
exports.onBottomNavLoaded = (args) => { | ||
// Using the loaded event to ger a reference to the BottomNavigation | ||
const bottomNavigation = args.object; | ||
|
||
// Using selectedIndexChanged | ||
bottomNavigation.on("selectedIndexChanged", (args) => { | ||
// args is of type SelectedIndexChangedEventData | ||
const oldIndex = args.oldIndex; | ||
const newIndex = args.newIndex; | ||
console.log(`oldIndex: ${oldIndex}; newIndex: ${newIndex}`); | ||
|
||
args.object.page.bindingContext.set("selectedIndex", newIndex); | ||
}); | ||
}; | ||
// << bottom-navigation-events-js |
29 changes: 29 additions & 0 deletions
29
app/ns-ui-widgets-category/bottom-navigation/events/events-page.xml
This file contains 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,29 @@ | ||
<Page navigatingTo="onNavigatingTo"> | ||
<Page.actionBar> | ||
<ActionBar title="BottomNavigation - Events"/> | ||
</Page.actionBar> | ||
<!-- >> bottom-navigation-events-xml --> | ||
<BottomNavigation selectedIndex="1" loaded="onBottomNavLoaded"> | ||
|
||
<!-- The bottom tab UI is created via TabStrip (the containier) and TabStripItem (for each tab)--> | ||
<TabStrip> | ||
<TabStripItem title="Home" iconSource="res://baseline_home_black_24pt"></TabStripItem> | ||
<TabStripItem title="Account" iconSource="res://baseline_account_balance_black_24pt"></TabStripItem> | ||
</TabStrip> | ||
|
||
<!-- The number of TabContentItem components should corespond to the number of TabStripItem components --> | ||
<TabContentItem> | ||
<GridLayout rows="*, *"> | ||
<Label row="0" text="Home Page" class="h2 text-center" color="orange"></Label> | ||
<Label row="1" text="{{ 'newIndex: ' + selectedIndex }}" class="h2 text-center"></Label> | ||
</GridLayout> | ||
</TabContentItem> | ||
<TabContentItem> | ||
<GridLayout rows="*, *"> | ||
<Label row="0" text="Account Page" class="h2 text-center"></Label> | ||
<Label row="1" text="{{ 'newIndex: ' + selectedIndex }}" class="h2 text-center"></Label> | ||
</GridLayout> | ||
</TabContentItem> | ||
</BottomNavigation> | ||
<!-- << bottom-navigation-events-xml --> | ||
</Page> |
29 changes: 29 additions & 0 deletions
29
app/ns-ui-widgets-category/bottom-navigation/events/events-ts-page.ts
This file contains 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,29 @@ | ||
// >> bottom-navigation-events-tsc | ||
import { EventData, fromObject } from "tns-core-modules/data/observable"; | ||
import { BottomNavigation, SelectedIndexChangedEventData } from "tns-core-modules/ui/bottom-navigation"; | ||
// >> (hide) | ||
import { Page } from "tns-core-modules/ui/page"; | ||
|
||
export function onNavigatingTo(args: EventData) { | ||
const page = args.object as Page; | ||
const vm = fromObject({ | ||
selectedIndex: 1 | ||
}) | ||
|
||
page.bindingContext = vm; | ||
} | ||
// << (hide) | ||
export function onBottomNavLoaded(args: EventData) { | ||
// Using the loaded event to ger a reference to the BottomNavigation | ||
const bottomNavigation = args.object as BottomNavigation; | ||
|
||
// Using selectedIndexChanged | ||
bottomNavigation.on(BottomNavigation.selectedIndexChangedEvent , (args: SelectedIndexChangedEventData) => { | ||
const oldIndex: number = args.oldIndex; | ||
const newIndex: number = args.newIndex; | ||
console.log(`oldIndex: ${oldIndex}; newIndex: ${newIndex}`); | ||
|
||
(<any>args.object).page.bindingContext.set("selectedIndex", newIndex); | ||
}); | ||
}; | ||
// << bottom-navigation-events-tsc |
29 changes: 29 additions & 0 deletions
29
app/ns-ui-widgets-category/bottom-navigation/events/events-ts-page.xml
This file contains 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,29 @@ | ||
<Page navigatingTo="onNavigatingTo"> | ||
<Page.actionBar> | ||
<ActionBar title="BottomNavigation - Events"/> | ||
</Page.actionBar> | ||
<!-- >> bottom-navigation-events-xml --> | ||
<BottomNavigation selectedIndex="1" loaded="onBottomNavLoaded"> | ||
|
||
<!-- The bottom tab UI is created via TabStrip (the containier) and TabStripItem (for each tab)--> | ||
<TabStrip> | ||
<TabStripItem title="Home" iconSource="res://baseline_home_black_24pt"></TabStripItem> | ||
<TabStripItem title="Account" iconSource="res://baseline_account_balance_black_24pt"></TabStripItem> | ||
</TabStrip> | ||
|
||
<!-- The number of TabContentItem components should corespond to the number of TabStripItem components --> | ||
<TabContentItem> | ||
<GridLayout rows="*, *"> | ||
<Label row="0" text="Home Page" class="h2 text-center" color="orangered"></Label> | ||
<Label row="1" text="{{ 'newIndex: ' + selectedIndex }}" class="h2 text-center"></Label> | ||
</GridLayout> | ||
</TabContentItem> | ||
<TabContentItem> | ||
<GridLayout rows="*, *"> | ||
<Label row="0" text="Account Page" class="h2 text-center"></Label> | ||
<Label row="1" text="{{ 'selectednewIndexIndex: ' + selectedIndex }}" class="h2 text-center"></Label> | ||
</GridLayout> | ||
</TabContentItem> | ||
</BottomNavigation> | ||
<!-- << bottom-navigation-events-xml --> | ||
</Page> |
This file contains 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 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
14 changes: 14 additions & 0 deletions
14
app/ns-ui-widgets-category/bottom-navigation/properties/article.md
This file contains 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,14 @@ | ||
|
||
- `items: Array<TabContentItem>;` - Gets or sets the items of the BottomNavigation. | ||
|
||
- `tabStrip: TabStrip;` - Gets or sets the tab strip of the BottomNavigation. | ||
|
||
- `selectedIndex: number;` - Gets or sets the selectedIndex of the BottomNavigation. | ||
|
||
- `android: any` /* android.view.View */; - Gets the native [android widget](http://developer.android.com/reference/android/support/v4/view/ViewPager.html) that represents the user interface for this component. Valid only when running on Android OS. | ||
|
||
- `ios: any` /* UITabBarController */; - Gets the native iOS [UITabBarController](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarController_Class/) that represents the user interface for this component. Valid only when running on iOS. | ||
|
||
<snippet id='bottom-navigation-properties-js'/> | ||
<snippet id='bottom-navigation-properties-tsc'/> | ||
<snippet id='bottom-navigation-properties-tsc-xml'> |
87 changes: 87 additions & 0 deletions
87
app/ns-ui-widgets-category/bottom-navigation/properties/properties-page.js
This file contains 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,87 @@ | ||
const Label = require("tns-core-modules/ui/label").Label; | ||
const StackLayout = require("tns-core-modules/ui/layouts/stack-layout").StackLayout; | ||
const Color = require("tns-core-modules/color/color").Color; | ||
// >> bottom-navigation-events-js | ||
const TabStrip = require("tns-core-modules/ui/bottom-navigation").TabStrip; | ||
const TabStripItem = require("tns-core-modules/ui/bottom-navigation").TabStripItem; | ||
const TabContentItem = require("tns-core-modules/ui/bottom-navigation").TabContentItem; | ||
|
||
exports.onBottomNavLoaded = (args) => { | ||
// BottomNavigation | ||
const bottomNav = args.object; | ||
/* | ||
Using the items property to assign array of TabContentItem components (with content) | ||
Note: The number of TabContentItem components should be equal to the number of TabStripItem components | ||
*/ | ||
const tabContentItemsArray = createTabsContentArray(); | ||
bottomNav.items = tabContentItemsArray; | ||
|
||
/* | ||
Using the tabStrip property to createa a TabStrip with multiple TabStripItems (tabs) | ||
Note: The number of TabStripItem components should be equal to the number of TabContentItem components | ||
*/ | ||
const tabStrip = createTabStrip(); | ||
bottomNav.tabStrip = tabStrip; | ||
|
||
/* | ||
Using the selectedIndex property | ||
*/ | ||
bottomNav.selectedIndex = 1; | ||
|
||
/* | ||
Using the nativeView property (correspnding to bottomNav.ios or bottomNav.android depending on the used platform) | ||
*/ | ||
console.log("bottomNav.nativeView: ", bottomNav.nativeView); | ||
}; | ||
// << bottom-navigation-events-js | ||
|
||
function createTabStrip() { | ||
// TabStrip | ||
const tabStrip = new TabStrip(); | ||
tabStrip.iosIconRenderingMode = "automatic"; // iOS only (automatic is the default value) | ||
|
||
// An array of TabStripItem | ||
const tabStripItems = []; | ||
for (let index = 0; index < 3; index++) { | ||
// Each item is of type TabStripItem | ||
const item = new TabStripItem(); | ||
/* | ||
Using TabStripItem title property | ||
*/ | ||
item.title = `${index === 0 ? "Home" : (index === 1 ? "Account" : "Search")}`; | ||
/* | ||
Using TabStripItem title property | ||
*/ | ||
item.iconSource = index === 0 ? "res://baseline_home_black_24pt" : (index === 1 ? "res://baseline_account_balance_black_24pt" : "res://baseline_search_black_24pt"); | ||
tabStripItems.push(item); | ||
} | ||
tabStrip.items = tabStripItems; | ||
|
||
return tabStrip; | ||
} | ||
|
||
function createTabsContentArray() { | ||
// array of TabContentItem | ||
const arr = []; | ||
for (let index = 0; index < 3; index++) { | ||
// item is of type TabContentItem | ||
const item = new TabContentItem(); | ||
// The createContent is a custom method that returns a StackLayout with a Label as a chils | ||
item.view = createContent(index); | ||
arr.push(item); | ||
} | ||
|
||
return arr; | ||
} | ||
|
||
function createContent(index) { | ||
const label = new Label(); | ||
label.text = `${index === 0 ? "Home" : (index === 1 ? "Account" : "Search")}`; | ||
label.className = "h2 text-center"; | ||
label.color = new Color("red"); | ||
const stack = new StackLayout(); | ||
stack.verticalAlignment = "middle"; | ||
stack.addChild(label); | ||
|
||
return stack; | ||
} |
7 changes: 7 additions & 0 deletions
7
app/ns-ui-widgets-category/bottom-navigation/properties/properties-page.xml
This file contains 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,7 @@ | ||
<Page> | ||
<Page.actionBar> | ||
<ActionBar title="BottomNavigation - Usage"/> | ||
</Page.actionBar> | ||
|
||
<BottomNavigation loaded="onBottomNavLoaded"></BottomNavigation> | ||
</Page> |
Oops, something went wrong.