mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: default tabs
This commit is contained in:
@@ -13,113 +13,113 @@ const STATUS_BAR_LIGHT_BCKG = -657931;
|
||||
const STATUS_BAR_DARK_BCKG = 1711276032;
|
||||
|
||||
export class Page extends PageBase {
|
||||
nativeViewProtected: org.nativescript.widgets.GridLayout;
|
||||
nativeViewProtected: org.nativescript.widgets.GridLayout;
|
||||
|
||||
public createNativeView() {
|
||||
const layout = new org.nativescript.widgets.GridLayout(this._context);
|
||||
layout.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto));
|
||||
layout.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star));
|
||||
public createNativeView() {
|
||||
const layout = new org.nativescript.widgets.GridLayout(this._context);
|
||||
layout.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.auto));
|
||||
layout.addRow(new org.nativescript.widgets.ItemSpec(1, org.nativescript.widgets.GridUnitType.star));
|
||||
|
||||
return layout;
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
public initNativeView(): void {
|
||||
super.initNativeView();
|
||||
this.nativeViewProtected.setBackgroundColor(-1); // White color.
|
||||
}
|
||||
public initNativeView(): void {
|
||||
super.initNativeView();
|
||||
this.nativeViewProtected.setBackgroundColor(-1); // White color.
|
||||
}
|
||||
|
||||
public _addViewToNativeVisualTree(child: View, atIndex?: number): boolean {
|
||||
// Set the row property for the child
|
||||
if (this.nativeViewProtected && child.nativeViewProtected) {
|
||||
if (child instanceof ActionBar) {
|
||||
GridLayout.setRow(child, 0);
|
||||
child.horizontalAlignment = 'stretch';
|
||||
child.verticalAlignment = 'top';
|
||||
} else {
|
||||
GridLayout.setRow(child, 1);
|
||||
}
|
||||
}
|
||||
public _addViewToNativeVisualTree(child: View, atIndex?: number): boolean {
|
||||
// Set the row property for the child
|
||||
if (this.nativeViewProtected && child.nativeViewProtected) {
|
||||
if (child instanceof ActionBar) {
|
||||
GridLayout.setRow(child, 0);
|
||||
child.horizontalAlignment = 'stretch';
|
||||
child.verticalAlignment = 'top';
|
||||
} else {
|
||||
GridLayout.setRow(child, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return super._addViewToNativeVisualTree(child, atIndex);
|
||||
}
|
||||
return super._addViewToNativeVisualTree(child, atIndex);
|
||||
}
|
||||
|
||||
@profile
|
||||
public onLoaded() {
|
||||
super.onLoaded();
|
||||
if (!this.hasActionBar && this.actionBarHidden !== true) {
|
||||
// ensure actionBar is created
|
||||
// but we only need to do that if the actionBarHidden is not hidden
|
||||
this.actionBar = new ActionBar();
|
||||
}
|
||||
if (this.hasActionBar) {
|
||||
this.updateActionBar();
|
||||
}
|
||||
}
|
||||
@profile
|
||||
public onLoaded() {
|
||||
super.onLoaded();
|
||||
if (!this.hasActionBar && this.actionBarHidden !== true) {
|
||||
// ensure actionBar is created
|
||||
// but we only need to do that if the actionBarHidden is not hidden
|
||||
this.actionBar = new ActionBar();
|
||||
}
|
||||
if (this.hasActionBar) {
|
||||
this.updateActionBar();
|
||||
}
|
||||
}
|
||||
|
||||
private updateActionBar() {
|
||||
// the test is actually to ensure the actionBar is created
|
||||
// it will be created if not
|
||||
if (this.actionBar) {
|
||||
this.actionBar.update();
|
||||
}
|
||||
}
|
||||
private updateActionBar() {
|
||||
// the test is actually to ensure the actionBar is created
|
||||
// it will be created if not
|
||||
if (this.actionBar) {
|
||||
this.actionBar.update();
|
||||
}
|
||||
}
|
||||
|
||||
[actionBarHiddenProperty.setNative](value: boolean) {
|
||||
// in case the actionBar is not created and actionBarHidden is changed to true
|
||||
// the actionBar will be created by updateActionBar
|
||||
if (!value || this.hasActionBar) {
|
||||
this.updateActionBar();
|
||||
}
|
||||
}
|
||||
[actionBarHiddenProperty.setNative](value: boolean) {
|
||||
// in case the actionBar is not created and actionBarHidden is changed to true
|
||||
// the actionBar will be created by updateActionBar
|
||||
if (!value || this.hasActionBar) {
|
||||
this.updateActionBar();
|
||||
}
|
||||
}
|
||||
|
||||
[statusBarStyleProperty.getDefault](): {
|
||||
color: number;
|
||||
systemUiVisibility: number;
|
||||
} {
|
||||
if (Device.sdkVersion >= '21') {
|
||||
const window = (<androidx.appcompat.app.AppCompatActivity>this._context).getWindow();
|
||||
const decorView = window.getDecorView();
|
||||
[statusBarStyleProperty.getDefault](): {
|
||||
color: number;
|
||||
systemUiVisibility: number;
|
||||
} {
|
||||
if (Device.sdkVersion >= '21') {
|
||||
const window = (<androidx.appcompat.app.AppCompatActivity>this._context).getWindow();
|
||||
const decorView = window.getDecorView();
|
||||
|
||||
return {
|
||||
color: (<any>window).getStatusBarColor(),
|
||||
systemUiVisibility: decorView.getSystemUiVisibility(),
|
||||
};
|
||||
}
|
||||
return {
|
||||
color: (<any>window).getStatusBarColor(),
|
||||
systemUiVisibility: decorView.getSystemUiVisibility(),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
[statusBarStyleProperty.setNative](value: 'dark' | 'light' | { color: number; systemUiVisibility: number }) {
|
||||
if (Device.sdkVersion >= '21') {
|
||||
const window = (<androidx.appcompat.app.AppCompatActivity>this._context).getWindow();
|
||||
const decorView = window.getDecorView();
|
||||
return null;
|
||||
}
|
||||
[statusBarStyleProperty.setNative](value: 'dark' | 'light' | { color: number; systemUiVisibility: number }) {
|
||||
if (Device.sdkVersion >= '21') {
|
||||
const window = (<androidx.appcompat.app.AppCompatActivity>this._context).getWindow();
|
||||
const decorView = window.getDecorView();
|
||||
|
||||
if (value === 'light') {
|
||||
(<any>window).setStatusBarColor(STATUS_BAR_LIGHT_BCKG);
|
||||
decorView.setSystemUiVisibility(SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
} else if (value === 'dark') {
|
||||
(<any>window).setStatusBarColor(STATUS_BAR_DARK_BCKG);
|
||||
decorView.setSystemUiVisibility(0);
|
||||
} else {
|
||||
(<any>window).setStatusBarColor(value.color);
|
||||
decorView.setSystemUiVisibility(value.systemUiVisibility);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (value === 'light') {
|
||||
(<any>window).setStatusBarColor(STATUS_BAR_LIGHT_BCKG);
|
||||
decorView.setSystemUiVisibility(SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
} else if (value === 'dark') {
|
||||
(<any>window).setStatusBarColor(STATUS_BAR_DARK_BCKG);
|
||||
decorView.setSystemUiVisibility(0);
|
||||
} else {
|
||||
(<any>window).setStatusBarColor(value.color);
|
||||
decorView.setSystemUiVisibility(value.systemUiVisibility);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[androidStatusBarBackgroundProperty.getDefault](): number {
|
||||
if (Device.sdkVersion >= '21') {
|
||||
const window = (<androidx.appcompat.app.AppCompatActivity>this._context).getWindow();
|
||||
[androidStatusBarBackgroundProperty.getDefault](): number {
|
||||
if (Device.sdkVersion >= '21') {
|
||||
const window = (<androidx.appcompat.app.AppCompatActivity>this._context).getWindow();
|
||||
|
||||
return (<any>window).getStatusBarColor();
|
||||
}
|
||||
return (<any>window).getStatusBarColor();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
[androidStatusBarBackgroundProperty.setNative](value: number | Color) {
|
||||
if (Device.sdkVersion >= '21') {
|
||||
const window = (<androidx.appcompat.app.AppCompatActivity>this._context).getWindow();
|
||||
const color = value instanceof Color ? value.android : value;
|
||||
(<any>window).setStatusBarColor(color);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
[androidStatusBarBackgroundProperty.setNative](value: number | Color) {
|
||||
if (Device.sdkVersion >= '21') {
|
||||
const window = (<androidx.appcompat.app.AppCompatActivity>this._context).getWindow();
|
||||
const color = value instanceof Color ? value.android : value;
|
||||
(<any>window).setStatusBarColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
240
nativescript-core/ui/page/index.d.ts
vendored
240
nativescript-core/ui/page/index.d.ts
vendored
@@ -13,158 +13,158 @@ export * from './page-common';
|
||||
* Defines the data for the page navigation events.
|
||||
*/
|
||||
export interface NavigatedData extends EventData {
|
||||
/**
|
||||
* The navigation context (optional, may be undefined) passed to the page navigation events method.
|
||||
*/
|
||||
context: any;
|
||||
/**
|
||||
* The navigation context (optional, may be undefined) passed to the page navigation events method.
|
||||
*/
|
||||
context: any;
|
||||
|
||||
/**
|
||||
* Represents if a navigation is forward or backward.
|
||||
*/
|
||||
isBackNavigation: boolean;
|
||||
/**
|
||||
* Represents if a navigation is forward or backward.
|
||||
*/
|
||||
isBackNavigation: boolean;
|
||||
}
|
||||
|
||||
export module knownCollections {
|
||||
export const actionItems: string;
|
||||
export const actionItems: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a logical unit for navigation (inside Frame).
|
||||
*/
|
||||
export declare class Page extends PageBase {
|
||||
/**
|
||||
* String value used when hooking to navigatingTo event.
|
||||
*/
|
||||
public static navigatingToEvent: string;
|
||||
/**
|
||||
* String value used when hooking to navigatingTo event.
|
||||
*/
|
||||
public static navigatingToEvent: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to navigatedTo event.
|
||||
*/
|
||||
public static navigatedToEvent: string;
|
||||
/**
|
||||
* String value used when hooking to navigatedTo event.
|
||||
*/
|
||||
public static navigatedToEvent: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to navigatingFrom event.
|
||||
*/
|
||||
public static navigatingFromEvent: string;
|
||||
/**
|
||||
* String value used when hooking to navigatingFrom event.
|
||||
*/
|
||||
public static navigatingFromEvent: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to navigatedFrom event.
|
||||
*/
|
||||
public static navigatedFromEvent: string;
|
||||
/**
|
||||
* String value used when hooking to navigatedFrom event.
|
||||
*/
|
||||
public static navigatedFromEvent: string;
|
||||
|
||||
/**
|
||||
* Gets or sets whether page background spans under status bar.
|
||||
*/
|
||||
public backgroundSpanUnderStatusBar: boolean;
|
||||
/**
|
||||
* Gets or sets whether page background spans under status bar.
|
||||
*/
|
||||
public backgroundSpanUnderStatusBar: boolean;
|
||||
|
||||
/**
|
||||
* Gets or sets the style of the status bar.
|
||||
*/
|
||||
public statusBarStyle: 'light' | 'dark';
|
||||
/**
|
||||
* Gets or sets the style of the status bar.
|
||||
*/
|
||||
public statusBarStyle: 'light' | 'dark';
|
||||
|
||||
/**
|
||||
* Gets or sets the color of the status bar in Android.
|
||||
*/
|
||||
public androidStatusBarBackground: Color;
|
||||
/**
|
||||
* Gets or sets the color of the status bar in Android.
|
||||
*/
|
||||
public androidStatusBarBackground: Color;
|
||||
|
||||
/**
|
||||
* Used to hide the Navigation Bar in iOS and the Action Bar in Android.
|
||||
*/
|
||||
public actionBarHidden: boolean;
|
||||
/**
|
||||
* Used to hide the Navigation Bar in iOS and the Action Bar in Android.
|
||||
*/
|
||||
public actionBarHidden: boolean;
|
||||
|
||||
/**
|
||||
* Used to control if swipe back navigation in iOS is enabled. This property is iOS specific. Default value: true
|
||||
*/
|
||||
public enableSwipeBackNavigation: boolean;
|
||||
/**
|
||||
* Used to control if swipe back navigation in iOS is enabled. This property is iOS specific. Default value: true
|
||||
*/
|
||||
public enableSwipeBackNavigation: boolean;
|
||||
|
||||
/**
|
||||
* Returns a CSS keyframe animation with the specified name, if it exists.
|
||||
*/
|
||||
public getKeyframeAnimationWithName(animationName: string): KeyframeAnimationInfo;
|
||||
/**
|
||||
* Returns a CSS keyframe animation with the specified name, if it exists.
|
||||
*/
|
||||
public getKeyframeAnimationWithName(animationName: string): KeyframeAnimationInfo;
|
||||
|
||||
/**
|
||||
* A property that is used to pass a data from another page (while navigate to).
|
||||
*/
|
||||
public navigationContext: any;
|
||||
/**
|
||||
* A property that is used to pass a data from another page (while navigate to).
|
||||
*/
|
||||
public navigationContext: any;
|
||||
|
||||
/**
|
||||
* Gets the Frame object controlling this instance.
|
||||
*/
|
||||
public frame: Frame;
|
||||
/**
|
||||
* Gets the Frame object controlling this instance.
|
||||
*/
|
||||
public frame: Frame;
|
||||
|
||||
/**
|
||||
* Gets the ActionBar for this page.
|
||||
*/
|
||||
public actionBar: ActionBar;
|
||||
/**
|
||||
* Gets the ActionBar for this page.
|
||||
*/
|
||||
public actionBar: ActionBar;
|
||||
|
||||
/**
|
||||
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
|
||||
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
|
||||
* @param callback - Callback function which will be executed when event is raised.
|
||||
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
|
||||
*/
|
||||
public on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void;
|
||||
/**
|
||||
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
|
||||
* @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
|
||||
* @param callback - Callback function which will be executed when event is raised.
|
||||
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
|
||||
*/
|
||||
public on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void;
|
||||
|
||||
/**
|
||||
* Raised when navigation to the page has started.
|
||||
*/
|
||||
public on(event: 'navigatingTo', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Raised when navigation to the page has started.
|
||||
*/
|
||||
public on(event: 'navigatingTo', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
|
||||
/**
|
||||
* Raised when navigation to the page has finished.
|
||||
*/
|
||||
public on(event: 'navigatedTo', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Raised when navigation to the page has finished.
|
||||
*/
|
||||
public on(event: 'navigatedTo', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
|
||||
/**
|
||||
* Raised when navigation from the page has started.
|
||||
*/
|
||||
public on(event: 'navigatingFrom', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
/**
|
||||
* Raised when navigation from the page has started.
|
||||
*/
|
||||
public on(event: 'navigatingFrom', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
|
||||
/**
|
||||
* Raised when navigation from the page has finished.
|
||||
*/
|
||||
public on(event: 'navigatedFrom', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
//@private
|
||||
/**
|
||||
* Raised when navigation from the page has finished.
|
||||
*/
|
||||
public on(event: 'navigatedFrom', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
//@private
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
hasActionBar: boolean;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_frame: Frame;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
hasActionBar: boolean;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_frame: Frame;
|
||||
|
||||
/**
|
||||
* A method called before navigating to the page.
|
||||
* @private
|
||||
* @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. Optional.
|
||||
*/
|
||||
public onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext?: any): void;
|
||||
/**
|
||||
* A method called before navigating to the page.
|
||||
* @private
|
||||
* @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. Optional.
|
||||
*/
|
||||
public onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext?: any): void;
|
||||
|
||||
/**
|
||||
* A method called after navigated to the page.
|
||||
* @private
|
||||
* @param isBackNavigation - True if the Page is being navigated from using the Frame.goBack() method, false otherwise.
|
||||
*/
|
||||
public onNavigatedTo(isBackNavigation: boolean): void;
|
||||
/**
|
||||
* A method called after navigated to the page.
|
||||
* @private
|
||||
* @param isBackNavigation - True if the Page is being navigated from using the Frame.goBack() method, false otherwise.
|
||||
*/
|
||||
public onNavigatedTo(isBackNavigation: boolean): void;
|
||||
|
||||
/**
|
||||
* A method called before navigating from the page.
|
||||
* @private
|
||||
* @param isBackNavigation - True if the Page is being navigated from using the Frame.goBack() method, false otherwise.
|
||||
*/
|
||||
public onNavigatingFrom(isBackNavigation: boolean): void;
|
||||
/**
|
||||
* A method called before navigating from the page.
|
||||
* @private
|
||||
* @param isBackNavigation - True if the Page is being navigated from using the Frame.goBack() method, false otherwise.
|
||||
*/
|
||||
public onNavigatingFrom(isBackNavigation: boolean): void;
|
||||
|
||||
/**
|
||||
* A method called after navigated from the page.
|
||||
* @private
|
||||
* @param isBackNavigation - True if the Page is being navigated from using the Frame.goBack() method, false otherwise.
|
||||
*/
|
||||
public onNavigatedFrom(isBackNavigation: boolean): void;
|
||||
//@endprivate
|
||||
/**
|
||||
* A method called after navigated from the page.
|
||||
* @private
|
||||
* @param isBackNavigation - True if the Page is being navigated from using the Frame.goBack() method, false otherwise.
|
||||
*/
|
||||
public onNavigatedFrom(isBackNavigation: boolean): void;
|
||||
//@endprivate
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,521 +19,521 @@ const NON_ANIMATED_TRANSITION = 'non-animated';
|
||||
const majorVersion = iosUtils.MajorVersion;
|
||||
|
||||
function isBackNavigationTo(page: Page, entry): boolean {
|
||||
const frame = page.frame;
|
||||
if (!frame) {
|
||||
return false;
|
||||
}
|
||||
const frame = page.frame;
|
||||
if (!frame) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if executing context is null here this most probably means back navigation through iOS back button
|
||||
const navigationContext = frame._executingContext || {
|
||||
navigationType: NavigationType.back,
|
||||
};
|
||||
const isReplace = navigationContext.navigationType === NavigationType.replace;
|
||||
if (isReplace) {
|
||||
return false;
|
||||
}
|
||||
// if executing context is null here this most probably means back navigation through iOS back button
|
||||
const navigationContext = frame._executingContext || {
|
||||
navigationType: NavigationType.back,
|
||||
};
|
||||
const isReplace = navigationContext.navigationType === NavigationType.replace;
|
||||
if (isReplace) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (frame.navigationQueueIsEmpty()) {
|
||||
return true;
|
||||
}
|
||||
if (frame.navigationQueueIsEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const navigationQueue = (<any>frame)._navigationQueue;
|
||||
for (let i = 0; i < navigationQueue.length; i++) {
|
||||
if (navigationQueue[i].entry === entry) {
|
||||
return navigationQueue[i].navigationType === NavigationType.back;
|
||||
}
|
||||
}
|
||||
const navigationQueue = (<any>frame)._navigationQueue;
|
||||
for (let i = 0; i < navigationQueue.length; i++) {
|
||||
if (navigationQueue[i].entry === entry) {
|
||||
return navigationQueue[i].navigationType === NavigationType.back;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
function isBackNavigationFrom(controller: UIViewControllerImpl, page: Page): boolean {
|
||||
if (!page.frame) {
|
||||
return false;
|
||||
}
|
||||
if (!page.frame) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Controller is cleared or backstack skipped
|
||||
if (controller.isBackstackCleared || controller.isBackstackSkipped) {
|
||||
return false;
|
||||
}
|
||||
// Controller is cleared or backstack skipped
|
||||
if (controller.isBackstackCleared || controller.isBackstackSkipped) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (controller.navigationController && controller.navigationController.viewControllers.containsObject(controller)) {
|
||||
return false;
|
||||
}
|
||||
if (controller.navigationController && controller.navigationController.viewControllers.containsObject(controller)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
class UIViewControllerImpl extends UIViewController {
|
||||
private _owner: WeakRef<Page>;
|
||||
private _owner: WeakRef<Page>;
|
||||
|
||||
public isBackstackSkipped: boolean;
|
||||
public isBackstackCleared: boolean;
|
||||
public isBackstackSkipped: boolean;
|
||||
public isBackstackCleared: boolean;
|
||||
|
||||
public static initWithOwner(owner: WeakRef<Page>): UIViewControllerImpl {
|
||||
const controller = <UIViewControllerImpl>UIViewControllerImpl.new();
|
||||
controller._owner = owner;
|
||||
public static initWithOwner(owner: WeakRef<Page>): UIViewControllerImpl {
|
||||
const controller = <UIViewControllerImpl>UIViewControllerImpl.new();
|
||||
controller._owner = owner;
|
||||
|
||||
return controller;
|
||||
}
|
||||
return controller;
|
||||
}
|
||||
|
||||
public viewDidLoad(): void {
|
||||
super.viewDidLoad();
|
||||
public viewDidLoad(): void {
|
||||
super.viewDidLoad();
|
||||
|
||||
// Unify translucent and opaque bars layout
|
||||
// this.edgesForExtendedLayout = UIRectEdgeBottom;
|
||||
this.extendedLayoutIncludesOpaqueBars = true;
|
||||
}
|
||||
// Unify translucent and opaque bars layout
|
||||
// this.edgesForExtendedLayout = UIRectEdgeBottom;
|
||||
this.extendedLayoutIncludesOpaqueBars = true;
|
||||
}
|
||||
|
||||
public viewWillAppear(animated: boolean): void {
|
||||
super.viewWillAppear(animated);
|
||||
const owner = this._owner.get();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
public viewWillAppear(animated: boolean): void {
|
||||
super.viewWillAppear(animated);
|
||||
const owner = this._owner.get();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
const frame = this.navigationController ? (<any>this.navigationController).owner : null;
|
||||
const newEntry = this[ENTRY];
|
||||
const frame = this.navigationController ? (<any>this.navigationController).owner : null;
|
||||
const newEntry = this[ENTRY];
|
||||
|
||||
// Don't raise event if currentPage was showing modal page.
|
||||
if (!owner._presentedViewController && newEntry && (!frame || frame.currentPage !== owner)) {
|
||||
const isBack = isBackNavigationTo(owner, newEntry);
|
||||
owner.onNavigatingTo(newEntry.entry.context, isBack, newEntry.entry.bindingContext);
|
||||
}
|
||||
// Don't raise event if currentPage was showing modal page.
|
||||
if (!owner._presentedViewController && newEntry && (!frame || frame.currentPage !== owner)) {
|
||||
const isBack = isBackNavigationTo(owner, newEntry);
|
||||
owner.onNavigatingTo(newEntry.entry.context, isBack, newEntry.entry.bindingContext);
|
||||
}
|
||||
|
||||
if (frame) {
|
||||
if (!owner.parent) {
|
||||
owner._frame = frame;
|
||||
if (!frame._styleScope) {
|
||||
// Make sure page will have styleScope even if frame don't.
|
||||
owner._updateStyleScope();
|
||||
}
|
||||
if (frame) {
|
||||
if (!owner.parent) {
|
||||
owner._frame = frame;
|
||||
if (!frame._styleScope) {
|
||||
// Make sure page will have styleScope even if frame don't.
|
||||
owner._updateStyleScope();
|
||||
}
|
||||
|
||||
frame._addView(owner);
|
||||
} else if (owner.parent !== frame) {
|
||||
throw new Error('Page is already shown on another frame.');
|
||||
}
|
||||
frame._addView(owner);
|
||||
} else if (owner.parent !== frame) {
|
||||
throw new Error('Page is already shown on another frame.');
|
||||
}
|
||||
|
||||
frame._updateActionBar(owner);
|
||||
}
|
||||
frame._updateActionBar(owner);
|
||||
}
|
||||
|
||||
// Set autoAdjustScrollInsets in will appear - as early as possible
|
||||
IOSHelper.updateAutoAdjustScrollInsets(this, owner);
|
||||
// Set autoAdjustScrollInsets in will appear - as early as possible
|
||||
IOSHelper.updateAutoAdjustScrollInsets(this, owner);
|
||||
|
||||
// Pages in backstack are unloaded so raise loaded here.
|
||||
if (!owner.isLoaded) {
|
||||
owner.callLoaded();
|
||||
} else {
|
||||
// Note: Handle the case of canceled backstack navigation. (https://github.com/NativeScript/NativeScript/issues/7430)
|
||||
// In this case viewWillAppear will be executed for the previous page and it will change the ActionBar
|
||||
// because changes happen in an interactive transition - IOS will animate between the the states.
|
||||
// If canceled - viewWillAppear will be called for the current page(which is already loaded) and we need to
|
||||
// update the action bar explicitly, so that it is not left styles as the previous page.
|
||||
owner.actionBar.update();
|
||||
}
|
||||
}
|
||||
// Pages in backstack are unloaded so raise loaded here.
|
||||
if (!owner.isLoaded) {
|
||||
owner.callLoaded();
|
||||
} else {
|
||||
// Note: Handle the case of canceled backstack navigation. (https://github.com/NativeScript/NativeScript/issues/7430)
|
||||
// In this case viewWillAppear will be executed for the previous page and it will change the ActionBar
|
||||
// because changes happen in an interactive transition - IOS will animate between the the states.
|
||||
// If canceled - viewWillAppear will be called for the current page(which is already loaded) and we need to
|
||||
// update the action bar explicitly, so that it is not left styles as the previous page.
|
||||
owner.actionBar.update();
|
||||
}
|
||||
}
|
||||
|
||||
@profile
|
||||
public viewDidAppear(animated: boolean): void {
|
||||
super.viewDidAppear(animated);
|
||||
@profile
|
||||
public viewDidAppear(animated: boolean): void {
|
||||
super.viewDidAppear(animated);
|
||||
|
||||
const owner = this._owner.get();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
const owner = this._owner.get();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
const navigationController = this.navigationController;
|
||||
const frame: Frame = navigationController ? (<any>navigationController).owner : null;
|
||||
// Skip navigation events if modal page is shown.
|
||||
if (!owner._presentedViewController && frame) {
|
||||
const newEntry: BackstackEntry = this[ENTRY];
|
||||
const navigationController = this.navigationController;
|
||||
const frame: Frame = navigationController ? (<any>navigationController).owner : null;
|
||||
// Skip navigation events if modal page is shown.
|
||||
if (!owner._presentedViewController && frame) {
|
||||
const newEntry: BackstackEntry = this[ENTRY];
|
||||
|
||||
// frame.setCurrent(...) will reset executing context so retrieve it here
|
||||
// if executing context is null here this most probably means back navigation through iOS back button
|
||||
const navigationContext = frame._executingContext || {
|
||||
navigationType: NavigationType.back,
|
||||
};
|
||||
const isReplace = navigationContext.navigationType === NavigationType.replace;
|
||||
// frame.setCurrent(...) will reset executing context so retrieve it here
|
||||
// if executing context is null here this most probably means back navigation through iOS back button
|
||||
const navigationContext = frame._executingContext || {
|
||||
navigationType: NavigationType.back,
|
||||
};
|
||||
const isReplace = navigationContext.navigationType === NavigationType.replace;
|
||||
|
||||
frame.setCurrent(newEntry, navigationContext.navigationType);
|
||||
frame.setCurrent(newEntry, navigationContext.navigationType);
|
||||
|
||||
if (isReplace) {
|
||||
let controller = newEntry.resolvedPage.ios;
|
||||
if (controller) {
|
||||
const animated = frame._getIsAnimatedNavigation(newEntry.entry);
|
||||
if (animated) {
|
||||
controller[TRANSITION] = frame._getNavigationTransition(newEntry.entry);
|
||||
} else {
|
||||
controller[TRANSITION] = {
|
||||
name: NON_ANIMATED_TRANSITION,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isReplace) {
|
||||
let controller = newEntry.resolvedPage.ios;
|
||||
if (controller) {
|
||||
const animated = frame._getIsAnimatedNavigation(newEntry.entry);
|
||||
if (animated) {
|
||||
controller[TRANSITION] = frame._getNavigationTransition(newEntry.entry);
|
||||
} else {
|
||||
controller[TRANSITION] = {
|
||||
name: NON_ANIMATED_TRANSITION,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If page was shown with custom animation - we need to set the navigationController.delegate to the animatedDelegate.
|
||||
frame.ios.controller.delegate = this[DELEGATE];
|
||||
// If page was shown with custom animation - we need to set the navigationController.delegate to the animatedDelegate.
|
||||
frame.ios.controller.delegate = this[DELEGATE];
|
||||
|
||||
frame._processNavigationQueue(owner);
|
||||
frame._processNavigationQueue(owner);
|
||||
|
||||
// _processNavigationQueue will shift navigationQueue. Check canGoBack after that.
|
||||
// Workaround for disabled backswipe on second custom native transition
|
||||
if (frame.canGoBack()) {
|
||||
navigationController.interactivePopGestureRecognizer.delegate = navigationController;
|
||||
navigationController.interactivePopGestureRecognizer.enabled = owner.enableSwipeBackNavigation;
|
||||
} else {
|
||||
navigationController.interactivePopGestureRecognizer.enabled = false;
|
||||
}
|
||||
}
|
||||
// _processNavigationQueue will shift navigationQueue. Check canGoBack after that.
|
||||
// Workaround for disabled backswipe on second custom native transition
|
||||
if (frame.canGoBack()) {
|
||||
navigationController.interactivePopGestureRecognizer.delegate = navigationController;
|
||||
navigationController.interactivePopGestureRecognizer.enabled = owner.enableSwipeBackNavigation;
|
||||
} else {
|
||||
navigationController.interactivePopGestureRecognizer.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.presentedViewController) {
|
||||
// clear presented viewController here only if no presented controller.
|
||||
// this is needed because in iOS9 the order of events could be - willAppear, willDisappear, didAppear.
|
||||
// If we clean it when we have viewController then once presented VC is dismissed then
|
||||
owner._presentedViewController = null;
|
||||
}
|
||||
}
|
||||
if (!this.presentedViewController) {
|
||||
// clear presented viewController here only if no presented controller.
|
||||
// this is needed because in iOS9 the order of events could be - willAppear, willDisappear, didAppear.
|
||||
// If we clean it when we have viewController then once presented VC is dismissed then
|
||||
owner._presentedViewController = null;
|
||||
}
|
||||
}
|
||||
|
||||
@profile
|
||||
public viewWillDisappear(animated: boolean): void {
|
||||
super.viewWillDisappear(animated);
|
||||
@profile
|
||||
public viewWillDisappear(animated: boolean): void {
|
||||
super.viewWillDisappear(animated);
|
||||
|
||||
const owner = this._owner.get();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
const owner = this._owner.get();
|
||||
if (!owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache presentedViewController if any. We don't want to raise
|
||||
// navigation events in case of presenting view controller.
|
||||
if (!owner._presentedViewController) {
|
||||
owner._presentedViewController = this.presentedViewController;
|
||||
}
|
||||
// Cache presentedViewController if any. We don't want to raise
|
||||
// navigation events in case of presenting view controller.
|
||||
if (!owner._presentedViewController) {
|
||||
owner._presentedViewController = this.presentedViewController;
|
||||
}
|
||||
|
||||
const frame = owner.frame;
|
||||
// Skip navigation events if we are hiding because we are about to show a modal page,
|
||||
// or because we are closing a modal page,
|
||||
// or because we are in tab and another controller is selected.
|
||||
const tab = this.tabBarController;
|
||||
if (owner.onNavigatingFrom && !owner._presentedViewController && !this.presentingViewController && frame && frame.currentPage === owner) {
|
||||
const willSelectViewController = tab && (<any>tab)._willSelectViewController;
|
||||
if (!willSelectViewController || willSelectViewController === tab.selectedViewController) {
|
||||
const isBack = isBackNavigationFrom(this, owner);
|
||||
owner.onNavigatingFrom(isBack);
|
||||
}
|
||||
}
|
||||
}
|
||||
const frame = owner.frame;
|
||||
// Skip navigation events if we are hiding because we are about to show a modal page,
|
||||
// or because we are closing a modal page,
|
||||
// or because we are in tab and another controller is selected.
|
||||
const tab = this.tabBarController;
|
||||
if (owner.onNavigatingFrom && !owner._presentedViewController && !this.presentingViewController && frame && frame.currentPage === owner) {
|
||||
const willSelectViewController = tab && (<any>tab)._willSelectViewController;
|
||||
if (!willSelectViewController || willSelectViewController === tab.selectedViewController) {
|
||||
const isBack = isBackNavigationFrom(this, owner);
|
||||
owner.onNavigatingFrom(isBack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@profile
|
||||
public viewDidDisappear(animated: boolean): void {
|
||||
super.viewDidDisappear(animated);
|
||||
@profile
|
||||
public viewDidDisappear(animated: boolean): void {
|
||||
super.viewDidDisappear(animated);
|
||||
|
||||
const page = this._owner.get();
|
||||
// Exit if no page or page is hiding because it shows another page modally.
|
||||
if (!page || page.modal || page._presentedViewController) {
|
||||
return;
|
||||
}
|
||||
// Forward navigation does not remove page from frame so we raise unloaded manually.
|
||||
if (page.isLoaded) {
|
||||
page.callUnloaded();
|
||||
}
|
||||
}
|
||||
const page = this._owner.get();
|
||||
// Exit if no page or page is hiding because it shows another page modally.
|
||||
if (!page || page.modal || page._presentedViewController) {
|
||||
return;
|
||||
}
|
||||
// Forward navigation does not remove page from frame so we raise unloaded manually.
|
||||
if (page.isLoaded) {
|
||||
page.callUnloaded();
|
||||
}
|
||||
}
|
||||
|
||||
public viewWillLayoutSubviews(): void {
|
||||
super.viewWillLayoutSubviews();
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
IOSHelper.updateConstraints(this, owner);
|
||||
}
|
||||
}
|
||||
public viewWillLayoutSubviews(): void {
|
||||
super.viewWillLayoutSubviews();
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
IOSHelper.updateConstraints(this, owner);
|
||||
}
|
||||
}
|
||||
|
||||
public viewDidLayoutSubviews(): void {
|
||||
super.viewDidLayoutSubviews();
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
// layout(owner.actionBar)
|
||||
// layout(owner.content)
|
||||
public viewDidLayoutSubviews(): void {
|
||||
super.viewDidLayoutSubviews();
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
// layout(owner.actionBar)
|
||||
// layout(owner.content)
|
||||
|
||||
if (majorVersion >= 11) {
|
||||
// Handle nested Page safe area insets application.
|
||||
// A Page is nested if its Frame has a parent.
|
||||
// If the Page is nested, cross check safe area insets on top and bottom with Frame parent.
|
||||
const frame = owner.parent;
|
||||
// There is a legacy scenario where Page is not in a Frame - the root of a Modal View, so it has no parent.
|
||||
let frameParent = frame && frame.parent;
|
||||
if (majorVersion >= 11) {
|
||||
// Handle nested Page safe area insets application.
|
||||
// A Page is nested if its Frame has a parent.
|
||||
// If the Page is nested, cross check safe area insets on top and bottom with Frame parent.
|
||||
const frame = owner.parent;
|
||||
// There is a legacy scenario where Page is not in a Frame - the root of a Modal View, so it has no parent.
|
||||
let frameParent = frame && frame.parent;
|
||||
|
||||
// Handle Angular scenario where TabView is in a ProxyViewContainer
|
||||
// It is possible to wrap components in ProxyViewContainers indefinitely
|
||||
// Not using instanceof ProxyViewContainer to avoid circular dependency
|
||||
// TODO: Try moving UIViewControllerImpl out of page module
|
||||
while (frameParent && !frameParent.nativeViewProtected) {
|
||||
frameParent = frameParent.parent;
|
||||
}
|
||||
// Handle Angular scenario where TabView is in a ProxyViewContainer
|
||||
// It is possible to wrap components in ProxyViewContainers indefinitely
|
||||
// Not using instanceof ProxyViewContainer to avoid circular dependency
|
||||
// TODO: Try moving UIViewControllerImpl out of page module
|
||||
while (frameParent && !frameParent.nativeViewProtected) {
|
||||
frameParent = frameParent.parent;
|
||||
}
|
||||
|
||||
if (frameParent) {
|
||||
const parentPageInsetsTop = frameParent.nativeViewProtected.safeAreaInsets.top;
|
||||
const currentInsetsTop = this.view.safeAreaInsets.top;
|
||||
const additionalInsetsTop = Math.max(parentPageInsetsTop - currentInsetsTop, 0);
|
||||
if (frameParent) {
|
||||
const parentPageInsetsTop = frameParent.nativeViewProtected.safeAreaInsets.top;
|
||||
const currentInsetsTop = this.view.safeAreaInsets.top;
|
||||
const additionalInsetsTop = Math.max(parentPageInsetsTop - currentInsetsTop, 0);
|
||||
|
||||
const parentPageInsetsBottom = frameParent.nativeViewProtected.safeAreaInsets.bottom;
|
||||
const currentInsetsBottom = this.view.safeAreaInsets.bottom;
|
||||
const additionalInsetsBottom = Math.max(parentPageInsetsBottom - currentInsetsBottom, 0);
|
||||
const parentPageInsetsBottom = frameParent.nativeViewProtected.safeAreaInsets.bottom;
|
||||
const currentInsetsBottom = this.view.safeAreaInsets.bottom;
|
||||
const additionalInsetsBottom = Math.max(parentPageInsetsBottom - currentInsetsBottom, 0);
|
||||
|
||||
if (additionalInsetsTop > 0 || additionalInsetsBottom > 0) {
|
||||
const additionalInsets = new UIEdgeInsets({
|
||||
top: additionalInsetsTop,
|
||||
left: 0,
|
||||
bottom: additionalInsetsBottom,
|
||||
right: 0,
|
||||
});
|
||||
this.additionalSafeAreaInsets = additionalInsets;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (additionalInsetsTop > 0 || additionalInsetsBottom > 0) {
|
||||
const additionalInsets = new UIEdgeInsets({
|
||||
top: additionalInsetsTop,
|
||||
left: 0,
|
||||
bottom: additionalInsetsBottom,
|
||||
right: 0,
|
||||
});
|
||||
this.additionalSafeAreaInsets = additionalInsets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IOSHelper.layoutView(this, owner);
|
||||
}
|
||||
}
|
||||
IOSHelper.layoutView(this, owner);
|
||||
}
|
||||
}
|
||||
|
||||
// Mind implementation for other controllerss
|
||||
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
|
||||
super.traitCollectionDidChange(previousTraitCollection);
|
||||
// Mind implementation for other controllerss
|
||||
public traitCollectionDidChange(previousTraitCollection: UITraitCollection): void {
|
||||
super.traitCollectionDidChange(previousTraitCollection);
|
||||
|
||||
if (majorVersion >= 13) {
|
||||
const owner = this._owner.get();
|
||||
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
owner.notify({
|
||||
eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent,
|
||||
object: owner,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (majorVersion >= 13) {
|
||||
const owner = this._owner.get();
|
||||
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
owner.notify({
|
||||
eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent,
|
||||
object: owner,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public get preferredStatusBarStyle(): UIStatusBarStyle {
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
return owner.statusBarStyle === 'dark' ? UIStatusBarStyle.LightContent : UIStatusBarStyle.Default;
|
||||
} else {
|
||||
return UIStatusBarStyle.Default;
|
||||
}
|
||||
}
|
||||
public get preferredStatusBarStyle(): UIStatusBarStyle {
|
||||
const owner = this._owner.get();
|
||||
if (owner) {
|
||||
return owner.statusBarStyle === 'dark' ? UIStatusBarStyle.LightContent : UIStatusBarStyle.Default;
|
||||
} else {
|
||||
return UIStatusBarStyle.Default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class Page extends PageBase {
|
||||
nativeViewProtected: UIView;
|
||||
viewController: UIViewControllerImpl;
|
||||
nativeViewProtected: UIView;
|
||||
viewController: UIViewControllerImpl;
|
||||
|
||||
private _backgroundColor = majorVersion <= 12 && !UIColor.systemBackgroundColor ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
private _ios: UIViewControllerImpl;
|
||||
public _presentedViewController: UIViewController; // used when our page present native viewController without going through our abstraction.
|
||||
private _backgroundColor = majorVersion <= 12 && !UIColor.systemBackgroundColor ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
private _ios: UIViewControllerImpl;
|
||||
public _presentedViewController: UIViewController; // used when our page present native viewController without going through our abstraction.
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
const controller = UIViewControllerImpl.initWithOwner(new WeakRef(this));
|
||||
this.viewController = this._ios = controller;
|
||||
constructor() {
|
||||
super();
|
||||
const controller = UIViewControllerImpl.initWithOwner(new WeakRef(this));
|
||||
this.viewController = this._ios = controller;
|
||||
|
||||
// Make transitions look good
|
||||
controller.view.backgroundColor = this._backgroundColor;
|
||||
}
|
||||
// Make transitions look good
|
||||
controller.view.backgroundColor = this._backgroundColor;
|
||||
}
|
||||
|
||||
createNativeView() {
|
||||
return this.viewController.view;
|
||||
}
|
||||
createNativeView() {
|
||||
return this.viewController.view;
|
||||
}
|
||||
|
||||
get ios(): UIViewController {
|
||||
return this._ios;
|
||||
}
|
||||
get ios(): UIViewController {
|
||||
return this._ios;
|
||||
}
|
||||
|
||||
get frame(): Frame {
|
||||
return this._frame;
|
||||
}
|
||||
get frame(): Frame {
|
||||
return this._frame;
|
||||
}
|
||||
|
||||
public layoutNativeView(left: number, top: number, right: number, bottom: number): void {
|
||||
//
|
||||
}
|
||||
public layoutNativeView(left: number, top: number, right: number, bottom: number): void {
|
||||
//
|
||||
}
|
||||
|
||||
public _setNativeViewFrame(nativeView: UIView, frame: CGRect) {
|
||||
//
|
||||
}
|
||||
public _setNativeViewFrame(nativeView: UIView, frame: CGRect) {
|
||||
//
|
||||
}
|
||||
|
||||
public _shouldDelayLayout(): boolean {
|
||||
return this._frame && this._frame._animationInProgress;
|
||||
}
|
||||
public _shouldDelayLayout(): boolean {
|
||||
return this._frame && this._frame._animationInProgress;
|
||||
}
|
||||
|
||||
public onLoaded(): void {
|
||||
super.onLoaded();
|
||||
if (this.hasActionBar) {
|
||||
this.actionBar.update();
|
||||
}
|
||||
}
|
||||
public onLoaded(): void {
|
||||
super.onLoaded();
|
||||
if (this.hasActionBar) {
|
||||
this.actionBar.update();
|
||||
}
|
||||
}
|
||||
|
||||
public updateStatusBar() {
|
||||
this._updateStatusBarStyle(this.statusBarStyle);
|
||||
}
|
||||
public updateStatusBar() {
|
||||
this._updateStatusBarStyle(this.statusBarStyle);
|
||||
}
|
||||
|
||||
public _updateStatusBarStyle(value?: string) {
|
||||
const frame = this.frame;
|
||||
if (this.frame && value) {
|
||||
const navigationController: UINavigationController = frame.ios.controller;
|
||||
const navigationBar = navigationController.navigationBar;
|
||||
public _updateStatusBarStyle(value?: string) {
|
||||
const frame = this.frame;
|
||||
if (this.frame && value) {
|
||||
const navigationController: UINavigationController = frame.ios.controller;
|
||||
const navigationBar = navigationController.navigationBar;
|
||||
|
||||
navigationBar.barStyle = value === 'dark' ? UIBarStyle.Black : UIBarStyle.Default;
|
||||
}
|
||||
}
|
||||
navigationBar.barStyle = value === 'dark' ? UIBarStyle.Black : UIBarStyle.Default;
|
||||
}
|
||||
}
|
||||
|
||||
public _updateEnableSwipeBackNavigation(enabled: boolean) {
|
||||
const navController = this._ios.navigationController;
|
||||
if (this.frame && navController && navController.interactivePopGestureRecognizer) {
|
||||
// Make sure we don't set true if cannot go back
|
||||
enabled = enabled && this.frame.canGoBack();
|
||||
navController.interactivePopGestureRecognizer.enabled = enabled;
|
||||
}
|
||||
}
|
||||
public _updateEnableSwipeBackNavigation(enabled: boolean) {
|
||||
const navController = this._ios.navigationController;
|
||||
if (this.frame && navController && navController.interactivePopGestureRecognizer) {
|
||||
// Make sure we don't set true if cannot go back
|
||||
enabled = enabled && this.frame.canGoBack();
|
||||
navController.interactivePopGestureRecognizer.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number) {
|
||||
const width = layout.getMeasureSpecSize(widthMeasureSpec);
|
||||
const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
|
||||
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number) {
|
||||
const width = layout.getMeasureSpecSize(widthMeasureSpec);
|
||||
const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
|
||||
|
||||
const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
||||
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
||||
const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
||||
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
||||
|
||||
if (this.frame && this.frame._getNavBarVisible(this)) {
|
||||
const { width, height } = this.actionBar._getActualSize;
|
||||
const widthSpec = layout.makeMeasureSpec(width, layout.EXACTLY);
|
||||
const heightSpec = layout.makeMeasureSpec(height, layout.EXACTLY);
|
||||
View.measureChild(this, this.actionBar, widthSpec, heightSpec);
|
||||
}
|
||||
if (this.frame && this.frame._getNavBarVisible(this)) {
|
||||
const { width, height } = this.actionBar._getActualSize;
|
||||
const widthSpec = layout.makeMeasureSpec(width, layout.EXACTLY);
|
||||
const heightSpec = layout.makeMeasureSpec(height, layout.EXACTLY);
|
||||
View.measureChild(this, this.actionBar, widthSpec, heightSpec);
|
||||
}
|
||||
|
||||
const result = View.measureChild(this, this.layoutView, widthMeasureSpec, heightMeasureSpec);
|
||||
const result = View.measureChild(this, this.layoutView, widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
const measureWidth = Math.max(result.measuredWidth, this.effectiveMinWidth);
|
||||
const measureHeight = Math.max(result.measuredHeight, this.effectiveMinHeight);
|
||||
const measureWidth = Math.max(result.measuredWidth, this.effectiveMinWidth);
|
||||
const measureHeight = Math.max(result.measuredHeight, this.effectiveMinHeight);
|
||||
|
||||
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||
|
||||
this.setMeasuredDimension(widthAndState, heightAndState);
|
||||
}
|
||||
this.setMeasuredDimension(widthAndState, heightAndState);
|
||||
}
|
||||
|
||||
public onLayout(left: number, top: number, right: number, bottom: number) {
|
||||
const { width: actionBarWidth, height: actionBarHeight } = this.actionBar._getActualSize;
|
||||
View.layoutChild(this, this.actionBar, 0, 0, actionBarWidth, actionBarHeight);
|
||||
public onLayout(left: number, top: number, right: number, bottom: number) {
|
||||
const { width: actionBarWidth, height: actionBarHeight } = this.actionBar._getActualSize;
|
||||
View.layoutChild(this, this.actionBar, 0, 0, actionBarWidth, actionBarHeight);
|
||||
|
||||
const insets = this.getSafeAreaInsets();
|
||||
const insets = this.getSafeAreaInsets();
|
||||
|
||||
if (majorVersion <= 10) {
|
||||
// iOS 10 and below don't have safe area insets API,
|
||||
// there we need only the top inset on the Page
|
||||
insets.top = layout.round(layout.toDevicePixels(this.viewController.view.safeAreaLayoutGuide.layoutFrame.origin.y));
|
||||
}
|
||||
if (majorVersion <= 10) {
|
||||
// iOS 10 and below don't have safe area insets API,
|
||||
// there we need only the top inset on the Page
|
||||
insets.top = layout.round(layout.toDevicePixels(this.viewController.view.safeAreaLayoutGuide.layoutFrame.origin.y));
|
||||
}
|
||||
|
||||
const childLeft = 0 + insets.left;
|
||||
const childTop = 0 + insets.top;
|
||||
const childRight = right - insets.right;
|
||||
let childBottom = bottom - insets.bottom;
|
||||
const childLeft = 0 + insets.left;
|
||||
const childTop = 0 + insets.top;
|
||||
const childRight = right - insets.right;
|
||||
let childBottom = bottom - insets.bottom;
|
||||
|
||||
View.layoutChild(this, this.layoutView, childLeft, childTop, childRight, childBottom);
|
||||
}
|
||||
View.layoutChild(this, this.layoutView, childLeft, childTop, childRight, childBottom);
|
||||
}
|
||||
|
||||
public _addViewToNativeVisualTree(child: View, atIndex: number): boolean {
|
||||
// ActionBar is handled by the UINavigationController
|
||||
if (child === this.actionBar) {
|
||||
return true;
|
||||
}
|
||||
public _addViewToNativeVisualTree(child: View, atIndex: number): boolean {
|
||||
// ActionBar is handled by the UINavigationController
|
||||
if (child === this.actionBar) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const nativeParent = this.nativeViewProtected;
|
||||
const nativeChild = child.nativeViewProtected;
|
||||
const nativeParent = this.nativeViewProtected;
|
||||
const nativeChild = child.nativeViewProtected;
|
||||
|
||||
const viewController = child.ios instanceof UIViewController ? child.ios : child.viewController;
|
||||
if (viewController) {
|
||||
// Adding modal controllers to as child will make app freeze.
|
||||
if (this.viewController.presentedViewController === viewController) {
|
||||
return true;
|
||||
}
|
||||
const viewController = child.ios instanceof UIViewController ? child.ios : child.viewController;
|
||||
if (viewController) {
|
||||
// Adding modal controllers to as child will make app freeze.
|
||||
if (this.viewController.presentedViewController === viewController) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this.viewController.addChildViewController(viewController);
|
||||
}
|
||||
this.viewController.addChildViewController(viewController);
|
||||
}
|
||||
|
||||
if (nativeParent && nativeChild) {
|
||||
if (typeof atIndex !== 'number' || atIndex >= nativeParent.subviews.count) {
|
||||
nativeParent.addSubview(nativeChild);
|
||||
} else {
|
||||
nativeParent.insertSubviewAtIndex(nativeChild, atIndex);
|
||||
}
|
||||
if (nativeParent && nativeChild) {
|
||||
if (typeof atIndex !== 'number' || atIndex >= nativeParent.subviews.count) {
|
||||
nativeParent.addSubview(nativeChild);
|
||||
} else {
|
||||
nativeParent.insertSubviewAtIndex(nativeChild, atIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public _removeViewFromNativeVisualTree(child: View): void {
|
||||
// ActionBar is handled by the UINavigationController
|
||||
if (child === this.actionBar) {
|
||||
return;
|
||||
}
|
||||
public _removeViewFromNativeVisualTree(child: View): void {
|
||||
// ActionBar is handled by the UINavigationController
|
||||
if (child === this.actionBar) {
|
||||
return;
|
||||
}
|
||||
|
||||
const viewController = child.ios instanceof UIViewController ? child.ios : child.viewController;
|
||||
if (viewController) {
|
||||
viewController.removeFromParentViewController();
|
||||
}
|
||||
const viewController = child.ios instanceof UIViewController ? child.ios : child.viewController;
|
||||
if (viewController) {
|
||||
viewController.removeFromParentViewController();
|
||||
}
|
||||
|
||||
super._removeViewFromNativeVisualTree(child);
|
||||
}
|
||||
super._removeViewFromNativeVisualTree(child);
|
||||
}
|
||||
|
||||
[actionBarHiddenProperty.setNative](value: boolean) {
|
||||
this._updateEnableSwipeBackNavigation(value);
|
||||
[actionBarHiddenProperty.setNative](value: boolean) {
|
||||
this._updateEnableSwipeBackNavigation(value);
|
||||
|
||||
// Invalidate all inner controller.
|
||||
invalidateTopmostController(this.viewController);
|
||||
// Invalidate all inner controller.
|
||||
invalidateTopmostController(this.viewController);
|
||||
|
||||
const frame = this.frame;
|
||||
if (frame) {
|
||||
// Update nav-bar visibility with disabled animations
|
||||
frame._updateActionBar(this, true);
|
||||
}
|
||||
}
|
||||
const frame = this.frame;
|
||||
if (frame) {
|
||||
// Update nav-bar visibility with disabled animations
|
||||
frame._updateActionBar(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
[statusBarStyleProperty.getDefault](): UIBarStyle {
|
||||
return UIBarStyle.Default;
|
||||
}
|
||||
[statusBarStyleProperty.setNative](value: string | UIBarStyle) {
|
||||
const frame = this.frame;
|
||||
if (frame) {
|
||||
const navigationBar = (<UINavigationController>frame.ios.controller).navigationBar;
|
||||
if (typeof value === 'string') {
|
||||
navigationBar.barStyle = value === 'dark' ? UIBarStyle.Black : UIBarStyle.Default;
|
||||
} else {
|
||||
navigationBar.barStyle = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
[statusBarStyleProperty.getDefault](): UIBarStyle {
|
||||
return UIBarStyle.Default;
|
||||
}
|
||||
[statusBarStyleProperty.setNative](value: string | UIBarStyle) {
|
||||
const frame = this.frame;
|
||||
if (frame) {
|
||||
const navigationBar = (<UINavigationController>frame.ios.controller).navigationBar;
|
||||
if (typeof value === 'string') {
|
||||
navigationBar.barStyle = value === 'dark' ? UIBarStyle.Black : UIBarStyle.Default;
|
||||
} else {
|
||||
navigationBar.barStyle = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function invalidateTopmostController(controller: UIViewController): void {
|
||||
if (!controller) {
|
||||
return;
|
||||
}
|
||||
if (!controller) {
|
||||
return;
|
||||
}
|
||||
|
||||
controller.view.setNeedsLayout();
|
||||
controller.view.setNeedsLayout();
|
||||
|
||||
const presentedViewController = controller.presentedViewController;
|
||||
if (presentedViewController) {
|
||||
return invalidateTopmostController(presentedViewController);
|
||||
}
|
||||
const presentedViewController = controller.presentedViewController;
|
||||
if (presentedViewController) {
|
||||
return invalidateTopmostController(presentedViewController);
|
||||
}
|
||||
|
||||
const childControllers = controller.childViewControllers;
|
||||
let size = controller.childViewControllers.count;
|
||||
while (size > 0) {
|
||||
const childController = childControllers[--size];
|
||||
if (childController instanceof UITabBarController) {
|
||||
invalidateTopmostController(childController.selectedViewController);
|
||||
} else if (childController instanceof UINavigationController) {
|
||||
invalidateTopmostController(childController.topViewController);
|
||||
} else if (childController instanceof UISplitViewController) {
|
||||
invalidateTopmostController(childController.viewControllers.lastObject);
|
||||
} else {
|
||||
invalidateTopmostController(childController);
|
||||
}
|
||||
}
|
||||
const childControllers = controller.childViewControllers;
|
||||
let size = controller.childViewControllers.count;
|
||||
while (size > 0) {
|
||||
const childController = childControllers[--size];
|
||||
if (childController instanceof UITabBarController) {
|
||||
invalidateTopmostController(childController.selectedViewController);
|
||||
} else if (childController instanceof UINavigationController) {
|
||||
invalidateTopmostController(childController.topViewController);
|
||||
} else if (childController instanceof UISplitViewController) {
|
||||
invalidateTopmostController(childController.viewControllers.lastObject);
|
||||
} else {
|
||||
invalidateTopmostController(childController);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
nativescript-core/ui/page/page-common.d.ts
vendored
60
nativescript-core/ui/page/page-common.d.ts
vendored
@@ -7,46 +7,46 @@ import { Color } from '../../color';
|
||||
import { ActionBar } from '../action-bar';
|
||||
import { View } from '../core/view';
|
||||
export declare class PageBase extends ContentView {
|
||||
static navigatingToEvent: string;
|
||||
static navigatedToEvent: string;
|
||||
static navigatingFromEvent: string;
|
||||
static navigatedFromEvent: string;
|
||||
_frame: Frame;
|
||||
actionBarHidden: boolean;
|
||||
enableSwipeBackNavigation: boolean;
|
||||
backgroundSpanUnderStatusBar: boolean;
|
||||
hasActionBar: boolean;
|
||||
readonly navigationContext: any;
|
||||
static navigatingToEvent: string;
|
||||
static navigatedToEvent: string;
|
||||
static navigatingFromEvent: string;
|
||||
static navigatedFromEvent: string;
|
||||
_frame: Frame;
|
||||
actionBarHidden: boolean;
|
||||
enableSwipeBackNavigation: boolean;
|
||||
backgroundSpanUnderStatusBar: boolean;
|
||||
hasActionBar: boolean;
|
||||
readonly navigationContext: any;
|
||||
|
||||
actionBar: ActionBar;
|
||||
actionBar: ActionBar;
|
||||
|
||||
statusBarStyle: 'light' | 'dark';
|
||||
androidStatusBarBackground: Color;
|
||||
statusBarStyle: 'light' | 'dark';
|
||||
androidStatusBarBackground: Color;
|
||||
|
||||
readonly page: PageDefinition;
|
||||
readonly page: PageDefinition;
|
||||
|
||||
_addChildFromBuilder(name: string, value: any): void;
|
||||
_addChildFromBuilder(name: string, value: any): void;
|
||||
|
||||
getKeyframeAnimationWithName(animationName: string): KeyframeAnimationInfo;
|
||||
getKeyframeAnimationWithName(animationName: string): KeyframeAnimationInfo;
|
||||
|
||||
readonly frame: Frame;
|
||||
readonly frame: Frame;
|
||||
|
||||
createNavigatedData(eventName: string, isBackNavigation: boolean): NavigatedData {
|
||||
return {
|
||||
eventName: eventName,
|
||||
object: this,
|
||||
context: this.navigationContext,
|
||||
isBackNavigation: isBackNavigation,
|
||||
};
|
||||
}
|
||||
createNavigatedData(eventName: string, isBackNavigation: boolean): NavigatedData {
|
||||
return {
|
||||
eventName: eventName,
|
||||
object: this,
|
||||
context: this.navigationContext,
|
||||
isBackNavigation: isBackNavigation,
|
||||
};
|
||||
}
|
||||
|
||||
onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext?: any): void;
|
||||
onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext?: any): void;
|
||||
|
||||
onNavigatedTo(isBackNavigation: boolean): void;
|
||||
onNavigatedTo(isBackNavigation: boolean): void;
|
||||
|
||||
onNavigatingFrom(isBackNavigation: boolean): void;
|
||||
onNavigatingFrom(isBackNavigation: boolean): void;
|
||||
|
||||
onNavigatedFrom(isBackNavigation: boolean): void;
|
||||
onNavigatedFrom(isBackNavigation: boolean): void;
|
||||
|
||||
eachChildView(callback: (child: View) => boolean): void;
|
||||
eachChildView(callback: (child: View) => boolean): void;
|
||||
}
|
||||
|
||||
@@ -13,166 +13,166 @@ import { KeyframeAnimationInfo } from '../animation/keyframe-animation';
|
||||
import { profile } from '../../profiling';
|
||||
|
||||
interface NavigatedData extends EventData {
|
||||
context: any;
|
||||
isBackNavigation: boolean;
|
||||
context: any;
|
||||
isBackNavigation: boolean;
|
||||
}
|
||||
|
||||
@CSSType('Page')
|
||||
export class PageBase extends ContentView {
|
||||
public static navigatingToEvent = 'navigatingTo';
|
||||
public static navigatedToEvent = 'navigatedTo';
|
||||
public static navigatingFromEvent = 'navigatingFrom';
|
||||
public static navigatedFromEvent = 'navigatedFrom';
|
||||
public static navigatingToEvent = 'navigatingTo';
|
||||
public static navigatedToEvent = 'navigatedTo';
|
||||
public static navigatingFromEvent = 'navigatingFrom';
|
||||
public static navigatedFromEvent = 'navigatedFrom';
|
||||
|
||||
private _navigationContext: any;
|
||||
private _actionBar: ActionBar;
|
||||
private _navigationContext: any;
|
||||
private _actionBar: ActionBar;
|
||||
|
||||
public _frame: Frame;
|
||||
public _frame: Frame;
|
||||
|
||||
public actionBarHidden: boolean;
|
||||
public enableSwipeBackNavigation: boolean;
|
||||
public backgroundSpanUnderStatusBar: boolean;
|
||||
public hasActionBar: boolean;
|
||||
public actionBarHidden: boolean;
|
||||
public enableSwipeBackNavigation: boolean;
|
||||
public backgroundSpanUnderStatusBar: boolean;
|
||||
public hasActionBar: boolean;
|
||||
|
||||
get navigationContext(): any {
|
||||
return this._navigationContext;
|
||||
}
|
||||
get navigationContext(): any {
|
||||
return this._navigationContext;
|
||||
}
|
||||
|
||||
get actionBar(): ActionBar {
|
||||
if (!this._actionBar) {
|
||||
this.hasActionBar = true;
|
||||
this._actionBar = new ActionBar();
|
||||
this._addView(this._actionBar);
|
||||
}
|
||||
get actionBar(): ActionBar {
|
||||
if (!this._actionBar) {
|
||||
this.hasActionBar = true;
|
||||
this._actionBar = new ActionBar();
|
||||
this._addView(this._actionBar);
|
||||
}
|
||||
|
||||
return this._actionBar;
|
||||
}
|
||||
set actionBar(value: ActionBar) {
|
||||
if (!value) {
|
||||
throw new Error('ActionBar cannot be null or undefined.');
|
||||
}
|
||||
return this._actionBar;
|
||||
}
|
||||
set actionBar(value: ActionBar) {
|
||||
if (!value) {
|
||||
throw new Error('ActionBar cannot be null or undefined.');
|
||||
}
|
||||
|
||||
if (this._actionBar !== value) {
|
||||
if (this._actionBar) {
|
||||
this._removeView(this._actionBar);
|
||||
}
|
||||
this.hasActionBar = true;
|
||||
this._actionBar = value;
|
||||
this._addView(this._actionBar);
|
||||
}
|
||||
}
|
||||
if (this._actionBar !== value) {
|
||||
if (this._actionBar) {
|
||||
this._removeView(this._actionBar);
|
||||
}
|
||||
this.hasActionBar = true;
|
||||
this._actionBar = value;
|
||||
this._addView(this._actionBar);
|
||||
}
|
||||
}
|
||||
|
||||
get statusBarStyle(): 'light' | 'dark' {
|
||||
return this.style.statusBarStyle;
|
||||
}
|
||||
set statusBarStyle(value: 'light' | 'dark') {
|
||||
this.style.statusBarStyle = value;
|
||||
}
|
||||
get statusBarStyle(): 'light' | 'dark' {
|
||||
return this.style.statusBarStyle;
|
||||
}
|
||||
set statusBarStyle(value: 'light' | 'dark') {
|
||||
this.style.statusBarStyle = value;
|
||||
}
|
||||
|
||||
public get androidStatusBarBackground(): Color {
|
||||
return this.style.androidStatusBarBackground;
|
||||
}
|
||||
public set androidStatusBarBackground(value: Color) {
|
||||
this.style.androidStatusBarBackground = value;
|
||||
}
|
||||
public get androidStatusBarBackground(): Color {
|
||||
return this.style.androidStatusBarBackground;
|
||||
}
|
||||
public set androidStatusBarBackground(value: Color) {
|
||||
this.style.androidStatusBarBackground = value;
|
||||
}
|
||||
|
||||
get page(): PageDefinition {
|
||||
return this;
|
||||
}
|
||||
get page(): PageDefinition {
|
||||
return this;
|
||||
}
|
||||
|
||||
public _addChildFromBuilder(name: string, value: any) {
|
||||
if (value instanceof ActionBar) {
|
||||
this.actionBar = value;
|
||||
} else {
|
||||
super._addChildFromBuilder(name, value);
|
||||
}
|
||||
}
|
||||
public _addChildFromBuilder(name: string, value: any) {
|
||||
if (value instanceof ActionBar) {
|
||||
this.actionBar = value;
|
||||
} else {
|
||||
super._addChildFromBuilder(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
public getKeyframeAnimationWithName(animationName: string): KeyframeAnimationInfo {
|
||||
return this._styleScope.getKeyframeAnimationWithName(animationName);
|
||||
}
|
||||
public getKeyframeAnimationWithName(animationName: string): KeyframeAnimationInfo {
|
||||
return this._styleScope.getKeyframeAnimationWithName(animationName);
|
||||
}
|
||||
|
||||
get frame(): Frame {
|
||||
const frame = this.parent;
|
||||
get frame(): Frame {
|
||||
const frame = this.parent;
|
||||
|
||||
return frame instanceof Frame ? frame : undefined;
|
||||
}
|
||||
return frame instanceof Frame ? frame : undefined;
|
||||
}
|
||||
|
||||
private createNavigatedData(eventName: string, isBackNavigation: boolean): NavigatedData {
|
||||
return {
|
||||
eventName: eventName,
|
||||
object: this,
|
||||
context: this.navigationContext,
|
||||
isBackNavigation: isBackNavigation,
|
||||
};
|
||||
}
|
||||
private createNavigatedData(eventName: string, isBackNavigation: boolean): NavigatedData {
|
||||
return {
|
||||
eventName: eventName,
|
||||
object: this,
|
||||
context: this.navigationContext,
|
||||
isBackNavigation: isBackNavigation,
|
||||
};
|
||||
}
|
||||
|
||||
@profile
|
||||
public onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext?: any) {
|
||||
this._navigationContext = context;
|
||||
@profile
|
||||
public onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext?: any) {
|
||||
this._navigationContext = context;
|
||||
|
||||
if (isBackNavigation && this._styleScope) {
|
||||
this._styleScope.ensureSelectors();
|
||||
if (!this._cssState.isSelectorsLatestVersionApplied()) {
|
||||
this._onCssStateChange();
|
||||
}
|
||||
}
|
||||
if (isBackNavigation && this._styleScope) {
|
||||
this._styleScope.ensureSelectors();
|
||||
if (!this._cssState.isSelectorsLatestVersionApplied()) {
|
||||
this._onCssStateChange();
|
||||
}
|
||||
}
|
||||
|
||||
//https://github.com/NativeScript/NativeScript/issues/731
|
||||
if (!isBackNavigation && bindingContext !== undefined && bindingContext !== null) {
|
||||
this.bindingContext = bindingContext;
|
||||
}
|
||||
this.notify(this.createNavigatedData(PageBase.navigatingToEvent, isBackNavigation));
|
||||
}
|
||||
//https://github.com/NativeScript/NativeScript/issues/731
|
||||
if (!isBackNavigation && bindingContext !== undefined && bindingContext !== null) {
|
||||
this.bindingContext = bindingContext;
|
||||
}
|
||||
this.notify(this.createNavigatedData(PageBase.navigatingToEvent, isBackNavigation));
|
||||
}
|
||||
|
||||
@profile
|
||||
public onNavigatedTo(isBackNavigation: boolean) {
|
||||
this.notify(this.createNavigatedData(PageBase.navigatedToEvent, isBackNavigation));
|
||||
}
|
||||
@profile
|
||||
public onNavigatedTo(isBackNavigation: boolean) {
|
||||
this.notify(this.createNavigatedData(PageBase.navigatedToEvent, isBackNavigation));
|
||||
}
|
||||
|
||||
@profile
|
||||
public onNavigatingFrom(isBackNavigation: boolean) {
|
||||
this.notify(this.createNavigatedData(PageBase.navigatingFromEvent, isBackNavigation));
|
||||
}
|
||||
@profile
|
||||
public onNavigatingFrom(isBackNavigation: boolean) {
|
||||
this.notify(this.createNavigatedData(PageBase.navigatingFromEvent, isBackNavigation));
|
||||
}
|
||||
|
||||
@profile
|
||||
public onNavigatedFrom(isBackNavigation: boolean) {
|
||||
this.notify(this.createNavigatedData(PageBase.navigatedFromEvent, isBackNavigation));
|
||||
@profile
|
||||
public onNavigatedFrom(isBackNavigation: boolean) {
|
||||
this.notify(this.createNavigatedData(PageBase.navigatedFromEvent, isBackNavigation));
|
||||
|
||||
this._navigationContext = undefined;
|
||||
}
|
||||
this._navigationContext = undefined;
|
||||
}
|
||||
|
||||
public eachChildView(callback: (child: View) => boolean) {
|
||||
super.eachChildView(callback);
|
||||
if (this.hasActionBar) {
|
||||
callback(this.actionBar);
|
||||
}
|
||||
}
|
||||
public eachChildView(callback: (child: View) => boolean) {
|
||||
super.eachChildView(callback);
|
||||
if (this.hasActionBar) {
|
||||
callback(this.actionBar);
|
||||
}
|
||||
}
|
||||
|
||||
get _childrenCount(): number {
|
||||
return (this.content ? 1 : 0) + (this._actionBar ? 1 : 0);
|
||||
}
|
||||
get _childrenCount(): number {
|
||||
return (this.content ? 1 : 0) + (this._actionBar ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
PageBase.prototype.recycleNativeView = 'never';
|
||||
|
||||
export interface PageBase {
|
||||
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void;
|
||||
on(event: 'navigatingTo', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
on(event: 'navigatedTo', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
on(event: 'navigatingFrom', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
on(event: 'navigatedFrom', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
on(event: 'showingModally', callback: (args: ShownModallyData) => void, thisArg?: any): void;
|
||||
on(event: 'shownModally', callback: (args: ShownModallyData) => void, thisArg?: any);
|
||||
on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void;
|
||||
on(event: 'navigatingTo', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
on(event: 'navigatedTo', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
on(event: 'navigatingFrom', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
on(event: 'navigatedFrom', callback: (args: NavigatedData) => void, thisArg?: any): void;
|
||||
on(event: 'showingModally', callback: (args: ShownModallyData) => void, thisArg?: any): void;
|
||||
on(event: 'shownModally', callback: (args: ShownModallyData) => void, thisArg?: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dependency property used to hide the Navigation Bar in iOS and the Action Bar in Android.
|
||||
*/
|
||||
export const actionBarHiddenProperty = new Property<PageBase, boolean>({
|
||||
name: 'actionBarHidden',
|
||||
affectsLayout: isIOS,
|
||||
valueConverter: booleanConverter,
|
||||
name: 'actionBarHidden',
|
||||
affectsLayout: isIOS,
|
||||
valueConverter: booleanConverter,
|
||||
});
|
||||
actionBarHiddenProperty.register(PageBase);
|
||||
|
||||
@@ -180,10 +180,10 @@ actionBarHiddenProperty.register(PageBase);
|
||||
* Dependency property that specify if page background should span under status bar.
|
||||
*/
|
||||
export const backgroundSpanUnderStatusBarProperty = new Property<PageBase, boolean>({
|
||||
name: 'backgroundSpanUnderStatusBar',
|
||||
defaultValue: false,
|
||||
affectsLayout: isIOS,
|
||||
valueConverter: booleanConverter,
|
||||
name: 'backgroundSpanUnderStatusBar',
|
||||
defaultValue: false,
|
||||
affectsLayout: isIOS,
|
||||
valueConverter: booleanConverter,
|
||||
});
|
||||
backgroundSpanUnderStatusBarProperty.register(PageBase);
|
||||
|
||||
@@ -192,9 +192,9 @@ backgroundSpanUnderStatusBarProperty.register(PageBase);
|
||||
* This property is iOS specific. Default value: true
|
||||
*/
|
||||
export const enableSwipeBackNavigationProperty = new Property<PageBase, boolean>({
|
||||
name: 'enableSwipeBackNavigation',
|
||||
defaultValue: true,
|
||||
valueConverter: booleanConverter,
|
||||
name: 'enableSwipeBackNavigation',
|
||||
defaultValue: true,
|
||||
valueConverter: booleanConverter,
|
||||
});
|
||||
enableSwipeBackNavigationProperty.register(PageBase);
|
||||
|
||||
@@ -202,8 +202,8 @@ enableSwipeBackNavigationProperty.register(PageBase);
|
||||
* Property backing statusBarStyle.
|
||||
*/
|
||||
export const statusBarStyleProperty = new CssProperty<Style, 'light' | 'dark'>({
|
||||
name: 'statusBarStyle',
|
||||
cssName: 'status-bar-style',
|
||||
name: 'statusBarStyle',
|
||||
cssName: 'status-bar-style',
|
||||
});
|
||||
statusBarStyleProperty.register(Style);
|
||||
|
||||
@@ -211,9 +211,9 @@ statusBarStyleProperty.register(Style);
|
||||
* Property backing androidStatusBarBackground.
|
||||
*/
|
||||
export const androidStatusBarBackgroundProperty = new CssProperty<Style, Color>({
|
||||
name: 'androidStatusBarBackground',
|
||||
cssName: 'android-status-bar-background',
|
||||
equalityComparer: Color.equals,
|
||||
valueConverter: (v) => new Color(v),
|
||||
name: 'androidStatusBarBackground',
|
||||
cssName: 'android-status-bar-background',
|
||||
equalityComparer: Color.equals,
|
||||
valueConverter: (v) => new Color(v),
|
||||
});
|
||||
androidStatusBarBackgroundProperty.register(Style);
|
||||
|
||||
Reference in New Issue
Block a user