mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup
This commit is contained in:
committed by
Nathan Walker
parent
3e001ff9e7
commit
2c9f189c34
145
packages/core/__tests__/ui/styling/css-shadow.ts
Normal file
145
packages/core/__tests__/ui/styling/css-shadow.ts
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
// This has been disabled/unfinished becase with the current testing setup
|
||||||
|
// the imports don't work. We need to fully switch to jest & set up ts support
|
||||||
|
// todo: fix tests.
|
||||||
|
|
||||||
|
// import { parseCSSShadow } from "@nativescript/core/ui/styling/css-shadow";
|
||||||
|
// import { zeroLength } from "@nativescript/core";
|
||||||
|
|
||||||
|
// describe('ui', () => {
|
||||||
|
// describe('styling', () => {
|
||||||
|
// describe('css-shadow', () => {
|
||||||
|
//
|
||||||
|
// it("empty", () => {
|
||||||
|
// const shadow = parseCSSShadow("")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(zeroLength)
|
||||||
|
// expect(shadow.offsetY).toBe(zeroLength)
|
||||||
|
// expect(shadow.blurRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('black')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("1px 1px 2px black", () => {
|
||||||
|
// const shadow = parseCSSShadow("1px 1px 2px black")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(1)
|
||||||
|
// expect(shadow.offsetY).toBe(1)
|
||||||
|
// expect(shadow.blurRadius).toBe(2)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('black')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("#fc0 1px 0 10px", () => {
|
||||||
|
// const shadow = parseCSSShadow("#fc0 1px 0 10px")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(1)
|
||||||
|
// expect(shadow.offsetY).toBe(zeroLength)
|
||||||
|
// expect(shadow.blurRadius).toBe(10)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('#fc0')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("5px 5px #558abb", () => {
|
||||||
|
// const shadow = parseCSSShadow("5px 5px #558abb")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(5)
|
||||||
|
// expect(shadow.offsetY).toBe(5)
|
||||||
|
// expect(shadow.blurRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('#558abb')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("white 2px 5px", () => {
|
||||||
|
// const shadow = parseCSSShadow("white 2px 5px")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(2)
|
||||||
|
// expect(shadow.offsetY).toBe(5)
|
||||||
|
// expect(shadow.blurRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('white')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("5px 10px", () => {
|
||||||
|
// const shadow = parseCSSShadow("5px 10px")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(5)
|
||||||
|
// expect(shadow.offsetY).toBe(10)
|
||||||
|
// expect(shadow.blurRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('black')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// // box
|
||||||
|
// it("60px -16px teal", () => {
|
||||||
|
// const shadow = parseCSSShadow("60px -16px teal")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(60)
|
||||||
|
// expect(shadow.offsetY).toBe(-16)
|
||||||
|
// expect(shadow.blurRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('teal')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("10px 5px 5px black", () => {
|
||||||
|
// const shadow = parseCSSShadow("10px 5px 5px black")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(10)
|
||||||
|
// expect(shadow.offsetY).toBe(5)
|
||||||
|
// expect(shadow.blurRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('black')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("2px 2px 2px 1px rgba(0, 0, 0, 0.2)", () => {
|
||||||
|
// const shadow = parseCSSShadow("2px 2px 2px 1px rgba(0, 0, 0, 0.2)")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(2)
|
||||||
|
// expect(shadow.offsetY).toBe(2)
|
||||||
|
// expect(shadow.blurRadius).toBe(2)
|
||||||
|
// expect(shadow.spreadRadius).toBe(1)
|
||||||
|
// expect(shadow.color).toBe('rgba(0, 0, 0, 0.2)')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("inset 5em 1em gold", () => {
|
||||||
|
// const shadow = parseCSSShadow("inset 5em 1em gold")
|
||||||
|
// expect(shadow.inset).toBe(true)
|
||||||
|
// expect(shadow.offsetX).toBe(5)
|
||||||
|
// expect(shadow.offsetY).toBe(1)
|
||||||
|
// expect(shadow.blurRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('gold')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("5 10", () => {
|
||||||
|
// const shadow = parseCSSShadow("5 10")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(5)
|
||||||
|
// expect(shadow.offsetY).toBe(10)
|
||||||
|
// expect(shadow.blurRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('black')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("2 2 2 #333", () => {
|
||||||
|
// const shadow = parseCSSShadow("2 2 2 #333")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(2)
|
||||||
|
// expect(shadow.offsetY).toBe(2)
|
||||||
|
// expect(shadow.blurRadius).toBe(2)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('#333')
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// it("-1 -1 1 #333", () => {
|
||||||
|
// const shadow = parseCSSShadow("-1 -1 1 #333")
|
||||||
|
// expect(shadow.inset).toBe(false)
|
||||||
|
// expect(shadow.offsetX).toBe(-1)
|
||||||
|
// expect(shadow.offsetY).toBe(-1)
|
||||||
|
// expect(shadow.blurRadius).toBe(1)
|
||||||
|
// expect(shadow.spreadRadius).toBe(zeroLength)
|
||||||
|
// expect(shadow.color).toBe('#333')
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
//
|
||||||
@@ -20,6 +20,7 @@ class AndroidSharedA11YObservable extends SharedA11YObservable {
|
|||||||
[accessibilityStateEnabledPropName]: boolean;
|
[accessibilityStateEnabledPropName]: boolean;
|
||||||
[touchExplorationStateEnabledPropName]: boolean;
|
[touchExplorationStateEnabledPropName]: boolean;
|
||||||
|
|
||||||
|
// @ts-ignore todo: fix
|
||||||
get accessibilityServiceEnabled(): boolean {
|
get accessibilityServiceEnabled(): boolean {
|
||||||
return !!this[accessibilityStateEnabledPropName] && !!this[touchExplorationStateEnabledPropName];
|
return !!this[accessibilityStateEnabledPropName] && !!this[touchExplorationStateEnabledPropName];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import { parse } from '../../css-value';
|
|||||||
import { path, knownFolders } from '../../file-system';
|
import { path, knownFolders } from '../../file-system';
|
||||||
import * as application from '../../application';
|
import * as application from '../../application';
|
||||||
import { profile } from '../../profiling';
|
import { profile } from '../../profiling';
|
||||||
import { BoxShadow } from './box-shadow';
|
|
||||||
import { Color } from '../../color';
|
import { Color } from '../../color';
|
||||||
import { Screen } from '../../platform';
|
import { Screen } from '../../platform';
|
||||||
|
import { CSSShadow } from './css-shadow';
|
||||||
export * from './background-common';
|
export * from './background-common';
|
||||||
|
|
||||||
interface AndroidView {
|
interface AndroidView {
|
||||||
@@ -227,7 +227,7 @@ function createNativeCSSValueArray(css: string): androidNative.Array<org.natives
|
|||||||
return nativeArray;
|
return nativeArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawBoxShadow(nativeView: android.view.View, view: View, boxShadow: BoxShadow) {
|
function drawBoxShadow(nativeView: android.view.View, view: View, boxShadow: CSSShadow) {
|
||||||
const color = boxShadow.color;
|
const color = boxShadow.color;
|
||||||
const shadowOpacity = color.a;
|
const shadowOpacity = color.a;
|
||||||
const shadowColor = new Color(shadowOpacity, color.r, color.g, color.b);
|
const shadowColor = new Color(shadowOpacity, color.r, color.g, color.b);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Types
|
// Types
|
||||||
import { TextDecoration, TextAlignment, TextTransform, TextShadow, WhiteSpace, getClosestPropertyValue } from './text-base-common';
|
import { TextDecoration, TextAlignment, TextTransform, WhiteSpace, getClosestPropertyValue } from './text-base-common';
|
||||||
|
import { CSSShadow } from '../styling/css-shadow';
|
||||||
|
|
||||||
// Requires
|
// Requires
|
||||||
import { Font } from '../styling/font';
|
import { Font } from '../styling/font';
|
||||||
@@ -387,7 +388,7 @@ export class TextBase extends TextBaseCommon {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[textShadowProperty.setNative](value: TextShadow) {
|
[textShadowProperty.setNative](value: CSSShadow) {
|
||||||
this.nativeViewProtected.setShadowLayer(Length.toDevicePixels(value.blurRadius, 0), Length.toDevicePixels(value.offsetX, 0), Length.toDevicePixels(value.offsetY, 0), value.color.android);
|
this.nativeViewProtected.setShadowLayer(Length.toDevicePixels(value.blurRadius, 0), Length.toDevicePixels(value.offsetX, 0), Length.toDevicePixels(value.offsetY, 0), value.color.android);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user