chore: cleanup

This commit is contained in:
Nathan Walker
2020-07-06 14:25:11 -07:00
parent 94cf5c4706
commit 6336eac4b5
477 changed files with 59087 additions and 74961 deletions

View File

@@ -1,102 +1,68 @@
import { setActivityCallbacks, AndroidActivityCallbacks } from "./frame";
import * as globals from "../../globals";
import * as appModule from "../../application";
import { setActivityCallbacks, AndroidActivityCallbacks } from '.';
import * as globals from '../../globals';
import * as appModule from '../../application';
if (global.__snapshot) {
globals.initGlobal();
globals.initGlobal();
}
//@ts-ignore
@JavaProxy("com.tns.NativeScriptActivity")
@JavaProxy('com.tns.NativeScriptActivity')
class NativeScriptActivity extends androidx.appcompat.app.AppCompatActivity {
private _callbacks: AndroidActivityCallbacks;
public isNativeScriptActivity;
constructor() {
super();
private _callbacks: AndroidActivityCallbacks;
public isNativeScriptActivity;
constructor() {
super();
return global.__native(this);
}
return global.__native(this);
}
public onCreate(savedInstanceState: android.os.Bundle): void {
appModule.android.init(this.getApplication());
public onCreate(savedInstanceState: android.os.Bundle): void {
appModule.android.init(this.getApplication());
// Set isNativeScriptActivity in onCreate.
// The JS constructor might not be called because the activity is created from Android.
this.isNativeScriptActivity = true;
if (!this._callbacks) {
setActivityCallbacks(this);
}
// Set isNativeScriptActivity in onCreate.
// The JS constructor might not be called because the activity is created from Android.
this.isNativeScriptActivity = true;
if (!this._callbacks) {
setActivityCallbacks(this);
}
this._callbacks.onCreate(
this,
savedInstanceState,
this.getIntent(),
super.onCreate
);
}
this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), super.onCreate);
}
public onNewIntent(intent: android.content.Intent): void {
this._callbacks.onNewIntent(
this,
intent,
super.setIntent,
super.onNewIntent
);
}
public onNewIntent(intent: android.content.Intent): void {
this._callbacks.onNewIntent(this, intent, super.setIntent, super.onNewIntent);
}
public onSaveInstanceState(outState: android.os.Bundle): void {
this._callbacks.onSaveInstanceState(
this,
outState,
super.onSaveInstanceState
);
}
public onSaveInstanceState(outState: android.os.Bundle): void {
this._callbacks.onSaveInstanceState(this, outState, super.onSaveInstanceState);
}
public onStart(): void {
this._callbacks.onStart(this, super.onStart);
}
public onStart(): void {
this._callbacks.onStart(this, super.onStart);
}
public onStop(): void {
this._callbacks.onStop(this, super.onStop);
}
public onStop(): void {
this._callbacks.onStop(this, super.onStop);
}
public onDestroy(): void {
this._callbacks.onDestroy(this, super.onDestroy);
}
public onDestroy(): void {
this._callbacks.onDestroy(this, super.onDestroy);
}
public onPostResume(): void {
this._callbacks.onPostResume(this, super.onPostResume);
}
public onPostResume(): void {
this._callbacks.onPostResume(this, super.onPostResume);
}
public onBackPressed(): void {
this._callbacks.onBackPressed(this, super.onBackPressed);
}
public onBackPressed(): void {
this._callbacks.onBackPressed(this, super.onBackPressed);
}
public onRequestPermissionsResult(
requestCode: number,
permissions: Array<string>,
grantResults: Array<number>
): void {
this._callbacks.onRequestPermissionsResult(
this,
requestCode,
permissions,
grantResults,
undefined /*TODO: Enable if needed*/
);
}
public onRequestPermissionsResult(requestCode: number, permissions: Array<string>, grantResults: Array<number>): void {
this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/);
}
public onActivityResult(
requestCode: number,
resultCode: number,
data: android.content.Intent
): void {
this._callbacks.onActivityResult(
this,
requestCode,
resultCode,
data,
super.onActivityResult
);
}
public onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void {
this._callbacks.onActivityResult(this, requestCode, resultCode, data, super.onActivityResult);
}
}

View File

@@ -1,95 +1,67 @@
import {
AndroidFragmentCallbacks,
setFragmentCallbacks,
setFragmentClass,
} from "./frame";
import { AndroidFragmentCallbacks, setFragmentCallbacks, setFragmentClass } from '.';
@JavaProxy("com.tns.FragmentClass")
@JavaProxy('com.tns.FragmentClass')
class FragmentClass extends org.nativescript.widgets.FragmentBase {
// This field is updated in the frame module upon `new` (although hacky this eases the Fragment->callbacks association a lot)
private _callbacks: AndroidFragmentCallbacks;
// This field is updated in the frame module upon `new` (although hacky this eases the Fragment->callbacks association a lot)
private _callbacks: AndroidFragmentCallbacks;
constructor() {
super();
constructor() {
super();
return global.__native(this);
}
return global.__native(this);
}
public onHiddenChanged(hidden: boolean): void {
this._callbacks.onHiddenChanged(this, hidden, super.onHiddenChanged);
}
public onHiddenChanged(hidden: boolean): void {
this._callbacks.onHiddenChanged(this, hidden, super.onHiddenChanged);
}
public onCreateAnimator(
transit: number,
enter: boolean,
nextAnim: number
): android.animation.Animator {
return this._callbacks.onCreateAnimator(
this,
transit,
enter,
nextAnim,
super.onCreateAnimator
);
}
public onCreateAnimator(transit: number, enter: boolean, nextAnim: number): android.animation.Animator {
return this._callbacks.onCreateAnimator(this, transit, enter, nextAnim, super.onCreateAnimator);
}
public onStop(): void {
this._callbacks.onStop(this, super.onStop);
}
public onStop(): void {
this._callbacks.onStop(this, super.onStop);
}
public onPause(): void {
this._callbacks.onPause(this, super.onStop);
}
public onPause(): void {
this._callbacks.onPause(this, super.onStop);
}
public onCreate(savedInstanceState: android.os.Bundle) {
if (!this._callbacks) {
setFragmentCallbacks(this);
}
public onCreate(savedInstanceState: android.os.Bundle) {
if (!this._callbacks) {
setFragmentCallbacks(this);
}
this.setHasOptionsMenu(true);
this._callbacks.onCreate(this, savedInstanceState, super.onCreate);
}
this.setHasOptionsMenu(true);
this._callbacks.onCreate(this, savedInstanceState, super.onCreate);
}
public onCreateView(
inflater: android.view.LayoutInflater,
container: android.view.ViewGroup,
savedInstanceState: android.os.Bundle
) {
let result = this._callbacks.onCreateView(
this,
inflater,
container,
savedInstanceState,
super.onCreateView
);
public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle) {
let result = this._callbacks.onCreateView(this, inflater, container, savedInstanceState, super.onCreateView);
return result;
}
return result;
}
public onSaveInstanceState(outState: android.os.Bundle) {
this._callbacks.onSaveInstanceState(
this,
outState,
super.onSaveInstanceState
);
}
public onSaveInstanceState(outState: android.os.Bundle) {
this._callbacks.onSaveInstanceState(this, outState, super.onSaveInstanceState);
}
public onDestroyView() {
this._callbacks.onDestroyView(this, super.onDestroyView);
}
public onDestroyView() {
this._callbacks.onDestroyView(this, super.onDestroyView);
}
public onDestroy() {
this._callbacks.onDestroy(this, super.onDestroy);
}
public onDestroy() {
this._callbacks.onDestroy(this, super.onDestroy);
}
public toString(): string {
const callbacks = this._callbacks;
if (callbacks) {
return callbacks.toStringOverride(this, super.toString);
} else {
super.toString();
}
}
public toString(): string {
const callbacks = this._callbacks;
if (callbacks) {
return callbacks.toStringOverride(this, super.toString);
} else {
super.toString();
}
}
}
setFragmentClass(FragmentClass);

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,9 @@
import { NavigationTransition, BackstackEntry } from "../frame";
import { NavigationTransition, BackstackEntry } from '.';
/**
* @private
*/
export function _setAndroidFragmentTransitions(
animated: boolean,
navigationTransition: NavigationTransition,
currentEntry: BackstackEntry,
newEntry: BackstackEntry,
frameId: number,
fragmentTransaction: any,
isNestedDefaultTransition?: boolean
): void;
export function _setAndroidFragmentTransitions(animated: boolean, navigationTransition: NavigationTransition, currentEntry: BackstackEntry, newEntry: BackstackEntry, frameId: number, fragmentTransaction: any, isNestedDefaultTransition?: boolean): void;
/**
* @private
*/
@@ -27,10 +19,7 @@ export function _updateTransitions(entry: BackstackEntry): void;
* Called once fragment is going to reappear from backstack.
* Reverse transitions from entry to fragment if any.
*/
export function _reverseTransitions(
previousEntry: BackstackEntry,
currentEntry: BackstackEntry
): boolean;
export function _reverseTransitions(previousEntry: BackstackEntry, currentEntry: BackstackEntry): boolean;
/**
* @private
* Called when entry is removed from backstack (either back navigation or
@@ -48,20 +37,11 @@ export function _clearFragment(entry: BackstackEntry): void;
/**
* @private
*/
export function _createIOSAnimatedTransitioning(
navigationTransition: NavigationTransition,
nativeCurve: any,
operation: number,
fromVC: any,
toVC: any
): any;
export function _createIOSAnimatedTransitioning(navigationTransition: NavigationTransition, nativeCurve: any, operation: number, fromVC: any, toVC: any): any;
/**
* @private
* nativeTransition: androidx.transition.Transition
*/
export function addNativeTransitionListener(
entry: any,
nativeTransition: any
): any;
export function addNativeTransitionListener(entry: any, nativeTransition: any): any;
//@endprivate

View File

@@ -1,140 +1,95 @@
import { NavigationTransition } from "./frame";
import { Transition } from "../transition";
import { SlideTransition } from "../transition/slide-transition";
import { FadeTransition } from "../transition/fade-transition";
import { NavigationTransition } from '.';
import { Transition } from '../transition';
import { SlideTransition } from '../transition/slide-transition';
import { FadeTransition } from '../transition/fade-transition';
import { Trace } from "../../trace";
import { Trace } from '../../trace';
module UIViewControllerAnimatedTransitioningMethods {
const methodSignature = NSMethodSignature.signatureWithObjCTypes("v@:c");
const invocation = NSInvocation.invocationWithMethodSignature(
methodSignature
);
invocation.selector = "completeTransition:";
const methodSignature = NSMethodSignature.signatureWithObjCTypes('v@:c');
const invocation = NSInvocation.invocationWithMethodSignature(methodSignature);
invocation.selector = 'completeTransition:';
export function completeTransition(didComplete: boolean) {
const didCompleteReference = new interop.Reference(
interop.types.bool,
didComplete
);
invocation.setArgumentAtIndex(didCompleteReference, 2);
invocation.invokeWithTarget(this);
}
export function completeTransition(didComplete: boolean) {
const didCompleteReference = new interop.Reference(interop.types.bool, didComplete);
invocation.setArgumentAtIndex(didCompleteReference, 2);
invocation.invokeWithTarget(this);
}
}
class AnimatedTransitioning extends NSObject
implements UIViewControllerAnimatedTransitioning {
public static ObjCProtocols = [UIViewControllerAnimatedTransitioning];
class AnimatedTransitioning extends NSObject implements UIViewControllerAnimatedTransitioning {
public static ObjCProtocols = [UIViewControllerAnimatedTransitioning];
private _transition: Transition;
private _operation: UINavigationControllerOperation;
private _fromVC: UIViewController;
private _toVC: UIViewController;
private _transitionType: string;
private _transition: Transition;
private _operation: UINavigationControllerOperation;
private _fromVC: UIViewController;
private _toVC: UIViewController;
private _transitionType: string;
public static init(
transition: Transition,
operation: UINavigationControllerOperation,
fromVC: UIViewController,
toVC: UIViewController
): AnimatedTransitioning {
const impl = <AnimatedTransitioning>AnimatedTransitioning.new();
impl._transition = transition;
impl._operation = operation;
impl._fromVC = fromVC;
impl._toVC = toVC;
public static init(transition: Transition, operation: UINavigationControllerOperation, fromVC: UIViewController, toVC: UIViewController): AnimatedTransitioning {
const impl = <AnimatedTransitioning>AnimatedTransitioning.new();
impl._transition = transition;
impl._operation = operation;
impl._fromVC = fromVC;
impl._toVC = toVC;
return impl;
}
return impl;
}
public animateTransition(transitionContext: any): void {
const containerView = transitionContext.valueForKey("containerView");
const completion = UIViewControllerAnimatedTransitioningMethods.completeTransition.bind(
transitionContext
);
switch (this._operation) {
case UINavigationControllerOperation.Push:
this._transitionType = "push";
break;
case UINavigationControllerOperation.Pop:
this._transitionType = "pop";
break;
case UINavigationControllerOperation.None:
this._transitionType = "none";
break;
}
public animateTransition(transitionContext: any): void {
const containerView = transitionContext.valueForKey('containerView');
const completion = UIViewControllerAnimatedTransitioningMethods.completeTransition.bind(transitionContext);
switch (this._operation) {
case UINavigationControllerOperation.Push:
this._transitionType = 'push';
break;
case UINavigationControllerOperation.Pop:
this._transitionType = 'pop';
break;
case UINavigationControllerOperation.None:
this._transitionType = 'none';
break;
}
if (Trace.isEnabled()) {
Trace.write(
`START ${this._transition} ${this._transitionType}`,
Trace.categories.Transition
);
}
this._transition.animateIOSTransition(
containerView,
this._fromVC.view,
this._toVC.view,
this._operation,
completion
);
}
if (Trace.isEnabled()) {
Trace.write(`START ${this._transition} ${this._transitionType}`, Trace.categories.Transition);
}
this._transition.animateIOSTransition(containerView, this._fromVC.view, this._toVC.view, this._operation, completion);
}
public transitionDuration(
transitionContext: UIViewControllerContextTransitioning
): number {
return this._transition.getDuration();
}
public transitionDuration(transitionContext: UIViewControllerContextTransitioning): number {
return this._transition.getDuration();
}
public animationEnded(transitionCompleted: boolean): void {
if (transitionCompleted) {
if (Trace.isEnabled()) {
Trace.write(
`END ${this._transition} ${this._transitionType}`,
Trace.categories.Transition
);
}
} else {
if (Trace.isEnabled()) {
Trace.write(
`CANCEL ${this._transition} ${this._transitionType}`,
Trace.categories.Transition
);
}
}
}
public animationEnded(transitionCompleted: boolean): void {
if (transitionCompleted) {
if (Trace.isEnabled()) {
Trace.write(`END ${this._transition} ${this._transitionType}`, Trace.categories.Transition);
}
} else {
if (Trace.isEnabled()) {
Trace.write(`CANCEL ${this._transition} ${this._transitionType}`, Trace.categories.Transition);
}
}
}
}
export function _createIOSAnimatedTransitioning(
navigationTransition: NavigationTransition,
nativeCurve: UIViewAnimationCurve,
operation: UINavigationControllerOperation,
fromVC: UIViewController,
toVC: UIViewController
): UIViewControllerAnimatedTransitioning {
const instance = <Transition>navigationTransition.instance;
let transition: Transition;
export function _createIOSAnimatedTransitioning(navigationTransition: NavigationTransition, nativeCurve: UIViewAnimationCurve, operation: UINavigationControllerOperation, fromVC: UIViewController, toVC: UIViewController): UIViewControllerAnimatedTransitioning {
const instance = <Transition>navigationTransition.instance;
let transition: Transition;
if (instance) {
// Instance transition should take precedence even if the given name match existing transition.
transition = instance;
} else if (navigationTransition.name) {
const name = navigationTransition.name.toLowerCase();
if (name.indexOf("slide") === 0) {
const direction = name.substr("slide".length) || "left"; //Extract the direction from the string
transition = new SlideTransition(
direction,
navigationTransition.duration,
nativeCurve
);
} else if (name === "fade") {
transition = new FadeTransition(
navigationTransition.duration,
nativeCurve
);
}
}
if (instance) {
// Instance transition should take precedence even if the given name match existing transition.
transition = instance;
} else if (navigationTransition.name) {
const name = navigationTransition.name.toLowerCase();
if (name.indexOf('slide') === 0) {
const direction = name.substr('slide'.length) || 'left'; //Extract the direction from the string
transition = new SlideTransition(direction, navigationTransition.duration, nativeCurve);
} else if (name === 'fade') {
transition = new FadeTransition(navigationTransition.duration, nativeCurve);
}
}
return transition
? AnimatedTransitioning.init(transition, operation, fromVC, toVC)
: undefined;
return transition ? AnimatedTransitioning.init(transition, operation, fromVC, toVC) : undefined;
}

View File

@@ -1,7 +1,7 @@
//@private
export const enum AnimationType {
enterFakeResourceId = -10,
exitFakeResourceId = -20,
popEnterFakeResourceId = -30,
popExitFakeResourceId = -40,
enterFakeResourceId = -10,
exitFakeResourceId = -20,
popEnterFakeResourceId = -30,
popExitFakeResourceId = -40,
}

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,149 +1,107 @@
// Types
import { View } from "../core/view";
import { Page } from "../page";
import { Transition } from "../transition";
import { Observable } from "../../data/observable";
import { View } from '../core/view';
import { Page } from '../page';
import { Transition } from '../transition';
import { Observable } from '../../data/observable';
export enum NavigationType {
back,
forward,
replace,
back,
forward,
replace,
}
export interface TransitionState {
enterTransitionListener: any;
exitTransitionListener: any;
reenterTransitionListener: any;
returnTransitionListener: any;
transitionName: string;
entry: BackstackEntry;
enterTransitionListener: any;
exitTransitionListener: any;
reenterTransitionListener: any;
returnTransitionListener: any;
transitionName: string;
entry: BackstackEntry;
}
export interface ViewEntry {
moduleName?: string;
create?: () => View;
moduleName?: string;
create?: () => View;
}
export interface NavigationEntry extends ViewEntry {
context?: any;
bindingContext?: any;
animated?: boolean;
transition?: NavigationTransition;
transitioniOS?: NavigationTransition;
transitionAndroid?: NavigationTransition;
backstackVisible?: boolean;
clearHistory?: boolean;
context?: any;
bindingContext?: any;
animated?: boolean;
transition?: NavigationTransition;
transitioniOS?: NavigationTransition;
transitionAndroid?: NavigationTransition;
backstackVisible?: boolean;
clearHistory?: boolean;
}
export interface NavigationContext {
entry: BackstackEntry;
// TODO: remove isBackNavigation for NativeScript 7.0
isBackNavigation: boolean;
navigationType: NavigationType;
entry: BackstackEntry;
// TODO: remove isBackNavigation for NativeScript 7.0
isBackNavigation: boolean;
navigationType: NavigationType;
}
export interface NavigationTransition {
name?: string;
instance?: Transition;
duration?: number;
curve?: any;
name?: string;
instance?: Transition;
duration?: number;
curve?: any;
}
export interface BackstackEntry {
entry: NavigationEntry;
resolvedPage: Page;
navDepth: number;
fragmentTag: string;
fragment?: any;
viewSavedState?: any;
frameId?: number;
recreated?: boolean;
entry: NavigationEntry;
resolvedPage: Page;
navDepth: number;
fragmentTag: string;
fragment?: any;
viewSavedState?: any;
frameId?: number;
recreated?: boolean;
}
export interface AndroidFrame extends Observable {
rootViewGroup: any /* android.view.ViewGroup */;
activity: any /* androidx.appcompat.app.AppCompatActivity */;
currentActivity: any /* androidx.appcompat.app.AppCompatActivity */;
actionBar: any /* android.app.ActionBar */;
showActionBar: boolean;
fragmentForPage(entry: BackstackEntry): any;
rootViewGroup: any /* android.view.ViewGroup */;
activity: any /* androidx.appcompat.app.AppCompatActivity */;
currentActivity: any /* androidx.appcompat.app.AppCompatActivity */;
actionBar: any /* android.app.ActionBar */;
showActionBar: boolean;
fragmentForPage(entry: BackstackEntry): any;
}
export interface AndroidActivityCallbacks {
getRootView(): View;
resetActivityContent(activity: any): void;
getRootView(): View;
resetActivityContent(activity: any): void;
onCreate(
activity: any,
savedInstanceState: any,
intent: any,
superFunc: Function
): void;
onSaveInstanceState(
activity: any,
outState: any,
superFunc: Function
): void;
onStart(activity: any, superFunc: Function): void;
onStop(activity: any, superFunc: Function): void;
onPostResume(activity: any, superFunc: Function): void;
onDestroy(activity: any, superFunc: Function): void;
onBackPressed(activity: any, superFunc: Function): void;
onRequestPermissionsResult(
activity: any,
requestCode: number,
permissions: Array<String>,
grantResults: Array<number>,
superFunc: Function
): void;
onActivityResult(
activity: any,
requestCode: number,
resultCode: number,
data: any,
superFunc: Function
);
onNewIntent(
activity: any,
intent: any,
superSetIntentFunc: Function,
superFunc: Function
): void;
onCreate(activity: any, savedInstanceState: any, intent: any, superFunc: Function): void;
onSaveInstanceState(activity: any, outState: any, superFunc: Function): void;
onStart(activity: any, superFunc: Function): void;
onStop(activity: any, superFunc: Function): void;
onPostResume(activity: any, superFunc: Function): void;
onDestroy(activity: any, superFunc: Function): void;
onBackPressed(activity: any, superFunc: Function): void;
onRequestPermissionsResult(activity: any, requestCode: number, permissions: Array<String>, grantResults: Array<number>, superFunc: Function): void;
onActivityResult(activity: any, requestCode: number, resultCode: number, data: any, superFunc: Function);
onNewIntent(activity: any, intent: any, superSetIntentFunc: Function, superFunc: Function): void;
}
export interface AndroidFragmentCallbacks {
onHiddenChanged(fragment: any, hidden: boolean, superFunc: Function): void;
onCreateAnimator(
fragment: any,
transit: number,
enter: boolean,
nextAnim: number,
superFunc: Function
): any;
onCreate(fragment: any, savedInstanceState: any, superFunc: Function): void;
onCreateView(
fragment: any,
inflater: any,
container: any,
savedInstanceState: any,
superFunc: Function
): any;
onSaveInstanceState(
fragment: any,
outState: any,
superFunc: Function
): void;
onDestroyView(fragment: any, superFunc: Function): void;
onDestroy(fragment: any, superFunc: Function): void;
onPause(fragment: any, superFunc: Function): void;
onStop(fragment: any, superFunc: Function): void;
toStringOverride(fragment: any, superFunc: Function): string;
onHiddenChanged(fragment: any, hidden: boolean, superFunc: Function): void;
onCreateAnimator(fragment: any, transit: number, enter: boolean, nextAnim: number, superFunc: Function): any;
onCreate(fragment: any, savedInstanceState: any, superFunc: Function): void;
onCreateView(fragment: any, inflater: any, container: any, savedInstanceState: any, superFunc: Function): any;
onSaveInstanceState(fragment: any, outState: any, superFunc: Function): void;
onDestroyView(fragment: any, superFunc: Function): void;
onDestroy(fragment: any, superFunc: Function): void;
onPause(fragment: any, superFunc: Function): void;
onStop(fragment: any, superFunc: Function): void;
toStringOverride(fragment: any, superFunc: Function): string;
}
/* tslint:disable */
export interface iOSFrame {
/* tslint:enable */
controller: any /* UINavigationController */;
navBarVisibility: "auto" | "never" | "always";
_disableNavBarAnimation: boolean;
/* tslint:enable */
controller: any /* UINavigationController */;
navBarVisibility: 'auto' | 'never' | 'always';
_disableNavBarAnimation: boolean;
}

View File

@@ -1,52 +1,50 @@
// Types.
import { FrameBase } from "./frame-common";
import { FrameBase } from './frame-common';
export let frameStack: Array<FrameBase> = [];
export function topmost(): FrameBase {
if (frameStack.length > 0) {
return frameStack[frameStack.length - 1];
}
if (frameStack.length > 0) {
return frameStack[frameStack.length - 1];
}
return undefined;
return undefined;
}
export function _pushInFrameStack(frame: FrameBase): void {
if (frame._isInFrameStack && frameStack[frameStack.length - 1] === frame) {
return;
}
if (frame._isInFrameStack && frameStack[frameStack.length - 1] === frame) {
return;
}
if (frame._isInFrameStack) {
const indexOfFrame = frameStack.indexOf(frame);
frameStack.splice(indexOfFrame, 1);
}
if (frame._isInFrameStack) {
const indexOfFrame = frameStack.indexOf(frame);
frameStack.splice(indexOfFrame, 1);
}
frameStack.push(frame);
frame._isInFrameStack = true;
frameStack.push(frame);
frame._isInFrameStack = true;
}
export function _popFromFrameStack(frame: FrameBase): void {
if (!frame._isInFrameStack) {
return;
}
if (!frame._isInFrameStack) {
return;
}
const top = topmost();
if (top !== frame) {
throw new Error(
"Cannot pop a Frame which is not at the top of the navigation stack."
);
}
const top = topmost();
if (top !== frame) {
throw new Error('Cannot pop a Frame which is not at the top of the navigation stack.');
}
frameStack.pop();
frame._isInFrameStack = false;
frameStack.pop();
frame._isInFrameStack = false;
}
export function _removeFromFrameStack(frame: FrameBase): void {
if (!frame._isInFrameStack) {
return;
}
if (!frame._isInFrameStack) {
return;
}
const index = frameStack.indexOf(frame);
frameStack.splice(index, 1);
frame._isInFrameStack = false;
const index = frameStack.indexOf(frame);
frameStack.splice(index, 1);
frame._isInFrameStack = false;
}

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,546 +0,0 @@
import { NavigationType } from "./frame-common";
import { Page } from "../page";
import { Observable, EventData } from "../../data/observable";
import { View } from "../core/view";
import { Transition } from "../transition";
/**
* Represents the logical View unit that is responsible for navigation within an application.
* Nested frames are supported, enabling hierarchical navigation scenarios.
*/
export class Frame extends View {
/**
* Gets a frame by id.
*/
static getFrameById(id: string): Frame;
/**
* Gets the topmost frame in the frames stack. An application will typically has one frame instance. Multiple frames handle nested (hierarchical) navigation scenarios.
*/
static topmost(): Frame;
/**
* Navigates back using the navigation hierarchy (if any). Updates the Frame stack as needed.
* This method will start from the topmost Frame and will recursively search for an instance that has the canGoBack operation available.
*/
static goBack();
/**
* @private
*/
static reloadPage(context?: ModuleContext): void;
/**
* @private
*/
static _stack(): Array<Frame>;
/**
* Navigates to the previous entry (if any) in the back stack.
* @param to The backstack entry to navigate back to.
*/
goBack(to?: BackstackEntry);
/**
* Checks whether the goBack operation is available.
*/
canGoBack(): boolean;
/**
* Navigates to a Page instance as described by the module name.
* This method will require the module and will check for a Page property in the exports of the module.
* @param pageModuleName The name of the module to require starting from the application root.
* For example if you want to navigate to page called "myPage.js" in a folder called "subFolder" and your root folder is "app" you can call navigate method like this:
* const frames = require("&#64;nativescript/core/ui/frame");
* frames.topmost().navigate("app/subFolder/myPage");
*/
navigate(pageModuleName: string);
/**
* Creates a new Page instance using the provided callback and navigates to that Page.
* @param create The function to be used to create the new Page instance.
*/
navigate(create: () => Page);
/**
* Navigates to a Page resolved by the provided NavigationEntry object.
* Since there are a couple of ways to specify a Page instance through an entry, there is a resolution priority:
* 1. entry.moduleName
* 2. entry.create()
* @param entry The NavigationEntry instance.
*/
navigate(entry: NavigationEntry);
/**
* Used to control the visibility the Navigation Bar in iOS and the Action Bar in Android.
*/
public actionBarVisibility: "auto" | "never" | "always";
/**
* Gets the back stack of this instance.
*/
backStack: Array<BackstackEntry>;
/**
* Gets the Page instance the Frame is currently navigated to.
*/
currentPage: Page;
/**
* Gets the NavigationEntry instance the Frame is currently navigated to.
*/
currentEntry: NavigationEntry;
/**
* Gets or sets if navigation transitions should be animated.
*/
animated: boolean;
/**
* Gets or sets the default navigation transition for this frame.
*/
transition: NavigationTransition;
/**
* Gets or sets if navigation transitions should be animated globally.
*/
static defaultAnimatedNavigation: boolean;
/**
* Gets or sets the default NavigationTransition for all frames across the app.
*/
static defaultTransition: NavigationTransition;
/**
* Gets the AndroidFrame object that represents the Android-specific APIs for this Frame. Valid when running on Android OS.
*/
android: AndroidFrame;
/**
* Gets the iOSFrame object that represents the iOS-specific APIs for this Frame. Valid when running on iOS.
*/
ios: iOSFrame;
//@private
/**
* @private
* @param entry to check
*/
isCurrent(entry: BackstackEntry): boolean;
/**
* @private
* @param entry to set as current
* @param navigationType
*/
setCurrent(entry: BackstackEntry, navigationType: NavigationType): void;
/**
* @private
*/
navigationQueueIsEmpty(): boolean;
/**
* @private
*/
navigationBarHeight: number;
/**
* @private
*/
_animationInProgress: boolean;
/**
* @private
*/
_currentEntry: BackstackEntry;
/**
* @private
*/
_executingContext: NavigationContext;
/**
* @private
*/
_processNavigationQueue(page: Page);
/**
* @private
*/
_getIsAnimatedNavigation(entry: NavigationEntry): boolean;
/**
* @private
*/
_getNavigationTransition(entry: NavigationEntry): NavigationTransition;
/**
* @private
*/
_updateActionBar(page?: Page, disableNavBarAnimation?: boolean);
/**
* @private
* @param navigationContext
*/
public performNavigation(navigationContext: NavigationContext): void;
/**
* @private
*/
_getNavBarVisible(page: Page): boolean;
/**
* @private
*/
_findEntryForTag(fragmentTag: string): BackstackEntry;
/**
* @private
*/
_updateBackstack(
entry: BackstackEntry,
navigationType: NavigationType
): void;
/**
* @private
*/
_pushInFrameStack();
/**
* @private
*/
_pushInFrameStackRecursive();
/**
* @private
*/
_removeFromFrameStack();
//@endprivate
/**
* 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.
*/
on(eventNames: string, callback: (args: EventData) => void, thisArg?: any);
}
/**
* Sets the extended androidx.fragment.app.Fragment class to the Frame and navigation routine. An instance of this class will be created to represent the Page currently visible on the srceen. This method is available only for the Android platform.
*/
export function setFragmentClass(clazz: any): void;
/**
* @deprecated Use Frame.getFrameById() instead.
*
* Gets a frame by id.
*/
export function getFrameById(id: string): Frame;
/**
* @deprecated Use Frame.topmost() instead.
*
* Gets the topmost frame in the frames stack. An application will typically has one frame instance. Multiple frames handle nested (hierarchical) navigation scenarios.
*/
export function topmost(): Frame;
/**
* @deprecated Use Frame.goBack() instead.
*
* Navigates back using the navigation hierarchy (if any). Updates the Frame stack as needed.
* This method will start from the topmost Frame and will recursively search for an instance that has the canGoBack operation available.
*/
export function goBack();
//@private
/**
* @deprecated Use Frame._stack() instead.
*
* @private
*/
export function _stack(): Array<Frame>;
//@endprivate
/**
* Represents an entry to be used to create a view or load it form file
*/
export interface ViewEntry {
/**
* The name of the module containing the View instance to load. Optional.
*/
moduleName?: string;
/**
* A function used to create the View instance. Optional.
*/
create?: () => View;
}
/**
* Represents an entry in passed to navigate method.
*/
export interface NavigationEntry extends ViewEntry {
/**
* An object passed to the onNavigatedTo callback of the Page. Typically this is used to pass some data among pages. Optional.
*/
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.
*/
animated?: boolean;
/**
* Specifies an optional navigation transition for all platforms. If not specified, the default platform transition will be used.
*/
transition?: NavigationTransition;
/**
* Specifies an optional navigation transition for iOS. If not specified, the default platform transition will be used.
*/
transitioniOS?: NavigationTransition;
/**
* Specifies an optional navigation transition for Android. If not specified, the default platform transition will be used.
*/
transitionAndroid?: NavigationTransition;
/**
* True to record the navigation in the backstack, false otherwise.
* If the parameter is set to false then the Page will be displayed but once navigated from it will not be able to be navigated back to.
*/
backstackVisible?: boolean;
/**
* True to clear the navigation history, false otherwise. Very useful when navigating away from login pages.
*/
clearHistory?: boolean;
}
/**
* Represents a context passed to navigation methods.
*/
export interface NavigationContext {
entry: BackstackEntry;
isBackNavigation: boolean;
navigationType: NavigationType;
}
/**
* Represents an object specifying a page navigation transition.
*/
export interface NavigationTransition {
/**
* Can be one of the built-in transitions:
* - curl (same as curlUp) (iOS only)
* - curlUp (iOS only)
* - curlDown (iOS only)
* - explode (Android Lollipop(21) and up only)
* - fade
* - flip (same as flipRight)
* - flipRight
* - flipLeft
* - slide (same as slideLeft)
* - slideLeft
* - slideRight
* - slideTop
* - slideBottom
*/
name?: string;
/**
* An user-defined instance of the "ui/transition".Transition class.
*/
instance?: Transition;
/**
* The length of the transition in milliseconds. If you do not specify this, the default platform transition duration will be used.
*/
duration?: number;
/**
* An optional transition animation curve. Possible values are contained in the [AnimationCurve enumeration](https://docs.nativescript.org/api-reference/modules/_ui_enums_.animationcurve.html).
* Alternatively, you can pass an instance of type UIViewAnimationCurve for iOS or android.animation.TimeInterpolator for Android.
*/
curve?: any;
}
/**
* Represents an entry in the back stack of a Frame object.
*/
export interface BackstackEntry {
entry: NavigationEntry;
resolvedPage: Page;
//@private
/**
* @private
*/
navDepth: number;
/**
* @private
*/
fragmentTag: string;
/**
* @private
*/
fragment?: any;
/**
* @private
*/
viewSavedState?: any;
/**
* @private
*/
frameId?: number;
/**
* @private
*/
recreated?: boolean;
//@endprivate
}
/**
* Represents the Android-specific Frame object, aggregated within the common Frame one.
* In Android there are two types of navigation - using new Activity instances or using Fragments within the main Activity.
* To start a new Activity, a new Frame instance should be created and navigated to the desired Page.
*/
export interface AndroidFrame extends Observable {
/**
* Gets the native [android ViewGroup](http://developer.android.com/reference/android/view/ViewGroup.html) instance that represents the root layout part of the Frame.
*/
rootViewGroup: any /* android.view.ViewGroup */;
/**
* Gets the native [android Activity](http://developer.android.com/reference/android/app/Activity.html) instance associated with this Frame. In case of nested Frame objects, this property points to the activity of the root Frame.
*/
activity: any /* androidx.appcompat.app.AppCompatActivity */;
/**
* Gets the current (foreground) activity for the application. This property will recursively traverse all existing Frame objects and check for own Activity property.
*/
currentActivity: any /* androidx.appcompat.app.AppCompatActivity */;
/**
* Gets the actionBar property of the currentActivity.
*/
actionBar: any /* android.app.ActionBar */;
/**
* Determines whether the Activity associated with this Frame will display an action bar or not.
*/
showActionBar: boolean;
/**
* Finds the native androidx.fragment.app.Fragment instance created for the specified Page.
* @param page The Page instance to search for.
*/
fragmentForPage(entry: BackstackEntry): any;
}
export interface AndroidActivityCallbacks {
getRootView(): View;
resetActivityContent(activity: any): void;
onCreate(
activity: any,
savedInstanceState: any,
intent: any,
superFunc: Function
): void;
onSaveInstanceState(
activity: any,
outState: any,
superFunc: Function
): void;
onStart(activity: any, superFunc: Function): void;
onStop(activity: any, superFunc: Function): void;
onPostResume(activity: any, superFunc: Function): void;
onDestroy(activity: any, superFunc: Function): void;
onBackPressed(activity: any, superFunc: Function): void;
onRequestPermissionsResult(
activity: any,
requestCode: number,
permissions: Array<String>,
grantResults: Array<number>,
superFunc: Function
): void;
onActivityResult(
activity: any,
requestCode: number,
resultCode: number,
data: any,
superFunc: Function
);
onNewIntent(
activity: any,
intent: any,
superSetIntentFunc: Function,
superFunc: Function
): void;
}
export interface AndroidFragmentCallbacks {
onHiddenChanged(fragment: any, hidden: boolean, superFunc: Function): void;
onCreateAnimator(
fragment: any,
transit: number,
enter: boolean,
nextAnim: number,
superFunc: Function
): any;
onCreate(fragment: any, savedInstanceState: any, superFunc: Function): void;
onCreateView(
fragment: any,
inflater: any,
container: any,
savedInstanceState: any,
superFunc: Function
): any;
onSaveInstanceState(
fragment: any,
outState: any,
superFunc: Function
): void;
onDestroyView(fragment: any, superFunc: Function): void;
onDestroy(fragment: any, superFunc: Function): void;
onPause(fragment: any, superFunc: Function): void;
onStop(fragment: any, superFunc: Function): void;
toStringOverride(fragment: any, superFunc: Function): string;
}
/* tslint:disable */
/**
* Represents the iOS-specific Frame object, aggregated within the common Frame one.
* In iOS the native controller, associated with a Frame object is UINavigationController.
* The navigation controller will automatically hide/show its navigation bar depending on the back stack of the Frame.
*/
export interface iOSFrame {
/**
* Gets the native [UINavigationController](https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UINavigationController_Class/index.html) instance associated with this Frame.
*/
controller: any /* UINavigationController */;
/**
* Gets or sets the visibility of navigationBar.
* Use NavBarVisibility enumeration - auto, never, always
*/
navBarVisibility: "auto" | "never" | "always";
//@private
/**
* @private
*/
_disableNavBarAnimation: boolean;
//@endprivate
}
export function setActivityCallbacks(
activity: any /*androidx.appcompat.app.AppCompatActivity*/
): void;
//@private
/**
* @deprecated Use Frame.reloadPage() instead.
*
* @private
*/
export function reloadPage(context?: ModuleContext): void;
/**
* @private
*/
export function setFragmentCallbacks(
fragment: any /*androidx.fragment.app.Fragment*/
): void;
//@endprivate

View File

@@ -1,907 +0,0 @@
//Types
import {
iOSFrame as iOSFrameDefinition,
BackstackEntry,
NavigationTransition,
} from ".";
import { FrameBase, NavigationType } from "./frame-common";
import { Page } from "../page";
import { View } from "../core/view";
// Requires
import { _createIOSAnimatedTransitioning } from "./fragment.transitions";
import { IOSHelper } from "../core/view/view-helper";
import { profile } from "../../profiling";
import { ios as iosUtils, layout } from "../../utils/utils";
import { Trace } from "../../trace";
export * from "./frame-common";
const majorVersion = iosUtils.MajorVersion;
const ENTRY = "_entry";
const DELEGATE = "_delegate";
const NAV_DEPTH = "_navDepth";
const TRANSITION = "_transition";
const NON_ANIMATED_TRANSITION = "non-animated";
const HMR_REPLACE_TRANSITION = "fade";
let navDepth = -1;
export class Frame extends FrameBase {
public viewController: UINavigationControllerImpl;
public _animatedDelegate = <UINavigationControllerDelegate>(
UINavigationControllerAnimatedDelegate.new()
);
public _ios: iOSFrame;
constructor() {
super();
this._ios = new iOSFrame(this);
this.viewController = this._ios.controller;
}
createNativeView() {
return this.viewController.view;
}
public disposeNativeView() {
this._removeFromFrameStack();
this.viewController = null;
this._ios.controller = null;
super.disposeNativeView();
}
public get ios(): iOSFrame {
return this._ios;
}
public setCurrent(
entry: BackstackEntry,
navigationType: NavigationType
): void {
const current = this._currentEntry;
const currentEntryChanged = current !== entry;
if (currentEntryChanged) {
this._updateBackstack(entry, navigationType);
super.setCurrent(entry, navigationType);
}
}
// !!! THIS PROFILE DECORATOR CREATES A CIRCULAR DEPENDENCY
// !!! BECAUSE THE PARAMETER TYPE IS EVALUATED WITH TYPEOF
@profile()
public _navigateCore(backstackEntry: any) {
super._navigateCore(backstackEntry);
let viewController: UIViewController = backstackEntry.resolvedPage.ios;
if (!viewController) {
throw new Error(
"Required page does not have a viewController created."
);
}
let clearHistory = backstackEntry.entry.clearHistory;
if (clearHistory) {
navDepth = -1;
}
const isReplace =
this._executingContext &&
this._executingContext.navigationType === NavigationType.replace;
if (!isReplace) {
navDepth++;
}
let navigationTransition: NavigationTransition;
let animated = this.currentPage
? this._getIsAnimatedNavigation(backstackEntry.entry)
: false;
if (isReplace) {
animated = true;
navigationTransition = {
name: HMR_REPLACE_TRANSITION,
duration: 100,
};
viewController[TRANSITION] = navigationTransition;
} else if (animated) {
navigationTransition = this._getNavigationTransition(
backstackEntry.entry
);
if (navigationTransition) {
viewController[TRANSITION] = navigationTransition;
}
} else {
//https://github.com/NativeScript/NativeScript/issues/1787
viewController[TRANSITION] = { name: NON_ANIMATED_TRANSITION };
}
let nativeTransition = _getNativeTransition(navigationTransition, true);
if (!nativeTransition && navigationTransition) {
this._ios.controller.delegate = this._animatedDelegate;
viewController[DELEGATE] = this._animatedDelegate;
} else {
viewController[DELEGATE] = null;
this._ios.controller.delegate = null;
}
backstackEntry[NAV_DEPTH] = navDepth;
viewController[ENTRY] = backstackEntry;
if (!animated && majorVersion > 10) {
// Reset back button title before pushing view controller to prevent
// displaying default 'back' title (when NavigaitonButton custom title is set).
let barButtonItem = UIBarButtonItem.alloc().initWithTitleStyleTargetAction(
"",
UIBarButtonItemStyle.Plain,
null,
null
);
viewController.navigationItem.backBarButtonItem = barButtonItem;
}
// First navigation.
if (!this._currentEntry) {
// Update action-bar with disabled animations before the initial navigation.
this._updateActionBar(backstackEntry.resolvedPage, true);
this._ios.controller.pushViewControllerAnimated(
viewController,
animated
);
if (Trace.isEnabled()) {
Trace.write(
`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`,
Trace.categories.Navigation
);
}
return;
}
// We should clear the entire history.
if (clearHistory) {
viewController.navigationItem.hidesBackButton = true;
const newControllers = NSMutableArray.alloc().initWithCapacity(1);
newControllers.addObject(viewController);
// Mark all previous ViewControllers as cleared
const oldControllers = this._ios.controller.viewControllers;
for (let i = 0; i < oldControllers.count; i++) {
(<any>(
oldControllers.objectAtIndex(i)
)).isBackstackCleared = true;
}
this._ios.controller.setViewControllersAnimated(
newControllers,
animated
);
if (Trace.isEnabled()) {
Trace.write(
`${this}.setViewControllersAnimated([${viewController}], ${animated}); depth = ${navDepth}`,
Trace.categories.Navigation
);
}
return;
}
// We should hide the current entry from the back stack.
// This is the case for HMR when NavigationType.replace.
if (!Frame._isEntryBackstackVisible(this._currentEntry) || isReplace) {
let newControllers = NSMutableArray.alloc<
UIViewController
>().initWithArray(this._ios.controller.viewControllers);
if (newControllers.count === 0) {
throw new Error("Wrong controllers count.");
}
// the code below fixes a phantom animation that appears on the Back button in this case
// TODO: investigate why the animation happens at first place before working around it
viewController.navigationItem.hidesBackButton =
this.backStack.length === 0;
// swap the top entry with the new one
const skippedNavController = newControllers.lastObject;
(<any>skippedNavController).isBackstackSkipped = true;
newControllers.removeLastObject();
newControllers.addObject(viewController);
// replace the controllers instead of pushing directly
this._ios.controller.setViewControllersAnimated(
newControllers,
animated
);
if (Trace.isEnabled()) {
Trace.write(
`${this}.setViewControllersAnimated([originalControllers - lastController + ${viewController}], ${animated}); depth = ${navDepth}`,
Trace.categories.Navigation
);
}
return;
}
// General case.
this._ios.controller.pushViewControllerAnimated(
viewController,
animated
);
if (Trace.isEnabled()) {
Trace.write(
`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`,
Trace.categories.Navigation
);
}
}
public _goBackCore(backstackEntry: BackstackEntry) {
super._goBackCore(backstackEntry);
navDepth = backstackEntry[NAV_DEPTH];
let controller = backstackEntry.resolvedPage.ios;
let animated = this._currentEntry
? this._getIsAnimatedNavigation(this._currentEntry.entry)
: false;
this._updateActionBar(backstackEntry.resolvedPage);
if (Trace.isEnabled()) {
Trace.write(
`${this}.popToViewControllerAnimated(${controller}, ${animated}); depth = ${navDepth}`,
Trace.categories.Navigation
);
}
this._ios.controller.popToViewControllerAnimated(controller, animated);
}
public _updateActionBar(
page?: Page,
disableNavBarAnimation: boolean = false
): void {
super._updateActionBar(page);
if (page && this.currentPage && this.currentPage.modal === page) {
return;
}
page = page || this.currentPage;
let newValue = this._getNavBarVisible(page);
let disableNavBarAnimationCache = this._ios._disableNavBarAnimation;
if (disableNavBarAnimation) {
this._ios._disableNavBarAnimation = true;
}
this._ios.showNavigationBar = newValue;
if (disableNavBarAnimation) {
this._ios._disableNavBarAnimation = disableNavBarAnimationCache;
}
if (this._ios.controller.navigationBar) {
this._ios.controller.navigationBar.userInteractionEnabled = this.navigationQueueIsEmpty();
}
}
public _getNavBarVisible(page: Page): boolean {
switch (this.actionBarVisibility) {
case "always":
return true;
case "never":
return false;
case "auto":
switch (this._ios.navBarVisibility) {
case "always":
return true;
case "never":
return false;
case "auto":
let newValue: boolean;
if (page && page.actionBarHidden !== undefined) {
newValue = !page.actionBarHidden;
} else {
newValue =
this.ios.controller.viewControllers.count > 1 ||
(page &&
page.actionBar &&
!page.actionBar._isEmpty());
}
newValue = !!newValue;
return newValue;
}
}
}
public static get defaultAnimatedNavigation(): boolean {
return FrameBase.defaultAnimatedNavigation;
}
public static set defaultAnimatedNavigation(value: boolean) {
FrameBase.defaultAnimatedNavigation = value;
}
public static get defaultTransition(): NavigationTransition {
return FrameBase.defaultTransition;
}
public static set defaultTransition(value: NavigationTransition) {
FrameBase.defaultTransition = value;
}
public onMeasure(
widthMeasureSpec: number,
heightMeasureSpec: number
): void {
const width = layout.getMeasureSpecSize(widthMeasureSpec);
const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
const height = layout.getMeasureSpecSize(heightMeasureSpec);
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
const widthAndState = View.resolveSizeAndState(
width,
width,
widthMode,
0
);
const heightAndState = View.resolveSizeAndState(
height,
height,
heightMode,
0
);
this.setMeasuredDimension(widthAndState, heightAndState);
}
public layoutNativeView(
left: number,
top: number,
right: number,
bottom: number
): void {
//
}
public _setNativeViewFrame(nativeView: UIView, frame: CGRect) {
//
}
public _onNavigatingTo(backstackEntry: BackstackEntry, isBack: boolean) {
//
}
}
let transitionDelegates = new Array<TransitionDelegate>();
class TransitionDelegate extends NSObject {
private _id: string;
public static initWithOwnerId(id: string): TransitionDelegate {
let delegate = <TransitionDelegate>TransitionDelegate.new();
delegate._id = id;
transitionDelegates.push(delegate);
return delegate;
}
public animationWillStart(animationID: string, context: any): void {
if (Trace.isEnabled()) {
Trace.write(`START ${this._id}`, Trace.categories.Transition);
}
}
public animationDidStop(
animationID: string,
finished: boolean,
context: any
): void {
if (finished) {
if (Trace.isEnabled()) {
Trace.write(`END ${this._id}`, Trace.categories.Transition);
}
} else {
if (Trace.isEnabled()) {
Trace.write(`CANCEL ${this._id}`, Trace.categories.Transition);
}
}
let index = transitionDelegates.indexOf(this);
if (index > -1) {
transitionDelegates.splice(index, 1);
}
}
public static ObjCExposedMethods = {
animationWillStart: {
returns: interop.types.void,
params: [NSString, NSObject],
},
animationDidStop: {
returns: interop.types.void,
params: [NSString, NSNumber, NSObject],
},
};
}
const _defaultTransitionDuration = 0.35;
class UINavigationControllerAnimatedDelegate extends NSObject
implements UINavigationControllerDelegate {
public static ObjCProtocols = [UINavigationControllerDelegate];
navigationControllerAnimationControllerForOperationFromViewControllerToViewController(
navigationController: UINavigationController,
operation: number,
fromVC: UIViewController,
toVC: UIViewController
): UIViewControllerAnimatedTransitioning {
let viewController: UIViewController;
switch (operation) {
case UINavigationControllerOperation.Push:
viewController = toVC;
break;
case UINavigationControllerOperation.Pop:
viewController = fromVC;
break;
}
if (!viewController) {
return null;
}
let navigationTransition = <NavigationTransition>(
viewController[TRANSITION]
);
if (!navigationTransition) {
return null;
}
if (Trace.isEnabled()) {
Trace.write(
`UINavigationControllerImpl.navigationControllerAnimationControllerForOperationFromViewControllerToViewController(${operation}, ${fromVC}, ${toVC}), transition: ${JSON.stringify(
navigationTransition
)}`,
Trace.categories.NativeLifecycle
);
}
let curve = _getNativeCurve(navigationTransition);
let animationController = _createIOSAnimatedTransitioning(
navigationTransition,
curve,
operation,
fromVC,
toVC
);
return animationController;
}
}
class UINavigationControllerImpl extends UINavigationController {
private _owner: WeakRef<Frame>;
public static initWithOwner(
owner: WeakRef<Frame>
): UINavigationControllerImpl {
let controller = <UINavigationControllerImpl>(
UINavigationControllerImpl.new()
);
controller._owner = owner;
return controller;
}
get owner(): Frame {
return this._owner.get();
}
@profile()
public viewWillAppear(animated: boolean): void {
super.viewWillAppear(animated);
const owner = this._owner.get();
if (owner && !owner.isLoaded && !owner.parent) {
owner.callLoaded();
}
}
@profile()
public viewDidDisappear(animated: boolean): void {
super.viewDidDisappear(animated);
const owner = this._owner.get();
if (
owner &&
owner.isLoaded &&
!owner.parent &&
!this.presentedViewController
) {
owner.callUnloaded();
owner._tearDownUI(true);
}
}
private animateWithDuration(
navigationTransition: NavigationTransition,
nativeTransition: UIViewAnimationTransition,
transitionType: string,
baseCallback: Function
): void {
let duration = navigationTransition.duration
? navigationTransition.duration / 1000
: _defaultTransitionDuration;
let curve = _getNativeCurve(navigationTransition);
let transitionTraced = Trace.isCategorySet(Trace.categories.Transition);
let transitionDelegate: TransitionDelegate;
if (transitionTraced) {
let id = _getTransitionId(nativeTransition, transitionType);
transitionDelegate = TransitionDelegate.initWithOwnerId(id);
}
UIView.animateWithDurationAnimations(duration, () => {
if (transitionTraced) {
UIView.setAnimationDelegate(transitionDelegate);
}
UIView.setAnimationWillStartSelector("animationWillStart");
UIView.setAnimationDidStopSelector("animationDidStop");
UIView.setAnimationCurve(curve);
baseCallback();
UIView.setAnimationTransitionForViewCache(
nativeTransition,
this.view,
true
);
});
}
@profile()
public pushViewControllerAnimated(
viewController: UIViewController,
animated: boolean
): void {
let navigationTransition = <NavigationTransition>(
viewController[TRANSITION]
);
if (Trace.isEnabled()) {
Trace.write(
`UINavigationControllerImpl.pushViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(
navigationTransition
)}`,
Trace.categories.NativeLifecycle
);
}
let nativeTransition = _getNativeTransition(navigationTransition, true);
if (!animated || !navigationTransition || !nativeTransition) {
super.pushViewControllerAnimated(viewController, animated);
return;
}
this.animateWithDuration(
navigationTransition,
nativeTransition,
"push",
() => {
super.pushViewControllerAnimated(viewController, false);
}
);
}
@profile()
public setViewControllersAnimated(
viewControllers: NSArray<any>,
animated: boolean
): void {
let viewController = viewControllers.lastObject;
let navigationTransition = <NavigationTransition>(
viewController[TRANSITION]
);
if (Trace.isEnabled()) {
Trace.write(
`UINavigationControllerImpl.setViewControllersAnimated(${viewControllers}, ${animated}); transition: ${JSON.stringify(
navigationTransition
)}`,
Trace.categories.NativeLifecycle
);
}
let nativeTransition = _getNativeTransition(navigationTransition, true);
if (!animated || !navigationTransition || !nativeTransition) {
super.setViewControllersAnimated(viewControllers, animated);
return;
}
this.animateWithDuration(
navigationTransition,
nativeTransition,
"set",
() => {
super.setViewControllersAnimated(viewControllers, false);
}
);
}
public popViewControllerAnimated(animated: boolean): UIViewController {
let lastViewController = this.viewControllers.lastObject;
let navigationTransition = <NavigationTransition>(
lastViewController[TRANSITION]
);
if (Trace.isEnabled()) {
Trace.write(
`UINavigationControllerImpl.popViewControllerAnimated(${animated}); transition: ${JSON.stringify(
navigationTransition
)}`,
Trace.categories.NativeLifecycle
);
}
if (
navigationTransition &&
navigationTransition.name === NON_ANIMATED_TRANSITION
) {
//https://github.com/NativeScript/NativeScript/issues/1787
return super.popViewControllerAnimated(false);
}
let nativeTransition = _getNativeTransition(
navigationTransition,
false
);
if (!animated || !navigationTransition || !nativeTransition) {
return super.popViewControllerAnimated(animated);
}
this.animateWithDuration(
navigationTransition,
nativeTransition,
"pop",
() => {
super.popViewControllerAnimated(false);
}
);
return null;
}
public popToViewControllerAnimated(
viewController: UIViewController,
animated: boolean
): NSArray<UIViewController> {
let lastViewController = this.viewControllers.lastObject;
let navigationTransition = <NavigationTransition>(
lastViewController[TRANSITION]
);
if (Trace.isEnabled()) {
Trace.write(
`UINavigationControllerImpl.popToViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(
navigationTransition
)}`,
Trace.categories.NativeLifecycle
);
}
if (
navigationTransition &&
navigationTransition.name === NON_ANIMATED_TRANSITION
) {
//https://github.com/NativeScript/NativeScript/issues/1787
return super.popToViewControllerAnimated(viewController, false);
}
let nativeTransition = _getNativeTransition(
navigationTransition,
false
);
if (!animated || !navigationTransition || !nativeTransition) {
return super.popToViewControllerAnimated(viewController, animated);
}
this.animateWithDuration(
navigationTransition,
nativeTransition,
"popTo",
() => {
super.popToViewControllerAnimated(viewController, false);
}
);
return null;
}
// Mind implementation for other controllers
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,
});
}
}
}
}
function _getTransitionId(
nativeTransition: UIViewAnimationTransition,
transitionType: string
): string {
let name;
switch (nativeTransition) {
case UIViewAnimationTransition.CurlDown:
name = "CurlDown";
break;
case UIViewAnimationTransition.CurlUp:
name = "CurlUp";
break;
case UIViewAnimationTransition.FlipFromLeft:
name = "FlipFromLeft";
break;
case UIViewAnimationTransition.FlipFromRight:
name = "FlipFromRight";
break;
case UIViewAnimationTransition.None:
name = "None";
break;
}
return `${name} ${transitionType}`;
}
function _getNativeTransition(
navigationTransition: NavigationTransition,
push: boolean
): UIViewAnimationTransition {
if (navigationTransition && navigationTransition.name) {
switch (navigationTransition.name.toLowerCase()) {
case "flip":
case "flipright":
return push
? UIViewAnimationTransition.FlipFromRight
: UIViewAnimationTransition.FlipFromLeft;
case "flipleft":
return push
? UIViewAnimationTransition.FlipFromLeft
: UIViewAnimationTransition.FlipFromRight;
case "curl":
case "curlup":
return push
? UIViewAnimationTransition.CurlUp
: UIViewAnimationTransition.CurlDown;
case "curldown":
return push
? UIViewAnimationTransition.CurlDown
: UIViewAnimationTransition.CurlUp;
}
}
return null;
}
export function _getNativeCurve(
transition: NavigationTransition
): UIViewAnimationCurve {
if (transition.curve) {
switch (transition.curve) {
case "easeIn":
if (Trace.isEnabled()) {
Trace.write(
"Transition curve resolved to UIViewAnimationCurve.EaseIn.",
Trace.categories.Transition
);
}
return UIViewAnimationCurve.EaseIn;
case "easeOut":
if (Trace.isEnabled()) {
Trace.write(
"Transition curve resolved to UIViewAnimationCurve.EaseOut.",
Trace.categories.Transition
);
}
return UIViewAnimationCurve.EaseOut;
case "easeInOut":
if (Trace.isEnabled()) {
Trace.write(
"Transition curve resolved to UIViewAnimationCurve.EaseInOut.",
Trace.categories.Transition
);
}
return UIViewAnimationCurve.EaseInOut;
case "linear":
if (Trace.isEnabled()) {
Trace.write(
"Transition curve resolved to UIViewAnimationCurve.Linear.",
Trace.categories.Transition
);
}
return UIViewAnimationCurve.Linear;
default:
if (Trace.isEnabled()) {
Trace.write(
"Transition curve resolved to original: " +
transition.curve,
Trace.categories.Transition
);
}
return transition.curve;
}
}
return UIViewAnimationCurve.EaseInOut;
}
/* tslint:disable */
class iOSFrame implements iOSFrameDefinition {
/* tslint:enable */
private _controller: UINavigationControllerImpl;
private _showNavigationBar: boolean;
private _navBarVisibility: "auto" | "never" | "always" = "auto";
// TabView uses this flag to disable animation while showing/hiding the navigation bar because of the "< More" bar.
// See the TabView._handleTwoNavigationBars method for more details.
public _disableNavBarAnimation: boolean;
constructor(frame: Frame) {
this._controller = UINavigationControllerImpl.initWithOwner(
new WeakRef(frame)
);
}
public get controller() {
return this._controller;
}
public set controller(value: UINavigationControllerImpl) {
this._controller = value;
}
public get showNavigationBar(): boolean {
return this._showNavigationBar;
}
public set showNavigationBar(value: boolean) {
this._showNavigationBar = value;
this._controller.setNavigationBarHiddenAnimated(
!value,
!this._disableNavBarAnimation
);
}
public get navBarVisibility(): "auto" | "never" | "always" {
return this._navBarVisibility;
}
public set navBarVisibility(value: "auto" | "never" | "always") {
this._navBarVisibility = value;
}
}

View File

File diff suppressed because it is too large Load Diff

499
nativescript-core/ui/frame/index.d.ts vendored Normal file
View File

@@ -0,0 +1,499 @@
import { NavigationType } from './frame-common';
import { Page } from '../page';
import { Observable, EventData } from '../../data/observable';
import { View } from '../core/view';
import { Transition } from '../transition';
export * from './frame-interfaces';
/**
* Represents the logical View unit that is responsible for navigation within an application.
* Nested frames are supported, enabling hierarchical navigation scenarios.
*/
export class Frame extends View {
/**
* Gets a frame by id.
*/
static getFrameById(id: string): Frame;
/**
* Gets the topmost frame in the frames stack. An application will typically has one frame instance. Multiple frames handle nested (hierarchical) navigation scenarios.
*/
static topmost(): Frame;
/**
* Navigates back using the navigation hierarchy (if any). Updates the Frame stack as needed.
* This method will start from the topmost Frame and will recursively search for an instance that has the canGoBack operation available.
*/
static goBack();
/**
* @private
*/
static reloadPage(context?: ModuleContext): void;
/**
* @private
*/
static _stack(): Array<Frame>;
/**
* Navigates to the previous entry (if any) in the back stack.
* @param to The backstack entry to navigate back to.
*/
goBack(to?: BackstackEntry);
/**
* Checks whether the goBack operation is available.
*/
canGoBack(): boolean;
/**
* Navigates to a Page instance as described by the module name.
* This method will require the module and will check for a Page property in the exports of the module.
* @param pageModuleName The name of the module to require starting from the application root.
* For example if you want to navigate to page called "myPage.js" in a folder called "subFolder" and your root folder is "app" you can call navigate method like this:
* const frames = require("&#64;nativescript/core/ui/frame");
* frames.topmost().navigate("app/subFolder/myPage");
*/
navigate(pageModuleName: string);
/**
* Creates a new Page instance using the provided callback and navigates to that Page.
* @param create The function to be used to create the new Page instance.
*/
navigate(create: () => Page);
/**
* Navigates to a Page resolved by the provided NavigationEntry object.
* Since there are a couple of ways to specify a Page instance through an entry, there is a resolution priority:
* 1. entry.moduleName
* 2. entry.create()
* @param entry The NavigationEntry instance.
*/
navigate(entry: NavigationEntry);
/**
* Used to control the visibility the Navigation Bar in iOS and the Action Bar in Android.
*/
public actionBarVisibility: 'auto' | 'never' | 'always';
/**
* Gets the back stack of this instance.
*/
backStack: Array<BackstackEntry>;
/**
* Gets the Page instance the Frame is currently navigated to.
*/
currentPage: Page;
/**
* Gets the NavigationEntry instance the Frame is currently navigated to.
*/
currentEntry: NavigationEntry;
/**
* Gets or sets if navigation transitions should be animated.
*/
animated: boolean;
/**
* Gets or sets the default navigation transition for this frame.
*/
transition: NavigationTransition;
/**
* Gets or sets if navigation transitions should be animated globally.
*/
static defaultAnimatedNavigation: boolean;
/**
* Gets or sets the default NavigationTransition for all frames across the app.
*/
static defaultTransition: NavigationTransition;
/**
* Gets the AndroidFrame object that represents the Android-specific APIs for this Frame. Valid when running on Android OS.
*/
android: AndroidFrame;
/**
* Gets the iOSFrame object that represents the iOS-specific APIs for this Frame. Valid when running on iOS.
*/
ios: iOSFrame;
//@private
/**
* @private
* @param entry to check
*/
isCurrent(entry: BackstackEntry): boolean;
/**
* @private
* @param entry to set as current
* @param navigationType
*/
setCurrent(entry: BackstackEntry, navigationType: NavigationType): void;
/**
* @private
*/
navigationQueueIsEmpty(): boolean;
/**
* @private
*/
navigationBarHeight: number;
/**
* @private
*/
_animationInProgress: boolean;
/**
* @private
*/
_currentEntry: BackstackEntry;
/**
* @private
*/
_executingContext: NavigationContext;
/**
* @private
*/
_processNavigationQueue(page: Page);
/**
* @private
*/
_getIsAnimatedNavigation(entry: NavigationEntry): boolean;
/**
* @private
*/
_getNavigationTransition(entry: NavigationEntry): NavigationTransition;
/**
* @private
*/
_updateActionBar(page?: Page, disableNavBarAnimation?: boolean);
/**
* @private
* @param navigationContext
*/
public performNavigation(navigationContext: NavigationContext): void;
/**
* @private
*/
_getNavBarVisible(page: Page): boolean;
/**
* @private
*/
_findEntryForTag(fragmentTag: string): BackstackEntry;
/**
* @private
*/
_updateBackstack(entry: BackstackEntry, navigationType: NavigationType): void;
/**
* @private
*/
_pushInFrameStack();
/**
* @private
*/
_pushInFrameStackRecursive();
/**
* @private
*/
_removeFromFrameStack();
//@endprivate
/**
* 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.
*/
on(eventNames: string, callback: (args: EventData) => void, thisArg?: any);
}
/**
* Sets the extended androidx.fragment.app.Fragment class to the Frame and navigation routine. An instance of this class will be created to represent the Page currently visible on the srceen. This method is available only for the Android platform.
*/
export function setFragmentClass(clazz: any): void;
/**
* @deprecated Use Frame.getFrameById() instead.
*
* Gets a frame by id.
*/
export function getFrameById(id: string): Frame;
/**
* @deprecated Use Frame.topmost() instead.
*
* Gets the topmost frame in the frames stack. An application will typically has one frame instance. Multiple frames handle nested (hierarchical) navigation scenarios.
*/
export function topmost(): Frame;
/**
* @deprecated Use Frame.goBack() instead.
*
* Navigates back using the navigation hierarchy (if any). Updates the Frame stack as needed.
* This method will start from the topmost Frame and will recursively search for an instance that has the canGoBack operation available.
*/
export function goBack();
//@private
/**
* @deprecated Use Frame._stack() instead.
*
* @private
*/
export function _stack(): Array<Frame>;
//@endprivate
/**
* Represents an entry to be used to create a view or load it form file
*/
export interface ViewEntry {
/**
* The name of the module containing the View instance to load. Optional.
*/
moduleName?: string;
/**
* A function used to create the View instance. Optional.
*/
create?: () => View;
}
/**
* Represents an entry in passed to navigate method.
*/
export interface NavigationEntry extends ViewEntry {
/**
* An object passed to the onNavigatedTo callback of the Page. Typically this is used to pass some data among pages. Optional.
*/
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.
*/
animated?: boolean;
/**
* Specifies an optional navigation transition for all platforms. If not specified, the default platform transition will be used.
*/
transition?: NavigationTransition;
/**
* Specifies an optional navigation transition for iOS. If not specified, the default platform transition will be used.
*/
transitioniOS?: NavigationTransition;
/**
* Specifies an optional navigation transition for Android. If not specified, the default platform transition will be used.
*/
transitionAndroid?: NavigationTransition;
/**
* True to record the navigation in the backstack, false otherwise.
* If the parameter is set to false then the Page will be displayed but once navigated from it will not be able to be navigated back to.
*/
backstackVisible?: boolean;
/**
* True to clear the navigation history, false otherwise. Very useful when navigating away from login pages.
*/
clearHistory?: boolean;
}
/**
* Represents a context passed to navigation methods.
*/
export interface NavigationContext {
entry: BackstackEntry;
isBackNavigation: boolean;
navigationType: NavigationType;
}
/**
* Represents an object specifying a page navigation transition.
*/
export interface NavigationTransition {
/**
* Can be one of the built-in transitions:
* - curl (same as curlUp) (iOS only)
* - curlUp (iOS only)
* - curlDown (iOS only)
* - explode (Android Lollipop(21) and up only)
* - fade
* - flip (same as flipRight)
* - flipRight
* - flipLeft
* - slide (same as slideLeft)
* - slideLeft
* - slideRight
* - slideTop
* - slideBottom
*/
name?: string;
/**
* An user-defined instance of the "ui/transition".Transition class.
*/
instance?: Transition;
/**
* The length of the transition in milliseconds. If you do not specify this, the default platform transition duration will be used.
*/
duration?: number;
/**
* An optional transition animation curve. Possible values are contained in the [AnimationCurve enumeration](https://docs.nativescript.org/api-reference/modules/_ui_enums_.animationcurve.html).
* Alternatively, you can pass an instance of type UIViewAnimationCurve for iOS or android.animation.TimeInterpolator for Android.
*/
curve?: any;
}
/**
* Represents an entry in the back stack of a Frame object.
*/
export interface BackstackEntry {
entry: NavigationEntry;
resolvedPage: Page;
//@private
/**
* @private
*/
navDepth: number;
/**
* @private
*/
fragmentTag: string;
/**
* @private
*/
fragment?: any;
/**
* @private
*/
viewSavedState?: any;
/**
* @private
*/
frameId?: number;
/**
* @private
*/
recreated?: boolean;
//@endprivate
}
/**
* Represents the Android-specific Frame object, aggregated within the common Frame one.
* In Android there are two types of navigation - using new Activity instances or using Fragments within the main Activity.
* To start a new Activity, a new Frame instance should be created and navigated to the desired Page.
*/
export interface AndroidFrame extends Observable {
/**
* Gets the native [android ViewGroup](http://developer.android.com/reference/android/view/ViewGroup.html) instance that represents the root layout part of the Frame.
*/
rootViewGroup: any /* android.view.ViewGroup */;
/**
* Gets the native [android Activity](http://developer.android.com/reference/android/app/Activity.html) instance associated with this Frame. In case of nested Frame objects, this property points to the activity of the root Frame.
*/
activity: any /* androidx.appcompat.app.AppCompatActivity */;
/**
* Gets the current (foreground) activity for the application. This property will recursively traverse all existing Frame objects and check for own Activity property.
*/
currentActivity: any /* androidx.appcompat.app.AppCompatActivity */;
/**
* Gets the actionBar property of the currentActivity.
*/
actionBar: any /* android.app.ActionBar */;
/**
* Determines whether the Activity associated with this Frame will display an action bar or not.
*/
showActionBar: boolean;
/**
* Finds the native androidx.fragment.app.Fragment instance created for the specified Page.
* @param page The Page instance to search for.
*/
fragmentForPage(entry: BackstackEntry): any;
}
export interface AndroidActivityCallbacks {
getRootView(): View;
resetActivityContent(activity: any): void;
onCreate(activity: any, savedInstanceState: any, intent: any, superFunc: Function): void;
onSaveInstanceState(activity: any, outState: any, superFunc: Function): void;
onStart(activity: any, superFunc: Function): void;
onStop(activity: any, superFunc: Function): void;
onPostResume(activity: any, superFunc: Function): void;
onDestroy(activity: any, superFunc: Function): void;
onBackPressed(activity: any, superFunc: Function): void;
onRequestPermissionsResult(activity: any, requestCode: number, permissions: Array<String>, grantResults: Array<number>, superFunc: Function): void;
onActivityResult(activity: any, requestCode: number, resultCode: number, data: any, superFunc: Function);
onNewIntent(activity: any, intent: any, superSetIntentFunc: Function, superFunc: Function): void;
}
export interface AndroidFragmentCallbacks {
onHiddenChanged(fragment: any, hidden: boolean, superFunc: Function): void;
onCreateAnimator(fragment: any, transit: number, enter: boolean, nextAnim: number, superFunc: Function): any;
onCreate(fragment: any, savedInstanceState: any, superFunc: Function): void;
onCreateView(fragment: any, inflater: any, container: any, savedInstanceState: any, superFunc: Function): any;
onSaveInstanceState(fragment: any, outState: any, superFunc: Function): void;
onDestroyView(fragment: any, superFunc: Function): void;
onDestroy(fragment: any, superFunc: Function): void;
onPause(fragment: any, superFunc: Function): void;
onStop(fragment: any, superFunc: Function): void;
toStringOverride(fragment: any, superFunc: Function): string;
}
/* tslint:disable */
/**
* Represents the iOS-specific Frame object, aggregated within the common Frame one.
* In iOS the native controller, associated with a Frame object is UINavigationController.
* The navigation controller will automatically hide/show its navigation bar depending on the back stack of the Frame.
*/
export interface iOSFrame {
/**
* Gets the native [UINavigationController](https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UINavigationController_Class/index.html) instance associated with this Frame.
*/
controller: any /* UINavigationController */;
/**
* Gets or sets the visibility of navigationBar.
* Use NavBarVisibility enumeration - auto, never, always
*/
navBarVisibility: 'auto' | 'never' | 'always';
//@private
/**
* @private
*/
_disableNavBarAnimation: boolean;
//@endprivate
}
export function setActivityCallbacks(activity: any /*androidx.appcompat.app.AppCompatActivity*/): void;
//@private
/**
* @deprecated Use Frame.reloadPage() instead.
*
* @private
*/
export function reloadPage(context?: ModuleContext): void;
/**
* @private
*/
export function setFragmentCallbacks(fragment: any /*androidx.fragment.app.Fragment*/): void;
//@endprivate

View File

@@ -0,0 +1,667 @@
//Types
import { iOSFrame as iOSFrameDefinition, BackstackEntry, NavigationTransition } from '.';
import { FrameBase, NavigationType } from './frame-common';
import { Page } from '../page';
import { View } from '../core/view';
// Requires
import { _createIOSAnimatedTransitioning } from './fragment.transitions';
import { IOSHelper } from '../core/view/view-helper';
import { profile } from '../../profiling';
import { ios as iosUtils, layout } from '../../utils';
import { Trace } from '../../trace';
export * from './frame-common';
const majorVersion = iosUtils.MajorVersion;
const ENTRY = '_entry';
const DELEGATE = '_delegate';
const NAV_DEPTH = '_navDepth';
const TRANSITION = '_transition';
const NON_ANIMATED_TRANSITION = 'non-animated';
const HMR_REPLACE_TRANSITION = 'fade';
let navDepth = -1;
export class Frame extends FrameBase {
public viewController: UINavigationControllerImpl;
public _animatedDelegate = <UINavigationControllerDelegate>UINavigationControllerAnimatedDelegate.new();
public _ios: iOSFrame;
constructor() {
super();
this._ios = new iOSFrame(this);
this.viewController = this._ios.controller;
}
createNativeView() {
return this.viewController.view;
}
public disposeNativeView() {
this._removeFromFrameStack();
this.viewController = null;
this._ios.controller = null;
super.disposeNativeView();
}
public get ios(): iOSFrame {
return this._ios;
}
public setCurrent(entry: BackstackEntry, navigationType: NavigationType): void {
const current = this._currentEntry;
const currentEntryChanged = current !== entry;
if (currentEntryChanged) {
this._updateBackstack(entry, navigationType);
super.setCurrent(entry, navigationType);
}
}
// !!! THIS PROFILE DECORATOR CREATES A CIRCULAR DEPENDENCY
// !!! BECAUSE THE PARAMETER TYPE IS EVALUATED WITH TYPEOF
@profile()
public _navigateCore(backstackEntry: any) {
super._navigateCore(backstackEntry);
let viewController: UIViewController = backstackEntry.resolvedPage.ios;
if (!viewController) {
throw new Error('Required page does not have a viewController created.');
}
let clearHistory = backstackEntry.entry.clearHistory;
if (clearHistory) {
navDepth = -1;
}
const isReplace = this._executingContext && this._executingContext.navigationType === NavigationType.replace;
if (!isReplace) {
navDepth++;
}
let navigationTransition: NavigationTransition;
let animated = this.currentPage ? this._getIsAnimatedNavigation(backstackEntry.entry) : false;
if (isReplace) {
animated = true;
navigationTransition = {
name: HMR_REPLACE_TRANSITION,
duration: 100,
};
viewController[TRANSITION] = navigationTransition;
} else if (animated) {
navigationTransition = this._getNavigationTransition(backstackEntry.entry);
if (navigationTransition) {
viewController[TRANSITION] = navigationTransition;
}
} else {
//https://github.com/NativeScript/NativeScript/issues/1787
viewController[TRANSITION] = { name: NON_ANIMATED_TRANSITION };
}
let nativeTransition = _getNativeTransition(navigationTransition, true);
if (!nativeTransition && navigationTransition) {
this._ios.controller.delegate = this._animatedDelegate;
viewController[DELEGATE] = this._animatedDelegate;
} else {
viewController[DELEGATE] = null;
this._ios.controller.delegate = null;
}
backstackEntry[NAV_DEPTH] = navDepth;
viewController[ENTRY] = backstackEntry;
if (!animated && majorVersion > 10) {
// Reset back button title before pushing view controller to prevent
// displaying default 'back' title (when NavigaitonButton custom title is set).
let barButtonItem = UIBarButtonItem.alloc().initWithTitleStyleTargetAction('', UIBarButtonItemStyle.Plain, null, null);
viewController.navigationItem.backBarButtonItem = barButtonItem;
}
// First navigation.
if (!this._currentEntry) {
// Update action-bar with disabled animations before the initial navigation.
this._updateActionBar(backstackEntry.resolvedPage, true);
this._ios.controller.pushViewControllerAnimated(viewController, animated);
if (Trace.isEnabled()) {
Trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, Trace.categories.Navigation);
}
return;
}
// We should clear the entire history.
if (clearHistory) {
viewController.navigationItem.hidesBackButton = true;
const newControllers = NSMutableArray.alloc().initWithCapacity(1);
newControllers.addObject(viewController);
// Mark all previous ViewControllers as cleared
const oldControllers = this._ios.controller.viewControllers;
for (let i = 0; i < oldControllers.count; i++) {
(<any>oldControllers.objectAtIndex(i)).isBackstackCleared = true;
}
this._ios.controller.setViewControllersAnimated(newControllers, animated);
if (Trace.isEnabled()) {
Trace.write(`${this}.setViewControllersAnimated([${viewController}], ${animated}); depth = ${navDepth}`, Trace.categories.Navigation);
}
return;
}
// We should hide the current entry from the back stack.
// This is the case for HMR when NavigationType.replace.
if (!Frame._isEntryBackstackVisible(this._currentEntry) || isReplace) {
let newControllers = NSMutableArray.alloc<UIViewController>().initWithArray(this._ios.controller.viewControllers);
if (newControllers.count === 0) {
throw new Error('Wrong controllers count.');
}
// the code below fixes a phantom animation that appears on the Back button in this case
// TODO: investigate why the animation happens at first place before working around it
viewController.navigationItem.hidesBackButton = this.backStack.length === 0;
// swap the top entry with the new one
const skippedNavController = newControllers.lastObject;
(<any>skippedNavController).isBackstackSkipped = true;
newControllers.removeLastObject();
newControllers.addObject(viewController);
// replace the controllers instead of pushing directly
this._ios.controller.setViewControllersAnimated(newControllers, animated);
if (Trace.isEnabled()) {
Trace.write(`${this}.setViewControllersAnimated([originalControllers - lastController + ${viewController}], ${animated}); depth = ${navDepth}`, Trace.categories.Navigation);
}
return;
}
// General case.
this._ios.controller.pushViewControllerAnimated(viewController, animated);
if (Trace.isEnabled()) {
Trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, Trace.categories.Navigation);
}
}
public _goBackCore(backstackEntry: BackstackEntry) {
super._goBackCore(backstackEntry);
navDepth = backstackEntry[NAV_DEPTH];
let controller = backstackEntry.resolvedPage.ios;
let animated = this._currentEntry ? this._getIsAnimatedNavigation(this._currentEntry.entry) : false;
this._updateActionBar(backstackEntry.resolvedPage);
if (Trace.isEnabled()) {
Trace.write(`${this}.popToViewControllerAnimated(${controller}, ${animated}); depth = ${navDepth}`, Trace.categories.Navigation);
}
this._ios.controller.popToViewControllerAnimated(controller, animated);
}
public _updateActionBar(page?: Page, disableNavBarAnimation: boolean = false): void {
super._updateActionBar(page);
if (page && this.currentPage && this.currentPage.modal === page) {
return;
}
page = page || this.currentPage;
let newValue = this._getNavBarVisible(page);
let disableNavBarAnimationCache = this._ios._disableNavBarAnimation;
if (disableNavBarAnimation) {
this._ios._disableNavBarAnimation = true;
}
this._ios.showNavigationBar = newValue;
if (disableNavBarAnimation) {
this._ios._disableNavBarAnimation = disableNavBarAnimationCache;
}
if (this._ios.controller.navigationBar) {
this._ios.controller.navigationBar.userInteractionEnabled = this.navigationQueueIsEmpty();
}
}
public _getNavBarVisible(page: Page): boolean {
switch (this.actionBarVisibility) {
case 'always':
return true;
case 'never':
return false;
case 'auto':
switch (this._ios.navBarVisibility) {
case 'always':
return true;
case 'never':
return false;
case 'auto':
let newValue: boolean;
if (page && page.actionBarHidden !== undefined) {
newValue = !page.actionBarHidden;
} else {
newValue = this.ios.controller.viewControllers.count > 1 || (page && page.actionBar && !page.actionBar._isEmpty());
}
newValue = !!newValue;
return newValue;
}
}
}
public static get defaultAnimatedNavigation(): boolean {
return FrameBase.defaultAnimatedNavigation;
}
public static set defaultAnimatedNavigation(value: boolean) {
FrameBase.defaultAnimatedNavigation = value;
}
public static get defaultTransition(): NavigationTransition {
return FrameBase.defaultTransition;
}
public static set defaultTransition(value: NavigationTransition) {
FrameBase.defaultTransition = value;
}
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
const width = layout.getMeasureSpecSize(widthMeasureSpec);
const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
const height = layout.getMeasureSpecSize(heightMeasureSpec);
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
const widthAndState = View.resolveSizeAndState(width, width, widthMode, 0);
const heightAndState = View.resolveSizeAndState(height, height, heightMode, 0);
this.setMeasuredDimension(widthAndState, heightAndState);
}
public layoutNativeView(left: number, top: number, right: number, bottom: number): void {
//
}
public _setNativeViewFrame(nativeView: UIView, frame: CGRect) {
//
}
public _onNavigatingTo(backstackEntry: BackstackEntry, isBack: boolean) {
//
}
}
let transitionDelegates = new Array<TransitionDelegate>();
class TransitionDelegate extends NSObject {
private _id: string;
public static initWithOwnerId(id: string): TransitionDelegate {
let delegate = <TransitionDelegate>TransitionDelegate.new();
delegate._id = id;
transitionDelegates.push(delegate);
return delegate;
}
public animationWillStart(animationID: string, context: any): void {
if (Trace.isEnabled()) {
Trace.write(`START ${this._id}`, Trace.categories.Transition);
}
}
public animationDidStop(animationID: string, finished: boolean, context: any): void {
if (finished) {
if (Trace.isEnabled()) {
Trace.write(`END ${this._id}`, Trace.categories.Transition);
}
} else {
if (Trace.isEnabled()) {
Trace.write(`CANCEL ${this._id}`, Trace.categories.Transition);
}
}
let index = transitionDelegates.indexOf(this);
if (index > -1) {
transitionDelegates.splice(index, 1);
}
}
public static ObjCExposedMethods = {
animationWillStart: {
returns: interop.types.void,
params: [NSString, NSObject],
},
animationDidStop: {
returns: interop.types.void,
params: [NSString, NSNumber, NSObject],
},
};
}
const _defaultTransitionDuration = 0.35;
class UINavigationControllerAnimatedDelegate extends NSObject implements UINavigationControllerDelegate {
public static ObjCProtocols = [UINavigationControllerDelegate];
navigationControllerAnimationControllerForOperationFromViewControllerToViewController(navigationController: UINavigationController, operation: number, fromVC: UIViewController, toVC: UIViewController): UIViewControllerAnimatedTransitioning {
let viewController: UIViewController;
switch (operation) {
case UINavigationControllerOperation.Push:
viewController = toVC;
break;
case UINavigationControllerOperation.Pop:
viewController = fromVC;
break;
}
if (!viewController) {
return null;
}
let navigationTransition = <NavigationTransition>viewController[TRANSITION];
if (!navigationTransition) {
return null;
}
if (Trace.isEnabled()) {
Trace.write(`UINavigationControllerImpl.navigationControllerAnimationControllerForOperationFromViewControllerToViewController(${operation}, ${fromVC}, ${toVC}), transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle);
}
let curve = _getNativeCurve(navigationTransition);
let animationController = _createIOSAnimatedTransitioning(navigationTransition, curve, operation, fromVC, toVC);
return animationController;
}
}
class UINavigationControllerImpl extends UINavigationController {
private _owner: WeakRef<Frame>;
public static initWithOwner(owner: WeakRef<Frame>): UINavigationControllerImpl {
let controller = <UINavigationControllerImpl>UINavigationControllerImpl.new();
controller._owner = owner;
return controller;
}
get owner(): Frame {
return this._owner.get();
}
@profile()
public viewWillAppear(animated: boolean): void {
super.viewWillAppear(animated);
const owner = this._owner.get();
if (owner && !owner.isLoaded && !owner.parent) {
owner.callLoaded();
}
}
@profile()
public viewDidDisappear(animated: boolean): void {
super.viewDidDisappear(animated);
const owner = this._owner.get();
if (owner && owner.isLoaded && !owner.parent && !this.presentedViewController) {
owner.callUnloaded();
owner._tearDownUI(true);
}
}
private animateWithDuration(navigationTransition: NavigationTransition, nativeTransition: UIViewAnimationTransition, transitionType: string, baseCallback: Function): void {
let duration = navigationTransition.duration ? navigationTransition.duration / 1000 : _defaultTransitionDuration;
let curve = _getNativeCurve(navigationTransition);
let transitionTraced = Trace.isCategorySet(Trace.categories.Transition);
let transitionDelegate: TransitionDelegate;
if (transitionTraced) {
let id = _getTransitionId(nativeTransition, transitionType);
transitionDelegate = TransitionDelegate.initWithOwnerId(id);
}
UIView.animateWithDurationAnimations(duration, () => {
if (transitionTraced) {
UIView.setAnimationDelegate(transitionDelegate);
}
UIView.setAnimationWillStartSelector('animationWillStart');
UIView.setAnimationDidStopSelector('animationDidStop');
UIView.setAnimationCurve(curve);
baseCallback();
UIView.setAnimationTransitionForViewCache(nativeTransition, this.view, true);
});
}
@profile()
public pushViewControllerAnimated(viewController: UIViewController, animated: boolean): void {
let navigationTransition = <NavigationTransition>viewController[TRANSITION];
if (Trace.isEnabled()) {
Trace.write(`UINavigationControllerImpl.pushViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle);
}
let nativeTransition = _getNativeTransition(navigationTransition, true);
if (!animated || !navigationTransition || !nativeTransition) {
super.pushViewControllerAnimated(viewController, animated);
return;
}
this.animateWithDuration(navigationTransition, nativeTransition, 'push', () => {
super.pushViewControllerAnimated(viewController, false);
});
}
@profile()
public setViewControllersAnimated(viewControllers: NSArray<any>, animated: boolean): void {
let viewController = viewControllers.lastObject;
let navigationTransition = <NavigationTransition>viewController[TRANSITION];
if (Trace.isEnabled()) {
Trace.write(`UINavigationControllerImpl.setViewControllersAnimated(${viewControllers}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle);
}
let nativeTransition = _getNativeTransition(navigationTransition, true);
if (!animated || !navigationTransition || !nativeTransition) {
super.setViewControllersAnimated(viewControllers, animated);
return;
}
this.animateWithDuration(navigationTransition, nativeTransition, 'set', () => {
super.setViewControllersAnimated(viewControllers, false);
});
}
public popViewControllerAnimated(animated: boolean): UIViewController {
let lastViewController = this.viewControllers.lastObject;
let navigationTransition = <NavigationTransition>lastViewController[TRANSITION];
if (Trace.isEnabled()) {
Trace.write(`UINavigationControllerImpl.popViewControllerAnimated(${animated}); transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle);
}
if (navigationTransition && navigationTransition.name === NON_ANIMATED_TRANSITION) {
//https://github.com/NativeScript/NativeScript/issues/1787
return super.popViewControllerAnimated(false);
}
let nativeTransition = _getNativeTransition(navigationTransition, false);
if (!animated || !navigationTransition || !nativeTransition) {
return super.popViewControllerAnimated(animated);
}
this.animateWithDuration(navigationTransition, nativeTransition, 'pop', () => {
super.popViewControllerAnimated(false);
});
return null;
}
public popToViewControllerAnimated(viewController: UIViewController, animated: boolean): NSArray<UIViewController> {
let lastViewController = this.viewControllers.lastObject;
let navigationTransition = <NavigationTransition>lastViewController[TRANSITION];
if (Trace.isEnabled()) {
Trace.write(`UINavigationControllerImpl.popToViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, Trace.categories.NativeLifecycle);
}
if (navigationTransition && navigationTransition.name === NON_ANIMATED_TRANSITION) {
//https://github.com/NativeScript/NativeScript/issues/1787
return super.popToViewControllerAnimated(viewController, false);
}
let nativeTransition = _getNativeTransition(navigationTransition, false);
if (!animated || !navigationTransition || !nativeTransition) {
return super.popToViewControllerAnimated(viewController, animated);
}
this.animateWithDuration(navigationTransition, nativeTransition, 'popTo', () => {
super.popToViewControllerAnimated(viewController, false);
});
return null;
}
// Mind implementation for other controllers
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,
});
}
}
}
}
function _getTransitionId(nativeTransition: UIViewAnimationTransition, transitionType: string): string {
let name;
switch (nativeTransition) {
case UIViewAnimationTransition.CurlDown:
name = 'CurlDown';
break;
case UIViewAnimationTransition.CurlUp:
name = 'CurlUp';
break;
case UIViewAnimationTransition.FlipFromLeft:
name = 'FlipFromLeft';
break;
case UIViewAnimationTransition.FlipFromRight:
name = 'FlipFromRight';
break;
case UIViewAnimationTransition.None:
name = 'None';
break;
}
return `${name} ${transitionType}`;
}
function _getNativeTransition(navigationTransition: NavigationTransition, push: boolean): UIViewAnimationTransition {
if (navigationTransition && navigationTransition.name) {
switch (navigationTransition.name.toLowerCase()) {
case 'flip':
case 'flipright':
return push ? UIViewAnimationTransition.FlipFromRight : UIViewAnimationTransition.FlipFromLeft;
case 'flipleft':
return push ? UIViewAnimationTransition.FlipFromLeft : UIViewAnimationTransition.FlipFromRight;
case 'curl':
case 'curlup':
return push ? UIViewAnimationTransition.CurlUp : UIViewAnimationTransition.CurlDown;
case 'curldown':
return push ? UIViewAnimationTransition.CurlDown : UIViewAnimationTransition.CurlUp;
}
}
return null;
}
export function _getNativeCurve(transition: NavigationTransition): UIViewAnimationCurve {
if (transition.curve) {
switch (transition.curve) {
case 'easeIn':
if (Trace.isEnabled()) {
Trace.write('Transition curve resolved to UIViewAnimationCurve.EaseIn.', Trace.categories.Transition);
}
return UIViewAnimationCurve.EaseIn;
case 'easeOut':
if (Trace.isEnabled()) {
Trace.write('Transition curve resolved to UIViewAnimationCurve.EaseOut.', Trace.categories.Transition);
}
return UIViewAnimationCurve.EaseOut;
case 'easeInOut':
if (Trace.isEnabled()) {
Trace.write('Transition curve resolved to UIViewAnimationCurve.EaseInOut.', Trace.categories.Transition);
}
return UIViewAnimationCurve.EaseInOut;
case 'linear':
if (Trace.isEnabled()) {
Trace.write('Transition curve resolved to UIViewAnimationCurve.Linear.', Trace.categories.Transition);
}
return UIViewAnimationCurve.Linear;
default:
if (Trace.isEnabled()) {
Trace.write('Transition curve resolved to original: ' + transition.curve, Trace.categories.Transition);
}
return transition.curve;
}
}
return UIViewAnimationCurve.EaseInOut;
}
/* tslint:disable */
class iOSFrame implements iOSFrameDefinition {
/* tslint:enable */
private _controller: UINavigationControllerImpl;
private _showNavigationBar: boolean;
private _navBarVisibility: 'auto' | 'never' | 'always' = 'auto';
// TabView uses this flag to disable animation while showing/hiding the navigation bar because of the "< More" bar.
// See the TabView._handleTwoNavigationBars method for more details.
public _disableNavBarAnimation: boolean;
constructor(frame: Frame) {
this._controller = UINavigationControllerImpl.initWithOwner(new WeakRef(frame));
}
public get controller() {
return this._controller;
}
public set controller(value: UINavigationControllerImpl) {
this._controller = value;
}
public get showNavigationBar(): boolean {
return this._showNavigationBar;
}
public set showNavigationBar(value: boolean) {
this._showNavigationBar = value;
this._controller.setNavigationBarHiddenAnimated(!value, !this._disableNavBarAnimation);
}
public get navBarVisibility(): 'auto' | 'never' | 'always' {
return this._navBarVisibility;
}
public set navBarVisibility(value: 'auto' | 'never' | 'always') {
this._navBarVisibility = value;
}
}

View File

@@ -1,5 +0,0 @@
{
"name": "frame",
"main": "frame",
"types": "frame.d.ts"
}

View File

@@ -1,72 +1,54 @@
// Definitions for Android API lvl 21 transitions
declare module android {
export module transition {
export abstract class Transition extends java.lang.Object {
addListener(transition: Transition.TransitionListener): Transition;
removeListener(
transition: Transition.TransitionListener
): Transition;
setDuration(duration: number): Transition;
setInterpolator(
interpolator: android.animation.TimeInterpolator
): Transition;
}
export module transition {
export abstract class Transition extends java.lang.Object {
addListener(transition: Transition.TransitionListener): Transition;
removeListener(transition: Transition.TransitionListener): Transition;
setDuration(duration: number): Transition;
setInterpolator(interpolator: android.animation.TimeInterpolator): Transition;
}
export abstract class Visibility extends android.transition.Transition {
constructor();
}
export abstract class Visibility extends android.transition.Transition {
constructor();
}
export class Slide extends Visibility {
constructor(slideEdge: number);
}
export class Slide extends Visibility {
constructor(slideEdge: number);
}
export class Fade extends Visibility {
constructor(fadingMode: number);
static IN: number;
static OUT: number;
}
export class Fade extends Visibility {
constructor(fadingMode: number);
static IN: number;
static OUT: number;
}
export class Explode extends Visibility {
constructor();
}
export class Explode extends Visibility {
constructor();
}
export module Transition {
export interface TransitionListener {
onTransitionStart(
transition: android.transition.Transition
): void;
onTransitionEnd(
transition: android.transition.Transition
): void;
onTransitionResume(
transition: android.transition.Transition
): void;
onTransitionPause(
transition: android.transition.Transition
): void;
onTransitionCancel(
transition: android.transition.Transition
): void;
}
}
}
export module Transition {
export interface TransitionListener {
onTransitionStart(transition: android.transition.Transition): void;
onTransitionEnd(transition: android.transition.Transition): void;
onTransitionResume(transition: android.transition.Transition): void;
onTransitionPause(transition: android.transition.Transition): void;
onTransitionCancel(transition: android.transition.Transition): void;
}
}
}
export module app {
export interface Fragment {
getEnterTransition(): android.transition.Transition;
getExitTransition(): android.transition.Transition;
getReenterTransition(): android.transition.Transition;
getReturnTransition(): android.transition.Transition;
setEnterTransition(transition: android.transition.Transition): void;
setExitTransition(transition: android.transition.Transition): void;
setReenterTransition(
transition: android.transition.Transition
): void;
setReturnTransition(
transition: android.transition.Transition
): void;
setAllowEnterTransitionOverlap(allow: boolean): void;
setAllowReturnTransitionOverlap(allow: boolean): void;
}
}
export module app {
export interface Fragment {
getEnterTransition(): android.transition.Transition;
getExitTransition(): android.transition.Transition;
getReenterTransition(): android.transition.Transition;
getReturnTransition(): android.transition.Transition;
setEnterTransition(transition: android.transition.Transition): void;
setExitTransition(transition: android.transition.Transition): void;
setReenterTransition(transition: android.transition.Transition): void;
setReturnTransition(transition: android.transition.Transition): void;
setAllowEnterTransitionOverlap(allow: boolean): void;
setAllowReturnTransitionOverlap(allow: boolean): void;
}
}
}