mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
refactor: circular deps part 14
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { PageTransition, SharedTransition, SharedTransitionAnimationType, SharedTransitionHelper, Transition, Utils } from '@nativescript/core';
|
||||
import { CORE_ANIMATION_DEFAULTS } from '@nativescript/core/utils';
|
||||
|
||||
export class CustomTransition extends Transition {
|
||||
constructor(duration: number, curve: any) {
|
||||
@@ -32,7 +31,7 @@ export class CustomTransition extends Transition {
|
||||
},
|
||||
(finished) => {
|
||||
transitionContext.completeTransition(finished);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +89,7 @@ class PageTransitionController extends NSObject implements UIViewControllerAnima
|
||||
}
|
||||
}
|
||||
}
|
||||
return CORE_ANIMATION_DEFAULTS.duration;
|
||||
return Utils.CORE_ANIMATION_DEFAULTS.duration;
|
||||
}
|
||||
|
||||
animateTransition(transitionContext: UIViewControllerContextTransitioning): void {
|
||||
|
||||
@@ -15,7 +15,7 @@ import { ImageSource } from '@nativescript/core/image-source';
|
||||
import * as ViewModule from '@nativescript/core/ui/core/view';
|
||||
import * as helper from '../../ui-helper';
|
||||
import * as color from '@nativescript/core/color';
|
||||
import * as backgroundModule from '@nativescript/core/ui/styling/background';
|
||||
import * as appHelpers from '@nativescript/core/application/helpers-common';
|
||||
import { Application } from '@nativescript/core';
|
||||
const imagePath = '~/assets/logo.png';
|
||||
|
||||
@@ -23,8 +23,8 @@ export function test_recycling() {
|
||||
helper.nativeView_recycling_test(() => new Image());
|
||||
}
|
||||
|
||||
if (global.isAndroid) {
|
||||
(<any>backgroundModule).initImageCache(Application.android.startActivity, (<any>backgroundModule).CacheMode.memory); // use memory cache only.
|
||||
if (__ANDROID__) {
|
||||
appHelpers.initImageCache(Application.android.startActivity, appHelpers.CacheMode.memory); // use memory cache only.
|
||||
}
|
||||
|
||||
const expectLayoutRequest = __APPLE__ && Utils.SDK_VERSION >= 18;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as TKUnit from '../../tk-unit';
|
||||
import { View, eachDescendant, getViewById, InheritedProperty, CssProperty, CssAnimationProperty, ShorthandProperty, Property, Style, Frame, Page, Button, Label, Color, StackLayout, AbsoluteLayout, Observable, Utils, BindingOptions, isAndroid, LayoutBase } from '@nativescript/core';
|
||||
import * as helper from '../../ui-helper';
|
||||
import { checkNativeBackgroundColor, checkNativeBackgroundImage } from './view-tests';
|
||||
|
||||
export function test_eachDescendant() {
|
||||
const test = function (views: Array<View>) {
|
||||
@@ -491,7 +490,7 @@ export function test_NativeSetter_called_only_once_with_cssValue() {
|
||||
TKUnit.assertEqual(testView.cssAnimPropNativeValue, 'testCssAnimValue', 'Native value');
|
||||
TKUnit.assertEqual(testView.viewPropNativeValue, 'testViewValue', 'Native value');
|
||||
},
|
||||
{ pageCss: pageCSS }
|
||||
{ pageCss: pageCSS },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -521,7 +520,7 @@ export function test_NativeSetter_called_only_once_with_cssValue_and_localValue(
|
||||
// View property set from CSS sets local value
|
||||
TKUnit.assertEqual(testView.viewPropNativeValue, 'testViewValueCSS', 'Native value');
|
||||
},
|
||||
{ pageCss: pageCSS }
|
||||
{ pageCss: pageCSS },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -909,7 +908,7 @@ export function test_binding_style_opacity() {
|
||||
property_binding_style_test('opacity', 0.5, 0.6);
|
||||
}
|
||||
|
||||
function _createLabelWithBorder(): View {
|
||||
export function _createLabelWithBorder(): View {
|
||||
const lbl = new Label();
|
||||
lbl.borderRadius = 10;
|
||||
lbl.borderWidth = 2;
|
||||
@@ -919,7 +918,7 @@ function _createLabelWithBorder(): View {
|
||||
return lbl;
|
||||
}
|
||||
|
||||
function _createBackgroundColorView(): View {
|
||||
export function _createBackgroundColorView(): View {
|
||||
const lbl = new Label();
|
||||
lbl.backgroundColor = new Color('#FFFF00');
|
||||
return lbl;
|
||||
@@ -952,41 +951,6 @@ export function testSetInlineStyle() {
|
||||
});
|
||||
}
|
||||
|
||||
export function testBackgroundColor() {
|
||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<View>) {
|
||||
const lbl = views[0];
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
});
|
||||
}
|
||||
|
||||
export function testBackgroundBorderColor() {
|
||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<View>) {
|
||||
const lbl = views[0];
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
});
|
||||
}
|
||||
export function testSetAndRemoveBackgroundColor() {
|
||||
helper.buildUIAndRunTest(_createBackgroundColorView(), function (views: Array<View>) {
|
||||
const lbl = views[0];
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
lbl.backgroundColor = null;
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
});
|
||||
}
|
||||
|
||||
export function testBackgroundImage() {
|
||||
const lbl = _createLabelWithBorder();
|
||||
lbl.className = 'myClass';
|
||||
helper.buildUIAndRunTest(lbl, function (views: Array<View>) {
|
||||
const page = <Page>views[1];
|
||||
page.css = ".myClass { background-image: url('~/assets/logo.png') }";
|
||||
TKUnit.assertEqual(checkNativeBackgroundImage(lbl), true, 'Style background-image not loaded correctly.');
|
||||
});
|
||||
}
|
||||
|
||||
export function testBackgroundShorthand_With_EmptyBorder() {
|
||||
// Related to issue https://github.com/NativeScript/NativeScript/issues/4415
|
||||
const lbl = new Label();
|
||||
@@ -998,7 +962,7 @@ export function testBackgroundShorthand_With_EmptyBorder() {
|
||||
(views: Array<View>) => {
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
},
|
||||
{ pageCss: css }
|
||||
{ pageCss: css },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as TKUnit from '../../tk-unit';
|
||||
import * as helper from '../../ui-helper';
|
||||
import { View, unsetValue, Button, StackLayout, Label, Color, isIOS, Trace, Utils } from '@nativescript/core';
|
||||
import { View, unsetValue, Button, StackLayout, Label, Color, isIOS, Trace, Utils, Page } from '@nativescript/core';
|
||||
import { _createBackgroundColorView, _createLabelWithBorder } from './view-tests-common';
|
||||
|
||||
// enable the trace, it is disabled by default
|
||||
Trace.enable();
|
||||
@@ -297,3 +298,38 @@ export function checkNativeBackgroundImage(v: View): boolean {
|
||||
|
||||
return bkg && !Utils.isNullOrUndefined(bkg.getBackgroundImage());
|
||||
}
|
||||
|
||||
export function testBackgroundColor() {
|
||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<View>) {
|
||||
const lbl = views[0];
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
});
|
||||
}
|
||||
|
||||
export function testBackgroundBorderColor() {
|
||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<View>) {
|
||||
const lbl = views[0];
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
});
|
||||
}
|
||||
export function testSetAndRemoveBackgroundColor() {
|
||||
helper.buildUIAndRunTest(_createBackgroundColorView(), function (views: Array<View>) {
|
||||
const lbl = views[0];
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
lbl.backgroundColor = null;
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
});
|
||||
}
|
||||
|
||||
export function testBackgroundImage() {
|
||||
const lbl = _createLabelWithBorder();
|
||||
lbl.className = 'myClass';
|
||||
helper.buildUIAndRunTest(lbl, function (views: Array<View>) {
|
||||
const page = <Page>views[1];
|
||||
page.css = ".myClass { background-image: url('~/assets/logo.png') }";
|
||||
TKUnit.assertEqual(checkNativeBackgroundImage(lbl), true, 'Style background-image not loaded correctly.');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import { View } from '@nativescript/core/ui/core/view';
|
||||
import { Button } from '@nativescript/core/ui/button';
|
||||
import { GridLayout } from '@nativescript/core/ui/layouts/grid-layout';
|
||||
import { Color } from '@nativescript/core/color';
|
||||
import { View, Page, Button, GridLayout, Color, Utils } from '@nativescript/core';
|
||||
import * as helper from '../../ui-helper';
|
||||
import * as TKUnit from '../../tk-unit';
|
||||
import * as utils from '@nativescript/core/utils';
|
||||
import { _createBackgroundColorView, _createLabelWithBorder } from './view-tests-common';
|
||||
|
||||
export * from './view-tests-common';
|
||||
|
||||
@@ -18,7 +15,7 @@ class MyGrid extends GridLayout {
|
||||
}
|
||||
|
||||
export function getUniformNativeBorderWidth(v: View): number {
|
||||
return utils.layout.toDevicePixels((<UIView>v.ios).layer.borderWidth);
|
||||
return Utils.layout.toDevicePixels((<UIView>v.ios).layer.borderWidth);
|
||||
}
|
||||
|
||||
export function checkUniformNativeBorderColor(v: View): boolean {
|
||||
@@ -30,7 +27,42 @@ export function checkUniformNativeBorderColor(v: View): boolean {
|
||||
}
|
||||
|
||||
export function getUniformNativeCornerRadius(v: View): number {
|
||||
return utils.layout.toDevicePixels((<UIView>v.ios).layer.cornerRadius);
|
||||
return Utils.layout.toDevicePixels((<UIView>v.ios).layer.cornerRadius);
|
||||
}
|
||||
|
||||
export function testBackgroundColor() {
|
||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<View>) {
|
||||
const lbl = views[0];
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
});
|
||||
}
|
||||
|
||||
export function testBackgroundBorderColor() {
|
||||
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<View>) {
|
||||
const lbl = views[0];
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
});
|
||||
}
|
||||
export function testSetAndRemoveBackgroundColor() {
|
||||
helper.buildUIAndRunTest(_createBackgroundColorView(), function (views: Array<View>) {
|
||||
const lbl = views[0];
|
||||
helper.waitUntilLayoutReady(lbl);
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
lbl.backgroundColor = null;
|
||||
TKUnit.assertEqual(checkNativeBackgroundColor(lbl), true, 'BackgroundColor not applied correctly!');
|
||||
});
|
||||
}
|
||||
|
||||
export function testBackgroundImage() {
|
||||
const lbl = _createLabelWithBorder();
|
||||
lbl.className = 'myClass';
|
||||
helper.buildUIAndRunTest(lbl, function (views: Array<View>) {
|
||||
const page = <Page>views[1];
|
||||
page.css = ".myClass { background-image: url('~/assets/logo.png') }";
|
||||
TKUnit.assertEqual(checkNativeBackgroundImage(lbl), true, 'Style background-image not loaded correctly.');
|
||||
});
|
||||
}
|
||||
|
||||
export function checkNativeBackgroundColor(v: View): boolean {
|
||||
|
||||
Reference in New Issue
Block a user