mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
chore: typing cleanup
This commit is contained in:
2
packages/core/ui/action-bar/index.d.ts
vendored
2
packages/core/ui/action-bar/index.d.ts
vendored
@ -151,11 +151,13 @@ export class ActionItem extends ViewBase {
|
||||
/**
|
||||
* Gets the iOS specific options of the action item.
|
||||
*/
|
||||
// @ts-ignore
|
||||
ios: IOSActionItemSettings;
|
||||
|
||||
/**
|
||||
* Gets the Android specific options of the action item.
|
||||
*/
|
||||
// @ts-ignore
|
||||
android: AndroidActionItemSettings;
|
||||
}
|
||||
|
||||
|
2
packages/core/ui/core/view/index.d.ts
vendored
2
packages/core/ui/core/view/index.d.ts
vendored
@ -150,11 +150,13 @@ export abstract class View extends ViewBase {
|
||||
/**
|
||||
* Gets the android-specific native instance that lies behind this proxy. Will be available if running on an Android platform.
|
||||
*/
|
||||
// @ts-ignore
|
||||
public android: any;
|
||||
|
||||
/**
|
||||
* Gets the ios-specific native instance that lies behind this proxy. Will be available if running on an iOS platform.
|
||||
*/
|
||||
// @ts-ignore
|
||||
public ios: any;
|
||||
|
||||
/**
|
||||
|
6
packages/core/ui/frame/index.d.ts
vendored
6
packages/core/ui/frame/index.d.ts
vendored
@ -87,26 +87,31 @@ export class Frame extends FrameBase {
|
||||
/**
|
||||
* Gets the back stack of this instance.
|
||||
*/
|
||||
// @ts-ignore
|
||||
backStack: Array<BackstackEntry>;
|
||||
|
||||
/**
|
||||
* Gets the Page instance the Frame is currently navigated to.
|
||||
*/
|
||||
// @ts-ignore
|
||||
currentPage: Page;
|
||||
|
||||
/**
|
||||
* Gets the NavigationEntry instance the Frame is currently navigated to.
|
||||
*/
|
||||
// @ts-ignore
|
||||
currentEntry: NavigationEntry;
|
||||
|
||||
/**
|
||||
* Gets or sets if navigation transitions should be animated.
|
||||
*/
|
||||
// @ts-ignore
|
||||
animated: boolean;
|
||||
|
||||
/**
|
||||
* Gets or sets the default navigation transition for this frame.
|
||||
*/
|
||||
// @ts-ignore
|
||||
transition: NavigationTransition;
|
||||
|
||||
/**
|
||||
@ -149,6 +154,7 @@ export class Frame extends FrameBase {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
// @ts-ignore
|
||||
navigationBarHeight: number;
|
||||
/**
|
||||
* @private
|
||||
|
@ -60,6 +60,7 @@ export { Slider } from './slider';
|
||||
export { addTaggedAdditionalCSS, removeTaggedAdditionalCSS, resolveFileNameFromUrl } from './styling/style-scope';
|
||||
export { Background } from './styling/background';
|
||||
export type { CacheMode } from './styling/background';
|
||||
export { parseCSSShadow } from './styling/css-shadow';
|
||||
export { animationTimingFunctionConverter, timeConverter } from './styling/converters';
|
||||
export { Font } from './styling/font';
|
||||
export { Style } from './styling/style';
|
||||
|
@ -39,5 +39,5 @@ export interface TransitionAnimation {
|
||||
rotate?: number; // in degrees
|
||||
opacity?: number;
|
||||
duration?: number; // in milliseconds
|
||||
curve?: AnimationCurve;
|
||||
curve?: any; // TODO: type collisision branch fixes this! AnimationCurve;
|
||||
}
|
||||
|
6
packages/core/ui/page/index.d.ts
vendored
6
packages/core/ui/page/index.d.ts
vendored
@ -56,16 +56,19 @@ export declare class Page extends PageBase {
|
||||
/**
|
||||
* Gets or sets the style of the status bar.
|
||||
*/
|
||||
// @ts-ignore
|
||||
public statusBarStyle: 'light' | 'dark';
|
||||
|
||||
/**
|
||||
* Gets or sets the color of the status bar in Android.
|
||||
*/
|
||||
// @ts-ignore
|
||||
public androidStatusBarBackground: Color;
|
||||
|
||||
/**
|
||||
* Used to hide the Navigation Bar in iOS and the Action Bar in Android.
|
||||
*/
|
||||
// @ts-ignore
|
||||
public actionBarHidden: boolean;
|
||||
|
||||
/**
|
||||
@ -81,16 +84,19 @@ export declare class Page extends PageBase {
|
||||
/**
|
||||
* A property that is used to pass a data from another page (while navigate to).
|
||||
*/
|
||||
// @ts-ignore
|
||||
public navigationContext: any;
|
||||
|
||||
/**
|
||||
* Gets the Frame object controlling this instance.
|
||||
*/
|
||||
// @ts-ignore
|
||||
public frame: Frame;
|
||||
|
||||
/**
|
||||
* Gets the ActionBar for this page.
|
||||
*/
|
||||
// @ts-ignore
|
||||
public actionBar: ActionBar;
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@ import { Background as BackgroundDefinition } from './background';
|
||||
import { View, Point } from '../core/view';
|
||||
import { LinearGradient } from './linear-gradient';
|
||||
import { Color } from '../../color';
|
||||
import { isDataURI, isFileOrResourcePath, layout } from '../../utils';
|
||||
import { iOSNativeHelper, isDataURI, isFileOrResourcePath, layout } from '../../utils';
|
||||
import { ImageSource } from '../../image-source';
|
||||
import { CSSValue, parse as cssParse } from '../../css-value';
|
||||
import { CSSShadow } from './css-shadow';
|
||||
@ -718,8 +718,7 @@ function drawNoRadiusNonUniformBorders(nativeView: NativeView, background: Backg
|
||||
|
||||
// TODO: use sublayer if its applied to a layout
|
||||
function drawBoxShadow(nativeView: NativeView, view: View, boxShadow: CSSShadow, background: BackgroundDefinition, useSubLayer: boolean = false) {
|
||||
// TODO: fine named 'shadow-layer' first and otherwise need to search through sublayers (need logic used in text-shadow for layer - see getShadowLayer)
|
||||
const layer: CALayer = nativeView.layer;
|
||||
const layer: CALayer = iOSNativeHelper.getShadowLayer(nativeView, 'ns-box-shadow');
|
||||
|
||||
layer.masksToBounds = false;
|
||||
nativeView.clipsToBounds = false;
|
||||
@ -752,7 +751,7 @@ function drawBoxShadow(nativeView: NativeView, view: View, boxShadow: CSSShadow,
|
||||
|
||||
function clearBoxShadow(nativeView: NativeView) {
|
||||
nativeView.clipsToBounds = true;
|
||||
const layer: CALayer = nativeView.layer;
|
||||
const layer: CALayer = iOSNativeHelper.getShadowLayer(nativeView, 'ns-box-shadow');
|
||||
layer.masksToBounds = true;
|
||||
layer.shadowOffset = CGSizeMake(0, 0);
|
||||
layer.shadowColor = UIColor.clearColor.CGColor;
|
||||
|
@ -802,8 +802,7 @@ export const backgroundImageProperty = new CssProperty<Style, string | LinearGra
|
||||
name: 'backgroundImage',
|
||||
cssName: 'background-image',
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withImage(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withImage(newValue);
|
||||
},
|
||||
equalityComparer: (value1, value2) => {
|
||||
if (value1 instanceof LinearGradient && value2 instanceof LinearGradient) {
|
||||
@ -816,8 +815,7 @@ export const backgroundImageProperty = new CssProperty<Style, string | LinearGra
|
||||
if (typeof value === 'string') {
|
||||
const parsed = parser.parseBackground(value);
|
||||
if (parsed) {
|
||||
const background = parsed.value;
|
||||
value = typeof background.image === 'object' ? LinearGradient.parse(background.image) : value;
|
||||
value = typeof parsed.value.image === 'object' ? LinearGradient.parse(parsed.value.image) : value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -830,8 +828,7 @@ export const backgroundColorProperty = new CssAnimationProperty<Style, Color>({
|
||||
name: 'backgroundColor',
|
||||
cssName: 'background-color',
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withColor(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withColor(newValue);
|
||||
},
|
||||
equalityComparer: Color.equals,
|
||||
valueConverter: (value) => new Color(value),
|
||||
@ -853,8 +850,7 @@ export const backgroundRepeatProperty = new CssProperty<Style, BackgroundRepeat>
|
||||
cssName: 'background-repeat',
|
||||
valueConverter: BackgroundRepeat.parse,
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withRepeat(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withRepeat(newValue);
|
||||
},
|
||||
});
|
||||
backgroundRepeatProperty.register(Style);
|
||||
@ -863,8 +859,7 @@ export const backgroundSizeProperty = new CssProperty<Style, string>({
|
||||
name: 'backgroundSize',
|
||||
cssName: 'background-size',
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withSize(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withSize(newValue);
|
||||
},
|
||||
});
|
||||
backgroundSizeProperty.register(Style);
|
||||
@ -873,8 +868,7 @@ export const backgroundPositionProperty = new CssProperty<Style, string>({
|
||||
name: 'backgroundPosition',
|
||||
cssName: 'background-position',
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withPosition(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withPosition(newValue);
|
||||
},
|
||||
});
|
||||
backgroundPositionProperty.register(Style);
|
||||
@ -998,8 +992,7 @@ export const borderTopColorProperty = new CssProperty<Style, Color>({
|
||||
name: 'borderTopColor',
|
||||
cssName: 'border-top-color',
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withBorderTopColor(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderTopColor(newValue);
|
||||
},
|
||||
equalityComparer: Color.equals,
|
||||
valueConverter: (value) => new Color(value),
|
||||
@ -1010,8 +1003,7 @@ export const borderRightColorProperty = new CssProperty<Style, Color>({
|
||||
name: 'borderRightColor',
|
||||
cssName: 'border-right-color',
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withBorderRightColor(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderRightColor(newValue);
|
||||
},
|
||||
equalityComparer: Color.equals,
|
||||
valueConverter: (value) => new Color(value),
|
||||
@ -1022,8 +1014,7 @@ export const borderBottomColorProperty = new CssProperty<Style, Color>({
|
||||
name: 'borderBottomColor',
|
||||
cssName: 'border-bottom-color',
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withBorderBottomColor(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderBottomColor(newValue);
|
||||
},
|
||||
equalityComparer: Color.equals,
|
||||
valueConverter: (value) => new Color(value),
|
||||
@ -1034,8 +1025,7 @@ export const borderLeftColorProperty = new CssProperty<Style, Color>({
|
||||
name: 'borderLeftColor',
|
||||
cssName: 'border-left-color',
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withBorderLeftColor(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderLeftColor(newValue);
|
||||
},
|
||||
equalityComparer: Color.equals,
|
||||
valueConverter: (value) => new Color(value),
|
||||
@ -1093,8 +1083,7 @@ export const borderTopWidthProperty = new CssProperty<Style, Length>({
|
||||
} else {
|
||||
Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
|
||||
}
|
||||
const background = target.backgroundInternal.withBorderTopWidth(value);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderTopWidth(value);
|
||||
},
|
||||
valueConverter: Length.parse,
|
||||
});
|
||||
@ -1118,8 +1107,7 @@ export const borderRightWidthProperty = new CssProperty<Style, Length>({
|
||||
} else {
|
||||
Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
|
||||
}
|
||||
const background = target.backgroundInternal.withBorderRightWidth(value);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderRightWidth(value);
|
||||
},
|
||||
valueConverter: Length.parse,
|
||||
});
|
||||
@ -1143,8 +1131,7 @@ export const borderBottomWidthProperty = new CssProperty<Style, Length>({
|
||||
} else {
|
||||
Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
|
||||
}
|
||||
const background = target.backgroundInternal.withBorderBottomWidth(value);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderBottomWidth(value);
|
||||
},
|
||||
valueConverter: Length.parse,
|
||||
});
|
||||
@ -1168,8 +1155,7 @@ export const borderLeftWidthProperty = new CssProperty<Style, Length>({
|
||||
} else {
|
||||
Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn);
|
||||
}
|
||||
const background = target.backgroundInternal.withBorderLeftWidth(value);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderLeftWidth(value);
|
||||
},
|
||||
valueConverter: Length.parse,
|
||||
});
|
||||
@ -1218,8 +1204,7 @@ export const borderTopLeftRadiusProperty = new CssProperty<Style, Length>({
|
||||
if (!isNonNegativeFiniteNumber(value)) {
|
||||
throw new Error(`border-top-left-radius should be Non-Negative Finite number. Value: ${value}`);
|
||||
}
|
||||
const background = target.backgroundInternal.withBorderTopLeftRadius(value);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderTopLeftRadius(value);
|
||||
},
|
||||
valueConverter: Length.parse,
|
||||
});
|
||||
@ -1235,8 +1220,7 @@ export const borderTopRightRadiusProperty = new CssProperty<Style, Length>({
|
||||
if (!isNonNegativeFiniteNumber(value)) {
|
||||
throw new Error(`border-top-right-radius should be Non-Negative Finite number. Value: ${value}`);
|
||||
}
|
||||
const background = target.backgroundInternal.withBorderTopRightRadius(value);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderTopRightRadius(value);
|
||||
},
|
||||
valueConverter: Length.parse,
|
||||
});
|
||||
@ -1252,8 +1236,7 @@ export const borderBottomRightRadiusProperty = new CssProperty<Style, Length>({
|
||||
if (!isNonNegativeFiniteNumber(value)) {
|
||||
throw new Error(`border-bottom-right-radius should be Non-Negative Finite number. Value: ${value}`);
|
||||
}
|
||||
const background = target.backgroundInternal.withBorderBottomRightRadius(value);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderBottomRightRadius(value);
|
||||
},
|
||||
valueConverter: Length.parse,
|
||||
});
|
||||
@ -1269,8 +1252,7 @@ export const borderBottomLeftRadiusProperty = new CssProperty<Style, Length>({
|
||||
if (!isNonNegativeFiniteNumber(value)) {
|
||||
throw new Error(`border-bottom-left-radius should be Non-Negative Finite number. Value: ${value}`);
|
||||
}
|
||||
const background = target.backgroundInternal.withBorderBottomLeftRadius(value);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBorderBottomLeftRadius(value);
|
||||
},
|
||||
valueConverter: Length.parse,
|
||||
});
|
||||
@ -1280,8 +1262,7 @@ const boxShadowProperty = new CssProperty<Style, CSSShadow>({
|
||||
name: 'boxShadow',
|
||||
cssName: 'box-shadow',
|
||||
valueChanged: (target, oldValue, newValue) => {
|
||||
const background = target.backgroundInternal.withBoxShadow(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withBoxShadow(newValue);
|
||||
},
|
||||
valueConverter: (value) => {
|
||||
return parseCSSShadow(value);
|
||||
@ -1311,8 +1292,7 @@ export const clipPathProperty = new CssProperty<Style, string>({
|
||||
throw new Error('clip-path is not valid.');
|
||||
}
|
||||
|
||||
const background = target.backgroundInternal.withClipPath(newValue);
|
||||
target.backgroundInternal = background;
|
||||
target.backgroundInternal = target.backgroundInternal.withClipPath(newValue);
|
||||
},
|
||||
});
|
||||
clipPathProperty.register(Style);
|
||||
|
@ -349,7 +349,7 @@ export class TextBase extends TextBaseCommon {
|
||||
}
|
||||
|
||||
_setShadow(value: CSSShadow): void {
|
||||
const layer = getShadowLayer(this);
|
||||
const layer = iOSNativeHelper.getShadowLayer(this.nativeTextViewProtected, 'ns-text-shadow');
|
||||
if (!layer) {
|
||||
Trace.write('text-shadow not applied, no layer.', Trace.categories.Style, Trace.messageType.info);
|
||||
return;
|
||||
@ -504,42 +504,6 @@ export function getTransformedText(text: string, textTransform: TextTransform):
|
||||
}
|
||||
}
|
||||
|
||||
// todo: clean up nesting & logs
|
||||
export function getShadowLayer(view: TextBase): CALayer {
|
||||
let layer: CALayer;
|
||||
const name = 'shadow-layer';
|
||||
const nativeView = view && view.nativeTextViewProtected;
|
||||
if (nativeView) {
|
||||
if (nativeView.layer) {
|
||||
if (nativeView.layer.name === name) {
|
||||
return nativeView.layer;
|
||||
} else {
|
||||
if (nativeView.layer.sublayers && nativeView.layer.sublayers.count) {
|
||||
console.log('this.nativeTextViewProtected.layer.sublayers.count:', nativeView.layer.sublayers.count);
|
||||
for (let i = 0; i < nativeView.layer.sublayers.count; i++) {
|
||||
console.log(`layer ${i}:`, nativeView.layer.sublayers.objectAtIndex(i));
|
||||
if (nativeView.layer.sublayers.objectAtIndex(i).name === name) {
|
||||
return nativeView.layer.sublayers.objectAtIndex(i);
|
||||
}
|
||||
}
|
||||
if (nativeView instanceof UITextView) {
|
||||
layer = nativeView.layer.sublayers.objectAtIndex(1);
|
||||
} else {
|
||||
layer = nativeView.layer.sublayers.objectAtIndex(nativeView.layer.sublayers.count - 1);
|
||||
}
|
||||
} else {
|
||||
layer = nativeView.layer;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// could this occur?
|
||||
console.log('no layer!');
|
||||
}
|
||||
}
|
||||
layer.name = name;
|
||||
return layer;
|
||||
}
|
||||
|
||||
function NSStringFromNSAttributedString(source: NSAttributedString | string): NSString {
|
||||
return NSString.stringWithString((source instanceof NSAttributedString && source.string) || <string>source);
|
||||
}
|
||||
|
Reference in New Issue
Block a user