mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Merge remote-tracking branch 'origin/master' into merge-release-in-master
This commit is contained in:
@@ -69,7 +69,7 @@ class AnimatedTransitioning extends NSObject implements UIViewControllerAnimated
|
||||
}
|
||||
|
||||
export function _createIOSAnimatedTransitioning(navigationTransition: NavigationTransition, nativeCurve: UIViewAnimationCurve, operation: UINavigationControllerOperation, fromVC: UIViewController, toVC: UIViewController): UIViewControllerAnimatedTransitioning {
|
||||
const instance = navigationTransition.instance;
|
||||
const instance = <Transition>navigationTransition.instance;
|
||||
let transition: Transition;
|
||||
|
||||
if (instance) {
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
// Definitions.
|
||||
import { Frame as FrameDefinition, NavigationEntry, BackstackEntry, NavigationTransition } from ".";
|
||||
import { Page } from "../page";
|
||||
|
||||
// Types.
|
||||
import { getAncestor, viewMatchesModuleContext } from "../core/view/view-common";
|
||||
import { Frame as FrameDefinition } from ".";
|
||||
import { BackstackEntry, NavigationContext, NavigationEntry, NavigationTransition, NavigationType } from "./frame-interfaces";
|
||||
import { Page } from "../page";
|
||||
import { View, CustomLayoutView, isIOS, isAndroid, traceEnabled, traceWrite, traceCategories, Property, CSSType } from "../core/view";
|
||||
|
||||
// Requires.
|
||||
import { frameStack, topmost as frameStackTopmost, _pushInFrameStack, _popFromFrameStack, _removeFromFrameStack } from "./frame-stack";
|
||||
import { getAncestor, viewMatchesModuleContext } from "../core/view/view-common";
|
||||
import { Builder } from "../builder";
|
||||
import { sanitizeModuleName } from "../builder/module-name-sanitizer";
|
||||
import { profile } from "../../profiling";
|
||||
|
||||
import { frameStack, topmost as frameStackTopmost, _pushInFrameStack, _popFromFrameStack, _removeFromFrameStack } from "./frame-stack";
|
||||
import { sanitizeModuleName } from "../builder/module-name-sanitizer";
|
||||
export * from "./frame-interfaces";
|
||||
export * from "../core/view";
|
||||
|
||||
export enum NavigationType {
|
||||
back,
|
||||
forward,
|
||||
replace
|
||||
}
|
||||
|
||||
function buildEntryFromArgs(arg: any): NavigationEntry {
|
||||
let entry: NavigationEntry;
|
||||
if (typeof arg === "string") {
|
||||
@@ -35,13 +31,6 @@ function buildEntryFromArgs(arg: any): NavigationEntry {
|
||||
return entry;
|
||||
}
|
||||
|
||||
export interface NavigationContext {
|
||||
entry: BackstackEntry;
|
||||
// TODO: remove isBackNavigation for NativeScript 6.0
|
||||
isBackNavigation: boolean;
|
||||
navigationType: NavigationType;
|
||||
}
|
||||
|
||||
@CSSType("Frame")
|
||||
export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
public static androidOptionSelectedEvent = "optionSelected";
|
||||
|
||||
107
nativescript-core/ui/frame/frame-interfaces.ts
Normal file
107
nativescript-core/ui/frame/frame-interfaces.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
// Types
|
||||
import { View } from "../core/view";
|
||||
import { Page } from "../page";
|
||||
import { Transition } from "../transition";
|
||||
import { Observable } from "../../data/observable";
|
||||
|
||||
export enum NavigationType {
|
||||
back,
|
||||
forward,
|
||||
replace
|
||||
}
|
||||
|
||||
export interface TransitionState {
|
||||
enterTransitionListener: any;
|
||||
exitTransitionListener: any;
|
||||
reenterTransitionListener: any;
|
||||
returnTransitionListener: any;
|
||||
transitionName: string;
|
||||
entry: BackstackEntry;
|
||||
}
|
||||
|
||||
export interface ViewEntry {
|
||||
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;
|
||||
}
|
||||
|
||||
export interface NavigationContext {
|
||||
entry: BackstackEntry;
|
||||
// TODO: remove isBackNavigation for NativeScript 7.0
|
||||
isBackNavigation: boolean;
|
||||
navigationType: NavigationType;
|
||||
}
|
||||
|
||||
export interface NavigationTransition {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 */
|
||||
export interface iOSFrame {
|
||||
/* tslint:enable */
|
||||
controller: any /* UINavigationController */;
|
||||
navBarVisibility: "auto" | "never" | "always";
|
||||
_disableNavBarAnimation: boolean;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
AndroidFrame as AndroidFrameDefinition, AndroidActivityCallbacks,
|
||||
AndroidFragmentCallbacks, BackstackEntry, NavigationTransition
|
||||
} from ".";
|
||||
import { TransitionState } from "./frame-common";
|
||||
import { Page } from "../page";
|
||||
|
||||
// Types.
|
||||
@@ -20,21 +21,17 @@ import {
|
||||
|
||||
// TODO: Remove this and get it from global to decouple builder for angular
|
||||
import { Builder } from "../builder";
|
||||
import { CLASS_PREFIX, getRootViewCssClasses, pushToRootViewCssClasses } from "../../css/system-classes";
|
||||
import {
|
||||
CLASS_PREFIX,
|
||||
getSystemCssClasses,
|
||||
pushToSystemCssClasses,
|
||||
ROOT_VIEW_CSS_CLASS
|
||||
} from "../../css/system-classes";
|
||||
import { device } from "../../platform/platform";
|
||||
import { profile } from "../../profiling";
|
||||
|
||||
export * from "./frame-common";
|
||||
|
||||
interface TransitionState {
|
||||
enterTransitionListener: any;
|
||||
exitTransitionListener: any;
|
||||
reenterTransitionListener: any;
|
||||
returnTransitionListener: any;
|
||||
transitionName: string;
|
||||
entry: BackstackEntry;
|
||||
}
|
||||
|
||||
const ANDROID_PLATFORM = "android";
|
||||
|
||||
const INTENT_EXTRA = "com.tns.activity";
|
||||
@@ -383,8 +380,10 @@ export class Frame extends FrameBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
// HACK: This @profile decorator creates a circular dependency
|
||||
// HACK: because the function parameter type is evaluated with 'typeof'
|
||||
@profile
|
||||
public _navigateCore(newEntry: BackstackEntry) {
|
||||
public _navigateCore(newEntry: any) { // should be (newEntry: BackstackEntry)
|
||||
super._navigateCore(newEntry);
|
||||
|
||||
// set frameId here so that we could use it in fragment.transitions
|
||||
@@ -1304,12 +1303,11 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
|
||||
savedInstanceState: android.os.Bundle,
|
||||
fireLaunchEvent: boolean
|
||||
): void {
|
||||
const shouldCreateRootFrame = application._shouldCreateRootFrame();
|
||||
let rootView = this._rootView;
|
||||
|
||||
if (traceEnabled()) {
|
||||
traceWrite(
|
||||
`Frame.setActivityContent rootView: ${rootView} shouldCreateRootFrame: ${shouldCreateRootFrame} fireLaunchEvent: ${fireLaunchEvent}`,
|
||||
`Frame.setActivityContent rootView: ${rootView} shouldCreateRootFrame: false fireLaunchEvent: ${fireLaunchEvent}`,
|
||||
traceCategories.NativeLifecycle
|
||||
);
|
||||
}
|
||||
@@ -1330,59 +1328,26 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks {
|
||||
throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap.");
|
||||
}
|
||||
|
||||
if (shouldCreateRootFrame) {
|
||||
const extras = intent.getExtras();
|
||||
let frameId = -1;
|
||||
|
||||
// We have extras when we call - new Frame().navigate();
|
||||
// savedInstanceState is used when activity is recreated.
|
||||
// NOTE: On API 23+ we get extras on first run.
|
||||
// Check changed - first try to get frameId from Extras if not from saveInstanceState.
|
||||
if (extras) {
|
||||
frameId = extras.getInt(INTENT_EXTRA, -1);
|
||||
}
|
||||
|
||||
if (savedInstanceState && frameId < 0) {
|
||||
frameId = savedInstanceState.getInt(INTENT_EXTRA, -1);
|
||||
}
|
||||
|
||||
if (!rootView) {
|
||||
// If we have frameId from extras - we are starting a new activity from navigation (e.g. new Frame().navigate()))
|
||||
// Then we check if we have frameId from savedInstanceState - this happens when Activity is destroyed but app was not (e.g. suspend)
|
||||
rootView = getFrameByNumberId(frameId) || new Frame();
|
||||
}
|
||||
|
||||
if (rootView instanceof Frame) {
|
||||
rootView.navigate(mainEntry);
|
||||
} else {
|
||||
throw new Error("A Frame must be used to navigate to a Page.");
|
||||
}
|
||||
} else {
|
||||
rootView = Builder.createViewFromEntry(mainEntry);
|
||||
}
|
||||
rootView = Builder.createViewFromEntry(mainEntry);
|
||||
}
|
||||
|
||||
this._rootView = rootView;
|
||||
activityRootViewsMap.set(rootView._domId, new WeakRef(rootView));
|
||||
|
||||
const deviceType = device.deviceType.toLowerCase();
|
||||
pushToRootViewCssClasses(`${CLASS_PREFIX}${ANDROID_PLATFORM}`);
|
||||
pushToRootViewCssClasses(`${CLASS_PREFIX}${deviceType}`);
|
||||
pushToRootViewCssClasses(`${CLASS_PREFIX}${application.android.orientation}`);
|
||||
pushToRootViewCssClasses(`${CLASS_PREFIX}${application.android.systemAppearance}`);
|
||||
|
||||
const rootViewCssClasses = getRootViewCssClasses();
|
||||
pushToSystemCssClasses(`${CLASS_PREFIX}${ANDROID_PLATFORM}`);
|
||||
pushToSystemCssClasses(`${CLASS_PREFIX}${deviceType}`);
|
||||
pushToSystemCssClasses(`${CLASS_PREFIX}${application.android.orientation}`);
|
||||
pushToSystemCssClasses(`${CLASS_PREFIX}${application.android.systemAppearance}`);
|
||||
|
||||
this._rootView.cssClasses.add(ROOT_VIEW_CSS_CLASS);
|
||||
const rootViewCssClasses = getSystemCssClasses();
|
||||
rootViewCssClasses.forEach(c => this._rootView.cssClasses.add(c));
|
||||
}
|
||||
|
||||
// Initialize native visual tree;
|
||||
if (shouldCreateRootFrame) {
|
||||
// Don't setup as styleScopeHost
|
||||
rootView._setupUI(activity);
|
||||
} else {
|
||||
// setup view as styleScopeHost
|
||||
rootView._setupAsRootView(activity);
|
||||
}
|
||||
// setup view as styleScopeHost
|
||||
rootView._setupAsRootView(activity);
|
||||
|
||||
activity.setContentView(rootView.nativeViewProtected, new org.nativescript.widgets.CommonLayoutParams());
|
||||
}
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
// Definitions.
|
||||
import {
|
||||
iOSFrame as iOSFrameDefinition, BackstackEntry, NavigationTransition
|
||||
} from ".";
|
||||
import { ios as iosView } from "../core/view";
|
||||
//Types
|
||||
import { iOSFrame as iOSFrameDefinition, BackstackEntry, NavigationTransition } from ".";
|
||||
import { FrameBase, NavigationType } from "./frame-common";
|
||||
import { Page } from "../page";
|
||||
import { profile } from "../../profiling";
|
||||
import { View } from "../core/view";
|
||||
|
||||
//Types.
|
||||
import {
|
||||
FrameBase, View, isCategorySet, layout,
|
||||
NavigationType, traceCategories, traceEnabled, traceWrite
|
||||
} from "./frame-common";
|
||||
// Requires
|
||||
import { _createIOSAnimatedTransitioning } from "./fragment.transitions";
|
||||
|
||||
import * as utils from "../../utils/utils";
|
||||
import { ios as iosViewHelper } from "../core/view/view-helper";
|
||||
import { profile } from "../../profiling";
|
||||
import { ios as iosUtils, layout } from "../../utils/utils";
|
||||
import {
|
||||
isCategorySet, isEnabled as traceEnabled,
|
||||
categories as traceCategories, write as traceWrite
|
||||
} from "../../trace";
|
||||
|
||||
export * from "./frame-common";
|
||||
|
||||
const majorVersion = utils.ios.MajorVersion;
|
||||
const majorVersion = iosUtils.MajorVersion;
|
||||
|
||||
const ENTRY = "_entry";
|
||||
const DELEGATE = "_delegate";
|
||||
@@ -64,8 +63,10 @@ export class Frame extends FrameBase {
|
||||
}
|
||||
}
|
||||
|
||||
// !!! THIS PROFILE DECORATOR CREATES A CIRCULAR DEPENDENCY
|
||||
// !!! BECAUSE THE PARAMETER TYPE IS EVALUATED WITH TYPEOF
|
||||
@profile
|
||||
public _navigateCore(backstackEntry: BackstackEntry) {
|
||||
public _navigateCore(backstackEntry: any) {
|
||||
super._navigateCore(backstackEntry);
|
||||
|
||||
let viewController: UIViewController = backstackEntry.resolvedPage.ios;
|
||||
@@ -543,7 +544,7 @@ class UINavigationControllerImpl extends UINavigationController {
|
||||
if (owner &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner });
|
||||
owner.notify({ eventName: iosViewHelper.traitCollectionColorAppearanceChangedEvent, object: owner });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user