mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: update tslint rules (#7391)
This commit is contained in:
@@ -13,6 +13,7 @@ class NativeScriptActivity extends androidx.appcompat.app.AppCompatActivity {
|
||||
public isNativeScriptActivity;
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ class FragmentClass extends org.nativescript.widgets.FragmentBase {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@@ -33,6 +34,7 @@ class FragmentClass extends org.nativescript.widgets.FragmentBase {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ interface ExpandedEntry extends BackstackEntry {
|
||||
|
||||
transition: Transition;
|
||||
transitionName: string;
|
||||
frameId: number
|
||||
frameId: number;
|
||||
useLollipopTransition: boolean;
|
||||
}
|
||||
|
||||
@@ -291,6 +291,7 @@ function getTransitionListener(entry: ExpandedEntry, transition: android.transit
|
||||
class TransitionListenerImpl extends java.lang.Object implements android.transition.Transition.TransitionListener {
|
||||
constructor(public entry: ExpandedEntry, public transition: android.transition.Transition) {
|
||||
super();
|
||||
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@@ -343,6 +344,7 @@ function getAnimationListener(): android.animation.Animator.AnimatorListener {
|
||||
class AnimationListenerImpl extends java.lang.Object implements android.animation.Animator.AnimatorListener {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@@ -710,6 +712,7 @@ function setUpNativeTransition(navigationTransition: NavigationTransition, nativ
|
||||
function addNativeTransitionListener(entry: ExpandedEntry, nativeTransition: android.transition.Transition): ExpandedTransitionListener {
|
||||
const listener = getTransitionListener(entry, nativeTransition);
|
||||
nativeTransition.addListener(listener);
|
||||
|
||||
return listener;
|
||||
}
|
||||
|
||||
@@ -778,12 +781,14 @@ function printTransitions(entry: ExpandedEntry) {
|
||||
function javaObjectArray(...params: java.lang.Object[]) {
|
||||
const nativeArray = Array.create(java.lang.Object, params.length);
|
||||
params.forEach((value, i) => nativeArray[i] = value);
|
||||
|
||||
return nativeArray;
|
||||
}
|
||||
|
||||
function createDummyZeroDurationAnimator(): android.animation.Animator {
|
||||
const animator = android.animation.ValueAnimator.ofObject(intEvaluator(), javaObjectArray(java.lang.Integer.valueOf(0), java.lang.Integer.valueOf(1)));
|
||||
animator.setDuration(0);
|
||||
|
||||
return animator;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NavigationTransition } from "./frame";
|
||||
import { NavigationTransition } from "./frame";
|
||||
import { Transition } from "../transition/transition";
|
||||
import { SlideTransition } from "../transition/slide-transition";
|
||||
import { FadeTransition } from "../transition/fade-transition";
|
||||
@@ -32,6 +32,7 @@ class AnimatedTransitioning extends NSObject implements UIViewControllerAnimated
|
||||
impl._operation = operation;
|
||||
impl._fromVC = fromVC;
|
||||
impl._toVC = toVC;
|
||||
|
||||
return impl;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Definitions.
|
||||
// Definitions.
|
||||
import { Frame as FrameDefinition, NavigationEntry, BackstackEntry, NavigationTransition } from ".";
|
||||
import { Page } from "../page";
|
||||
|
||||
@@ -27,7 +27,7 @@ function buildEntryFromArgs(arg: any): NavigationEntry {
|
||||
} else if (typeof arg === "function") {
|
||||
entry = {
|
||||
create: arg
|
||||
}
|
||||
};
|
||||
} else {
|
||||
entry = arg;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ export interface NavigationContext {
|
||||
entry: BackstackEntry;
|
||||
// TODO: remove isBackNavigation for NativeScript 6.0
|
||||
isBackNavigation: boolean;
|
||||
navigationType: NavigationType
|
||||
navigationType: NavigationType;
|
||||
}
|
||||
|
||||
@CSSType("Frame")
|
||||
@@ -139,7 +139,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
entry: backstackEntry,
|
||||
isBackNavigation: true,
|
||||
navigationType: NavigationType.back
|
||||
}
|
||||
};
|
||||
|
||||
this._navigationQueue.push(navigationContext);
|
||||
this._processNextNavigationEntry();
|
||||
@@ -210,7 +210,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
entry: backstackEntry,
|
||||
isBackNavigation: false,
|
||||
navigationType: NavigationType.forward
|
||||
}
|
||||
};
|
||||
|
||||
this._navigationQueue.push(navigationContext);
|
||||
this._processNextNavigationEntry();
|
||||
@@ -609,6 +609,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
traceWrite(`Change Handled: Replacing page ${context.path}`, traceCategories.Livesync);
|
||||
|
||||
this.replacePage(context);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -635,7 +636,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
create: currentEntry.create,
|
||||
moduleName: currentEntry.moduleName,
|
||||
backstackVisible: currentEntry.backstackVisible
|
||||
}
|
||||
};
|
||||
|
||||
// If create returns the same page instance we can't recreate it.
|
||||
// Instead of navigation set activity content.
|
||||
@@ -648,6 +649,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
}
|
||||
|
||||
this.navigate(newEntry);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -664,7 +666,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
frameId: currentBackstackEntry.frameId
|
||||
};
|
||||
|
||||
const navigationContext: NavigationContext = {
|
||||
const navigationContext: NavigationContext = {
|
||||
entry: newBackstackEntry,
|
||||
isBackNavigation: false,
|
||||
navigationType: NavigationType.replace
|
||||
@@ -687,6 +689,7 @@ export function goBack(): boolean {
|
||||
const top = topmost();
|
||||
if (top && top.canGoBack()) {
|
||||
top.goBack();
|
||||
|
||||
return true;
|
||||
} else if (top) {
|
||||
let parentFrameCanGoBack = false;
|
||||
@@ -702,6 +705,7 @@ export function goBack(): boolean {
|
||||
|
||||
if (parentFrame && parentFrameCanGoBack) {
|
||||
parentFrame.goBack();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -722,7 +726,7 @@ export const defaultPage = new Property<FrameBase, string>({
|
||||
frame.navigate({ moduleName: newValue });
|
||||
}
|
||||
});
|
||||
defaultPage.register(FrameBase)
|
||||
defaultPage.register(FrameBase);
|
||||
|
||||
export const actionBarVisibilityProperty = new Property<FrameBase, "auto" | "never" | "always">({ name: "actionBarVisibility", defaultValue: "auto", affectsLayout: isIOS });
|
||||
actionBarVisibilityProperty.register(FrameBase);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Definitions.
|
||||
// Definitions.
|
||||
import {
|
||||
AndroidFrame as AndroidFrameDefinition, AndroidActivityCallbacks,
|
||||
AndroidFragmentCallbacks, BackstackEntry, NavigationTransition
|
||||
@@ -59,6 +59,7 @@ function getAttachListener(): android.view.View.OnAttachStateChangeListener {
|
||||
class AttachListener extends java.lang.Object implements android.view.View.OnAttachStateChangeListener {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
return global.__native(this);
|
||||
}
|
||||
|
||||
@@ -330,6 +331,7 @@ export class Frame extends FrameBase {
|
||||
public onBackPressed(): boolean {
|
||||
if (this.canGoBack()) {
|
||||
this.goBack();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -337,6 +339,7 @@ export class Frame extends FrameBase {
|
||||
const manager = this._getFragmentManager();
|
||||
if (manager) {
|
||||
manager.executePendingTransactions();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -837,18 +840,21 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
||||
const entry = this.entry;
|
||||
if (!entry) {
|
||||
traceError(`${fragment}.onCreateView: entry is null or undefined`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const page = entry.resolvedPage;
|
||||
if (!page) {
|
||||
traceError(`${fragment}.onCreateView: entry has no resolvedPage`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const frame = this.frame;
|
||||
if (!frame) {
|
||||
traceError(`${fragment}.onCreateView: this.frame is null or undefined`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -927,6 +933,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
||||
const entry = this.entry;
|
||||
if (!entry) {
|
||||
traceError(`${fragment}.onDestroy: entry is null or undefined`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -939,6 +946,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
||||
const page = entry.resolvedPage;
|
||||
if (!page) {
|
||||
traceError(`${fragment}.onDestroy: entry has no resolvedPage`);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1296,6 +1304,7 @@ const notifyLaunch = profile("notifyLaunch", function notifyLaunch(intent: andro
|
||||
|
||||
application.notify(launchArgs);
|
||||
application.notify(<application.LoadAppCSSEventData>{ eventName: "loadAppCss", object: <any>this, cssFile: application.getCssFileName() });
|
||||
|
||||
return launchArgs.root;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Definitions.
|
||||
// Definitions.
|
||||
import {
|
||||
iOSFrame as iOSFrameDefinition, BackstackEntry, NavigationTransition
|
||||
} from ".";
|
||||
@@ -86,7 +86,7 @@ export class Frame extends FrameBase {
|
||||
let animated = this.currentPage ? this._getIsAnimatedNavigation(backstackEntry.entry) : false;
|
||||
if (isReplace) {
|
||||
animated = true;
|
||||
navigationTransition = { name: HMR_REPLACE_TRANSITION, duration: 100 }
|
||||
navigationTransition = { name: HMR_REPLACE_TRANSITION, duration: 100 };
|
||||
viewController[TRANSITION] = navigationTransition;
|
||||
} else if (animated) {
|
||||
navigationTransition = this._getNavigationTransition(backstackEntry.entry);
|
||||
@@ -126,6 +126,7 @@ export class Frame extends FrameBase {
|
||||
if (traceEnabled()) {
|
||||
traceWrite(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, traceCategories.Navigation);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -145,6 +146,7 @@ export class Frame extends FrameBase {
|
||||
if (traceEnabled()) {
|
||||
traceWrite(`${this}.setViewControllersAnimated([${viewController}], ${animated}); depth = ${navDepth}`, traceCategories.Navigation);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -172,6 +174,7 @@ export class Frame extends FrameBase {
|
||||
if (traceEnabled()) {
|
||||
traceWrite(`${this}.setViewControllersAnimated([originalControllers - lastController + ${viewController}], ${animated}); depth = ${navDepth}`, traceCategories.Navigation);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -249,7 +252,8 @@ export class Frame extends FrameBase {
|
||||
newValue = this.ios.controller.viewControllers.count > 1 || (page && page.actionBar && !page.actionBar._isEmpty());
|
||||
}
|
||||
|
||||
newValue = !!newValue; // Make sure it is boolean
|
||||
newValue = !!newValue;
|
||||
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
@@ -374,6 +378,7 @@ class UINavigationControllerAnimatedDelegate extends NSObject implements UINavig
|
||||
|
||||
let curve = _getNativeCurve(navigationTransition);
|
||||
let animationController = _createIOSAnimatedTransitioning(navigationTransition, curve, operation, fromVC, toVC);
|
||||
|
||||
return animationController;
|
||||
}
|
||||
}
|
||||
@@ -384,6 +389,7 @@ class UINavigationControllerImpl extends UINavigationController {
|
||||
public static initWithOwner(owner: WeakRef<Frame>): UINavigationControllerImpl {
|
||||
let controller = <UINavigationControllerImpl>UINavigationControllerImpl.new();
|
||||
controller._owner = owner;
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
@@ -449,6 +455,7 @@ class UINavigationControllerImpl extends UINavigationController {
|
||||
let nativeTransition = _getNativeTransition(navigationTransition, true);
|
||||
if (!animated || !navigationTransition || !nativeTransition) {
|
||||
super.pushViewControllerAnimated(viewController, animated);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -469,6 +476,7 @@ class UINavigationControllerImpl extends UINavigationController {
|
||||
let nativeTransition = _getNativeTransition(navigationTransition, true);
|
||||
if (!animated || !navigationTransition || !nativeTransition) {
|
||||
super.setViewControllersAnimated(viewControllers, animated);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -565,30 +573,35 @@ export function _getNativeCurve(transition: NavigationTransition): UIViewAnimati
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Transition curve resolved to UIViewAnimationCurve.EaseIn.", traceCategories.Transition);
|
||||
}
|
||||
|
||||
return UIViewAnimationCurve.EaseIn;
|
||||
|
||||
case "easeOut":
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Transition curve resolved to UIViewAnimationCurve.EaseOut.", traceCategories.Transition);
|
||||
}
|
||||
|
||||
return UIViewAnimationCurve.EaseOut;
|
||||
|
||||
case "easeInOut":
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Transition curve resolved to UIViewAnimationCurve.EaseInOut.", traceCategories.Transition);
|
||||
}
|
||||
|
||||
return UIViewAnimationCurve.EaseInOut;
|
||||
|
||||
case "linear":
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Transition curve resolved to UIViewAnimationCurve.Linear.", traceCategories.Transition);
|
||||
}
|
||||
|
||||
return UIViewAnimationCurve.Linear;
|
||||
|
||||
default:
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Transition curve resolved to original: " + transition.curve, traceCategories.Transition);
|
||||
}
|
||||
|
||||
return transition.curve;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user