mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fixed 'jurky` navigation between pages in iOS.
Fixed after application suspend/resume the UI was not restored. Fixed modal-views page
This commit is contained in:
@@ -1,67 +1,62 @@
|
||||
import observable = require("data/observable");
|
||||
import pages = require("ui/page");
|
||||
import labelModule = require("ui/label");
|
||||
import {EventData} from "data/observable";
|
||||
import {Page} from "ui/page";
|
||||
import {Label} from "ui/label";
|
||||
import frame = require("ui/frame");
|
||||
|
||||
var page: pages.Page;
|
||||
var label: labelModule.Label;
|
||||
|
||||
export function onNavigatingTo(args: observable.EventData) {
|
||||
export function onNavigatingTo(args: EventData) {
|
||||
console.log(">>> main-page.onNavigatingTo");
|
||||
//console.trace();
|
||||
}
|
||||
|
||||
export function onLoaded(args: observable.EventData) {
|
||||
export function onLoaded(args: EventData) {
|
||||
console.log(">>> main-page.onLoaded");
|
||||
//console.trace();
|
||||
if (args.object !== frame.topmost().currentPage) {
|
||||
throw new Error("args.object must equal frame.topmost().currentPage on page.loaded");
|
||||
}
|
||||
page = <pages.Page>args.object;
|
||||
label = frame.topmost().getViewById<labelModule.Label>("label");
|
||||
if (!label) {
|
||||
throw new Error("Could not find `label`");
|
||||
}
|
||||
}
|
||||
|
||||
export function onNavigatedTo(args: observable.EventData) {
|
||||
export function onNavigatedTo(args: EventData) {
|
||||
console.log(">>> main-page.onNavigatedTo");
|
||||
//console.trace();
|
||||
}
|
||||
|
||||
export function onNavigatingFrom(args: observable.EventData) {
|
||||
export function onNavigatingFrom(args: EventData) {
|
||||
console.log(">>> main-page.onNavigatingFrom");
|
||||
}
|
||||
|
||||
export function onNavigatedFrom(args: observable.EventData) {
|
||||
export function onNavigatedFrom(args: EventData) {
|
||||
console.log(">>> main-page.onNavigatedFrom");
|
||||
}
|
||||
|
||||
export function onUnloaded(args: observable.EventData) {
|
||||
export function onUnloaded(args: EventData) {
|
||||
console.log(">>> main-page.onUnloaded");
|
||||
}
|
||||
|
||||
export function onTap(args: observable.EventData) {
|
||||
export function onTap(args: EventData) {
|
||||
let page = (<any>args.object).page;
|
||||
if ((<any>args.object).text.indexOf("(navigate)") !== -1) {
|
||||
var entry: frame.NavigationEntry = {
|
||||
moduleName: "./login-page",
|
||||
context: "Context from navigate"
|
||||
};
|
||||
frame.topmost().navigate(entry);
|
||||
|
||||
page.frame.navigate(entry);
|
||||
}
|
||||
else {
|
||||
var fullscreen = (<any>args.object).text.indexOf("(full-screen)") !== -1;
|
||||
showModal(fullscreen);
|
||||
showModal(page, fullscreen);
|
||||
}
|
||||
}
|
||||
|
||||
function showModal(fullscreen?: boolean) {
|
||||
function showModal(page: Page, fullscreen?: boolean) {
|
||||
page.showModal("./modal-views-demo/login-page", "Context from showModal", function (username: string, password: string) {
|
||||
console.log(username + "/" + password);
|
||||
label.text = username + "/" + password;
|
||||
let label = page.getViewById<Label>("label");
|
||||
if (label) {
|
||||
label.text = username + "/" + password;
|
||||
}
|
||||
}, fullscreen);
|
||||
}
|
||||
|
||||
export function onCloseModal(args: observable.EventData) {
|
||||
export function onCloseModal(args: EventData) {
|
||||
let page = (<any>args.object).page;
|
||||
page.closeModal();
|
||||
}
|
||||
@@ -184,7 +184,7 @@ function onFragmentHidden(fragment) {
|
||||
export class Frame extends frameCommon.Frame {
|
||||
private _android: AndroidFrame;
|
||||
private _delayedNavigationEntry: definition.BackstackEntry;
|
||||
private _containerViewId: number;
|
||||
private _containerViewId: number = -1;
|
||||
private _listener: android.view.View.OnAttachStateChangeListener;
|
||||
constructor() {
|
||||
super();
|
||||
@@ -379,7 +379,10 @@ export class Frame extends frameCommon.Frame {
|
||||
|
||||
public _createUI() {
|
||||
let root = new org.nativescript.widgets.ContentLayout(this._context);
|
||||
this._containerViewId = android.view.View.generateViewId();
|
||||
if (this._containerViewId < 0) {
|
||||
this._containerViewId = android.view.View.generateViewId();
|
||||
}
|
||||
|
||||
this._android.rootViewGroup = root;
|
||||
this._android.rootViewGroup.setId(this._containerViewId);
|
||||
this._android.rootViewGroup.addOnAttachStateChangeListener(this._listener);
|
||||
|
||||
@@ -166,7 +166,7 @@ export class Frame extends frameCommon.Frame {
|
||||
newValue = !page.actionBarHidden;
|
||||
}
|
||||
else {
|
||||
newValue = this.backStack.length > 0 || (page && page.actionBar && !page.actionBar._isEmpty());
|
||||
newValue = this.ios.controller.viewControllers.count > 1 || (page && page.actionBar && !page.actionBar._isEmpty());
|
||||
}
|
||||
|
||||
newValue = !!newValue; // Make sure it is boolean
|
||||
@@ -174,7 +174,7 @@ export class Frame extends frameCommon.Frame {
|
||||
}
|
||||
}
|
||||
|
||||
public get ios(): definition.iOSFrame {
|
||||
public get ios(): iOSFrame {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
@@ -706,7 +706,7 @@ class iOSFrame implements definition.iOSFrame {
|
||||
public set showNavigationBar(value: boolean) {
|
||||
var change = this._showNavigationBar !== value;
|
||||
this._showNavigationBar = value;
|
||||
this._controller.navigationBarHidden = !value;
|
||||
this._controller.setNavigationBarHiddenAnimated(!value, true);
|
||||
|
||||
let currentPage = this._controller.owner.currentPage;
|
||||
if (currentPage && change) {
|
||||
|
||||
@@ -43,14 +43,14 @@ function onSeparatorColorPropertyChanged(data: dependencyObservable.PropertyChan
|
||||
export class ListView extends common.ListView {
|
||||
private _android: android.widget.ListView;
|
||||
public _realizedItems = {};
|
||||
private _androidViewId: number;
|
||||
private _androidViewId: number = -1;
|
||||
|
||||
public _createUI() {
|
||||
this._android = new android.widget.ListView(this._context);
|
||||
|
||||
// Fixes issue with black random black items when scrolling
|
||||
this._android.setCacheColorHint(android.graphics.Color.TRANSPARENT);
|
||||
if (!this._androidViewId) {
|
||||
if (this._androidViewId < 0) {
|
||||
this._androidViewId = android.view.View.generateViewId();
|
||||
}
|
||||
this._android.setId(this._androidViewId);
|
||||
|
||||
@@ -12,7 +12,7 @@ common.orientationProperty.metadata.onValueChanged = function scrollViewOrientat
|
||||
|
||||
export class ScrollView extends common.ScrollView implements definition.ScrollView {
|
||||
private _android: org.nativescript.widgets.VerticalScrollView | org.nativescript.widgets.HorizontalScrollView;
|
||||
private _androidViewId: number;
|
||||
private _androidViewId: number = -1;
|
||||
private handler: android.view.ViewTreeObserver.OnScrollChangedListener;
|
||||
|
||||
get android(): android.view.ViewGroup {
|
||||
@@ -86,7 +86,7 @@ export class ScrollView extends common.ScrollView implements definition.ScrollVi
|
||||
this._android = new org.nativescript.widgets.VerticalScrollView(this._context);
|
||||
}
|
||||
|
||||
if (!this._androidViewId) {
|
||||
if (this._androidViewId < 0) {
|
||||
this._androidViewId = android.view.View.generateViewId();
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ export class TabView extends common.TabView {
|
||||
private _tabLayout: org.nativescript.widgets.TabLayout;
|
||||
private _viewPager: android.support.v4.view.ViewPager;
|
||||
private _pagerAdapter: android.support.v4.view.PagerAdapter;
|
||||
private _androidViewId: number;
|
||||
private _androidViewId: number = -1;
|
||||
|
||||
private _pageChagedListener: android.support.v4.view.ViewPager.SimpleOnPageChangeListener;
|
||||
|
||||
@@ -227,7 +227,7 @@ export class TabView extends common.TabView {
|
||||
this._viewPager.setLayoutParams(lp);
|
||||
this._grid.addView(this._viewPager);
|
||||
|
||||
if (!this._androidViewId) {
|
||||
if (this._androidViewId < 0) {
|
||||
this._androidViewId = android.view.View.generateViewId();
|
||||
}
|
||||
this._grid.setId(this._androidViewId);
|
||||
|
||||
Reference in New Issue
Block a user