mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,7 +5,6 @@
|
||||
.sublime-grunt.cache
|
||||
tscommand*.tmp.txt
|
||||
.tscache
|
||||
.vscode
|
||||
|
||||
node_modules/
|
||||
dist/
|
||||
|
||||
85
.vscode/launch.json
vendored
Normal file
85
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch on iOS Device",
|
||||
"type": "nativescript",
|
||||
"platform": "ios",
|
||||
"request": "launch",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"diagnosticLogging": false,
|
||||
"emulator": false
|
||||
},
|
||||
{
|
||||
"name": "Attach on iOS Device",
|
||||
"type": "nativescript",
|
||||
"platform": "ios",
|
||||
"request": "attach",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"diagnosticLogging": false,
|
||||
"emulator": false
|
||||
},
|
||||
{
|
||||
"name": "Launch on iOS Emulator",
|
||||
"type": "nativescript",
|
||||
"platform": "ios",
|
||||
"request": "launch",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"diagnosticLogging": false,
|
||||
"emulator": true
|
||||
},
|
||||
{
|
||||
"name": "Attach on iOS Emulator",
|
||||
"type": "nativescript",
|
||||
"platform": "ios",
|
||||
"request": "attach",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"diagnosticLogging": false,
|
||||
"emulator": true
|
||||
},
|
||||
{
|
||||
"name": "Launch on Android Device",
|
||||
"type": "nativescript",
|
||||
"platform": "android",
|
||||
"request": "launch",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"diagnosticLogging": false,
|
||||
"emulator": false
|
||||
},
|
||||
{
|
||||
"name": "Launch on Android Emulator",
|
||||
"type": "nativescript",
|
||||
"platform": "android",
|
||||
"request": "launch",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"diagnosticLogging": false,
|
||||
"emulator": true
|
||||
},
|
||||
{
|
||||
"name": "Attach on Android Device",
|
||||
"type": "nativescript",
|
||||
"platform": "android",
|
||||
"request": "attach",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"diagnosticLogging": false,
|
||||
"emulator": false
|
||||
},
|
||||
{
|
||||
"name": "Attach on Android Emulator",
|
||||
"type": "nativescript",
|
||||
"platform": "android",
|
||||
"request": "attach",
|
||||
"appRoot": "${workspaceRoot}/tests",
|
||||
"sourceMaps": true,
|
||||
"diagnosticLogging": false,
|
||||
"emulator": true
|
||||
}
|
||||
]
|
||||
}
|
||||
10
.vscode/tasks.json
vendored
Normal file
10
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "0.1.0",
|
||||
"command": "tsc",
|
||||
"isShellCommand": true,
|
||||
"args": ["-p", "."],
|
||||
"showOutput": "always",
|
||||
"problemMatcher": "$tsc"
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import {Page} from "ui/page";
|
||||
import {EventData as ObservableEventData} from "data/observable";
|
||||
|
||||
// Event handler for Page "navigatedTo" event attached in details-page.xml
|
||||
export function pageNavigatedTo(args: ObservableEventData) {
|
||||
// Get the event sender
|
||||
var page = <Page>args.object;
|
||||
|
||||
page.bindingContext = page.navigationContext;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatedTo="pageNavigatedTo">
|
||||
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
|
||||
<GridLayout rows="*, auto">
|
||||
<ScrollView>
|
||||
<StackLayout>
|
||||
|
||||
@@ -23,7 +23,7 @@ export function listViewItemTap(args: ListViewItemEventData) {
|
||||
// Navigate to the details page with context set to the data item for specified index
|
||||
topmostFrame().navigate({
|
||||
moduleName: "cuteness.io/details-page",
|
||||
context: appViewModel.redditItems.getItem(args.index)
|
||||
bindingContext: appViewModel.redditItems.getItem(args.index)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ export function test_NavigateTo_WithContext() {
|
||||
}
|
||||
|
||||
//https://github.com/NativeScript/NativeScript/issues/731
|
||||
export function test_BindingContext_Becomes_NavigationContext_When_NavigatingTo() {
|
||||
export function test_NavigateTo_WithBindingContext() {
|
||||
let currentPage = frameModule.topmost().currentPage;
|
||||
let testPage: Page;
|
||||
let bindingContext;
|
||||
@@ -244,7 +244,7 @@ export function test_BindingContext_Becomes_NavigationContext_When_NavigatingTo(
|
||||
};
|
||||
let navEntry = {
|
||||
create: pageFactory,
|
||||
context: "This is the navigation context",
|
||||
bindingContext: "bindng context",
|
||||
animated: false
|
||||
};
|
||||
let topFrame = frameModule.topmost();
|
||||
@@ -252,7 +252,7 @@ export function test_BindingContext_Becomes_NavigationContext_When_NavigatingTo(
|
||||
TKUnit.waitUntilReady(() => topFrame.currentPage !== null && topFrame.currentPage !== currentPage && testPage.isLayoutValid);
|
||||
helper.goBack();
|
||||
|
||||
TKUnit.assertEqual(bindingContext, navEntry.context, "The Page's bindingContext should be set automatically to the navigation context when navigating to.");
|
||||
TKUnit.assertEqual(bindingContext, navEntry.bindingContext, "The Page's bindingContext should be equal to the NavigationEntry.bindingContext property when navigating to.");
|
||||
}
|
||||
|
||||
export function test_FrameBackStack_WhenNavigatingForwardAndBack() {
|
||||
|
||||
@@ -336,7 +336,7 @@ export class Frame extends CustomLayoutView implements definition.Frame {
|
||||
this.currentPage.onNavigatingFrom(isBack);
|
||||
}
|
||||
|
||||
backstackEntry.resolvedPage.onNavigatingTo(backstackEntry.entry.context, isBack);
|
||||
backstackEntry.resolvedPage.onNavigatingTo(backstackEntry.entry.context, isBack, backstackEntry.entry.bindingContext);
|
||||
}
|
||||
|
||||
public get animated(): boolean {
|
||||
|
||||
5
tns-core-modules/ui/frame/frame.d.ts
vendored
5
tns-core-modules/ui/frame/frame.d.ts
vendored
@@ -162,6 +162,11 @@ declare module "ui/frame" {
|
||||
*/
|
||||
context?: any;
|
||||
|
||||
/**
|
||||
* An object to become the binding context of the page navigating to. Optional.
|
||||
*/
|
||||
bindingContext?: any;
|
||||
|
||||
/**
|
||||
* True to navigate to the new Page using animated transitions, false otherwise.
|
||||
*/
|
||||
|
||||
@@ -200,12 +200,12 @@ export class Page extends ContentView implements dts.Page {
|
||||
};
|
||||
}
|
||||
|
||||
public onNavigatingTo(context: any, isBackNavigation: boolean) {
|
||||
public onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext: any) {
|
||||
this._navigationContext = context;
|
||||
|
||||
//https://github.com/NativeScript/NativeScript/issues/731
|
||||
if (!isBackNavigation && !types.isNullOrUndefined(context)){
|
||||
this.bindingContext = context;
|
||||
if (!isBackNavigation && !types.isNullOrUndefined(bindingContext)){
|
||||
this.bindingContext = bindingContext;
|
||||
}
|
||||
this.notify(this.createNavigatedData(Page.navigatingToEvent, isBackNavigation));
|
||||
}
|
||||
|
||||
3
tns-core-modules/ui/page/page.d.ts
vendored
3
tns-core-modules/ui/page/page.d.ts
vendored
@@ -227,8 +227,9 @@ declare module "ui/page" {
|
||||
* A method called before navigating to the page.
|
||||
* @param context - The data passed to the page through the NavigationEntry.context property.
|
||||
* @param isBackNavigation - True if the Page is being navigated from using the Frame.goBack() method, false otherwise.
|
||||
* @param bindingContext - An object to become the binding context of the page navigating to.
|
||||
*/
|
||||
onNavigatingTo(context: any, isBackNavigation: boolean): void;
|
||||
onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext: any): void;
|
||||
|
||||
/**
|
||||
* A method called after navigated to the page.
|
||||
|
||||
@@ -129,7 +129,7 @@ class UIViewControllerImpl extends UIViewController {
|
||||
// Don't raise event if currentPage was showing modal page.
|
||||
if (!page._presentedViewController && newEntry && (!frame || frame.currentPage !== page)) {
|
||||
let isBack = isBackNavigation(page, newEntry)
|
||||
page.onNavigatingTo(newEntry.entry.context, isBack);
|
||||
page.onNavigatingTo(newEntry.entry.context, isBack, newEntry.entry.bindingContext);
|
||||
}
|
||||
|
||||
if (frame) {
|
||||
|
||||
Reference in New Issue
Block a user