From 21da31562c3e3b8193141245b0f8371af98af91a Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Mon, 15 Mar 2021 22:05:47 -0700 Subject: [PATCH] chore: Enums > CoreTypes Cleanup type symbol usage by consolidating to manage in one spot. This makes them easier to use as well by providing a single rollup of all the common type symbol's used throughout core. --- .../qualifier-matcher-tests.ts | 12 +- .../src/navigation/transition-tests.ts | 4 +- apps/automated/src/pages/page7.ts | 4 +- apps/automated/src/test-runner.ts | 25 -- .../ui/action-bar/action-bar-tests.android.ts | 4 +- .../src/ui/action-bar/action-bar-tests.ios.ts | 4 +- .../src/ui/animation/animation-tests.ts | 8 +- .../src/ui/animation/css-animation-tests.ts | 26 +- .../ui/button/button-tests-native.android.ts | 6 +- .../src/ui/button/button-tests-native.ios.ts | 6 +- apps/automated/src/ui/image/image.md | 2 +- .../ui/label/label-tests-native.android.ts | 6 +- .../src/ui/label/label-tests-native.ios.ts | 6 +- apps/automated/src/ui/label/label-tests.ts | 14 +- .../src/ui/layouts/dock-layout-tests.ts | 4 +- .../src/ui/layouts/stack-layout-tests.ts | 6 +- .../styling/root-views-css-classes-tests.ts | 2 +- .../text-field-tests-native.android.ts | 6 +- .../text-field/text-field-tests-native.ios.ts | 6 +- .../text-view-tests-native.android.ts | 6 +- .../text-view/text-view-tests-native.ios.ts | 6 +- .../src/ui/text-view/text-view-tests.ts | 8 +- apps/toolbox/src/pages/root-layout.ts | 2 +- apps/ui/src/fonts-tests/all-fonts-page.ts | 8 +- apps/ui/src/image-view/mode-matrix-page.ts | 2 +- apps/ui/src/image-view/stretch-modes-page.ts | 4 +- apps/ui/src/layouts-percent/stack-page.ts | 6 +- apps/ui/src/layouts-percent/wrap-page.ts | 6 +- apps/ui/src/layouts/stack-page.ts | 6 +- apps/ui/src/layouts/wrap-page.ts | 6 +- .../core/application/application-common.ts | 6 +- packages/core/bundle-entry-points.ts | 5 - .../core/{ui/enums => core-types}/index.d.ts | 85 +++-- packages/core/core-types/index.ts | 315 ++++++++++++++++++ packages/core/index.d.ts | 1 + packages/core/index.ts | 2 + packages/core/package.json | 2 +- .../core/ui/action-bar/action-bar-common.ts | 24 +- .../ui/activity-indicator/index.android.ts | 20 +- .../core/ui/animation/animation-interfaces.ts | 6 +- packages/core/ui/animation/index.d.ts | 6 +- .../core/ui/animation/keyframe-animation.d.ts | 6 +- .../core/ui/animation/keyframe-animation.ts | 10 +- .../ui/builder/component-builder/index.ts | 5 - packages/core/ui/button/index.android.ts | 26 +- packages/core/ui/button/index.ios.ts | 40 +-- packages/core/ui/core/view-base/index.d.ts | 8 +- packages/core/ui/core/view-base/index.ts | 7 +- packages/core/ui/core/view/index.android.ts | 57 ++-- packages/core/ui/core/view/index.d.ts | 73 ++-- packages/core/ui/core/view/index.ios.ts | 26 +- packages/core/ui/core/view/view-common.ts | 114 +++---- .../view/view-helper/view-helper-common.ts | 6 +- .../editable-text-base-common.ts | 26 +- .../core/ui/editable-text-base/index.d.ts | 18 +- packages/core/ui/enums/enums.d.ts | 5 - packages/core/ui/enums/enums.ts | 5 - packages/core/ui/enums/index.ts | 283 ---------------- packages/core/ui/image/image-common.ts | 16 +- packages/core/ui/image/index.d.ts | 5 +- packages/core/ui/index.ts | 9 - packages/core/ui/label/index.android.ts | 4 +- packages/core/ui/label/index.ios.ts | 22 +- .../absolute-layout/absolute-layout-common.ts | 19 +- .../ui/layouts/absolute-layout/index.ios.ts | 7 +- .../layouts/dock-layout/dock-layout-common.ts | 12 +- .../core/ui/layouts/dock-layout/index.d.ts | 4 +- .../layouts/flexbox-layout/index.android.ts | 7 +- .../core/ui/layouts/layout-base-common.ts | 22 +- .../core/ui/layouts/layout-base.android.ts | 19 +- packages/core/ui/layouts/layout-base.d.ts | 14 +- .../core/ui/layouts/root-layout/index.d.ts | 2 +- .../layouts/root-layout/root-layout-common.ts | 4 +- .../core/ui/layouts/stack-layout/index.d.ts | 6 +- .../core/ui/layouts/stack-layout/index.ios.ts | 18 +- .../stack-layout/stack-layout-common.ts | 8 +- .../ui/layouts/wrap-layout/index.android.ts | 7 +- .../layouts/wrap-layout/wrap-layout-common.ts | 20 +- packages/core/ui/list-view/index.android.ts | 4 +- packages/core/ui/list-view/index.ios.ts | 9 +- .../core/ui/list-view/list-view-common.ts | 15 +- packages/core/ui/page/index.android.ts | 5 +- .../core/ui/scroll-view/scroll-view-common.ts | 12 +- packages/core/ui/styling/background-common.ts | 6 +- .../core/ui/styling/background.android.ts | 8 +- packages/core/ui/styling/background.ios.ts | 6 +- packages/core/ui/styling/converters.ts | 18 +- packages/core/ui/styling/css-shadow.ts | 11 +- packages/core/ui/styling/linear-gradient.ts | 4 +- .../core/ui/styling/style-properties.d.ts | 79 ++--- packages/core/ui/styling/style-properties.ts | 131 ++++---- packages/core/ui/styling/style/index.ts | 82 +++-- packages/core/ui/tab-view/index.android.ts | 4 +- packages/core/ui/tab-view/index.ios.ts | 4 +- packages/core/ui/tab-view/tab-view-common.ts | 6 +- .../core/ui/text-base/formatted-string.d.ts | 4 +- .../core/ui/text-base/formatted-string.ts | 6 +- packages/core/ui/text-base/index.android.ts | 40 +-- packages/core/ui/text-base/index.d.ts | 20 +- packages/core/ui/text-base/index.ios.ts | 14 +- packages/core/ui/text-base/span.d.ts | 4 +- packages/core/ui/text-base/span.ts | 6 +- .../core/ui/text-base/text-base-common.ts | 55 ++- packages/core/ui/text-field/index.android.ts | 6 +- packages/core/ui/text-field/index.ios.ts | 21 +- packages/core/ui/text-view/index.ios.ts | 35 +- 106 files changed, 1110 insertions(+), 1128 deletions(-) rename packages/core/{ui/enums => core-types}/index.d.ts (88%) create mode 100644 packages/core/core-types/index.ts delete mode 100644 packages/core/ui/enums/enums.d.ts delete mode 100644 packages/core/ui/enums/enums.ts delete mode 100644 packages/core/ui/enums/index.ts diff --git a/apps/automated/src/name-resolvers-tests/qualifier-matcher-tests.ts b/apps/automated/src/name-resolvers-tests/qualifier-matcher-tests.ts index f62fb47a9..f68e15914 100644 --- a/apps/automated/src/name-resolvers-tests/qualifier-matcher-tests.ts +++ b/apps/automated/src/name-resolvers-tests/qualifier-matcher-tests.ts @@ -1,39 +1,39 @@ import * as TKUnit from '../tk-unit'; -import { Enums } from '@nativescript/core'; +import { CoreTypes } from '@nativescript/core'; import { findMatch, PlatformContext } from '@nativescript/core/module-name-resolver/qualifier-matcher'; export const androidPhonePortraitContext: PlatformContext = { width: 360, height: 640, - deviceType: Enums.DeviceType.Phone, + deviceType: CoreTypes.DeviceType.Phone, os: 'android', }; export const androidPhoneLandscapeContext: PlatformContext = { width: 640, height: 360, - deviceType: Enums.DeviceType.Phone, + deviceType: CoreTypes.DeviceType.Phone, os: 'android', }; export const androidTabletPortraitContext: PlatformContext = { width: 600, height: 960, - deviceType: Enums.DeviceType.Tablet, + deviceType: CoreTypes.DeviceType.Tablet, os: 'android', }; export const iPhonePortraitContext: PlatformContext = { width: 320, height: 480, - deviceType: Enums.DeviceType.Phone, + deviceType: CoreTypes.DeviceType.Phone, os: 'ios', }; export const iPhoneLandscapeContext: PlatformContext = { width: 480, height: 320, - deviceType: Enums.DeviceType.Phone, + deviceType: CoreTypes.DeviceType.Phone, os: 'ios', }; diff --git a/apps/automated/src/navigation/transition-tests.ts b/apps/automated/src/navigation/transition-tests.ts index 20cc55b73..bd0efef4e 100644 --- a/apps/automated/src/navigation/transition-tests.ts +++ b/apps/automated/src/navigation/transition-tests.ts @@ -4,7 +4,7 @@ import { Trace } from '@nativescript/core'; import { Color } from '@nativescript/core/color'; import { NavigationEntry, NavigationTransition } from '@nativescript/core/ui/frame'; import { Page } from '@nativescript/core/ui/page'; -import { Enums } from '@nativescript/core'; +import { CoreTypes } from '@nativescript/core'; import { CustomTransition } from './custom-transition'; function _testTransition(navigationTransition: NavigationTransition) { @@ -51,7 +51,7 @@ export function test_Transitions() { // Built-in transitions transitions.forEach((name) => { - _testTransition({ name, duration: 20, curve: Enums.AnimationCurve.easeIn }); + _testTransition({ name, duration: 20, curve: CoreTypes.AnimationCurve.easeIn }); }); // helper.navigateWithEntry({ create: mainPageFactory, clearHistory: true, animated: false }); diff --git a/apps/automated/src/pages/page7.ts b/apps/automated/src/pages/page7.ts index 67610297e..be65104d6 100644 --- a/apps/automated/src/pages/page7.ts +++ b/apps/automated/src/pages/page7.ts @@ -1,6 +1,6 @@ import * as pages from '@nativescript/core/ui/page'; import * as buttons from '@nativescript/core/ui/button'; -import { Enums } from '@nativescript/core'; +import { CoreTypes } from '@nativescript/core'; export function createPage() { var page = new pages.Page(); @@ -10,7 +10,7 @@ export function createPage() { btn.height = 60; btn.text = 'test'; - var vAligns: Enums.VerticalAlignmentType[] = ['stretch', 'top', 'middle', 'bottom']; + var vAligns: CoreTypes.VerticalAlignmentType[] = ['stretch', 'top', 'middle', 'bottom']; //var hAligns = ["stretch", "left", "center", "right"]; var count = 0; btn.on(buttons.Button.tapEvent, function () { diff --git a/apps/automated/src/test-runner.ts b/apps/automated/src/test-runner.ts index f53bcac66..62ba954d6 100644 --- a/apps/automated/src/test-runner.ts +++ b/apps/automated/src/test-runner.ts @@ -187,24 +187,6 @@ allTests['BUTTON'] = buttonTests; import * as labelTests from './ui/label/label-tests'; allTests['LABEL'] = labelTests; -import * as bottomNavigationTests from './ui/bottom-navigation/bottom-navigation-tests'; -allTests['BOTTOM-NAVIGATION'] = bottomNavigationTests; - -import * as bottomNavigationTestsNew from './ui/bottom-navigation/bottom-navigation-tests-new'; -allTests['BOTTOM-NAVIGATION-NEW'] = bottomNavigationTestsNew; - -import * as bottomNavigationNavigationTests from './ui/bottom-navigation/bottom-navigation-navigation-tests'; -isIOS && (allTests['BOTTOM-NAVIGATION-NAVIGATION'] = bottomNavigationNavigationTests); - -import * as tabsTests from './ui/tabs/tabs-tests'; -allTests['TABS'] = tabsTests; - -import * as tabsTestsNew from './ui/tabs/tabs-tests-new'; -allTests['TABS-NEW'] = tabsTestsNew; - -import * as tabsNavigationTests from './ui/tabs/tabs-navigation-tests'; -allTests['TABS-NAVIGATION'] = tabsNavigationTests; - import * as tabViewTests from './ui/tab-view/tab-view-tests'; allTests['TAB-VIEW'] = tabViewTests; @@ -292,13 +274,6 @@ allTests['LIVESYNC'] = livesyncTests; import * as tabViewRootTests from './ui/tab-view/tab-view-root-tests'; allTests['TAB-VIEW-ROOT'] = tabViewRootTests; -import * as bottomNavigationRootTests from './ui/bottom-navigation/bottom-navigation-root-tests'; -allTests['BOTTOM-NAVIGATION-ROOT'] = bottomNavigationRootTests; - -// Reset root view didn't work with android tabs -import * as tabsRootTests from './ui/tabs/tabs-root-tests'; -isIOS && (allTests['TABS-ROOT'] = tabsRootTests); - import * as resetRootViewTests from './ui/root-view/reset-root-view-tests'; allTests['RESET-ROOT-VIEW'] = resetRootViewTests; diff --git a/apps/automated/src/ui/action-bar/action-bar-tests.android.ts b/apps/automated/src/ui/action-bar/action-bar-tests.android.ts index 260b78db0..517a47de9 100644 --- a/apps/automated/src/ui/action-bar/action-bar-tests.android.ts +++ b/apps/automated/src/ui/action-bar/action-bar-tests.android.ts @@ -15,7 +15,7 @@ export function test_actionItem_visibility() { const menu = toolbar.getMenu(); TKUnit.assertTrue(menu.hasVisibleItems(), 'Visibility does not work'); - actionItem.visibility = Enums.Visibility.collapse; + actionItem.visibility = CoreTypes.Visibility.collapse; TKUnit.assertFalse(menu.hasVisibleItems(), 'Visibility does not work'); } @@ -28,7 +28,7 @@ export function test_navigationButton_visibility() { const toolbar = page.actionBar.nativeViewProtected; TKUnit.assertNotNull(toolbar.getNavigationIcon(), 'Visibility does not work'); - actionItem.visibility = Enums.Visibility.collapse; + actionItem.visibility = CoreTypes.Visibility.collapse; TKUnit.assertNull(toolbar.getNavigationIcon(), 'Visibility does not work'); } diff --git a/apps/automated/src/ui/action-bar/action-bar-tests.ios.ts b/apps/automated/src/ui/action-bar/action-bar-tests.ios.ts index c7c5d98d8..9fd69e32c 100644 --- a/apps/automated/src/ui/action-bar/action-bar-tests.ios.ts +++ b/apps/automated/src/ui/action-bar/action-bar-tests.ios.ts @@ -95,7 +95,7 @@ export function test_actionItem_visibility() { var leftBarButtonItemsCount = navigationItem.leftBarButtonItems ? navigationItem.leftBarButtonItems.count : 0; TKUnit.assertEqual(leftBarButtonItemsCount, 1, 'Visibility does not work'); - actionItem.visibility = Enums.Visibility.collapse; + actionItem.visibility = CoreTypes.Visibility.collapse; TKUnit.waitUntilReady(() => { leftBarButtonItemsCount = navigationItem.leftBarButtonItems ? navigationItem.leftBarButtonItems.count : 0; @@ -118,7 +118,7 @@ export function test_navigationButton_visibility() { var navigationItem: UINavigationItem = viewController.navigationItem; TKUnit.assertFalse(navigationItem.hidesBackButton, 'Visibility does not work'); - actionItem.visibility = Enums.Visibility.collapse; + actionItem.visibility = CoreTypes.Visibility.collapse; TKUnit.waitUntilReady(() => { return navigationItem.hidesBackButton; diff --git a/apps/automated/src/ui/animation/animation-tests.ts b/apps/automated/src/ui/animation/animation-tests.ts index 0febdb79d..e6826b33c 100644 --- a/apps/automated/src/ui/animation/animation-tests.ts +++ b/apps/automated/src/ui/animation/animation-tests.ts @@ -9,7 +9,7 @@ import { AnimationPromise } from '@nativescript/core/ui/animation'; // >> animation-require import * as animation from '@nativescript/core/ui/animation'; -import { PercentLengthType, PercentLength } from '@nativescript/core'; +import { CoreTypes, PercentLength } from '@nativescript/core'; // << animation-require function prepareTest(parentHeight?: number, parentWidth?: number): Label { @@ -46,7 +46,7 @@ export function test_AnimatingProperties(done) { duration: 5, delay: 10, iterations: 3, - curve: Enums.AnimationCurve.easeIn, + curve: CoreTypes.AnimationCurve.easeIn, }) .then(() => { //console.log("Animation finished."); @@ -418,7 +418,7 @@ export function test_AnimateRotate(done) { }); } -function animateExtentAndAssertExpected(along: 'height' | 'width', value: PercentLengthType, pixelExpected: PercentLengthType): Promise { +function animateExtentAndAssertExpected(along: 'height' | 'width', value: CoreTypes.PercentLengthType, pixelExpected: CoreTypes.PercentLengthType): Promise { function pretty(val) { return JSON.stringify(val, null, 2); } @@ -478,7 +478,7 @@ export function test_AnimateExtent_Should_AcceptStringPixelValues(done) { const expected = { unit: 'px', value: pair[1], - } as PercentLengthType; + } as CoreTypes.PercentLengthType; promise = promise.then(() => { return animateExtentAndAssertExpected('height', input, expected); }); diff --git a/apps/automated/src/ui/animation/css-animation-tests.ts b/apps/automated/src/ui/animation/css-animation-tests.ts index e6a37386b..d9d17d637 100644 --- a/apps/automated/src/ui/animation/css-animation-tests.ts +++ b/apps/automated/src/ui/animation/css-animation-tests.ts @@ -1,7 +1,7 @@ import * as TKUnit from '../../tk-unit'; import * as styleScope from '@nativescript/core/ui/styling/style-scope'; import * as keyframeAnimation from '@nativescript/core/ui/animation/keyframe-animation'; -import { Enums } from '@nativescript/core'; +import { CoreTypes } from '@nativescript/core'; import * as helper from '../../ui-helper'; import * as stackModule from '@nativescript/core/ui/layouts/stack-layout'; import * as labelModule from '@nativescript/core/ui/label'; @@ -37,7 +37,7 @@ export function test_ReadAnimationProperties() { let animation = createAnimationFromCSS(css, 'test'); TKUnit.assertEqual(animation.name, 'first'); TKUnit.assertEqual(animation.duration, 4000); - TKUnit.assertEqual(animation.curve, Enums.AnimationCurve.easeIn); + TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.easeIn); TKUnit.assertEqual(animation.delay, 1500); TKUnit.assertEqual(animation.iterations, 10); TKUnit.assertTrue(animation.isForwards); @@ -48,22 +48,22 @@ export function test_ReadTheAnimationProperty() { let animation = createAnimationFromCSS('.test { animation: second 0.2s ease-out 1 2 }', 'test'); TKUnit.assertEqual(animation.name, 'second'); TKUnit.assertEqual(animation.duration, 200); - TKUnit.assertEqual(animation.curve, Enums.AnimationCurve.easeOut); + TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.easeOut); TKUnit.assertEqual(animation.delay, 1000); TKUnit.assertEqual(animation.iterations, 2); } export function test_ReadAnimationCurve() { let animation = createAnimationFromCSS('.test { animation-timing-function: ease-in; }', 'test'); - TKUnit.assertEqual(animation.curve, Enums.AnimationCurve.easeIn); + TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.easeIn); animation = createAnimationFromCSS('.test { animation-timing-function: ease-out; }', 'test'); - TKUnit.assertEqual(animation.curve, Enums.AnimationCurve.easeOut); + TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.easeOut); animation = createAnimationFromCSS('.test { animation-timing-function: linear; }', 'test'); - TKUnit.assertEqual(animation.curve, Enums.AnimationCurve.linear); + TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.linear); animation = createAnimationFromCSS('.test { animation-timing-function: ease-in-out; }', 'test'); - TKUnit.assertEqual(animation.curve, Enums.AnimationCurve.easeInOut); + TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.easeInOut); animation = createAnimationFromCSS('.test { animation-timing-function: spring; }', 'test'); - TKUnit.assertEqual(animation.curve, Enums.AnimationCurve.spring); + TKUnit.assertEqual(animation.curve, CoreTypes.AnimationCurve.spring); animation = createAnimationFromCSS('.test { animation-timing-function: cubic-bezier(0.1, 1.0, 0.5, 0.5); }', 'test'); let curve = animation.curve; TKUnit.assert(curve.x1 === 0.1 && curve.y1 === 1.0 && curve.x2 === 0.5 && curve.y2 === 0.5); @@ -389,8 +389,8 @@ export function test_ReadTwoAnimations() { scope.ensureSelectors(); let selector = findSelectorInScope(scope, 'test'); TKUnit.assertEqual(scope.getAnimations(selector.ruleset).length, 2); - TKUnit.assertEqual(scope.getAnimations(selector.ruleset)[0].curve, Enums.AnimationCurve.easeOut); - TKUnit.assertEqual(scope.getAnimations(selector.ruleset)[1].curve, Enums.AnimationCurve.easeIn); + TKUnit.assertEqual(scope.getAnimations(selector.ruleset)[0].curve, CoreTypes.AnimationCurve.easeOut); + TKUnit.assertEqual(scope.getAnimations(selector.ruleset)[1].curve, CoreTypes.AnimationCurve.easeIn); TKUnit.assertEqual(scope.getAnimations(selector.ruleset)[1].name, 'two'); TKUnit.assertEqual(scope.getAnimations(selector.ruleset)[1].duration, 2000); } @@ -401,12 +401,12 @@ export function test_AnimationCurveInKeyframes() { scope.ensureSelectors(); let selector = findSelectorInScope(scope, 'test'); let animation = scope.getAnimations(selector.ruleset)[0]; - TKUnit.assertEqual(animation.keyframes[0].curve, Enums.AnimationCurve.linear); + TKUnit.assertEqual(animation.keyframes[0].curve, CoreTypes.AnimationCurve.linear); TKUnit.assertEqual(animation.keyframes[1].curve, undefined); TKUnit.assertEqual(animation.keyframes[1].curve, undefined); let realAnimation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animation); - TKUnit.assertEqual(realAnimation.animations[1].curve, Enums.AnimationCurve.linear); - TKUnit.assertEqual(realAnimation.animations[2].curve, Enums.AnimationCurve.easeIn); + TKUnit.assertEqual(realAnimation.animations[1].curve, CoreTypes.AnimationCurve.linear); + TKUnit.assertEqual(realAnimation.animations[2].curve, CoreTypes.AnimationCurve.easeIn); } function getTransformsValues(declarations) { diff --git a/apps/automated/src/ui/button/button-tests-native.android.ts b/apps/automated/src/ui/button/button-tests-native.android.ts index d17d73298..c99ad9128 100644 --- a/apps/automated/src/ui/button/button-tests-native.android.ts +++ b/apps/automated/src/ui/button/button-tests-native.android.ts @@ -34,15 +34,15 @@ export function getNativeTextAlignment(button: Button): string { let gravity = button.android.getGravity(); if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) { - return Enums.TextAlignment.left; + return CoreTypes.TextAlignment.left; } if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) { - return Enums.TextAlignment.center; + return CoreTypes.TextAlignment.center; } if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) { - return Enums.TextAlignment.right; + return CoreTypes.TextAlignment.right; } return 'unexpected value'; diff --git a/apps/automated/src/ui/button/button-tests-native.ios.ts b/apps/automated/src/ui/button/button-tests-native.ios.ts index b78695bdb..6203d8cc2 100644 --- a/apps/automated/src/ui/button/button-tests-native.ios.ts +++ b/apps/automated/src/ui/button/button-tests-native.ios.ts @@ -26,11 +26,11 @@ export function getNativeBackgroundColor(button: buttonModule.Button): colorModu export function getNativeTextAlignment(button: buttonModule.Button): string { switch (button.ios.titleLabel.textAlignment) { case NSTextAlignment.Left: - return Enums.TextAlignment.left; + return CoreTypes.TextAlignment.left; case NSTextAlignment.Center: - return Enums.TextAlignment.center; + return CoreTypes.TextAlignment.center; case NSTextAlignment.Right: - return Enums.TextAlignment.right; + return CoreTypes.TextAlignment.right; default: return 'unexpected value'; } diff --git a/apps/automated/src/ui/image/image.md b/apps/automated/src/ui/image/image.md index 54387e8ed..77f80791a 100644 --- a/apps/automated/src/ui/image/image.md +++ b/apps/automated/src/ui/image/image.md @@ -126,7 +126,7 @@ The second example shows, how we could set up the property via code behind. In t import * as Enums from "tns-core-modules/ui/enums" const image = new ImageModule.Image(); -image.stretch=Enums.Stretch.none; +image.stretch=CoreTypes.Stretch.none; ``` diff --git a/apps/automated/src/ui/label/label-tests-native.android.ts b/apps/automated/src/ui/label/label-tests-native.android.ts index 76d1107da..1ffccaf33 100644 --- a/apps/automated/src/ui/label/label-tests-native.android.ts +++ b/apps/automated/src/ui/label/label-tests-native.android.ts @@ -6,15 +6,15 @@ export function getNativeTextAlignment(label: labelModule.Label): string { let gravity = label.android.getGravity(); if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) { - return Enums.TextAlignment.left; + return CoreTypes.TextAlignment.left; } if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) { - return Enums.TextAlignment.center; + return CoreTypes.TextAlignment.center; } if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) { - return Enums.TextAlignment.right; + return CoreTypes.TextAlignment.right; } return 'unexpected value'; diff --git a/apps/automated/src/ui/label/label-tests-native.ios.ts b/apps/automated/src/ui/label/label-tests-native.ios.ts index 78d37eeda..b0e6fa7b8 100644 --- a/apps/automated/src/ui/label/label-tests-native.ios.ts +++ b/apps/automated/src/ui/label/label-tests-native.ios.ts @@ -6,11 +6,11 @@ import { getColor } from '../../ui-helper'; export function getNativeTextAlignment(label: labelModule.Label): string { switch (label.ios.textAlignment) { case NSTextAlignment.Left: - return Enums.TextAlignment.left; + return CoreTypes.TextAlignment.left; case NSTextAlignment.Center: - return Enums.TextAlignment.center; + return CoreTypes.TextAlignment.center; case NSTextAlignment.Right: - return Enums.TextAlignment.right; + return CoreTypes.TextAlignment.right; default: return 'unexpected value'; } diff --git a/apps/automated/src/ui/label/label-tests.ts b/apps/automated/src/ui/label/label-tests.ts index cf011ba80..91306b373 100644 --- a/apps/automated/src/ui/label/label-tests.ts +++ b/apps/automated/src/ui/label/label-tests.ts @@ -10,7 +10,7 @@ import * as colorModule from '@nativescript/core/color'; import * as utils from '@nativescript/core/utils/utils'; import * as observableModule from '@nativescript/core/data/observable'; import * as bindable from '@nativescript/core/ui/core/bindable'; -import { Enums } from '@nativescript/core'; +import { CoreTypes } from '@nativescript/core'; import * as labelTestsNative from './label-tests-native'; import * as fs from '@nativescript/core/file-system'; @@ -489,7 +489,7 @@ export class LabelTest extends testModule.UITest { const actualResult = view.style.textAlignment; TKUnit.assertEqual(actualResult, this.expectedTextAlignment); - page.addCss('label { text-align: ' + Enums.TextAlignment.left + '; }'); + page.addCss('label { text-align: ' + CoreTypes.TextAlignment.left + '; }'); TKUnit.assertEqual(view.style.textAlignment, view.style.textAlignment); } @@ -500,7 +500,7 @@ export class LabelTest extends testModule.UITest { view.id = 'testLabel'; page.addCss('#testLabel { text-align: ' + this.expectedTextAlignment + '; }'); - page.addCss('label { text-align: ' + Enums.TextAlignment.left + '; }'); + page.addCss('label { text-align: ' + CoreTypes.TextAlignment.left + '; }'); const actualResult = view.style.textAlignment; // actual result is taken from #testLabel tag, because it has a greater priority (id vs type). @@ -585,8 +585,8 @@ export class LabelTest extends testModule.UITest { this.waitUntilTestElementIsLoaded(); view.setInlineStyle('text-transform: uppercase; text-decoration: underline; letter-spacing: 1;'); - TKUnit.assertEqual(view.style.textTransform, Enums.TextTransform.uppercase, 'TextTransform'); - TKUnit.assertEqual(view.style.textDecoration, Enums.TextDecoration.underline, 'TextDecoration'); + TKUnit.assertEqual(view.style.textTransform, CoreTypes.TextTransform.uppercase, 'TextTransform'); + TKUnit.assertEqual(view.style.textDecoration, CoreTypes.TextDecoration.underline, 'TextDecoration'); TKUnit.assertEqual(view.style.letterSpacing, 1, 'LetterSpacing'); } @@ -597,8 +597,8 @@ export class LabelTest extends testModule.UITest { view.formattedText = formattedString; view.setInlineStyle('text-transform: uppercase; text-decoration: underline; letter-spacing: 1;'); - TKUnit.assertEqual(view.style.textTransform, Enums.TextTransform.uppercase, 'TextTransform'); - TKUnit.assertEqual(view.style.textDecoration, Enums.TextDecoration.underline, 'TextDecoration'); + TKUnit.assertEqual(view.style.textTransform, CoreTypes.TextTransform.uppercase, 'TextTransform'); + TKUnit.assertEqual(view.style.textDecoration, CoreTypes.TextDecoration.underline, 'TextDecoration'); TKUnit.assertEqual(view.style.letterSpacing, 1, 'LetterSpacing'); } diff --git a/apps/automated/src/ui/layouts/dock-layout-tests.ts b/apps/automated/src/ui/layouts/dock-layout-tests.ts index ccbe5300a..748579bdd 100644 --- a/apps/automated/src/ui/layouts/dock-layout-tests.ts +++ b/apps/automated/src/ui/layouts/dock-layout-tests.ts @@ -11,7 +11,7 @@ import * as dockModule from '@nativescript/core/ui/layouts/dock-layout'; // << dock-layout-require // >> dock-layout-others -import { Enums } from '@nativescript/core'; +import { CoreTypes } from '@nativescript/core'; // << dock-layout-others export class DockLayoutTest extends testModule.UITest { @@ -41,7 +41,7 @@ export class DockLayoutTest extends testModule.UITest { public test_dock_DefaultValue() { var testBtn = new button.Button(); var value = dockModule.DockLayout.getDock(testBtn); - TKUnit.assertEqual(value, Enums.Dock.left, 'Default dock value.'); + TKUnit.assertEqual(value, CoreTypes.Dock.left, 'Default dock value.'); } public test_setInvalidDock_Throws() { diff --git a/apps/automated/src/ui/layouts/stack-layout-tests.ts b/apps/automated/src/ui/layouts/stack-layout-tests.ts index 4d47cd31c..b3efafaa9 100644 --- a/apps/automated/src/ui/layouts/stack-layout-tests.ts +++ b/apps/automated/src/ui/layouts/stack-layout-tests.ts @@ -30,7 +30,7 @@ export class StackLayoutTest extends testModule.UITest { } public test_orientation_DefaultValue() { - TKUnit.assertEqual(this.rootLayout.orientation, Enums.Orientation.vertical, 'Default orientation should be Vertical.'); + TKUnit.assertEqual(this.rootLayout.orientation, CoreTypes.Orientation.vertical, 'Default orientation should be Vertical.'); } public test_SetWrongOrientation_ShouldThrowError() { @@ -42,7 +42,7 @@ export class StackLayoutTest extends testModule.UITest { public test_Orientation_Change() { this.waitUntilTestElementLayoutIsValid(); - TKUnit.assertEqual(this.rootLayout.orientation, Enums.Orientation.vertical, 'Default orientation should be Vertical.'); + TKUnit.assertEqual(this.rootLayout.orientation, CoreTypes.Orientation.vertical, 'Default orientation should be Vertical.'); this.rootLayout.orientation = 'horizontal'; this.waitUntilTestElementLayoutIsValid(); @@ -54,7 +54,7 @@ export class StackLayoutTest extends testModule.UITest { public test_ShouldMeasureWith_AtMost_OnVertical() { this.waitUntilTestElementLayoutIsValid(); - TKUnit.assertEqual(this.rootLayout.orientation, Enums.Orientation.vertical, 'StackLayout should be vertical.'); + TKUnit.assertEqual(this.rootLayout.orientation, CoreTypes.Orientation.vertical, 'StackLayout should be vertical.'); TKUnit.assertTrue(this.rootLayout.measured, 'Layout should be measured.'); TKUnit.assertTrue(this.rootLayout.arranged, 'Layout should be arranged.'); diff --git a/apps/automated/src/ui/styling/root-views-css-classes-tests.ts b/apps/automated/src/ui/styling/root-views-css-classes-tests.ts index 44c72a35e..4576778fc 100644 --- a/apps/automated/src/ui/styling/root-views-css-classes-tests.ts +++ b/apps/automated/src/ui/styling/root-views-css-classes-tests.ts @@ -57,7 +57,7 @@ function _test_device_type_css_class(rootView: View, shouldSetClassName: boolean const cssClasses = rootView.cssClasses; const deviceType = Device.deviceType; - if (deviceType === Enums.DeviceType.Phone) { + if (deviceType === CoreTypes.DeviceType.Phone) { TKUnit.assertTrue(cssClasses.has(PHONE_DEVICE_TYPE_CSS_CLASS), `${PHONE_DEVICE_TYPE_CSS_CLASS} CSS class is missing`); TKUnit.assertFalse(cssClasses.has(TABLET_DEVICE_TYPE_CSS_CLASS), `${TABLET_DEVICE_TYPE_CSS_CLASS} CSS class is present`); } else { diff --git a/apps/automated/src/ui/text-field/text-field-tests-native.android.ts b/apps/automated/src/ui/text-field/text-field-tests-native.android.ts index adddb5843..767aaadad 100644 --- a/apps/automated/src/ui/text-field/text-field-tests-native.android.ts +++ b/apps/automated/src/ui/text-field/text-field-tests-native.android.ts @@ -44,15 +44,15 @@ export function getNativeTextAlignment(textField: TextField): string { var gravity = textField.android.getGravity(); if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) { - return Enums.TextAlignment.left; + return CoreTypes.TextAlignment.left; } if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) { - return Enums.TextAlignment.center; + return CoreTypes.TextAlignment.center; } if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) { - return Enums.TextAlignment.right; + return CoreTypes.TextAlignment.right; } return 'unexpected value'; diff --git a/apps/automated/src/ui/text-field/text-field-tests-native.ios.ts b/apps/automated/src/ui/text-field/text-field-tests-native.ios.ts index 526c33f9e..4ee999daf 100644 --- a/apps/automated/src/ui/text-field/text-field-tests-native.ios.ts +++ b/apps/automated/src/ui/text-field/text-field-tests-native.ios.ts @@ -34,11 +34,11 @@ export function getNativeBackgroundColor(textField: textFieldModule.TextField): export function getNativeTextAlignment(textField: textFieldModule.TextField): string { switch (textField.ios.textAlignment) { case NSTextAlignment.Left: - return Enums.TextAlignment.left; + return CoreTypes.TextAlignment.left; case NSTextAlignment.Center: - return Enums.TextAlignment.center; + return CoreTypes.TextAlignment.center; case NSTextAlignment.Right: - return Enums.TextAlignment.right; + return CoreTypes.TextAlignment.right; default: return 'unexpected value'; } diff --git a/apps/automated/src/ui/text-view/text-view-tests-native.android.ts b/apps/automated/src/ui/text-view/text-view-tests-native.android.ts index d3bb5c13e..0dc8c72b0 100644 --- a/apps/automated/src/ui/text-view/text-view-tests-native.android.ts +++ b/apps/automated/src/ui/text-view/text-view-tests-native.android.ts @@ -41,15 +41,15 @@ export function getNativeTextAlignment(textView: TextView): string { let gravity = textView.android.getGravity(); if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.LEFT) { - return Enums.TextAlignment.left; + return CoreTypes.TextAlignment.left; } if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.CENTER_HORIZONTAL) { - return Enums.TextAlignment.center; + return CoreTypes.TextAlignment.center; } if ((gravity & android.view.Gravity.HORIZONTAL_GRAVITY_MASK) === android.view.Gravity.RIGHT) { - return Enums.TextAlignment.right; + return CoreTypes.TextAlignment.right; } return 'unexpected value'; diff --git a/apps/automated/src/ui/text-view/text-view-tests-native.ios.ts b/apps/automated/src/ui/text-view/text-view-tests-native.ios.ts index f08ad2bc2..f1ced5939 100644 --- a/apps/automated/src/ui/text-view/text-view-tests-native.ios.ts +++ b/apps/automated/src/ui/text-view/text-view-tests-native.ios.ts @@ -35,11 +35,11 @@ export function getNativeBackgroundColor(textView: textViewModule.TextView): col export function getNativeTextAlignment(textView: textViewModule.TextView): string { switch (textView.ios.textAlignment) { case NSTextAlignment.Left: - return Enums.TextAlignment.left; + return CoreTypes.TextAlignment.left; case NSTextAlignment.Center: - return Enums.TextAlignment.center; + return CoreTypes.TextAlignment.center; case NSTextAlignment.Right: - return Enums.TextAlignment.right; + return CoreTypes.TextAlignment.right; default: return 'unexpected value'; } diff --git a/apps/automated/src/ui/text-view/text-view-tests.ts b/apps/automated/src/ui/text-view/text-view-tests.ts index 806c142ec..15345398a 100644 --- a/apps/automated/src/ui/text-view/text-view-tests.ts +++ b/apps/automated/src/ui/text-view/text-view-tests.ts @@ -537,8 +537,8 @@ export function test_IntegrationTest_Transform_Decoration_Spacing_WithoutFormatt view.text = 'NormalText'; view.setInlineStyle('text-transform: uppercase; text-decoration: underline; letter-spacing: 1;'); - TKUnit.assertEqual(view.style.textTransform, Enums.TextTransform.uppercase, 'TextTransform'); - TKUnit.assertEqual(view.style.textDecoration, Enums.TextDecoration.underline, 'TextDecoration'); + TKUnit.assertEqual(view.style.textTransform, CoreTypes.TextTransform.uppercase, 'TextTransform'); + TKUnit.assertEqual(view.style.textDecoration, CoreTypes.TextDecoration.underline, 'TextDecoration'); TKUnit.assertEqual(view.style.letterSpacing, 1, 'LetterSpacing'); }); } @@ -550,8 +550,8 @@ export function test_IntegrationTest_Transform_Decoration_Spacing_WithFormattedT view.formattedText = formattedString; view.setInlineStyle('text-transform: uppercase; text-decoration: underline; letter-spacing: 1;'); - TKUnit.assertEqual(view.style.textTransform, Enums.TextTransform.uppercase, 'TextTransform'); - TKUnit.assertEqual(view.style.textDecoration, Enums.TextDecoration.underline, 'TextDecoration'); + TKUnit.assertEqual(view.style.textTransform, CoreTypes.TextTransform.uppercase, 'TextTransform'); + TKUnit.assertEqual(view.style.textDecoration, CoreTypes.TextDecoration.underline, 'TextDecoration'); TKUnit.assertEqual(view.style.letterSpacing, 1, 'LetterSpacing'); }); } diff --git a/apps/toolbox/src/pages/root-layout.ts b/apps/toolbox/src/pages/root-layout.ts index 215c5c002..eeadf23d4 100644 --- a/apps/toolbox/src/pages/root-layout.ts +++ b/apps/toolbox/src/pages/root-layout.ts @@ -78,7 +78,7 @@ export class BoxShadowModel extends Observable { rotate: 180, opacity: 0, duration: 300, - curve: Enums.AnimationCurve.spring, + curve: CoreTypes.AnimationCurve.spring, }, }, }, diff --git a/apps/ui/src/fonts-tests/all-fonts-page.ts b/apps/ui/src/fonts-tests/all-fonts-page.ts index 4a9ae8cb3..0913acc9f 100644 --- a/apps/ui/src/fonts-tests/all-fonts-page.ts +++ b/apps/ui/src/fonts-tests/all-fonts-page.ts @@ -12,8 +12,8 @@ const genericFontFamilies = ['system', 'sans-serif', 'serif', 'monospace']; let fontFamilies = []; let fontNames = []; const embeddedFontNames = ['FontAwesome', 'Pacifico', 'Sofia']; -const fontStyles = [Enums.FontStyle.normal, Enums.FontStyle.italic]; -const fontWeights = [Enums.FontWeight.thin, Enums.FontWeight.extraLight, Enums.FontWeight.light, Enums.FontWeight.normal, Enums.FontWeight.medium, Enums.FontWeight.semiBold, Enums.FontWeight.bold, Enums.FontWeight.extraBold, Enums.FontWeight.black]; +const fontStyles = [CoreTypes.FontStyle.normal, CoreTypes.FontStyle.italic]; +const fontWeights = [CoreTypes.FontWeight.thin, CoreTypes.FontWeight.extraLight, CoreTypes.FontWeight.light, CoreTypes.FontWeight.normal, CoreTypes.FontWeight.medium, CoreTypes.FontWeight.semiBold, CoreTypes.FontWeight.bold, CoreTypes.FontWeight.extraBold, CoreTypes.FontWeight.black]; let green = new Color('Green'); let red = new Color('Red'); @@ -111,8 +111,8 @@ function prepareLabel(fontFamily: string, fontStyle: string, fontWeight: string) let label = new Label(); label['font-family'] = fontFamily; let fontFamilyCss = `font-family: ${fontFamily}; `; - let fontStyleCss = fontStyle !== Enums.FontStyle.normal ? `font-style: ${fontStyle}; ` : ''; - let fontWeightCss = fontWeight !== Enums.FontWeight.normal ? `font-weight: ${fontWeight}; ` : ''; + let fontStyleCss = fontStyle !== CoreTypes.FontStyle.normal ? `font-style: ${fontStyle}; ` : ''; + let fontWeightCss = fontWeight !== CoreTypes.FontWeight.normal ? `font-weight: ${fontWeight}; ` : ''; let css = `${fontFamilyCss}${fontStyleCss}${fontWeightCss}`; label.text = `${typeUtils.getClass(label)} {${css}};`; label.textWrap = true; diff --git a/apps/ui/src/image-view/mode-matrix-page.ts b/apps/ui/src/image-view/mode-matrix-page.ts index 91845b44b..0f6ed79c8 100644 --- a/apps/ui/src/image-view/mode-matrix-page.ts +++ b/apps/ui/src/image-view/mode-matrix-page.ts @@ -9,7 +9,7 @@ const sources = [ { src: 'upflip', rotation: 180 }, { src: 'upccw', rotation: 90 }, ].map(({ src, rotation }) => ({ src: `res://${src}`, rotation })); -const stretchModes: Enums.ImageStretchType[] = ['none', 'aspectFill', 'aspectFit', 'fill']; +const stretchModes: CoreTypes.ImageStretchType[] = ['none', 'aspectFill', 'aspectFit', 'fill']; export function navigatingTo(args) { const grid: GridLayout = args.object.getViewById('root'); diff --git a/apps/ui/src/image-view/stretch-modes-page.ts b/apps/ui/src/image-view/stretch-modes-page.ts index bc2657b17..85c2184eb 100644 --- a/apps/ui/src/image-view/stretch-modes-page.ts +++ b/apps/ui/src/image-view/stretch-modes-page.ts @@ -7,12 +7,12 @@ const sources = [ { w: 32, h: 32, src: 'i32x32' }, { w: 18, h: 32, src: 'i18x32' }, ].map(({ w, h, src }) => ({ w, h, src: `res://${src}` })); -const stretchModes: Enums.ImageStretchType[] = ['none', 'aspectFill', 'aspectFit', 'fill']; +const stretchModes: CoreTypes.ImageStretchType[] = ['none', 'aspectFill', 'aspectFit', 'fill']; const widths = [+8, 0, -8]; const heights = [+8, 0, -8]; export function navigatingTo(args) { - const variants: { src: string; stretch: Enums.ImageStretchType; width: number; height: number }[] = []; + const variants: { src: string; stretch: CoreTypes.ImageStretchType; width: number; height: number }[] = []; // Better way for cartesian product? sources.forEach((src) => stretchModes.forEach((stretch) => widths.forEach((width) => heights.forEach((height) => variants.push({ src: src.src, stretch, width: src.w + width, height: src.h + height }))))); diff --git a/apps/ui/src/layouts-percent/stack-page.ts b/apps/ui/src/layouts-percent/stack-page.ts index e4d884978..4098247fb 100644 --- a/apps/ui/src/layouts-percent/stack-page.ts +++ b/apps/ui/src/layouts-percent/stack-page.ts @@ -9,9 +9,9 @@ export function onLoaded(args: { eventName: string; object: any }) { export function onOrientation(args: { eventName: string; object: any }) { var layout = args.object.parent; - if (layout.orientation === Enums.Orientation.vertical) { - layout.orientation = Enums.Orientation.horizontal; + if (layout.orientation === CoreTypes.Orientation.vertical) { + layout.orientation = CoreTypes.Orientation.horizontal; } else { - layout.orientation = Enums.Orientation.vertical; + layout.orientation = CoreTypes.Orientation.vertical; } } diff --git a/apps/ui/src/layouts-percent/wrap-page.ts b/apps/ui/src/layouts-percent/wrap-page.ts index 8c6280443..9ff311b3f 100644 --- a/apps/ui/src/layouts-percent/wrap-page.ts +++ b/apps/ui/src/layouts-percent/wrap-page.ts @@ -9,10 +9,10 @@ export function onLoaded(args: { eventName: string; object: any }) { export function onOrientation(args: { eventName: string; object: any }) { var layout = args.object.parent; - if (layout.orientation === Enums.Orientation.vertical) { - layout.orientation = Enums.Orientation.horizontal; + if (layout.orientation === CoreTypes.Orientation.vertical) { + layout.orientation = CoreTypes.Orientation.horizontal; } else { - layout.orientation = Enums.Orientation.vertical; + layout.orientation = CoreTypes.Orientation.vertical; } } diff --git a/apps/ui/src/layouts/stack-page.ts b/apps/ui/src/layouts/stack-page.ts index 778d1ea15..f1e7ded8a 100644 --- a/apps/ui/src/layouts/stack-page.ts +++ b/apps/ui/src/layouts/stack-page.ts @@ -9,9 +9,9 @@ export function onLoaded(args: { eventName: string; object: any }) { export function onOrientation(args: { eventName: string; object: any }) { var layout = args.object.parent; - if (layout.orientation === Enums.Orientation.vertical) { - layout.orientation = Enums.Orientation.horizontal; + if (layout.orientation === CoreTypes.Orientation.vertical) { + layout.orientation = CoreTypes.Orientation.horizontal; } else { - layout.orientation = Enums.Orientation.vertical; + layout.orientation = CoreTypes.Orientation.vertical; } } diff --git a/apps/ui/src/layouts/wrap-page.ts b/apps/ui/src/layouts/wrap-page.ts index e47c6bdce..d8f1a33d5 100644 --- a/apps/ui/src/layouts/wrap-page.ts +++ b/apps/ui/src/layouts/wrap-page.ts @@ -9,10 +9,10 @@ export function onLoaded(args: { eventName: string; object: any }) { export function onOrientation(args: { eventName: string; object: any }) { var layout = args.object.parent; - if (layout.orientation === Enums.Orientation.vertical) { - layout.orientation = Enums.Orientation.horizontal; + if (layout.orientation === CoreTypes.Orientation.vertical) { + layout.orientation = CoreTypes.Orientation.horizontal; } else { - layout.orientation = Enums.Orientation.vertical; + layout.orientation = CoreTypes.Orientation.vertical; } } diff --git a/packages/core/application/application-common.ts b/packages/core/application/application-common.ts index e8ccf11fb..25a7c6837 100644 --- a/packages/core/application/application-common.ts +++ b/packages/core/application/application-common.ts @@ -10,7 +10,7 @@ import { View } from '../ui/core/view'; // Requires import * as bindableResources from '../ui/core/bindable/bindable-resources'; import { CSSUtils } from '../css/system-classes'; -import { Enums } from '../ui/enums'; +import { CoreTypes } from '../core-types'; import { Trace } from '../trace'; export * from './application-interfaces'; @@ -31,9 +31,9 @@ export const orientationChangedEvent = 'orientationChanged'; export const systemAppearanceChangedEvent = 'systemAppearanceChanged'; export const fontScaleChangedEvent = 'fontScaleChanged'; -const ORIENTATION_CSS_CLASSES = [`${CSSUtils.CLASS_PREFIX}${Enums.DeviceOrientation.portrait}`, `${CSSUtils.CLASS_PREFIX}${Enums.DeviceOrientation.landscape}`, `${CSSUtils.CLASS_PREFIX}${Enums.DeviceOrientation.unknown}`]; +const ORIENTATION_CSS_CLASSES = [`${CSSUtils.CLASS_PREFIX}${CoreTypes.DeviceOrientation.portrait}`, `${CSSUtils.CLASS_PREFIX}${CoreTypes.DeviceOrientation.landscape}`, `${CSSUtils.CLASS_PREFIX}${CoreTypes.DeviceOrientation.unknown}`]; -const SYSTEM_APPEARANCE_CSS_CLASSES = [`${CSSUtils.CLASS_PREFIX}${Enums.SystemAppearance.light}`, `${CSSUtils.CLASS_PREFIX}${Enums.SystemAppearance.dark}`]; +const SYSTEM_APPEARANCE_CSS_CLASSES = [`${CSSUtils.CLASS_PREFIX}${CoreTypes.SystemAppearance.light}`, `${CSSUtils.CLASS_PREFIX}${CoreTypes.SystemAppearance.dark}`]; let cssFile = './app.css'; diff --git a/packages/core/bundle-entry-points.ts b/packages/core/bundle-entry-points.ts index ea5bfda33..cab50f044 100644 --- a/packages/core/bundle-entry-points.ts +++ b/packages/core/bundle-entry-points.ts @@ -12,7 +12,6 @@ global.registerModule('@nativescript/core/ui', () => coreUIModules); // global.registerModule('ui/text-base/span', () => require('./ui/text-base/span')); // global.registerModule('ui/action-bar', () => require('./ui/action-bar')); // global.registerModule('ui/activity-indicator', () => require('./ui/activity-indicator')); -// global.registerModule('ui/bottom-navigation', () => require('./ui/bottom-navigation')); // global.registerModule('ui/button', () => require('./ui/button')); // global.registerModule('ui/content-view', () => require('./ui/content-view')); // global.registerModule('ui/date-picker', () => require('./ui/date-picker')); @@ -38,10 +37,6 @@ global.registerModule('@nativescript/core/ui', () => coreUIModules); // global.registerModule('ui/slider', () => require('./ui/slider')); // global.registerModule('ui/switch', () => require('./ui/switch')); // global.registerModule('ui/tab-view', () => require('./ui/tab-view')); -// global.registerModule('ui/tab-navigation-base/tab-strip', () => require('./ui/tab-navigation-base/tab-strip')); -// global.registerModule('ui/tab-navigation-base/tab-strip-item', () => require('./ui/tab-navigation-base/tab-strip-item')); -// global.registerModule('ui/tab-navigation-base/tab-content-item', () => require('./ui/tab-navigation-base/tab-content-item')); -// global.registerModule('ui/tabs', () => require('./ui/tabs')); // global.registerModule('ui/web-view', () => require('./ui/web-view')); // global.registerModule('ui/text-field', () => require('./ui/text-field')); // global.registerModule('ui/text-view', () => require('./ui/text-view')); diff --git a/packages/core/ui/enums/index.d.ts b/packages/core/core-types/index.d.ts similarity index 88% rename from packages/core/ui/enums/index.d.ts rename to packages/core/core-types/index.d.ts index 8c8671fac..0d4bd1e5d 100644 --- a/packages/core/ui/enums/index.d.ts +++ b/packages/core/core-types/index.d.ts @@ -1,8 +1,32 @@ -import { CubicBezierAnimationCurve } from '../animation'; -import { FontStyleType, FontWeightType } from '../styling/font-common'; +import { CubicBezierAnimationCurve } from '../ui/animation'; +import { FontStyleType, FontWeightType } from '../ui/styling/font-common'; + +export namespace CoreTypes { + /** + * Denotes a length number that is in device independent pixel units. + */ + export type dip = number; + + /** + * Denotes a length number that is in physical device pixels. + */ + export type px = number; + + /** + * Denotes a normalized percent number. + * 0% is represented as 0 + * 50% is represented as 0.5 + * 100% is represented as 1 + */ + export type percent = number; + + export type LengthDipUnit = { readonly unit: 'dip'; readonly value: dip }; + export type LengthPxUnit = { readonly unit: 'px'; readonly value: px }; + export type LengthPercentUnit = { readonly unit: '%'; readonly value: percent }; + + export type LengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit; + export type PercentLengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit | LengthPercentUnit; -export namespace Enums { - export type KeyboardInputType = 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer'; /** * Represents a soft keyboard flavor. @@ -44,7 +68,7 @@ export namespace Enums { export const integer: KeyboardInputType; } - export type ReturnKeyButtonType = 'done' | 'next' | 'go' | 'search' | 'send'; + export type ReturnKeyButtonType = 'done' | 'next' | 'go' | 'search' | 'send'; /** * Represents the flavor of the return key on the soft keyboard. */ @@ -80,7 +104,7 @@ export namespace Enums { export const send: string; } - export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right'; + export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right'; /** * Represents a text-align enumeration. */ @@ -116,7 +140,7 @@ export namespace Enums { export const vertical: OrientationType; } - export type DeviceOrientationType = 'portrait' | 'landscape' | 'unknown'; + export type DeviceOrientationType = 'portrait' | 'landscape' | 'unknown'; /** * Orientation of a device. */ @@ -135,7 +159,7 @@ export namespace Enums { export const unknown: string; } - export type HorizontalAlignmentType = 'left' | 'center' | 'right' | 'stretch'; + export type HorizontalAlignmentType = 'left' | 'center' | 'right' | 'stretch'; /** * HorizontalAlignment indicates where an element should be displayed on the horizontal axis relative to the allocated layout slot of the parent element. */ @@ -161,8 +185,8 @@ export namespace Enums { export const stretch: HorizontalAlignmentType; } - export type VerticalAlignmentType = 'top' | 'middle' | 'bottom' | 'stretch'; - export type VerticalAlignmentTextType = VerticalAlignmentType & 'text-top' | 'text-bottom' | 'super' | 'sub' | 'baseline'; + export type VerticalAlignmentType = 'top' | 'middle' | 'bottom' | 'stretch'; + export type VerticalAlignmentTextType = (VerticalAlignmentType & 'text-top') | 'text-bottom' | 'super' | 'sub' | 'baseline'; /** * VerticalAlignment indicates where an element should be displayed on the horizontal axis relative to the allocated layout slot of the parent element. */ @@ -193,7 +217,7 @@ export namespace Enums { export const stretch: VerticalAlignmentType; } - export type ImageStretchType = 'none' | 'aspectFill' | 'aspectFit' | 'fill'; + export type ImageStretchType = 'none' | 'aspectFill' | 'aspectFit' | 'fill'; /** * Describes how content is resized to fill its allocated space. */ @@ -222,7 +246,7 @@ export namespace Enums { export const fill: ImageStretchType; } - export type VisibilityType = 'visible' | 'hidden' | 'collapse' | 'collapsed'; + export type VisibilityType = 'visible' | 'hidden' | 'collapse' | 'collapsed'; /** * Represents the visibility mode of a view. */ @@ -235,12 +259,12 @@ export namespace Enums { /** * The view is not visible and won't take place in the layout. */ - export const collapse: VisibilityType; - - /** - * @deprecated Use collapse instead - */ - export const collapsed: VisibilityType; + export const collapse: VisibilityType; + + /** + * @deprecated Use collapse instead + */ + export const collapsed: VisibilityType; /** * The view is not visible but will take place in the layout. @@ -283,7 +307,7 @@ export namespace Enums { export const Tablet: string; } - export type UpdateTextTriggerType = 'focusLost' | 'textChanged'; + export type UpdateTextTriggerType = 'focusLost' | 'textChanged'; /** * Represents an enumeration specifying when the text property of an EditableTextBase will be updated. */ @@ -314,7 +338,7 @@ export namespace Enums { export const high: number; } - export type DockType = 'left' | 'top' | 'right' | 'bottom'; + export type DockType = 'left' | 'top' | 'right' | 'bottom'; /** * Specifies the Dock position of a child element that is inside a DockLayout. */ @@ -340,7 +364,7 @@ export namespace Enums { export const bottom: DockType; } - export type AutocapitalizationInputType = 'none' | 'words' | 'sentences' | 'allcharacters'; + export type AutocapitalizationInputType = 'none' | 'words' | 'sentences' | 'allcharacters'; /** * Represents the auto-capitalization style for a text input. */ @@ -450,7 +474,7 @@ export namespace Enums { export const italic: FontStyleType; } - export type TextDecorationType = 'none' | 'underline' | 'line-through' | 'underline line-through'; + export type TextDecorationType = 'none' | 'underline' | 'line-through' | 'underline line-through'; /** * Specifies different text decorations. */ @@ -471,7 +495,7 @@ export namespace Enums { export const lineThrough: TextDecorationType; } - export type TextTransformType = 'initial' | 'none' | 'capitalize' | 'uppercase' | 'lowercase'; + export type TextTransformType = 'initial' | 'none' | 'capitalize' | 'uppercase' | 'lowercase'; /** * Specifies different text transforms. */ @@ -497,7 +521,7 @@ export namespace Enums { export const lowercase: TextTransformType; } - export type WhiteSpaceType = 'initial' | 'normal' | 'nowrap'; + export type WhiteSpaceType = 'initial' | 'normal' | 'nowrap'; /** * Specifies different white spaces. */ @@ -563,7 +587,7 @@ export namespace Enums { export const black: FontWeightType; } - export type BackgroundRepeatType = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; + export type BackgroundRepeatType = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; /** * Specifies background repeat. */ @@ -571,9 +595,9 @@ export namespace Enums { export const repeat: BackgroundRepeatType; export const repeatX: BackgroundRepeatType; export const repeatY: BackgroundRepeatType; - export const noRepeat: BackgroundRepeatType; - export const isValid: (value: any) => BackgroundRepeatType; - export const parse: (value: any) => BackgroundRepeatType; + export const noRepeat: BackgroundRepeatType; + export const isValid: (value: any) => BackgroundRepeatType; + export const parse: (value: any) => BackgroundRepeatType; } /** @@ -729,3 +753,8 @@ export namespace Enums { // WhiteSpace: typeof WhiteSpace; // WhiteSpaceType: WhiteSpaceType; } + +/** + * @deprecated Use `CoreTypes` instead. Enums will be removed in 9.0 + */ +export const Enums: typeof CoreTypes; diff --git a/packages/core/core-types/index.ts b/packages/core/core-types/index.ts new file mode 100644 index 000000000..0da8fc35b --- /dev/null +++ b/packages/core/core-types/index.ts @@ -0,0 +1,315 @@ +/** + * General @nativescript/core types used throughout the library. + */ + +// imported for definition purposes only +import * as animationModule from '../ui/animation'; +import { makeValidator, makeParser } from '../ui/core/properties'; + +export namespace CoreTypes { + /** + * Denotes a length number that is in device independent pixel units. + */ + export type dip = number; + + /** + * Denotes a length number that is in physical device pixels. + */ + export type px = number; + + /** + * Denotes a normalized percent number. + * 0% is represented as 0 + * 50% is represented as 0.5 + * 100% is represented as 1 + */ + export type percent = number; + + export type LengthDipUnit = { readonly unit: 'dip'; readonly value: dip }; + export type LengthPxUnit = { readonly unit: 'px'; readonly value: px }; + export type LengthPercentUnit = { readonly unit: '%'; readonly value: percent }; + + export type LengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit; + export type PercentLengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit | LengthPercentUnit; + + export type KeyboardInputType = 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer'; + export module KeyboardType { + export const datetime = 'datetime'; + export const phone = 'phone'; + export const number = 'number'; + export const url = 'url'; + export const email = 'email'; + export const integer = 'integer'; + } + + export type ReturnKeyButtonType = 'done' | 'next' | 'go' | 'search' | 'send'; + export module ReturnKeyType { + export const done = 'done'; + export const next = 'next'; + export const go = 'go'; + export const search = 'search'; + export const send = 'send'; + } + + export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right'; + export module TextAlignment { + export const left = 'left'; + export const center = 'center'; + export const right = 'right'; + } + + export type TextDecorationType = 'none' | 'underline' | 'line-through' | 'underline line-through'; + export module TextDecoration { + export const none = 'none'; + export const underline = 'underline'; + export const lineThrough = 'line-through'; + } + + export type TextTransformType = 'initial' | 'none' | 'capitalize' | 'uppercase' | 'lowercase'; + export module TextTransform { + export const none = 'none'; + export const capitalize = 'capitalize'; + export const uppercase = 'uppercase'; + export const lowercase = 'lowercase'; + } + + export type WhiteSpaceType = 'initial' | 'normal' | 'nowrap'; + export module WhiteSpace { + export const normal = 'normal'; + export const nowrap = 'nowrap'; + } + + export type OrientationType = 'horizontal' | 'vertical'; + export module Orientation { + export const horizontal = 'horizontal'; + export const vertical = 'vertical'; + } + + export type DeviceOrientationType = 'portrait' | 'landscape' | 'unknown'; + export module DeviceOrientation { + export const portrait = 'portrait'; + export const landscape = 'landscape'; + export const unknown = 'unknown'; + } + + export type HorizontalAlignmentType = 'left' | 'center' | 'right' | 'stretch'; + export module HorizontalAlignment { + export const left = 'left'; + export const center = 'center'; + export const right = 'right'; + export const stretch = 'stretch'; + export const isValid = makeValidator(left, center, right, stretch); + export const parse = makeParser(isValid); + } + + export type VerticalAlignmentType = 'top' | 'middle' | 'bottom' | 'stretch'; + export module VerticalAlignment { + export const top = 'top'; + export const middle = 'middle'; + export const bottom = 'bottom'; + export const stretch = 'stretch'; + } + export type VerticalAlignmentTextType = VerticalAlignmentType | 'text-top' | 'text-bottom' | 'sup' | 'sub' | 'baseline'; + export namespace VerticalAlignmentText { + export const top = 'top'; + export const middle = 'middle'; + export const bottom = 'bottom'; + export const stretch = 'stretch'; + export const texttop = 'text-top'; + export const textbottom = 'text-bottom'; + export const sup = 'sup'; + export const sub = 'sub'; + export const baseline = 'baseline'; + export const isValid = makeValidator(top, middle, bottom, stretch, texttop, textbottom, sup, sub, baseline); + export const parse = (value: string) => (value.toLowerCase() === 'center' ? middle : parseStrict(value)); + const parseStrict = makeParser(isValid); + } + + export type ImageStretchType = 'none' | 'aspectFill' | 'aspectFit' | 'fill'; + export module ImageStretch { + export const none: ImageStretchType = 'none'; + export const aspectFill: ImageStretchType = 'aspectFill'; + export const aspectFit: ImageStretchType = 'aspectFit'; + export const fill: ImageStretchType = 'fill'; + } + + export type VisibilityType = 'visible' | 'hidden' | 'collapse' | 'collapsed'; + export module Visibility { + export const visible: VisibilityType = 'visible'; + export const collapse: VisibilityType = 'collapse'; + export const collapsed: VisibilityType = 'collapsed'; + export const hidden: VisibilityType = 'hidden'; + export const isValid = makeValidator(visible, hidden, collapse); + export const parse = (value: string) => (value.toLowerCase() === 'collapsed' ? collapse : parseStrict(value)); + const parseStrict = makeParser(isValid); + } + + export module FontAttributes { + export const Normal = 0; + export const Bold = 1; + export const Italic = 1 << 1; + } + + export module DeviceType { + export const Phone: string = 'Phone'; + export const Tablet: string = 'Tablet'; + } + + export type UpdateTextTriggerType = 'focusLost' | 'textChanged'; + export module UpdateTextTrigger { + export const focusLost: UpdateTextTriggerType = 'focusLost'; + export const textChanged: UpdateTextTriggerType = 'textChanged'; + } + + export module Accuracy { + export const any: number = 300; + export const high: number = 3; + } + + export type DockType = 'left' | 'top' | 'right' | 'bottom'; + export module Dock { + export const left: DockType = 'left'; + export const top: DockType = 'top'; + export const right: DockType = 'right'; + export const bottom: DockType = 'bottom'; + } + + export type AutocapitalizationInputType = 'none' | 'words' | 'sentences' | 'allcharacters'; + export module AutocapitalizationType { + export const none: AutocapitalizationInputType = 'none'; + export const words: AutocapitalizationInputType = 'words'; + export const sentences: AutocapitalizationInputType = 'sentences'; + export const allCharacters: AutocapitalizationInputType = 'allcharacters'; + } + + export module NavigationBarVisibility { + export const auto: string = 'auto'; + export const never: string = 'never'; + export const always: string = 'always'; + } + + export module AndroidActionBarIconVisibility { + export const auto: string = 'auto'; + export const never: string = 'never'; + export const always: string = 'always'; + } + + export module AndroidActionItemPosition { + export const actionBar: string = 'actionBar'; + export const actionBarIfRoom: string = 'actionBarIfRoom'; + export const popup: string = 'popup'; + } + + export module IOSActionItemPosition { + export const left: string = 'left'; + export const right: string = 'right'; + } + + export module ImageFormat { + export const png: string = 'png'; + export const jpeg: string = 'jpeg'; + export const jpg: string = 'jpg'; + } + + export module FontStyle { + export const normal: string = 'normal'; + export const italic: string = 'italic'; + } + + export module FontWeight { + export const thin: string = '100'; + export const extraLight: string = '200'; + export const light: string = '300'; + export const normal: string = 'normal'; // 400 + export const medium: string = '500'; + export const semiBold: string = '600'; + export const bold: string = 'bold'; // 700 + export const extraBold: string = '800'; + export const black: string = '900'; + } + + export type BackgroundRepeatType = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; + export module BackgroundRepeat { + export const repeat: BackgroundRepeatType = 'repeat'; + export const repeatX: BackgroundRepeatType = 'repeat-x'; + export const repeatY: BackgroundRepeatType = 'repeat-y'; + export const noRepeat: BackgroundRepeatType = 'no-repeat'; + export const isValid = makeValidator(repeat, repeatX, repeatY, noRepeat); + export const parse = makeParser(isValid); + } + + let animation: typeof animationModule; + + export module AnimationCurve { + export const ease = 'ease'; + export const easeIn = 'easeIn'; + export const easeOut = 'easeOut'; + export const easeInOut = 'easeInOut'; + export const linear = 'linear'; + export const spring = 'spring'; + export function cubicBezier(x1: number, y1: number, x2: number, y2: number): Object { + animation = animation || require('../ui/animation'); + + return new animation.CubicBezierAnimationCurve(x1, y1, x2, y2); + } + } + + export module StatusBarStyle { + export const light = 'light'; + export const dark = 'dark'; + } + + export module SystemAppearance { + export const light = 'light'; + export const dark = 'dark'; + } + + // Accuracy, + // AndroidActionBarIconVisibility, + // AndroidActionItemPosition, + // AnimationCurve, + // AutocapitalizationType, + // AutocapitalizationInputType: typeof AutocapitalizationType, + // BackgroundRepeat, + // BackgroundRepeatType: typeof BackgroundRepeat, + // DeviceOrientation, + // DeviceType, + // Dock, + // FontAttributes, + // FontStyle, + // FontStyleType: typeof FontStyle, + // FontWeight, + // FontWeightType: typeof FontWeight, + // HorizontalAlignment, + // HorizontalAlignmentType: typeof HorizontalAlignment, + // IOSActionItemPosition, + // ImageFormat, + // KeyboardType, + // KeyboardInputType: typeof KeyboardType, + // NavigationBarVisibility, + // Orientation, + // OrientationType: typeof Orientation, + // ReturnKeyType, + // StatusBarStyle, + // Stretch, + // SystemAppearance, + // TextAlignment, + // TextAlignmentType: typeof TextAlignment, + // TextDecoration, + // TextDecorationType: typeof TextDecoration, + // TextTransform, + // TextTransformType: typeof TextTransform, + // UpdateTextTrigger, + // UpdateTextTriggerType: typeof UpdateTextTrigger, + // VerticalAlignment, + // VerticalAlignmentType: typeof VerticalAlignment, + // Visibility, + // VisibilityType: typeof Visibility, + // WhiteSpace, + // WhiteSpaceType: typeof WhiteSpace +} + +/** + * @deprecated Use `CoreTypes` instead. Enums will be removed in 9.0 + */ +export const Enums: typeof CoreTypes = CoreTypes; diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts index d00b01d72..1cdfa46b8 100644 --- a/packages/core/index.d.ts +++ b/packages/core/index.d.ts @@ -70,6 +70,7 @@ export declare const Connectivity: { startMonitoring: typeof startMonitoring; stopMonitoring: typeof stopMonitoring; }; +export { CoreTypes, Enums } from './core-types'; export { CSSUtils } from './css/system-classes'; export { ObservableArray, ChangeType } from './data/observable-array'; export type { ChangedData } from './data/observable-array'; diff --git a/packages/core/index.ts b/packages/core/index.ts index 860a5c05c..e2fe873f9 100644 --- a/packages/core/index.ts +++ b/packages/core/index.ts @@ -77,6 +77,8 @@ export const Connectivity = { stopMonitoring, }; +export { CoreTypes, Enums } from './core-types'; + export { CSSUtils } from './css/system-classes'; export { ObservableArray, ChangeType } from './data/observable-array'; diff --git a/packages/core/package.json b/packages/core/package.json index da218abd8..bdaeaaf40 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "NativeScript Core Modules", - "version": "8.0.0-alpha.0", + "version": "8.0.0-alpha.1", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/core/ui/action-bar/action-bar-common.ts b/packages/core/ui/action-bar/action-bar-common.ts index 6d25f4d6f..5249eb18f 100644 --- a/packages/core/ui/action-bar/action-bar-common.ts +++ b/packages/core/ui/action-bar/action-bar-common.ts @@ -1,12 +1,12 @@ import { ActionBar as ActionBarDefinition, ActionItems as ActionItemsDefinition, ActionItem as ActionItemDefinition, NavigationButton, IOSActionItemSettings, AndroidActionItemSettings, AndroidActionBarSettings } from '.'; import { profile } from '../../profiling'; - +import { CoreTypes } from '../../core-types'; import { View, CSSType } from '../core/view'; import { ViewBase, booleanConverter } from '../core/view-base'; import { Trace } from '../../trace'; import { ShorthandProperty, CssProperty, Property, unsetValue } from '../core/properties'; -import { Length, horizontalAlignmentProperty, verticalAlignmentProperty, LengthType } from '../styling/style-properties'; +import { Length, horizontalAlignmentProperty, verticalAlignmentProperty } from '../styling/style-properties'; import { Style } from '../styling/style'; @CSSType('ActionBar') @@ -81,24 +81,24 @@ export class ActionBarBase extends View implements ActionBarDefinition { } } - public get androidContentInset(): string | LengthType { + public get androidContentInset(): string | CoreTypes.LengthType { return this.style.androidContentInset; } - public set androidContentInset(value: string | LengthType) { + public set androidContentInset(value: string | CoreTypes.LengthType) { this.style.androidContentInset = value; } - public get androidContentInsetLeft(): LengthType { + public get androidContentInsetLeft(): CoreTypes.LengthType { return this.style.androidContentInsetLeft; } - public set androidContentInsetLeft(value: LengthType) { + public set androidContentInsetLeft(value: CoreTypes.LengthType) { this.style.androidContentInsetLeft = value; } - public get androidContentInsetRight(): LengthType { + public get androidContentInsetRight(): CoreTypes.LengthType { return this.style.androidContentInsetRight; } - public set androidContentInsetRight(value: LengthType) { + public set androidContentInsetRight(value: CoreTypes.LengthType) { this.style.androidContentInsetRight = value; } @@ -363,7 +363,7 @@ export function traceMissingIcon(icon: string) { Trace.write('Could not load action bar icon: ' + icon, Trace.categories.Error, Trace.messageType.error); } -function convertToContentInset(this: void, value: string | LengthType): [CssProperty, any][] { +function convertToContentInset(this: void, value: string | CoreTypes.LengthType): [CssProperty, any][] { if (typeof value === 'string' && value !== 'auto') { const insets = value.split(/[ ,]+/); @@ -409,7 +409,7 @@ export const flatProperty = new Property({ }); flatProperty.register(ActionBarBase); -const androidContentInsetProperty = new ShorthandProperty({ +const androidContentInsetProperty = new ShorthandProperty({ name: 'androidContentInset', cssName: 'android-content-inset', getter: function (this: Style) { @@ -423,7 +423,7 @@ const androidContentInsetProperty = new ShorthandProperty({ +export const androidContentInsetLeftProperty = new CssProperty({ name: 'androidContentInsetLeft', cssName: 'android-content-inset-left', defaultValue: 'auto', @@ -440,7 +440,7 @@ export const androidContentInsetLeftProperty = new CssProperty({ +export const androidContentInsetRightProperty = new CssProperty({ name: 'androidContentInsetRight', cssName: 'android-content-inset-right', defaultValue: 'auto', diff --git a/packages/core/ui/activity-indicator/index.android.ts b/packages/core/ui/activity-indicator/index.android.ts index 693f6e3f2..7d283d4ab 100644 --- a/packages/core/ui/activity-indicator/index.android.ts +++ b/packages/core/ui/activity-indicator/index.android.ts @@ -1,7 +1,7 @@ import { ActivityIndicatorBase, busyProperty } from './activity-indicator-common'; -import { colorProperty, visibilityProperty } from '../styling/style-properties'; +import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; -import { Enums } from '../enums'; +import { colorProperty, visibilityProperty } from '../styling/style-properties'; export * from './activity-indicator-common'; @@ -20,27 +20,27 @@ export class ActivityIndicator extends ActivityIndicatorBase { return false; } [busyProperty.setNative](value: boolean) { - if (this.visibility === Enums.Visibility.visible) { + if (this.visibility === CoreTypes.Visibility.visible) { this.nativeViewProtected.setVisibility(value ? android.view.View.VISIBLE : android.view.View.INVISIBLE); } } - [visibilityProperty.getDefault](): Enums.VisibilityType { - return Enums.Visibility.hidden; + [visibilityProperty.getDefault](): CoreTypes.VisibilityType { + return CoreTypes.Visibility.hidden; } - [visibilityProperty.setNative](value: Enums.VisibilityType) { + [visibilityProperty.setNative](value: CoreTypes.VisibilityType) { switch (value) { - case Enums.Visibility.visible: + case CoreTypes.Visibility.visible: this.nativeViewProtected.setVisibility(this.busy ? android.view.View.VISIBLE : android.view.View.INVISIBLE); break; - case Enums.Visibility.hidden: + case CoreTypes.Visibility.hidden: this.nativeViewProtected.setVisibility(android.view.View.INVISIBLE); break; - case Enums.Visibility.collapse: + case CoreTypes.Visibility.collapse: this.nativeViewProtected.setVisibility(android.view.View.GONE); break; default: - throw new Error(`Invalid visibility value: ${value}. Valid values are: "${Enums.Visibility.visible}", "${Enums.Visibility.hidden}", "${Enums.Visibility.collapse}".`); + throw new Error(`Invalid visibility value: ${value}. Valid values are: "${CoreTypes.Visibility.visible}", "${CoreTypes.Visibility.hidden}", "${CoreTypes.Visibility.collapse}".`); } } diff --git a/packages/core/ui/animation/animation-interfaces.ts b/packages/core/ui/animation/animation-interfaces.ts index a3ef65640..06bec8e31 100644 --- a/packages/core/ui/animation/animation-interfaces.ts +++ b/packages/core/ui/animation/animation-interfaces.ts @@ -1,6 +1,6 @@ // Types import { View } from '../core/view'; -import { PercentLengthType } from '../styling/style-properties'; +import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; export type Transformation = { @@ -53,8 +53,8 @@ export interface AnimationDefinition { backgroundColor?: Color; translate?: Pair; scale?: Pair; - height?: PercentLengthType | string; - width?: PercentLengthType | string; + height?: CoreTypes.PercentLengthType | string; + width?: CoreTypes.PercentLengthType | string; rotate?: number; duration?: number; delay?: number; diff --git a/packages/core/ui/animation/index.d.ts b/packages/core/ui/animation/index.d.ts index ce260d9ed..d05431749 100644 --- a/packages/core/ui/animation/index.d.ts +++ b/packages/core/ui/animation/index.d.ts @@ -1,6 +1,6 @@ import { View } from '../core/view'; +import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; -import { PercentLengthType } from '../styling/style-properties'; export { KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './keyframe-animation'; @@ -36,12 +36,12 @@ export interface AnimationDefinition { /** * Animates the height of a view. */ - height?: PercentLengthType | string; + height?: CoreTypes.PercentLengthType | string; /** * Animates the width of a view. */ - width?: PercentLengthType | string; + width?: CoreTypes.PercentLengthType | string; /** * Animates the rotate affine transform of the view. Value should be a number specifying the rotation amount in degrees. diff --git a/packages/core/ui/animation/keyframe-animation.d.ts b/packages/core/ui/animation/keyframe-animation.d.ts index 2e2fc3aed..82578571e 100644 --- a/packages/core/ui/animation/keyframe-animation.d.ts +++ b/packages/core/ui/animation/keyframe-animation.d.ts @@ -1,6 +1,6 @@ import { View } from '../core/view'; +import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; -import { PercentLength } from '../styling/style-properties'; export declare const ANIMATION_PROPERTIES; @@ -10,8 +10,8 @@ interface Keyframe { translate?: { x: number; y: number }; rotate?: { x: number; y: number; z: number }; opacity?: number; - width?: PercentLength; - height?: PercentLength; + width?: CoreTypes.PercentLengthType; + height?: CoreTypes.PercentLengthType; valueSource?: 'keyframe' | 'animation'; duration?: number; curve?: any; diff --git a/packages/core/ui/animation/keyframe-animation.ts b/packages/core/ui/animation/keyframe-animation.ts index a23998f8b..c5df0dd5f 100644 --- a/packages/core/ui/animation/keyframe-animation.ts +++ b/packages/core/ui/animation/keyframe-animation.ts @@ -1,14 +1,14 @@ import { View } from '../core/view'; import { Color } from '../../color'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { Trace } from '../../trace'; // Types. import { unsetValue } from '../core/properties'; import { Animation } from '.'; -import { backgroundColorProperty, scaleXProperty, scaleYProperty, translateXProperty, translateYProperty, rotateProperty, opacityProperty, rotateXProperty, rotateYProperty, widthProperty, heightProperty, PercentLength, PercentLengthType } from '../styling/style-properties'; +import { backgroundColorProperty, scaleXProperty, scaleYProperty, translateXProperty, translateYProperty, rotateProperty, opacityProperty, rotateXProperty, rotateYProperty, widthProperty, heightProperty } from '../styling/style-properties'; export class Keyframes { name: string; @@ -28,7 +28,7 @@ export class KeyframeDeclaration { export class KeyframeInfo { public duration: number; public declarations: Array; - public curve?: any = Enums.AnimationCurve.ease; + public curve?: any = CoreTypes.AnimationCurve.ease; } export class KeyframeAnimationInfo { @@ -48,8 +48,8 @@ interface Keyframe { translate?: { x: number; y: number }; rotate?: { x: number; y: number; z: number }; opacity?: number; - width?: PercentLengthType; - height?: PercentLengthType; + width?: CoreTypes.PercentLengthType; + height?: CoreTypes.PercentLengthType; valueSource?: 'keyframe' | 'animation'; duration?: number; curve?: any; diff --git a/packages/core/ui/builder/component-builder/index.ts b/packages/core/ui/builder/component-builder/index.ts index 330c527ed..9ea01678d 100644 --- a/packages/core/ui/builder/component-builder/index.ts +++ b/packages/core/ui/builder/component-builder/index.ts @@ -22,7 +22,6 @@ const legacyShortBarrels = [ 'ui/text-base/span', 'ui/action-bar', 'ui/activity-indicator', - 'ui/bottom-navigation', 'ui/button', 'ui/content-view', 'ui/date-picker', @@ -48,10 +47,6 @@ const legacyShortBarrels = [ 'ui/slider', 'ui/switch', 'ui/tab-view', - 'ui/tab-navigation-base/tab-strip', - 'ui/tab-navigation-base/tab-strip-item', - 'ui/tab-navigation-base/tab-content-item', - 'ui/tabs', 'ui/web-view', 'ui/text-field', 'ui/text-view', diff --git a/packages/core/ui/button/index.android.ts b/packages/core/ui/button/index.android.ts index 2192a07b2..3dbdb738f 100644 --- a/packages/core/ui/button/index.android.ts +++ b/packages/core/ui/button/index.android.ts @@ -1,8 +1,8 @@ import { ButtonBase } from './button-common'; import { PseudoClassHandler } from '../core/view'; -import { paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length, zIndexProperty, minWidthProperty, minHeightProperty, LengthType } from '../styling/style-properties'; +import { paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length, zIndexProperty, minWidthProperty, minHeightProperty } from '../styling/style-properties'; import { textAlignmentProperty } from '../text-base'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { profile } from '../../profiling'; import { TouchGestureEventData, GestureTypes, TouchAction } from '../gestures'; import { Device } from '../../platform'; @@ -114,43 +114,43 @@ export class Button extends ButtonBase { } } - [minWidthProperty.getDefault](): LengthType { + [minWidthProperty.getDefault](): CoreTypes.LengthType { const dips = org.nativescript.widgets.ViewHelper.getMinWidth(this.nativeViewProtected); return { value: dips, unit: 'px' }; } - [minHeightProperty.getDefault](): LengthType { + [minHeightProperty.getDefault](): CoreTypes.LengthType { const dips = org.nativescript.widgets.ViewHelper.getMinHeight(this.nativeViewProtected); return { value: dips, unit: 'px' }; } - [paddingTopProperty.getDefault](): LengthType { + [paddingTopProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingTop, unit: 'px' }; } - [paddingTopProperty.setNative](value: LengthType) { + [paddingTopProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderTopWidth, 0)); } - [paddingRightProperty.getDefault](): LengthType { + [paddingRightProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingRight, unit: 'px' }; } - [paddingRightProperty.setNative](value: LengthType) { + [paddingRightProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderRightWidth, 0)); } - [paddingBottomProperty.getDefault](): LengthType { + [paddingBottomProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingBottom, unit: 'px' }; } - [paddingBottomProperty.setNative](value: LengthType) { + [paddingBottomProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderBottomWidth, 0)); } - [paddingLeftProperty.getDefault](): LengthType { + [paddingLeftProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingLeft, unit: 'px' }; } - [paddingLeftProperty.setNative](value: LengthType) { + [paddingLeftProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0)); } @@ -167,7 +167,7 @@ export class Button extends ButtonBase { org.nativescript.widgets.ViewHelper.setZIndex(this.nativeViewProtected, value); } - [textAlignmentProperty.setNative](value: Enums.TextAlignmentType) { + [textAlignmentProperty.setNative](value: CoreTypes.TextAlignmentType) { // Button initial value is center. const newValue = value === 'initial' ? 'center' : value; super[textAlignmentProperty.setNative](newValue); diff --git a/packages/core/ui/button/index.ios.ts b/packages/core/ui/button/index.ios.ts index d1a20fd4a..4b0828c10 100644 --- a/packages/core/ui/button/index.ios.ts +++ b/packages/core/ui/button/index.ios.ts @@ -1,10 +1,10 @@ import { ControlStateChangeListener } from '../core/control-state-change'; import { ButtonBase } from './button-common'; import { View, PseudoClassHandler } from '../core/view'; -import { borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, LengthType } from '../styling/style-properties'; +import { borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty } from '../styling/style-properties'; import { textAlignmentProperty, whiteSpaceProperty } from '../text-base'; import { layout } from '../../utils'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; export * from './button-common'; @@ -56,13 +56,13 @@ export class Button extends ButtonBase { } } - [borderTopWidthProperty.getDefault](): LengthType { + [borderTopWidthProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeViewProtected.contentEdgeInsets.top, unit: 'px', }; } - [borderTopWidthProperty.setNative](value: LengthType) { + [borderTopWidthProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeViewProtected.contentEdgeInsets; const top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth); this.nativeViewProtected.contentEdgeInsets = { @@ -73,13 +73,13 @@ export class Button extends ButtonBase { }; } - [borderRightWidthProperty.getDefault](): LengthType { + [borderRightWidthProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeViewProtected.contentEdgeInsets.right, unit: 'px', }; } - [borderRightWidthProperty.setNative](value: LengthType) { + [borderRightWidthProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeViewProtected.contentEdgeInsets; const right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth); this.nativeViewProtected.contentEdgeInsets = { @@ -90,13 +90,13 @@ export class Button extends ButtonBase { }; } - [borderBottomWidthProperty.getDefault](): LengthType { + [borderBottomWidthProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeViewProtected.contentEdgeInsets.bottom, unit: 'px', }; } - [borderBottomWidthProperty.setNative](value: LengthType) { + [borderBottomWidthProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeViewProtected.contentEdgeInsets; const bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth); this.nativeViewProtected.contentEdgeInsets = { @@ -107,13 +107,13 @@ export class Button extends ButtonBase { }; } - [borderLeftWidthProperty.getDefault](): LengthType { + [borderLeftWidthProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeViewProtected.contentEdgeInsets.left, unit: 'px', }; } - [borderLeftWidthProperty.setNative](value: LengthType) { + [borderLeftWidthProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeViewProtected.contentEdgeInsets; const left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth); this.nativeViewProtected.contentEdgeInsets = { @@ -124,13 +124,13 @@ export class Button extends ButtonBase { }; } - [paddingTopProperty.getDefault](): LengthType { + [paddingTopProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeViewProtected.contentEdgeInsets.top, unit: 'px', }; } - [paddingTopProperty.setNative](value: LengthType) { + [paddingTopProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeViewProtected.contentEdgeInsets; const top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth); this.nativeViewProtected.contentEdgeInsets = { @@ -141,13 +141,13 @@ export class Button extends ButtonBase { }; } - [paddingRightProperty.getDefault](): LengthType { + [paddingRightProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeViewProtected.contentEdgeInsets.right, unit: 'px', }; } - [paddingRightProperty.setNative](value: LengthType) { + [paddingRightProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeViewProtected.contentEdgeInsets; const right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth); this.nativeViewProtected.contentEdgeInsets = { @@ -158,13 +158,13 @@ export class Button extends ButtonBase { }; } - [paddingBottomProperty.getDefault](): LengthType { + [paddingBottomProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeViewProtected.contentEdgeInsets.bottom, unit: 'px', }; } - [paddingBottomProperty.setNative](value: LengthType) { + [paddingBottomProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeViewProtected.contentEdgeInsets; const bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth); this.nativeViewProtected.contentEdgeInsets = { @@ -175,13 +175,13 @@ export class Button extends ButtonBase { }; } - [paddingLeftProperty.getDefault](): LengthType { + [paddingLeftProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeViewProtected.contentEdgeInsets.left, unit: 'px', }; } - [paddingLeftProperty.setNative](value: LengthType) { + [paddingLeftProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeViewProtected.contentEdgeInsets; const left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth); this.nativeViewProtected.contentEdgeInsets = { @@ -192,7 +192,7 @@ export class Button extends ButtonBase { }; } - [textAlignmentProperty.setNative](value: Enums.TextAlignmentType) { + [textAlignmentProperty.setNative](value: CoreTypes.TextAlignmentType) { switch (value) { case 'left': this.nativeViewProtected.titleLabel.textAlignment = NSTextAlignment.Left; @@ -210,7 +210,7 @@ export class Button extends ButtonBase { } } - [whiteSpaceProperty.setNative](value: Enums.WhiteSpaceType) { + [whiteSpaceProperty.setNative](value: CoreTypes.WhiteSpaceType) { const nativeView = this.nativeViewProtected.titleLabel; switch (value) { case 'normal': diff --git a/packages/core/ui/core/view-base/index.d.ts b/packages/core/ui/core/view-base/index.d.ts index fc9157e8e..3675745a4 100644 --- a/packages/core/ui/core/view-base/index.d.ts +++ b/packages/core/ui/core/view-base/index.d.ts @@ -2,11 +2,11 @@ import { Property, CssProperty, CssAnimationProperty, InheritedProperty } from ' import { BindingOptions } from '../bindable'; import { Observable } from '../../../data/observable'; import { Style } from '../../styling/style'; - +import { CoreTypes } from '../../../core-types'; import { Page } from '../../page'; import { Order, FlexGrow, FlexShrink, FlexWrapBefore, AlignSelf } from '../../layouts/flexbox-layout'; -import { Length, LengthType } from '../../styling/style-properties'; +import { Length } from '../../styling/style-properties'; import { DOMNode } from '../../../debugger/dom-node'; /** @@ -105,8 +105,8 @@ export interface ShowModalOptions { export abstract class ViewBase extends Observable { // Dynamic properties. - left: LengthType; - top: LengthType; + left: CoreTypes.LengthType; + top: CoreTypes.LengthType; effectiveLeft: number; effectiveTop: number; dock: 'left' | 'top' | 'right' | 'bottom'; diff --git a/packages/core/ui/core/view-base/index.ts b/packages/core/ui/core/view-base/index.ts index 598e61c38..b185a7aec 100644 --- a/packages/core/ui/core/view-base/index.ts +++ b/packages/core/ui/core/view-base/index.ts @@ -3,6 +3,7 @@ import { AlignSelf, FlexGrow, FlexShrink, FlexWrapBefore, Order } from '../../la import { Page } from '../../page'; // Types. +import { CoreTypes } from '../../../core-types'; import { Property, CssProperty, CssAnimationProperty, InheritedProperty, clearInheritedProperties, propagateInheritableProperties, propagateInheritableCssProperties, initNativeView } from '../properties'; import { CSSUtils } from '../../../css/system-classes'; import { Source } from '../../../utils/debug'; @@ -10,7 +11,7 @@ import { Binding, BindingOptions } from '../bindable'; import { Trace } from '../../../trace'; import { Observable, PropertyChangeData, WrappedValue } from '../../../data/observable'; import { Style } from '../../styling/style'; -import { Length, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, LengthType } from '../../styling/style-properties'; +import { paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty } from '../../styling/style-properties'; // TODO: Remove this import! import { getClass } from '../../../utils/types'; @@ -284,8 +285,8 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition public _automaticallyAdjustsScrollViewInsets: boolean; // Dynamic properties. - left: LengthType; - top: LengthType; + left: CoreTypes.LengthType; + top: CoreTypes.LengthType; effectiveLeft: number; effectiveTop: number; dock: 'left' | 'top' | 'right' | 'bottom'; diff --git a/packages/core/ui/core/view/index.android.ts b/packages/core/ui/core/view/index.android.ts index 1eeb08876..1e481b058 100644 --- a/packages/core/ui/core/view/index.android.ts +++ b/packages/core/ui/core/view/index.android.ts @@ -1,5 +1,5 @@ // Definitions. -import type { Point, CustomLayoutView as CustomLayoutViewDefinition, dip } from '.'; +import type { Point, CustomLayoutView as CustomLayoutViewDefinition } from '.'; import type { GestureTypes, GestureEventData } from '../../gestures'; // Types. @@ -10,8 +10,8 @@ import { Trace } from '../../../trace'; import { ShowModalOptions } from '../view-base'; import { EventData } from '../../../data/observable'; -import { perspectiveProperty, visibilityProperty, opacityProperty, horizontalAlignmentProperty, verticalAlignmentProperty, minWidthProperty, minHeightProperty, widthProperty, heightProperty, marginLeftProperty, marginTopProperty, marginRightProperty, marginBottomProperty, rotateProperty, rotateXProperty, rotateYProperty, scaleXProperty, scaleYProperty, translateXProperty, translateYProperty, zIndexProperty, backgroundInternalProperty, androidElevationProperty, androidDynamicElevationOffsetProperty, LengthType, PercentLengthType } from '../../styling/style-properties'; -import { Enums } from '../../enums'; +import { perspectiveProperty, visibilityProperty, opacityProperty, horizontalAlignmentProperty, verticalAlignmentProperty, minWidthProperty, minHeightProperty, widthProperty, heightProperty, marginLeftProperty, marginTopProperty, marginRightProperty, marginBottomProperty, rotateProperty, rotateXProperty, rotateYProperty, scaleXProperty, scaleYProperty, translateXProperty, translateYProperty, zIndexProperty, backgroundInternalProperty, androidElevationProperty, androidDynamicElevationOffsetProperty } from '../../styling/style-properties'; +import { CoreTypes } from '../../../core-types'; import { Background, ad as androidBackground } from '../../styling/background'; import { profile } from '../../../profiling'; @@ -730,7 +730,7 @@ export class View extends ViewCommon { this.nativeViewProtected.setFocusable(value); } - [visibilityProperty.getDefault](): Enums.VisibilityType { + [visibilityProperty.getDefault](): CoreTypes.VisibilityType { const nativeVisibility = this.nativeViewProtected.getVisibility(); switch (nativeVisibility) { case android.view.View.VISIBLE: @@ -743,7 +743,7 @@ export class View extends ViewCommon { throw new Error(`Unsupported android.view.View visibility: ${nativeVisibility}. Currently supported values are android.view.View.VISIBLE, android.view.View.INVISIBLE, android.view.View.GONE.`); } } - [visibilityProperty.setNative](value: Enums.VisibilityType) { + [visibilityProperty.setNative](value: CoreTypes.VisibilityType) { switch (value) { case 'visible': this.nativeViewProtected.setVisibility(android.view.View.VISIBLE); @@ -919,10 +919,10 @@ export class View extends ViewCommon { nativeView.setStateListAnimator(stateListAnimator); } - [horizontalAlignmentProperty.getDefault](): Enums.HorizontalAlignmentType { - return org.nativescript.widgets.ViewHelper.getHorizontalAlignment(this.nativeViewProtected); + [horizontalAlignmentProperty.getDefault](): CoreTypes.HorizontalAlignmentType { + return org.nativescript.widgets.ViewHelper.getHorizontalAlignment(this.nativeViewProtected); } - [horizontalAlignmentProperty.setNative](value: Enums.HorizontalAlignmentType) { + [horizontalAlignmentProperty.setNative](value: CoreTypes.HorizontalAlignmentType) { const nativeView = this.nativeViewProtected; const lp: any = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams(); // Set only if params gravity exists. @@ -957,10 +957,10 @@ export class View extends ViewCommon { } } - [verticalAlignmentProperty.getDefault](): Enums.VerticalAlignmentType { - return org.nativescript.widgets.ViewHelper.getVerticalAlignment(this.nativeViewProtected); + [verticalAlignmentProperty.getDefault](): CoreTypes.VerticalAlignmentType { + return org.nativescript.widgets.ViewHelper.getVerticalAlignment(this.nativeViewProtected); } - [verticalAlignmentProperty.setNative](value: Enums.VerticalAlignmentType) { + [verticalAlignmentProperty.setNative](value: CoreTypes.VerticalAlignmentType) { const nativeView = this.nativeViewProtected; const lp: any = nativeView.getLayoutParams() || new org.nativescript.widgets.CommonLayoutParams(); // Set only if params gravity exists. @@ -1019,11 +1019,11 @@ export class View extends ViewCommon { org.nativescript.widgets.ViewHelper.setScaleY(this.nativeViewProtected, float(value)); } - [translateXProperty.setNative](value: dip) { + [translateXProperty.setNative](value: CoreTypes.dip) { org.nativescript.widgets.ViewHelper.setTranslateX(this.nativeViewProtected, layout.toDevicePixels(value)); } - [translateYProperty.setNative](value: dip) { + [translateYProperty.setNative](value: CoreTypes.dip) { org.nativescript.widgets.ViewHelper.setTranslateY(this.nativeViewProtected, layout.toDevicePixels(value)); } @@ -1056,7 +1056,7 @@ export class View extends ViewCommon { this._redrawNativeBackground(value); } - [minWidthProperty.setNative](value: LengthType) { + [minWidthProperty.setNative](value: CoreTypes.LengthType) { if (this.parent instanceof CustomLayoutView && this.parent.nativeViewProtected) { this.parent._setChildMinWidthNative(this, value); } else { @@ -1064,7 +1064,7 @@ export class View extends ViewCommon { } } - [minHeightProperty.setNative](value: LengthType) { + [minHeightProperty.setNative](value: CoreTypes.LengthType) { if (this.parent instanceof CustomLayoutView && this.parent.nativeViewProtected) { this.parent._setChildMinHeightNative(this, value); } else { @@ -1095,20 +1095,17 @@ export class View extends ViewCommon { } } - public androidSendAccessibilityEvent(eventName: AndroidAccessibilityEvent, msg?: string): void { - if (!isAccessibilityServiceEnabled()) { - return; - } - - sendAccessibilityEvent(this, eventName, msg); - } - - public accessibilityAnnouncement(msg = this.accessibilityLabel): void { - this.androidSendAccessibilityEvent(AndroidAccessibilityEvent.ANNOUNCEMENT, msg); + public accessibilityAnnouncement(message = this.accessibilityLabel): void { + this.sendAccessibilityEvent({ + androidAccessibilityEvent: AndroidAccessibilityEvent.ANNOUNCEMENT, + message, + }); } public accessibilityScreenChanged(): void { - this.androidSendAccessibilityEvent(AndroidAccessibilityEvent.WINDOW_STATE_CHANGED); + this.sendAccessibilityEvent({ + androidAccessibilityEvent: AndroidAccessibilityEvent.WINDOW_STATE_CHANGED, + }); } } @@ -1145,11 +1142,11 @@ export class CustomLayoutView extends ContainerView implements CustomLayoutViewD // noop } - public _setChildMinWidthNative(child: View, value: LengthType): void { + public _setChildMinWidthNative(child: View, value: CoreTypes.LengthType): void { child._setMinWidthNative(value); } - public _setChildMinHeightNative(child: View, value: LengthType): void { + public _setChildMinHeightNative(child: View, value: CoreTypes.LengthType): void { child._setMinHeightNative(value); } @@ -1186,7 +1183,7 @@ function createNativePercentLengthProperty(options: NativePercentLengthPropertyO const { getter, setter, auto = 0 } = options; let setPixels, getPixels, setPercent; if (getter) { - View.prototype[getter] = function (this: View): PercentLengthType { + View.prototype[getter] = function (this: View): CoreTypes.PercentLengthType { if (options) { setPixels = options.setPixels; getPixels = options.getPixels; @@ -1203,7 +1200,7 @@ function createNativePercentLengthProperty(options: NativePercentLengthPropertyO }; } if (setter) { - View.prototype[setter] = function (this: View, length: PercentLengthType) { + View.prototype[setter] = function (this: View, length: CoreTypes.PercentLengthType) { if (options) { setPixels = options.setPixels; getPixels = options.getPixels; diff --git a/packages/core/ui/core/view/index.d.ts b/packages/core/ui/core/view/index.d.ts index 6650f88b4..067fa37b8 100644 --- a/packages/core/ui/core/view/index.d.ts +++ b/packages/core/ui/core/view/index.d.ts @@ -3,11 +3,10 @@ import { Property, InheritedProperty } from '../properties'; import { EventData } from '../../../data/observable'; import { Color } from '../../../color'; import { Animation, AnimationDefinition, AnimationPromise } from '../../animation'; -import { LengthType, PercentLengthType } from '../../styling/style-properties'; import { GestureTypes, GesturesObserver } from '../../gestures'; import { LinearGradient } from '../../styling/gradient'; import { AccessibilityLiveRegion, AccessibilityRole, AccessibilityState, AccessibilityTrait, AccessibilityEventOptions } from '../../../accessibility/accessibility-types'; -import { Enums } from '../../enums'; +import { CoreTypes } from '../../core-types'; import { CSSShadow } from '../../styling/css-shadow'; // helpers (these are okay re-exported here) @@ -42,24 +41,6 @@ export function CSSType(type: string): ClassDecorator; */ export function viewMatchesModuleContext(view: View, context: ModuleContext, type: ModuleType[]): boolean; -/** - * Denotes a length number that is in device independent pixel units. - */ -export type dip = number; - -/** - * Denotes a length number that is in physical device pixels. - */ -export type px = number; - -/** - * Denotes a normalized percent number. - * 0% is represented as 0 - * 50% is represented as 0.5 - * 100% is represented as 1 - */ -export type percent = number; - /** * The Point interface describes a two dimensional location. * It has two properties x and y, representing the x and y coordinate of the location. @@ -193,52 +174,52 @@ export abstract class View extends ViewBase { /** * Gets or sets the border width of the view. */ - borderWidth: string | LengthType; + borderWidth: string | CoreTypes.LengthType; /** * Gets or sets the top border width of the view. */ - borderTopWidth: LengthType; + borderTopWidth: CoreTypes.LengthType; /** * Gets or sets the right border width of the view. */ - borderRightWidth: LengthType; + borderRightWidth: CoreTypes.LengthType; /** * Gets or sets the bottom border width of the view. */ - borderBottomWidth: LengthType; + borderBottomWidth: CoreTypes.LengthType; /** * Gets or sets the left border width of the view. */ - borderLeftWidth: LengthType; + borderLeftWidth: CoreTypes.LengthType; /** * Gets or sets the border radius of the view. */ - borderRadius: string | LengthType; + borderRadius: string | CoreTypes.LengthType; /** * Gets or sets the top left border radius of the view. */ - borderTopLeftRadius: LengthType; + borderTopLeftRadius: CoreTypes.LengthType; /** * Gets or sets the top right border radius of the view. */ - borderTopRightRadius: LengthType; + borderTopRightRadius: CoreTypes.LengthType; /** * Gets or sets the bottom right border radius of the view. */ - borderBottomRightRadius: LengthType; + borderBottomRightRadius: CoreTypes.LengthType; /** * Gets or sets the bottom left border radius of the view. */ - borderBottomLeftRadius: LengthType; + borderBottomLeftRadius: CoreTypes.LengthType; /** * Gets or sets the color of the view. @@ -339,62 +320,62 @@ export abstract class View extends ViewBase { /** * Gets or sets the minimum width the view may grow to. */ - minWidth: LengthType; + minWidth: CoreTypes.LengthType; /** * Gets or sets the minimum height the view may grow to. */ - minHeight: LengthType; + minHeight: CoreTypes.LengthType; /** * Gets or sets the desired width of the view. */ - width: PercentLengthType; + width: CoreTypes.PercentLengthType; /** * Gets or sets the desired height of the view. */ - height: PercentLengthType; + height: CoreTypes.PercentLengthType; /** * Gets or sets margin style property. */ - margin: string | PercentLengthType; + margin: string | CoreTypes.PercentLengthType; /** * Specifies extra space on the left side of this view. */ - marginLeft: PercentLengthType; + marginLeft: CoreTypes.PercentLengthType; /** * Specifies extra space on the top side of this view. */ - marginTop: PercentLengthType; + marginTop: CoreTypes.PercentLengthType; /** * Specifies extra space on the right side of this view. */ - marginRight: PercentLengthType; + marginRight: CoreTypes.PercentLengthType; /** * Specifies extra space on the bottom side of this view. */ - marginBottom: PercentLengthType; + marginBottom: CoreTypes.PercentLengthType; /** * Gets or sets the alignment of this view within its parent along the Horizontal axis. */ - horizontalAlignment: Enums.HorizontalAlignmentType; + horizontalAlignment: CoreTypes.HorizontalAlignmentType; /** * Gets or sets the alignment of this view within its parent along the Vertical axis. */ - verticalAlignment: Enums.VerticalAlignmentType; + verticalAlignment: CoreTypes.VerticalAlignmentType; /** * Gets or sets the visibility of the view. */ - visibility: Enums.VisibilityType; + visibility: CoreTypes.VisibilityType; /** * Gets or sets the opacity style property. @@ -838,11 +819,11 @@ export abstract class View extends ViewBase { /** * @private */ - _setMinWidthNative(value: LengthType): void; + _setMinWidthNative(value: CoreTypes.LengthType): void; /** * @private */ - _setMinHeightNative(value: LengthType): void; + _setMinHeightNative(value: CoreTypes.LengthType): void; /** * @private */ @@ -918,11 +899,11 @@ export class CustomLayoutView extends ContainerView { /** * @private */ - _setChildMinWidthNative(child: View, value: LengthType): void; + _setChildMinWidthNative(child: View, value: CoreTypes.LengthType): void; /** * @private */ - _setChildMinHeightNative(child: View, value: LengthType): void; + _setChildMinHeightNative(child: View, value: CoreTypes.LengthType): void; //@endprivate } diff --git a/packages/core/ui/core/view/index.ios.ts b/packages/core/ui/core/view/index.ios.ts index d2e6f9a22..98dffdbc4 100644 --- a/packages/core/ui/core/view/index.ios.ts +++ b/packages/core/ui/core/view/index.ios.ts @@ -1,5 +1,5 @@ // Types. -import { Point, View as ViewDefinition, dip } from '.'; +import { Point, View as ViewDefinition } from '.'; // Requires import { ViewCommon, isEnabledProperty, originXProperty, originYProperty, isUserInteractionEnabledProperty } from './view-common'; @@ -12,7 +12,7 @@ import { perspectiveProperty, visibilityProperty, opacityProperty, rotatePropert import { profile } from '../../../profiling'; import { accessibilityEnabledProperty, accessibilityHiddenProperty, accessibilityHintProperty, accessibilityIdentifierProperty, accessibilityLabelProperty, accessibilityLanguageProperty, accessibilityLiveRegionProperty, accessibilityMediaSessionProperty, accessibilityRoleProperty, accessibilityStateProperty, accessibilityValueProperty, accessibilityIgnoresInvertColorsProperty } from '../../../accessibility/accessibility-properties'; import { setupAccessibleView, IOSPostAccessibilityNotificationType, isAccessibilityServiceEnabled, updateAccessibilityProperties, AccessibilityEventOptions, AccessibilityRole, AccessibilityState } from '../../../accessibility'; -import { Enums } from '../../enums'; +import { CoreTypes } from '../../../core-types'; export * from './view-common'; // helpers (these are okay re-exported here) @@ -643,20 +643,20 @@ export class View extends ViewCommon implements ViewDefinition { this.nativeViewProtected.userInteractionEnabled = value; } - [visibilityProperty.getDefault](): Enums.VisibilityType { - return this.nativeViewProtected.hidden ? Enums.Visibility.collapse : Enums.Visibility.visible; + [visibilityProperty.getDefault](): CoreTypes.VisibilityType { + return this.nativeViewProtected.hidden ? CoreTypes.Visibility.collapse : CoreTypes.Visibility.visible; } - [visibilityProperty.setNative](value: Enums.VisibilityType) { + [visibilityProperty.setNative](value: CoreTypes.VisibilityType) { switch (value) { - case Enums.Visibility.visible: + case CoreTypes.Visibility.visible: this.nativeViewProtected.hidden = false; break; - case Enums.Visibility.hidden: - case Enums.Visibility.collapse: + case CoreTypes.Visibility.hidden: + case CoreTypes.Visibility.collapse: this.nativeViewProtected.hidden = true; break; default: - throw new Error(`Invalid visibility value: ${value}. Valid values are: "${Enums.Visibility.visible}", "${Enums.Visibility.hidden}", "${Enums.Visibility.collapse}".`); + throw new Error(`Invalid visibility value: ${value}. Valid values are: "${CoreTypes.Visibility.visible}", "${CoreTypes.Visibility.hidden}", "${CoreTypes.Visibility.collapse}".`); } } @@ -717,17 +717,17 @@ export class View extends ViewCommon implements ViewDefinition { this.updateNativeTransform(); } - [translateXProperty.getDefault](): dip { + [translateXProperty.getDefault](): CoreTypes.dip { return 0; } - [translateXProperty.setNative](value: dip) { + [translateXProperty.setNative](value: CoreTypes.dip) { this.updateNativeTransform(); } - [translateYProperty.getDefault](): dip { + [translateYProperty.getDefault](): CoreTypes.dip { return 0; } - [translateYProperty.setNative](value: dip) { + [translateYProperty.setNative](value: CoreTypes.dip) { this.updateNativeTransform(); } diff --git a/packages/core/ui/core/view/view-common.ts b/packages/core/ui/core/view/view-common.ts index 5c4385213..2b2ff610d 100644 --- a/packages/core/ui/core/view/view-common.ts +++ b/packages/core/ui/core/view/view-common.ts @@ -1,5 +1,5 @@ // Definitions. -import { View as ViewDefinition, Point, Size, dip, ShownModallyData } from '.'; +import { View as ViewDefinition, Point, Size, ShownModallyData } from '.'; import { booleanConverter, ShowModalOptions, ViewBase } from '../view-base'; import { getEventOrGestureName } from '../bindable'; @@ -8,10 +8,10 @@ import { Color } from '../../../color'; import { Property, InheritedProperty } from '../properties'; import { EventData } from '../../../data/observable'; import { Trace } from '../../../trace'; -import { Enums } from '../../enums'; +import { CoreTypes } from '../../../core-types'; import { ViewHelper } from './view-helper'; -import { PercentLength, LengthType, PercentLengthType } from '../../styling/style-properties'; +import { PercentLength } from '../../styling/style-properties'; import { observe as gestureObserve, GesturesObserver, GestureTypes, GestureEventData, fromString as gestureFromString } from '../../gestures'; @@ -98,8 +98,8 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { _currentWidthMeasureSpec: number; _currentHeightMeasureSpec: number; - _setMinWidthNative: (value: LengthType) => void; - _setMinHeightNative: (value: LengthType) => void; + _setMinWidthNative: (value: CoreTypes.LengthType) => void; + _setMinHeightNative: (value: CoreTypes.LengthType) => void; public _gestureObservers = {}; @@ -478,73 +478,73 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { this.style.borderLeftColor = value; } - get borderWidth(): string | LengthType { + get borderWidth(): string | CoreTypes.LengthType { return this.style.borderWidth; } - set borderWidth(value: string | LengthType) { + set borderWidth(value: string | CoreTypes.LengthType) { this.style.borderWidth = value; } - get borderTopWidth(): LengthType { + get borderTopWidth(): CoreTypes.LengthType { return this.style.borderTopWidth; } - set borderTopWidth(value: LengthType) { + set borderTopWidth(value: CoreTypes.LengthType) { this.style.borderTopWidth = value; } - get borderRightWidth(): LengthType { + get borderRightWidth(): CoreTypes.LengthType { return this.style.borderRightWidth; } - set borderRightWidth(value: LengthType) { + set borderRightWidth(value: CoreTypes.LengthType) { this.style.borderRightWidth = value; } - get borderBottomWidth(): LengthType { + get borderBottomWidth(): CoreTypes.LengthType { return this.style.borderBottomWidth; } - set borderBottomWidth(value: LengthType) { + set borderBottomWidth(value: CoreTypes.LengthType) { this.style.borderBottomWidth = value; } - get borderLeftWidth(): LengthType { + get borderLeftWidth(): CoreTypes.LengthType { return this.style.borderLeftWidth; } - set borderLeftWidth(value: LengthType) { + set borderLeftWidth(value: CoreTypes.LengthType) { this.style.borderLeftWidth = value; } - get borderRadius(): string | LengthType { + get borderRadius(): string | CoreTypes.LengthType { return this.style.borderRadius; } - set borderRadius(value: string | LengthType) { + set borderRadius(value: string | CoreTypes.LengthType) { this.style.borderRadius = value; } - get borderTopLeftRadius(): LengthType { + get borderTopLeftRadius(): CoreTypes.LengthType { return this.style.borderTopLeftRadius; } - set borderTopLeftRadius(value: LengthType) { + set borderTopLeftRadius(value: CoreTypes.LengthType) { this.style.borderTopLeftRadius = value; } - get borderTopRightRadius(): LengthType { + get borderTopRightRadius(): CoreTypes.LengthType { return this.style.borderTopRightRadius; } - set borderTopRightRadius(value: LengthType) { + set borderTopRightRadius(value: CoreTypes.LengthType) { this.style.borderTopRightRadius = value; } - get borderBottomRightRadius(): LengthType { + get borderBottomRightRadius(): CoreTypes.LengthType { return this.style.borderBottomRightRadius; } - set borderBottomRightRadius(value: LengthType) { + set borderBottomRightRadius(value: CoreTypes.LengthType) { this.style.borderBottomRightRadius = value; } - get borderBottomLeftRadius(): LengthType { + get borderBottomLeftRadius(): CoreTypes.LengthType { return this.style.borderBottomLeftRadius; } - set borderBottomLeftRadius(value: LengthType) { + set borderBottomLeftRadius(value: CoreTypes.LengthType) { this.style.borderBottomLeftRadius = value; } @@ -590,10 +590,10 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { this.style.backgroundPosition = value; } - get backgroundRepeat(): Enums.BackgroundRepeatType { + get backgroundRepeat(): CoreTypes.BackgroundRepeatType { return this.style.backgroundRepeat; } - set backgroundRepeat(value: Enums.BackgroundRepeatType) { + set backgroundRepeat(value: CoreTypes.BackgroundRepeatType) { this.style.backgroundRepeat = value; } @@ -604,88 +604,88 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { this.style.boxShadow = value; } - get minWidth(): LengthType { + get minWidth(): CoreTypes.LengthType { return this.style.minWidth; } - set minWidth(value: LengthType) { + set minWidth(value: CoreTypes.LengthType) { this.style.minWidth = value; } - get minHeight(): LengthType { + get minHeight(): CoreTypes.LengthType { return this.style.minHeight; } - set minHeight(value: LengthType) { + set minHeight(value: CoreTypes.LengthType) { this.style.minHeight = value; } - get width(): PercentLengthType { + get width(): CoreTypes.PercentLengthType { return this.style.width; } - set width(value: PercentLengthType) { + set width(value: CoreTypes.PercentLengthType) { this.style.width = value; } - get height(): PercentLengthType { + get height(): CoreTypes.PercentLengthType { return this.style.height; } - set height(value: PercentLengthType) { + set height(value: CoreTypes.PercentLengthType) { this.style.height = value; } - get margin(): string | PercentLengthType { + get margin(): string | CoreTypes.PercentLengthType { return this.style.margin; } - set margin(value: string | PercentLengthType) { + set margin(value: string | CoreTypes.PercentLengthType) { this.style.margin = value; } - get marginLeft(): PercentLengthType { + get marginLeft(): CoreTypes.PercentLengthType { return this.style.marginLeft; } - set marginLeft(value: PercentLengthType) { + set marginLeft(value: CoreTypes.PercentLengthType) { this.style.marginLeft = value; } - get marginTop(): PercentLengthType { + get marginTop(): CoreTypes.PercentLengthType { return this.style.marginTop; } - set marginTop(value: PercentLengthType) { + set marginTop(value: CoreTypes.PercentLengthType) { this.style.marginTop = value; } - get marginRight(): PercentLengthType { + get marginRight(): CoreTypes.PercentLengthType { return this.style.marginRight; } - set marginRight(value: PercentLengthType) { + set marginRight(value: CoreTypes.PercentLengthType) { this.style.marginRight = value; } - get marginBottom(): PercentLengthType { + get marginBottom(): CoreTypes.PercentLengthType { return this.style.marginBottom; } - set marginBottom(value: PercentLengthType) { + set marginBottom(value: CoreTypes.PercentLengthType) { this.style.marginBottom = value; } - get horizontalAlignment(): Enums.HorizontalAlignmentType { + get horizontalAlignment(): CoreTypes.HorizontalAlignmentType { return this.style.horizontalAlignment; } - set horizontalAlignment(value: Enums.HorizontalAlignmentType) { + set horizontalAlignment(value: CoreTypes.HorizontalAlignmentType) { this.style.horizontalAlignment = value; } - get verticalAlignment(): Enums.VerticalAlignmentType { + get verticalAlignment(): CoreTypes.VerticalAlignmentType { return this.style.verticalAlignment; } - set verticalAlignment(value: Enums.VerticalAlignmentType) { + set verticalAlignment(value: CoreTypes.VerticalAlignmentType) { this.style.verticalAlignment = value; } - get visibility(): Enums.VisibilityType { + get visibility(): CoreTypes.VisibilityType { return this.style.visibility; } - set visibility(value: Enums.VisibilityType) { + set visibility(value: CoreTypes.VisibilityType) { this.style.visibility = value; } @@ -724,24 +724,24 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { this.style.perspective = value; } - get textTransform(): Enums.TextTransformType { + get textTransform(): CoreTypes.TextTransformType { return this.style.textTransform; } - set textTransform(value: Enums.TextTransformType) { + set textTransform(value: CoreTypes.TextTransformType) { this.style.textTransform = value; } - get translateX(): dip { + get translateX(): CoreTypes.dip { return this.style.translateX; } - set translateX(value: dip) { + set translateX(value: CoreTypes.dip) { this.style.translateX = value; } - get translateY(): dip { + get translateY(): CoreTypes.dip { return this.style.translateY; } - set translateY(value: dip) { + set translateY(value: CoreTypes.dip) { this.style.translateY = value; } diff --git a/packages/core/ui/core/view/view-helper/view-helper-common.ts b/packages/core/ui/core/view/view-helper/view-helper-common.ts index 7fa219398..ae3ad9679 100644 --- a/packages/core/ui/core/view/view-helper/view-helper-common.ts +++ b/packages/core/ui/core/view/view-helper/view-helper-common.ts @@ -1,6 +1,6 @@ // Types import { View as ViewDefinition } from '..'; -import { Enums } from '../../../enums'; +import { CoreTypes } from '../../../../core-types'; // Requires import { layout } from '../../../../utils'; @@ -58,7 +58,7 @@ export class ViewHelper { const effectiveMarginTop = child.effectiveMarginTop; const effectiveMarginBottom = child.effectiveMarginBottom; - let vAlignment: Enums.VerticalAlignmentType; + let vAlignment: CoreTypes.VerticalAlignmentType; if (child.effectiveHeight >= 0 && childStyle.verticalAlignment === 'stretch') { vAlignment = 'middle'; } else { @@ -88,7 +88,7 @@ export class ViewHelper { const effectiveMarginLeft = child.effectiveMarginLeft; const effectiveMarginRight = child.effectiveMarginRight; - let hAlignment: Enums.HorizontalAlignmentType; + let hAlignment: CoreTypes.HorizontalAlignmentType; if (child.effectiveWidth >= 0 && childStyle.horizontalAlignment === 'stretch') { hAlignment = 'center'; } else { diff --git a/packages/core/ui/editable-text-base/editable-text-base-common.ts b/packages/core/ui/editable-text-base/editable-text-base-common.ts index 2e73a3489..1f4003d42 100644 --- a/packages/core/ui/editable-text-base/editable-text-base-common.ts +++ b/packages/core/ui/editable-text-base/editable-text-base-common.ts @@ -5,17 +5,17 @@ import { PseudoClassHandler } from '../core/view'; import { booleanConverter } from '../core/view-base'; import { Style } from '../styling/style'; import { Color } from '../../color'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; export abstract class EditableTextBase extends TextBase implements EditableTextBaseDefinition { public static blurEvent = 'blur'; public static focusEvent = 'focus'; public static textChangeEvent = 'textChange'; - public keyboardType: Enums.KeyboardInputType; - public returnKeyType: Enums.ReturnKeyButtonType; - public updateTextTrigger: Enums.UpdateTextTriggerType; - public autocapitalizationType: Enums.AutocapitalizationInputType; + public keyboardType: CoreTypes.KeyboardInputType; + public returnKeyType: CoreTypes.ReturnKeyButtonType; + public updateTextTrigger: CoreTypes.UpdateTextTriggerType; + public autocapitalizationType: CoreTypes.AutocapitalizationInputType; public editable: boolean; public autocorrect: boolean; public hint: string; @@ -48,14 +48,14 @@ export const placeholderColorProperty = new CssProperty({ }); placeholderColorProperty.register(Style); -const keyboardTypeConverter = makeParser(makeValidator(Enums.KeyboardType.datetime, Enums.KeyboardType.phone, Enums.KeyboardType.number, Enums.KeyboardType.url, Enums.KeyboardType.email, Enums.KeyboardType.integer), true); +const keyboardTypeConverter = makeParser(makeValidator(CoreTypes.KeyboardType.datetime, CoreTypes.KeyboardType.phone, CoreTypes.KeyboardType.number, CoreTypes.KeyboardType.url, CoreTypes.KeyboardType.email, CoreTypes.KeyboardType.integer), true); -export const keyboardTypeProperty = new Property({ name: 'keyboardType', valueConverter: keyboardTypeConverter }); +export const keyboardTypeProperty = new Property({ name: 'keyboardType', valueConverter: keyboardTypeConverter }); keyboardTypeProperty.register(EditableTextBase); -const returnKeyTypeConverter = makeParser(makeValidator(Enums.ReturnKeyType.done, Enums.ReturnKeyType.next, Enums.ReturnKeyType.go, Enums.ReturnKeyType.search, Enums.ReturnKeyType.send), true); +const returnKeyTypeConverter = makeParser(makeValidator(CoreTypes.ReturnKeyType.done, CoreTypes.ReturnKeyType.next, CoreTypes.ReturnKeyType.go, CoreTypes.ReturnKeyType.search, CoreTypes.ReturnKeyType.send), true); -export const returnKeyTypeProperty = new Property({ name: 'returnKeyType', valueConverter: returnKeyTypeConverter }); +export const returnKeyTypeProperty = new Property({ name: 'returnKeyType', valueConverter: returnKeyTypeConverter }); returnKeyTypeProperty.register(EditableTextBase); export const editableProperty = new Property({ @@ -65,14 +65,14 @@ export const editableProperty = new Property({ }); editableProperty.register(EditableTextBase); -export const updateTextTriggerProperty = new Property({ name: 'updateTextTrigger', defaultValue: Enums.UpdateTextTrigger.textChanged }); +export const updateTextTriggerProperty = new Property({ name: 'updateTextTrigger', defaultValue: CoreTypes.UpdateTextTrigger.textChanged }); updateTextTriggerProperty.register(EditableTextBase); -const autocapitalizationTypeConverter = makeParser(makeValidator(Enums.AutocapitalizationType.none, Enums.AutocapitalizationType.words, Enums.AutocapitalizationType.sentences, Enums.AutocapitalizationType.allCharacters), true); +const autocapitalizationTypeConverter = makeParser(makeValidator(CoreTypes.AutocapitalizationType.none, CoreTypes.AutocapitalizationType.words, CoreTypes.AutocapitalizationType.sentences, CoreTypes.AutocapitalizationType.allCharacters), true); -export const autocapitalizationTypeProperty = new Property({ +export const autocapitalizationTypeProperty = new Property({ name: 'autocapitalizationType', - defaultValue: Enums.AutocapitalizationType.sentences, + defaultValue: CoreTypes.AutocapitalizationType.sentences, valueConverter: autocapitalizationTypeConverter, }); autocapitalizationTypeProperty.register(EditableTextBase); diff --git a/packages/core/ui/editable-text-base/index.d.ts b/packages/core/ui/editable-text-base/index.d.ts index c8d6b1069..3821fb383 100644 --- a/packages/core/ui/editable-text-base/index.d.ts +++ b/packages/core/ui/editable-text-base/index.d.ts @@ -3,7 +3,7 @@ import { Color } from '../../color'; import { FormattedString } from '../text-base/formatted-string'; import { Style } from '../styling/style'; import { Property, CssProperty } from '../core/properties'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; /** * Represents the base class for all editable text views. @@ -16,22 +16,22 @@ export class EditableTextBase extends TextBase { /** * Gets or sets the soft keyboard type. */ - keyboardType: Enums.KeyboardInputType; + keyboardType: CoreTypes.KeyboardInputType; /** * Gets or sets the soft keyboard return key flavor. */ - returnKeyType: Enums.ReturnKeyButtonType; + returnKeyType: CoreTypes.ReturnKeyButtonType; /** * Gets or sets a value indicating when the text property will be updated. */ - updateTextTrigger: Enums.UpdateTextTriggerType; + updateTextTrigger: CoreTypes.UpdateTextTriggerType; /** * Gets or sets the autocapitalization type. */ - autocapitalizationType: Enums.AutocapitalizationType; + autocapitalizationType: CoreTypes.AutocapitalizationType; /** * Gets or sets whether the instance is editable. @@ -71,11 +71,11 @@ export class EditableTextBase extends TextBase { public setSelection(start: number, stop?: number); } -export const keyboardTypeProperty: Property; -export const returnKeyTypeProperty: Property; +export const keyboardTypeProperty: Property; +export const returnKeyTypeProperty: Property; export const editableProperty: Property; -export const updateTextTriggerProperty: Property; -export const autocapitalizationTypeProperty: Property; +export const updateTextTriggerProperty: Property; +export const autocapitalizationTypeProperty: Property; export const autocorrectProperty: Property; export const hintProperty: Property; export const placeholderColorProperty: CssProperty; diff --git a/packages/core/ui/enums/enums.d.ts b/packages/core/ui/enums/enums.d.ts deleted file mode 100644 index 8621a6c38..000000000 --- a/packages/core/ui/enums/enums.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * A lot of plugins still used enums/enums - * Left here for convenience (over time can eventually remove these) - */ -export * from './index'; diff --git a/packages/core/ui/enums/enums.ts b/packages/core/ui/enums/enums.ts deleted file mode 100644 index 8621a6c38..000000000 --- a/packages/core/ui/enums/enums.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * A lot of plugins still used enums/enums - * Left here for convenience (over time can eventually remove these) - */ -export * from './index'; diff --git a/packages/core/ui/enums/index.ts b/packages/core/ui/enums/index.ts deleted file mode 100644 index 682eb0731..000000000 --- a/packages/core/ui/enums/index.ts +++ /dev/null @@ -1,283 +0,0 @@ -// imported for definition purposes only -import * as animationModule from '../../ui/animation'; -import { makeValidator, makeParser } from '../core/properties'; - -export namespace Enums { - - export type KeyboardInputType = 'datetime' | 'phone' | 'number' | 'url' | 'email' | 'integer'; - export module KeyboardType { - export const datetime = 'datetime'; - export const phone = 'phone'; - export const number = 'number'; - export const url = 'url'; - export const email = 'email'; - export const integer = 'integer'; - } - - export type ReturnKeyButtonType = 'done' | 'next' | 'go' | 'search' | 'send'; - export module ReturnKeyType { - export const done = 'done'; - export const next = 'next'; - export const go = 'go'; - export const search = 'search'; - export const send = 'send'; - } - - export type TextAlignmentType = 'initial' | 'left' | 'center' | 'right'; - export module TextAlignment { - export const left = 'left'; - export const center = 'center'; - export const right = 'right'; - } - - export type TextDecorationType = 'none' | 'underline' | 'line-through' | 'underline line-through'; - export module TextDecoration { - export const none = 'none'; - export const underline = 'underline'; - export const lineThrough = 'line-through'; - } - - export type TextTransformType = 'initial' | 'none' | 'capitalize' | 'uppercase' | 'lowercase'; - export module TextTransform { - export const none = 'none'; - export const capitalize = 'capitalize'; - export const uppercase = 'uppercase'; - export const lowercase = 'lowercase'; - } - - export type WhiteSpaceType = 'initial' | 'normal' | 'nowrap'; - export module WhiteSpace { - export const normal = 'normal'; - export const nowrap = 'nowrap'; - } - - export type OrientationType = 'horizontal' | 'vertical'; - export module Orientation { - export const horizontal = 'horizontal'; - export const vertical = 'vertical'; - } - - export type DeviceOrientationType = 'portrait' | 'landscape' | 'unknown'; - export module DeviceOrientation { - export const portrait = 'portrait'; - export const landscape = 'landscape'; - export const unknown = 'unknown'; - } - - export type HorizontalAlignmentType = 'left' | 'center' | 'right' | 'stretch'; - export module HorizontalAlignment { - export const left = 'left'; - export const center = 'center'; - export const right = 'right'; - export const stretch = 'stretch'; - export const isValid = makeValidator(left, center, right, stretch); - export const parse = makeParser(isValid); - } - - - export type VerticalAlignmentType = 'top' | 'middle' | 'bottom' | 'stretch'; - export module VerticalAlignment { - export const top = 'top'; - export const middle = 'middle'; - export const bottom = 'bottom'; - export const stretch = 'stretch'; - } - export type VerticalAlignmentTextType = VerticalAlignmentType | 'text-top' | 'text-bottom' | 'sup' | 'sub' | 'baseline'; - export namespace VerticalAlignmentText { - export const top = 'top'; - export const middle = 'middle'; - export const bottom = 'bottom'; - export const stretch = 'stretch'; - export const texttop = 'text-top'; - export const textbottom = 'text-bottom'; - export const sup = 'sup'; - export const sub = 'sub'; - export const baseline = 'baseline'; - export const isValid = makeValidator(top, middle, bottom, stretch, texttop, textbottom, sup, sub, baseline); - export const parse = (value: string) => (value.toLowerCase() === 'center' ? middle : parseStrict(value)); - const parseStrict = makeParser(isValid); - } - - export type ImageStretchType = 'none' | 'aspectFill' | 'aspectFit' | 'fill'; - export module ImageStretch { - export const none: ImageStretchType = 'none'; - export const aspectFill: ImageStretchType = 'aspectFill'; - export const aspectFit: ImageStretchType = 'aspectFit'; - export const fill: ImageStretchType = 'fill'; - } - - export type VisibilityType = 'visible' | 'hidden' | 'collapse' | 'collapsed'; - export module Visibility { - export const visible: VisibilityType = 'visible'; - export const collapse: VisibilityType = 'collapse'; - export const collapsed: VisibilityType = 'collapsed'; - export const hidden: VisibilityType = 'hidden'; - export const isValid = makeValidator(visible, hidden, collapse); - export const parse = (value: string) => (value.toLowerCase() === 'collapsed' ? collapse : parseStrict(value)); - const parseStrict = makeParser(isValid); - } - - export module FontAttributes { - export const Normal = 0; - export const Bold = 1; - export const Italic = 1 << 1; - } - - export module DeviceType { - export const Phone: string = 'Phone'; - export const Tablet: string = 'Tablet'; - } - - export type UpdateTextTriggerType = 'focusLost' | 'textChanged'; - export module UpdateTextTrigger { - export const focusLost: UpdateTextTriggerType = 'focusLost'; - export const textChanged: UpdateTextTriggerType = 'textChanged'; - } - - export module Accuracy { - export const any: number = 300; - export const high: number = 3; - } - - export type DockType = 'left' | 'top' | 'right' | 'bottom'; - export module Dock { - export const left: DockType = 'left'; - export const top: DockType = 'top'; - export const right: DockType = 'right'; - export const bottom: DockType = 'bottom'; - } - - export type AutocapitalizationInputType = 'none' | 'words' | 'sentences' | 'allcharacters'; - export module AutocapitalizationType { - export const none: AutocapitalizationInputType = 'none'; - export const words: AutocapitalizationInputType = 'words'; - export const sentences: AutocapitalizationInputType = 'sentences'; - export const allCharacters: AutocapitalizationInputType = 'allcharacters'; - } - - export module NavigationBarVisibility { - export const auto: string = 'auto'; - export const never: string = 'never'; - export const always: string = 'always'; - } - - export module AndroidActionBarIconVisibility { - export const auto: string = 'auto'; - export const never: string = 'never'; - export const always: string = 'always'; - } - - export module AndroidActionItemPosition { - export const actionBar: string = 'actionBar'; - export const actionBarIfRoom: string = 'actionBarIfRoom'; - export const popup: string = 'popup'; - } - - export module IOSActionItemPosition { - export const left: string = 'left'; - export const right: string = 'right'; - } - - export module ImageFormat { - export const png: string = 'png'; - export const jpeg: string = 'jpeg'; - export const jpg: string = 'jpg'; - } - - export module FontStyle { - export const normal: string = 'normal'; - export const italic: string = 'italic'; - } - - export module FontWeight { - export const thin: string = '100'; - export const extraLight: string = '200'; - export const light: string = '300'; - export const normal: string = 'normal'; // 400 - export const medium: string = '500'; - export const semiBold: string = '600'; - export const bold: string = 'bold'; // 700 - export const extraBold: string = '800'; - export const black: string = '900'; - } - - export type BackgroundRepeatType = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; - export module BackgroundRepeat { - export const repeat: BackgroundRepeatType = 'repeat'; - export const repeatX: BackgroundRepeatType = 'repeat-x'; - export const repeatY: BackgroundRepeatType = 'repeat-y'; - export const noRepeat: BackgroundRepeatType = 'no-repeat'; - export const isValid = makeValidator(repeat, repeatX, repeatY, noRepeat); - export const parse = makeParser(isValid); - } - - let animation: typeof animationModule; - - export module AnimationCurve { - export const ease = 'ease'; - export const easeIn = 'easeIn'; - export const easeOut = 'easeOut'; - export const easeInOut = 'easeInOut'; - export const linear = 'linear'; - export const spring = 'spring'; - export function cubicBezier(x1: number, y1: number, x2: number, y2: number): Object { - animation = animation || require('../animation'); - - return new animation.CubicBezierAnimationCurve(x1, y1, x2, y2); - } - } - - export module StatusBarStyle { - export const light = 'light'; - export const dark = 'dark'; - } - - export module SystemAppearance { - export const light = 'light'; - export const dark = 'dark'; - } - - // Accuracy, - // AndroidActionBarIconVisibility, - // AndroidActionItemPosition, - // AnimationCurve, - // AutocapitalizationType, - // AutocapitalizationInputType: typeof AutocapitalizationType, - // BackgroundRepeat, - // BackgroundRepeatType: typeof BackgroundRepeat, - // DeviceOrientation, - // DeviceType, - // Dock, - // FontAttributes, - // FontStyle, - // FontStyleType: typeof FontStyle, - // FontWeight, - // FontWeightType: typeof FontWeight, - // HorizontalAlignment, - // HorizontalAlignmentType: typeof HorizontalAlignment, - // IOSActionItemPosition, - // ImageFormat, - // KeyboardType, - // KeyboardInputType: typeof KeyboardType, - // NavigationBarVisibility, - // Orientation, - // OrientationType: typeof Orientation, - // ReturnKeyType, - // StatusBarStyle, - // Stretch, - // SystemAppearance, - // TextAlignment, - // TextAlignmentType: typeof TextAlignment, - // TextDecoration, - // TextDecorationType: typeof TextDecoration, - // TextTransform, - // TextTransformType: typeof TextTransform, - // UpdateTextTrigger, - // UpdateTextTriggerType: typeof UpdateTextTrigger, - // VerticalAlignment, - // VerticalAlignmentType: typeof VerticalAlignment, - // Visibility, - // VisibilityType: typeof Visibility, - // WhiteSpace, - // WhiteSpaceType: typeof WhiteSpace -}; \ No newline at end of file diff --git a/packages/core/ui/image/image-common.ts b/packages/core/ui/image/image-common.ts index f7de59edc..efce0148f 100644 --- a/packages/core/ui/image/image-common.ts +++ b/packages/core/ui/image/image-common.ts @@ -1,13 +1,13 @@ import { Image as ImageDefinition } from '.'; import { View, CSSType } from '../core/view'; import { booleanConverter } from '../core/view-base'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { ImageAsset } from '../../image-asset'; import { ImageSource } from '../../image-source'; import { isDataURI, isFontIconURI, isFileOrResourcePath, RESOURCE_PREFIX } from '../../utils'; import { Color } from '../../color'; import { Style } from '../styling/style'; -import { Length, LengthType } from '../styling/style-properties'; +import { Length } from '../styling/style-properties'; import { Property, InheritedCssProperty } from '../core/properties'; import { Trace } from '../../trace'; @@ -16,10 +16,10 @@ export abstract class ImageBase extends View implements ImageDefinition { public imageSource: ImageSource; public src: string | ImageSource; public isLoading: boolean; - public stretch: Enums.ImageStretchType; + public stretch: CoreTypes.ImageStretchType; public loadMode: 'sync' | 'async'; - public decodeWidth: LengthType; - public decodeHeight: LengthType; + public decodeWidth: CoreTypes.LengthType; + public decodeHeight: CoreTypes.LengthType; get tintColor(): Color { return this.style.tintColor; @@ -144,7 +144,7 @@ export const isLoadingProperty = new Property({ }); isLoadingProperty.register(ImageBase); -export const stretchProperty = new Property({ +export const stretchProperty = new Property({ name: 'stretch', defaultValue: 'aspectFit', affectsLayout: global.isIOS, @@ -159,14 +159,14 @@ export const tintColorProperty = new InheritedCssProperty({ }); tintColorProperty.register(Style); -export const decodeHeightProperty = new Property({ +export const decodeHeightProperty = new Property({ name: 'decodeHeight', defaultValue: { value: 0, unit: 'dip' }, valueConverter: Length.parse, }); decodeHeightProperty.register(ImageBase); -export const decodeWidthProperty = new Property({ +export const decodeWidthProperty = new Property({ name: 'decodeWidth', defaultValue: { value: 0, unit: 'dip' }, valueConverter: Length.parse, diff --git a/packages/core/ui/image/index.d.ts b/packages/core/ui/image/index.d.ts index db5d9caaf..ffc04302d 100644 --- a/packages/core/ui/image/index.d.ts +++ b/packages/core/ui/image/index.d.ts @@ -3,8 +3,7 @@ import { Style } from '../styling/style'; import { ImageSource } from '../../image-source'; import { Color } from '../../color'; import { Property, InheritedCssProperty } from '../core/properties'; -import { Length } from '../styling/style-properties'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; /** * Represents a class that provides functionality for loading and streching image(s). @@ -70,7 +69,7 @@ export const imageSourceProperty: Property; export const srcProperty: Property; export const isLoadingProperty: Property; export const loadMode: Property; -export const stretchProperty: Property; +export const stretchProperty: Property; export const tintColorProperty: InheritedCssProperty; export const decodeHeightProperty: Property; export const decodeWidthProperty: Property; diff --git a/packages/core/ui/index.ts b/packages/core/ui/index.ts index ad6c77955..bb8e3d1ca 100644 --- a/packages/core/ui/index.ts +++ b/packages/core/ui/index.ts @@ -2,8 +2,6 @@ export { ActionBar, ActionItem, ActionItems, NavigationButton } from './action-b export { ActivityIndicator } from './activity-indicator'; export { Animation, KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './animation'; export type { AnimationDefinition } from './animation'; -export { BottomNavigation } from './bottom-navigation'; -export type { SelectedIndexChangedEventData } from './bottom-navigation'; export { Builder } from './builder'; export type { LoadOptions } from './builder'; export type { ComponentModule } from './builder/component-builder'; @@ -26,7 +24,6 @@ export { DialogStrings, action, alert, confirm, login, prompt, getCurrentPage, D export type { DialogOptions, CancelableOptions, AlertOptions, PromptResult, PromptOptions, ActionOptions, ConfirmOptions, LoginResult, LoginOptions } from './dialogs'; export * from './editable-text-base'; -export { Enums } from './enums'; export { Frame, setActivityCallbacks } from './frame'; export type { NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry, AndroidActivityCallbacks } from './frame'; @@ -70,13 +67,7 @@ export { CssAnimationParser, parseKeyframeDeclarations } from './styling/css-ani export { CSSHelper } from './styling/css-selector'; export { Switch } from './switch'; -export { TabContentItem } from './tab-navigation-base/tab-content-item'; -export { TabNavigationBase, getIconSpecSize, tabStripProperty } from './tab-navigation-base/tab-navigation-base'; -export { TabStrip } from './tab-navigation-base/tab-strip'; -export type { TabStripItemEventData } from './tab-navigation-base/tab-strip'; -export { TabStripItem } from './tab-navigation-base/tab-strip-item'; export { TabView, TabViewItem } from './tab-view'; -export { Tabs } from './tabs'; export { TextBase, getTransformedText, letterSpacingProperty, textAlignmentProperty, textDecorationProperty, textTransformProperty, textShadowProperty, whiteSpaceProperty, lineHeightProperty } from './text-base'; export { FormattedString } from './text-base/formatted-string'; export { Span } from './text-base/span'; diff --git a/packages/core/ui/label/index.android.ts b/packages/core/ui/label/index.android.ts index 2d741bb35..12cbb3f9c 100644 --- a/packages/core/ui/label/index.android.ts +++ b/packages/core/ui/label/index.android.ts @@ -3,7 +3,7 @@ import { TextBase, whiteSpaceProperty } from '../text-base'; import { profile } from '../../profiling'; import { CSSType } from '../core/view'; import { booleanConverter } from '../core/view-base'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; export * from '../text-base'; @@ -41,7 +41,7 @@ export class Label extends TextBase implements LabelDefinition { textView.setEllipsize(android.text.TextUtils.TruncateAt.END); } - [whiteSpaceProperty.setNative](value: Enums.WhiteSpaceType) { + [whiteSpaceProperty.setNative](value: CoreTypes.WhiteSpaceType) { // Label initial value is no-wrap. set in initNativeView const newValue = value === 'initial' ? 'nowrap' : value; super[whiteSpaceProperty.setNative](newValue); diff --git a/packages/core/ui/label/index.ios.ts b/packages/core/ui/label/index.ios.ts index 63c49ff7c..fb6426b3c 100644 --- a/packages/core/ui/label/index.ios.ts +++ b/packages/core/ui/label/index.ios.ts @@ -1,9 +1,9 @@ import { Label as LabelDefinition } from '.'; import { Background } from '../styling/background'; -import { Length, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, LengthType } from '../styling/style-properties'; +import { Length, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty } from '../styling/style-properties'; import { booleanConverter } from '../core/view-base'; import { View, CSSType } from '../core/view'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { TextBase, whiteSpaceProperty } from '../text-base'; import { layout } from '../../utils'; @@ -112,7 +112,7 @@ export class Label extends TextBase implements LabelDefinition { return nativeSize; } - [whiteSpaceProperty.setNative](value: Enums.WhiteSpaceType) { + [whiteSpaceProperty.setNative](value: CoreTypes.WhiteSpaceType) { const nativeView = this.nativeTextViewProtected; switch (value) { case 'normal': @@ -142,7 +142,7 @@ export class Label extends TextBase implements LabelDefinition { this._setNativeClipToBounds(); } - [borderTopWidthProperty.setNative](value: LengthType) { + [borderTopWidthProperty.setNative](value: CoreTypes.LengthType) { const nativeView = this.nativeTextViewProtected; const border = nativeView.borderThickness; nativeView.borderThickness = { @@ -153,7 +153,7 @@ export class Label extends TextBase implements LabelDefinition { }; } - [borderRightWidthProperty.setNative](value: LengthType) { + [borderRightWidthProperty.setNative](value: CoreTypes.LengthType) { const nativeView = this.nativeTextViewProtected; const border = nativeView.borderThickness; nativeView.borderThickness = { @@ -164,7 +164,7 @@ export class Label extends TextBase implements LabelDefinition { }; } - [borderBottomWidthProperty.setNative](value: LengthType) { + [borderBottomWidthProperty.setNative](value: CoreTypes.LengthType) { const nativeView = this.nativeTextViewProtected; const border = nativeView.borderThickness; nativeView.borderThickness = { @@ -175,7 +175,7 @@ export class Label extends TextBase implements LabelDefinition { }; } - [borderLeftWidthProperty.setNative](value: LengthType) { + [borderLeftWidthProperty.setNative](value: CoreTypes.LengthType) { const nativeView = this.nativeTextViewProtected; const border = nativeView.borderThickness; nativeView.borderThickness = { @@ -186,7 +186,7 @@ export class Label extends TextBase implements LabelDefinition { }; } - [paddingTopProperty.setNative](value: LengthType) { + [paddingTopProperty.setNative](value: CoreTypes.LengthType) { const nativeView = this.nativeTextViewProtected; const padding = nativeView.padding; nativeView.padding = { @@ -197,7 +197,7 @@ export class Label extends TextBase implements LabelDefinition { }; } - [paddingRightProperty.setNative](value: LengthType) { + [paddingRightProperty.setNative](value: CoreTypes.LengthType) { const nativeView = this.nativeTextViewProtected; const padding = nativeView.padding; nativeView.padding = { @@ -208,7 +208,7 @@ export class Label extends TextBase implements LabelDefinition { }; } - [paddingBottomProperty.setNative](value: LengthType) { + [paddingBottomProperty.setNative](value: CoreTypes.LengthType) { const nativeView = this.nativeTextViewProtected; const padding = nativeView.padding; nativeView.padding = { @@ -219,7 +219,7 @@ export class Label extends TextBase implements LabelDefinition { }; } - [paddingLeftProperty.setNative](value: LengthType) { + [paddingLeftProperty.setNative](value: CoreTypes.LengthType) { const nativeView = this.nativeTextViewProtected; const padding = nativeView.padding; nativeView.padding = { diff --git a/packages/core/ui/layouts/absolute-layout/absolute-layout-common.ts b/packages/core/ui/layouts/absolute-layout/absolute-layout-common.ts index a29dd763a..68a427488 100644 --- a/packages/core/ui/layouts/absolute-layout/absolute-layout-common.ts +++ b/packages/core/ui/layouts/absolute-layout/absolute-layout-common.ts @@ -1,8 +1,9 @@ import { AbsoluteLayout as AbsoluteLayoutDefinition } from '.'; import { LayoutBase } from '../layout-base'; +import { CoreTypes } from '../../../core-types'; import { View, CSSType } from '../../core/view'; import { Property } from '../../core/properties'; -import { Length, zeroLength, LengthType } from '../../styling/style-properties'; +import { Length, zeroLength } from '../../styling/style-properties'; export * from '../layout-base'; @@ -20,37 +21,37 @@ function validateArgs(element: View): View { @CSSType('AbsoluteLayout') export class AbsoluteLayoutBase extends LayoutBase implements AbsoluteLayoutDefinition { // TODO: Do we still need this? it can be get like view.left - public static getLeft(element: View): LengthType { + public static getLeft(element: View): CoreTypes.LengthType { return validateArgs(element).left; } // TODO: Do we still need this? it can be set like view.left=value - public static setLeft(element: View, value: LengthType): void { + public static setLeft(element: View, value: CoreTypes.LengthType): void { validateArgs(element).left = value; } // TODO: Do we still need this? it can be get like view.top - public static getTop(element: View): LengthType { + public static getTop(element: View): CoreTypes.LengthType { return validateArgs(element).top; } // TODO: Do we still need this? it can be set like view.top=value - public static setTop(element: View, value: LengthType): void { + public static setTop(element: View, value: CoreTypes.LengthType): void { validateArgs(element).top = value; } - onLeftChanged(view: View, oldValue: LengthType, newValue: LengthType) { + onLeftChanged(view: View, oldValue: CoreTypes.LengthType, newValue: CoreTypes.LengthType) { // } - onTopChanged(view: View, oldValue: LengthType, newValue: LengthType) { + onTopChanged(view: View, oldValue: CoreTypes.LengthType, newValue: CoreTypes.LengthType) { // } } AbsoluteLayoutBase.prototype.recycleNativeView = 'auto'; -export const leftProperty = new Property({ +export const leftProperty = new Property({ name: 'left', defaultValue: zeroLength, valueChanged: (target, oldValue, newValue) => { @@ -64,7 +65,7 @@ export const leftProperty = new Property({ }); leftProperty.register(View); -export const topProperty = new Property({ +export const topProperty = new Property({ name: 'top', defaultValue: zeroLength, valueChanged: (target, oldValue, newValue) => { diff --git a/packages/core/ui/layouts/absolute-layout/index.ios.ts b/packages/core/ui/layouts/absolute-layout/index.ios.ts index 602479fe3..82b08ad94 100644 --- a/packages/core/ui/layouts/absolute-layout/index.ios.ts +++ b/packages/core/ui/layouts/absolute-layout/index.ios.ts @@ -1,16 +1,17 @@ import { AbsoluteLayoutBase } from './absolute-layout-common'; +import { CoreTypes } from '../../../core-types'; import { View } from '../../core/view'; -import { Length, LengthType } from '../../styling/style-properties'; +import { Length } from '../../styling/style-properties'; import { layout } from '../../../utils'; export * from './absolute-layout-common'; export class AbsoluteLayout extends AbsoluteLayoutBase { - onLeftChanged(view: View, oldValue: LengthType, newValue: LengthType) { + onLeftChanged(view: View, oldValue: CoreTypes.LengthType, newValue: CoreTypes.LengthType) { this.requestLayout(); } - onTopChanged(view: View, oldValue: LengthType, newValue: LengthType) { + onTopChanged(view: View, oldValue: CoreTypes.LengthType, newValue: CoreTypes.LengthType) { this.requestLayout(); } diff --git a/packages/core/ui/layouts/dock-layout/dock-layout-common.ts b/packages/core/ui/layouts/dock-layout/dock-layout-common.ts index a15587fae..e9cc01979 100644 --- a/packages/core/ui/layouts/dock-layout/dock-layout-common.ts +++ b/packages/core/ui/layouts/dock-layout/dock-layout-common.ts @@ -1,5 +1,5 @@ import { DockLayout as DockLayoutDefinition } from '.'; -import { Enums } from '../../enums'; +import { CoreTypes } from '../../../core-types'; import { LayoutBase } from '../layout-base'; import { View, CSSType } from '../../core/view'; import { Property, makeValidator, makeParser } from '../../core/properties'; @@ -17,25 +17,25 @@ export * from '../layout-base'; @CSSType('DockLayout') export class DockLayoutBase extends LayoutBase implements DockLayoutDefinition { - public static getDock(element: View): Enums.DockType { + public static getDock(element: View): CoreTypes.DockType { return validateArgs(element).dock; } - public static setDock(element: View, value: Enums.DockType): void { + public static setDock(element: View, value: CoreTypes.DockType): void { validateArgs(element).dock = value; } public stretchLastChild: boolean; - public onDockChanged(view: View, oldValue: Enums.DockType, newValue: Enums.DockType) { + public onDockChanged(view: View, oldValue: CoreTypes.DockType, newValue: CoreTypes.DockType) { // } } DockLayoutBase.prototype.recycleNativeView = 'auto'; -const dockConverter = makeParser(makeValidator(Enums.Dock.left, Enums.Dock.top, Enums.Dock.right, Enums.Dock.bottom)); -export const dockProperty = new Property({ +const dockConverter = makeParser(makeValidator(CoreTypes.Dock.left, CoreTypes.Dock.top, CoreTypes.Dock.right, CoreTypes.Dock.bottom)); +export const dockProperty = new Property({ name: 'dock', defaultValue: 'left', valueChanged: (target, oldValue, newValue) => { diff --git a/packages/core/ui/layouts/dock-layout/index.d.ts b/packages/core/ui/layouts/dock-layout/index.d.ts index 12e66ae26..fc007c466 100644 --- a/packages/core/ui/layouts/dock-layout/index.d.ts +++ b/packages/core/ui/layouts/dock-layout/index.d.ts @@ -1,7 +1,7 @@ import { LayoutBase } from '../layout-base'; import { Property } from '../../core/properties'; import { View } from '../../core/view'; -import { Enums } from '../../enums'; +import { CoreTypes } from '../../../core-types'; /** * A Layout that arranges its children at its outer edges, and allows its last child to take up the remaining space. @@ -27,7 +27,7 @@ export class DockLayout extends LayoutBase { /** * Represents the observable property backing the dock property. */ -export const dockProperty: Property; +export const dockProperty: Property; /** * Represents the observable property backing the stretchLastChild property of each DockLayout instance. diff --git a/packages/core/ui/layouts/flexbox-layout/index.android.ts b/packages/core/ui/layouts/flexbox-layout/index.android.ts index b4201aaba..32d73d4f6 100644 --- a/packages/core/ui/layouts/flexbox-layout/index.android.ts +++ b/packages/core/ui/layouts/flexbox-layout/index.android.ts @@ -1,6 +1,7 @@ import { FlexDirection, FlexWrap, JustifyContent, AlignItems, AlignContent, FlexboxLayoutBase, orderProperty, Order, flexGrowProperty, FlexGrow, flexShrinkProperty, FlexShrink, flexWrapBeforeProperty, FlexWrapBefore, alignSelfProperty, AlignSelf, flexDirectionProperty, flexWrapProperty, justifyContentProperty, alignItemsProperty, alignContentProperty } from './flexbox-layout-common'; +import { CoreTypes } from '../../../core-types'; import { View } from '../../core/view'; -import { Length, LengthType } from '../../styling/style-properties'; +import { Length } from '../../styling/style-properties'; export * from './flexbox-layout-common'; @@ -149,7 +150,7 @@ export class FlexboxLayout extends FlexboxLayoutBase { child.nativeViewProtected.setLayoutParams(lp); } - public _setChildMinWidthNative(child: View, value: LengthType): void { + public _setChildMinWidthNative(child: View, value: CoreTypes.LengthType): void { // Check needed to maintain back-compat after https://github.com/NativeScript/NativeScript/pull/7804 if (!child._ignoreFlexMinWidthHeightReset) { child._setMinWidthNative(0); @@ -163,7 +164,7 @@ export class FlexboxLayout extends FlexboxLayoutBase { } } - public _setChildMinHeightNative(child: View, value: LengthType): void { + public _setChildMinHeightNative(child: View, value: CoreTypes.LengthType): void { // Check needed to maintain back-compat after https://github.com/NativeScript/NativeScript/pull/7804 if (!child._ignoreFlexMinWidthHeightReset) { child._setMinHeightNative(0); diff --git a/packages/core/ui/layouts/layout-base-common.ts b/packages/core/ui/layouts/layout-base-common.ts index ab128d003..95e10c70f 100644 --- a/packages/core/ui/layouts/layout-base-common.ts +++ b/packages/core/ui/layouts/layout-base-common.ts @@ -1,8 +1,8 @@ import { LayoutBase as LayoutBaseDefinition } from './layout-base'; +import { CoreTypes } from '../../core-types'; import { View, CustomLayoutView, AddChildFromBuilder } from '../core/view'; import { booleanConverter, getViewById } from '../core/view-base'; import { Property } from '../core/properties'; -import { LengthType } from '../styling/style-properties'; export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefinition, AddChildFromBuilder { private _subViews = new Array(); @@ -70,38 +70,38 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi } } - get padding(): string | LengthType { + get padding(): string | CoreTypes.LengthType { return this.style.padding; } - set padding(value: string | LengthType) { + set padding(value: string | CoreTypes.LengthType) { this.style.padding = value; } - get paddingTop(): LengthType { + get paddingTop(): CoreTypes.LengthType { return this.style.paddingTop; } - set paddingTop(value: LengthType) { + set paddingTop(value: CoreTypes.LengthType) { this.style.paddingTop = value; } - get paddingRight(): LengthType { + get paddingRight(): CoreTypes.LengthType { return this.style.paddingRight; } - set paddingRight(value: LengthType) { + set paddingRight(value: CoreTypes.LengthType) { this.style.paddingRight = value; } - get paddingBottom(): LengthType { + get paddingBottom(): CoreTypes.LengthType { return this.style.paddingBottom; } - set paddingBottom(value: LengthType) { + set paddingBottom(value: CoreTypes.LengthType) { this.style.paddingBottom = value; } - get paddingLeft(): LengthType { + get paddingLeft(): CoreTypes.LengthType { return this.style.paddingLeft; } - set paddingLeft(value: LengthType) { + set paddingLeft(value: CoreTypes.LengthType) { this.style.paddingLeft = value; } diff --git a/packages/core/ui/layouts/layout-base.android.ts b/packages/core/ui/layouts/layout-base.android.ts index d824da9fc..9fa969fe8 100644 --- a/packages/core/ui/layouts/layout-base.android.ts +++ b/packages/core/ui/layouts/layout-base.android.ts @@ -1,5 +1,6 @@ import { LayoutBaseCommon, clipToBoundsProperty, isPassThroughParentEnabledProperty } from './layout-base-common'; -import { Length, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, LengthType } from '../styling/style-properties'; +import { Length, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty } from '../styling/style-properties'; +import { CoreTypes } from '../../core-types'; export * from './layout-base-common'; @@ -26,31 +27,31 @@ export class LayoutBase extends LayoutBaseCommon { (this.nativeViewProtected).setPassThroughParent(value); } - [paddingTopProperty.getDefault](): LengthType { + [paddingTopProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingTop, unit: 'px' }; } - [paddingTopProperty.setNative](value: LengthType) { + [paddingTopProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderTopWidth, 0)); } - [paddingRightProperty.getDefault](): LengthType { + [paddingRightProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingRight, unit: 'px' }; } - [paddingRightProperty.setNative](value: LengthType) { + [paddingRightProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderRightWidth, 0)); } - [paddingBottomProperty.getDefault](): LengthType { + [paddingBottomProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingBottom, unit: 'px' }; } - [paddingBottomProperty.setNative](value: LengthType) { + [paddingBottomProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderBottomWidth, 0)); } - [paddingLeftProperty.getDefault](): LengthType { + [paddingLeftProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingLeft, unit: 'px' }; } - [paddingLeftProperty.setNative](value: LengthType) { + [paddingLeftProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0)); } } diff --git a/packages/core/ui/layouts/layout-base.d.ts b/packages/core/ui/layouts/layout-base.d.ts index 902c4ca0b..0fa7f4b88 100644 --- a/packages/core/ui/layouts/layout-base.d.ts +++ b/packages/core/ui/layouts/layout-base.d.ts @@ -1,6 +1,6 @@ -import { View, CustomLayoutView } from '../core/view'; +import { CoreTypes } from '../../core-types'; +import { View, CustomLayoutView } from '../core/view'; import { Property } from '../core/properties'; -import { Length } from '../styling/style-properties'; /** * Base class for all views that supports children positioning. @@ -66,27 +66,27 @@ export class LayoutBase extends CustomLayoutView { /** * Gets or sets padding style property. */ - padding: string | Length; + padding: string | CoreTypes.LengthType; /** * Specify the bottom padding of this layout. */ - paddingBottom: Length; + paddingBottom: CoreTypes.LengthType; /** * Specify the left padding of this layout. */ - paddingLeft: Length; + paddingLeft: CoreTypes.LengthType; /** * Specify the right padding of this layout. */ - paddingRight: Length; + paddingRight: CoreTypes.LengthType; /** * Specify the top padding of this layout. */ - paddingTop: Length; + paddingTop: CoreTypes.LengthType; /** * Gets or sets a value indicating whether to clip the content of this layout. diff --git a/packages/core/ui/layouts/root-layout/index.d.ts b/packages/core/ui/layouts/root-layout/index.d.ts index 5bb4954ef..4fa954944 100644 --- a/packages/core/ui/layouts/root-layout/index.d.ts +++ b/packages/core/ui/layouts/root-layout/index.d.ts @@ -1,6 +1,6 @@ import { GridLayout } from '../grid-layout'; import { View } from '../../core/view'; -import { AnimationCurve } from '../../enums'; +import { AnimationCurve } from '../../../core-types'; export class RootLayout extends GridLayout { open(view: View, options?: RootLayoutOptions): Promise; diff --git a/packages/core/ui/layouts/root-layout/root-layout-common.ts b/packages/core/ui/layouts/root-layout/root-layout-common.ts index 195b3ae29..d17811ff8 100644 --- a/packages/core/ui/layouts/root-layout/root-layout-common.ts +++ b/packages/core/ui/layouts/root-layout/root-layout-common.ts @@ -1,4 +1,4 @@ -import { Enums } from '../../enums'; +import { CoreTypes } from '../../../core-types'; import { Trace } from '../../../trace'; import { CSSType, View } from '../../core/view'; import { GridLayout } from '../grid-layout'; @@ -369,7 +369,7 @@ export const defaultTransitionAnimation: TransitionAnimation = { rotate: 0, opacity: 1, duration: 300, - curve: Enums.AnimationCurve.easeIn, + curve: CoreTypes.AnimationCurve.easeIn, }; export const defaultShadeCoverTransitionAnimation: TransitionAnimation = { diff --git a/packages/core/ui/layouts/stack-layout/index.d.ts b/packages/core/ui/layouts/stack-layout/index.d.ts index 85c2669b3..8d6b75ed7 100644 --- a/packages/core/ui/layouts/stack-layout/index.d.ts +++ b/packages/core/ui/layouts/stack-layout/index.d.ts @@ -1,6 +1,6 @@ import { LayoutBase } from '../layout-base'; import { Property } from '../../core/properties'; -import { Enums } from '../../enums'; +import { CoreTypes } from '../../core-types'; /** * A Layout that arranges its children horizontally or vertically. The direction can be set by orientation property. @@ -10,10 +10,10 @@ export class StackLayout extends LayoutBase { * Gets or sets if layout should be horizontal or vertical. * The default value is vertical. */ - orientation: Enums.OrientationType; + orientation: CoreTypes.OrientationType; } /** * Represents the observable property backing the orientation property of each StackLayout instance. */ -export const orientationProperty: Property; +export const orientationProperty: Property; diff --git a/packages/core/ui/layouts/stack-layout/index.ios.ts b/packages/core/ui/layouts/stack-layout/index.ios.ts index f675944b1..23af3e41c 100644 --- a/packages/core/ui/layouts/stack-layout/index.ios.ts +++ b/packages/core/ui/layouts/stack-layout/index.ios.ts @@ -1,6 +1,6 @@ import { StackLayoutBase } from './stack-layout-common'; +import { CoreTypes } from '../../../core-types'; import { View } from '../../core/view'; -import { Enums } from '../../enums'; import { layout } from '../../../utils'; import { Trace } from '../../../trace'; @@ -112,16 +112,16 @@ export class StackLayout extends StackLayoutBase { const childRight = right - left - paddingRight; switch (this.verticalAlignment) { - case Enums.VerticalAlignment.middle: + case CoreTypes.VerticalAlignment.middle: childTop = (bottom - top - this._totalLength) / 2 + paddingTop; break; - case Enums.VerticalAlignment.bottom: + case CoreTypes.VerticalAlignment.bottom: childTop = bottom - top - this._totalLength + paddingTop; break; - case Enums.VerticalAlignment.top: - case Enums.VerticalAlignment.stretch: + case CoreTypes.VerticalAlignment.top: + case CoreTypes.VerticalAlignment.stretch: default: childTop = paddingTop; break; @@ -146,16 +146,16 @@ export class StackLayout extends StackLayoutBase { const childBottom = bottom - top - paddingBottom; switch (this.horizontalAlignment) { - case Enums.HorizontalAlignment.center: + case CoreTypes.HorizontalAlignment.center: childLeft = (right - left - this._totalLength) / 2 + paddingLeft; break; - case Enums.HorizontalAlignment.right: + case CoreTypes.HorizontalAlignment.right: childLeft = right - left - this._totalLength + paddingLeft; break; - case Enums.HorizontalAlignment.left: - case Enums.HorizontalAlignment.stretch: + case CoreTypes.HorizontalAlignment.left: + case CoreTypes.HorizontalAlignment.stretch: default: childLeft = paddingLeft; break; diff --git a/packages/core/ui/layouts/stack-layout/stack-layout-common.ts b/packages/core/ui/layouts/stack-layout/stack-layout-common.ts index 46d8aa9fd..893f41b86 100644 --- a/packages/core/ui/layouts/stack-layout/stack-layout-common.ts +++ b/packages/core/ui/layouts/stack-layout/stack-layout-common.ts @@ -2,18 +2,18 @@ import { LayoutBase } from '../layout-base'; import { CSSType } from '../../core/view'; import { Property, makeParser, makeValidator } from '../../core/properties'; -import { Enums } from '../../enums'; +import { CoreTypes } from '../../../core-types'; @CSSType('StackLayout') export class StackLayoutBase extends LayoutBase implements StackLayoutDefinition { - public orientation: Enums.OrientationType; + public orientation: CoreTypes.OrientationType; } StackLayoutBase.prototype.recycleNativeView = 'auto'; -const converter = makeParser(makeValidator('horizontal', 'vertical')); +const converter = makeParser(makeValidator('horizontal', 'vertical')); -export const orientationProperty = new Property({ +export const orientationProperty = new Property({ name: 'orientation', defaultValue: 'vertical', affectsLayout: global.isIOS, diff --git a/packages/core/ui/layouts/wrap-layout/index.android.ts b/packages/core/ui/layouts/wrap-layout/index.android.ts index 7ac4f1901..205f86332 100644 --- a/packages/core/ui/layouts/wrap-layout/index.android.ts +++ b/packages/core/ui/layouts/wrap-layout/index.android.ts @@ -1,5 +1,6 @@ import { WrapLayoutBase, orientationProperty, itemWidthProperty, itemHeightProperty } from './wrap-layout-common'; -import { Length, LengthType } from '../../styling/style-properties'; +import { CoreTypes } from '../../../core-types'; +import { Length } from '../../styling/style-properties'; export * from './wrap-layout-common'; @@ -14,11 +15,11 @@ export class WrapLayout extends WrapLayoutBase { this.nativeViewProtected.setOrientation(value === 'vertical' ? org.nativescript.widgets.Orientation.vertical : org.nativescript.widgets.Orientation.horizontal); } - [itemWidthProperty.setNative](value: LengthType) { + [itemWidthProperty.setNative](value: CoreTypes.LengthType) { this.nativeViewProtected.setItemWidth(Length.toDevicePixels(value, -1)); } - [itemHeightProperty.setNative](value: LengthType) { + [itemHeightProperty.setNative](value: CoreTypes.LengthType) { this.nativeViewProtected.setItemHeight(Length.toDevicePixels(value, -1)); } } diff --git a/packages/core/ui/layouts/wrap-layout/wrap-layout-common.ts b/packages/core/ui/layouts/wrap-layout/wrap-layout-common.ts index a1879fb3d..80eb9df4d 100644 --- a/packages/core/ui/layouts/wrap-layout/wrap-layout-common.ts +++ b/packages/core/ui/layouts/wrap-layout/wrap-layout-common.ts @@ -2,23 +2,23 @@ import { LayoutBase } from '../layout-base'; import { CSSType } from '../../core/view'; import { Property, makeValidator, makeParser } from '../../core/properties'; -import { Length, LengthType } from '../../styling/style-properties'; -import { Enums } from '../../enums'; +import { Length } from '../../styling/style-properties'; +import { CoreTypes } from '../../../core-types'; export * from '../layout-base'; @CSSType('WrapLayout') export class WrapLayoutBase extends LayoutBase implements WrapLayoutDefinition { - public orientation: Enums.OrientationType; - public itemWidth: LengthType; - public itemHeight: LengthType; + public orientation: CoreTypes.OrientationType; + public itemWidth: CoreTypes.LengthType; + public itemHeight: CoreTypes.LengthType; public effectiveItemWidth: number; public effectiveItemHeight: number; } WrapLayoutBase.prototype.recycleNativeView = 'auto'; -export const itemWidthProperty = new Property({ +export const itemWidthProperty = new Property({ name: 'itemWidth', defaultValue: 'auto', affectsLayout: global.isIOS, @@ -27,7 +27,7 @@ export const itemWidthProperty = new Property({ }); itemWidthProperty.register(WrapLayoutBase); -export const itemHeightProperty = new Property({ +export const itemHeightProperty = new Property({ name: 'itemHeight', defaultValue: 'auto', affectsLayout: global.isIOS, @@ -36,10 +36,10 @@ export const itemHeightProperty = new Property({ }); itemHeightProperty.register(WrapLayoutBase); -const converter = makeParser(makeValidator(Enums.Orientation.horizontal, Enums.Orientation.vertical)); -export const orientationProperty = new Property({ +const converter = makeParser(makeValidator(CoreTypes.Orientation.horizontal, CoreTypes.Orientation.vertical)); +export const orientationProperty = new Property({ name: 'orientation', - defaultValue: Enums.Orientation.horizontal, + defaultValue: CoreTypes.Orientation.horizontal, affectsLayout: global.isIOS, valueConverter: converter, }); diff --git a/packages/core/ui/list-view/index.android.ts b/packages/core/ui/list-view/index.android.ts index bec57c87f..4da3a07b4 100644 --- a/packages/core/ui/list-view/index.android.ts +++ b/packages/core/ui/list-view/index.android.ts @@ -2,9 +2,9 @@ import { ItemEventData, ItemsSource } from '.'; import { ListViewBase, separatorColorProperty, itemTemplatesProperty } from './list-view-common'; import { View, KeyedTemplate } from '../core/view'; import { unsetValue } from '../core/properties'; +import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; import { Observable } from '../../data/observable'; -import { LengthType } from '../styling/style-properties'; import { StackLayout } from '../layouts/stack-layout'; import { ProxyViewContainer } from '../proxy-view-container'; import { LayoutBase } from '../layouts/layout-base'; @@ -395,7 +395,7 @@ function ensureListViewAdapterClass() { if (this.owner._effectiveRowHeight > -1) { args.view.height = this.owner.rowHeight; } else { - args.view.height = unsetValue; + args.view.height = unsetValue; } this.owner._prepareItem(args.view, index); diff --git a/packages/core/ui/list-view/index.ios.ts b/packages/core/ui/list-view/index.ios.ts index 8be9bb264..f7ec7f931 100644 --- a/packages/core/ui/list-view/index.ios.ts +++ b/packages/core/ui/list-view/index.ios.ts @@ -1,7 +1,8 @@ import { ItemEventData } from '.'; import { ListViewBase, separatorColorProperty, itemTemplatesProperty, iosEstimatedRowHeightProperty } from './list-view-common'; +import { CoreTypes } from '../../core-types'; import { View, KeyedTemplate } from '../core/view'; -import { Length, LengthType } from '../styling/style-properties'; +import { Length } from '../styling/style-properties'; import { Observable, EventData } from '../../data/observable'; import { Color } from '../../color'; import { layout } from '../../utils'; @@ -365,7 +366,7 @@ export class ListView extends ListViewBase { this._heights[index] = value; } - public _onRowHeightPropertyChanged(oldValue: LengthType, newValue: LengthType) { + public _onRowHeightPropertyChanged(oldValue: CoreTypes.LengthType, newValue: CoreTypes.LengthType) { const value = layout.toDeviceIndependentPixels(this._effectiveRowHeight); const nativeView = this.ios; if (value < 0) { @@ -522,10 +523,10 @@ export class ListView extends ListViewBase { this.refresh(); } - [iosEstimatedRowHeightProperty.getDefault](): LengthType { + [iosEstimatedRowHeightProperty.getDefault](): CoreTypes.LengthType { return DEFAULT_HEIGHT; } - [iosEstimatedRowHeightProperty.setNative](value: LengthType) { + [iosEstimatedRowHeightProperty.setNative](value: CoreTypes.LengthType) { const nativeView = this.ios; const estimatedHeight = Length.toDevicePixels(value, 0); nativeView.estimatedRowHeight = estimatedHeight < 0 ? DEFAULT_HEIGHT : estimatedHeight; diff --git a/packages/core/ui/list-view/list-view-common.ts b/packages/core/ui/list-view/list-view-common.ts index 19df5ff74..8120129de 100644 --- a/packages/core/ui/list-view/list-view-common.ts +++ b/packages/core/ui/list-view/list-view-common.ts @@ -1,7 +1,7 @@ import { ListView as ListViewDefinition, ItemsSource, ItemEventData, TemplatedItemsView } from '.'; import { View, ContainerView, Template, KeyedTemplate, CSSType } from '../core/view'; import { Property, CoercibleProperty, CssProperty } from '../core/properties'; -import { Length, LengthType } from '../styling/style-properties'; +import { Length } from '../styling/style-properties'; import { Style } from '../styling/style'; import { Color } from '../../color'; import { Builder } from '../builder'; @@ -9,6 +9,7 @@ import { Label } from '../label'; import { Observable, EventData } from '../../data/observable'; import { ObservableArray, ChangedData } from '../../data/observable-array'; import { addWeakEventListener, removeWeakEventListener } from '../core/weak-event-listener'; +import { CoreTypes } from '../../core-types'; const autoEffectiveRowHeight = -1; @@ -36,8 +37,8 @@ export abstract class ListViewBase extends ContainerView implements ListViewDefi public _itemTemplatesInternal = new Array(this._defaultTemplate); public _effectiveRowHeight: number = autoEffectiveRowHeight; - public rowHeight: LengthType; - public iosEstimatedRowHeight: LengthType; + public rowHeight: CoreTypes.LengthType; + public iosEstimatedRowHeight: CoreTypes.LengthType; public items: any[] | ItemsSource; public itemTemplate: string | Template; public itemTemplates: string | Array; @@ -137,7 +138,7 @@ export abstract class ListViewBase extends ContainerView implements ListViewDefi this.refresh(); } - public _onRowHeightPropertyChanged(oldValue: LengthType, newValue: LengthType) { + public _onRowHeightPropertyChanged(oldValue: CoreTypes.LengthType, newValue: CoreTypes.LengthType) { this.refresh(); } @@ -203,11 +204,11 @@ export const itemTemplatesProperty = new Property({ +export const rowHeightProperty = new CoercibleProperty({ name: 'rowHeight', defaultValue: defaultRowHeight, equalityComparer: Length.equals, @@ -223,7 +224,7 @@ export const rowHeightProperty = new CoercibleProperty }); rowHeightProperty.register(ListViewBase); -export const iosEstimatedRowHeightProperty = new Property({ +export const iosEstimatedRowHeightProperty = new Property({ name: 'iosEstimatedRowHeight', valueConverter: (v) => Length.parse(v), }); diff --git a/packages/core/ui/page/index.android.ts b/packages/core/ui/page/index.android.ts index 7f316923b..59a0d064d 100644 --- a/packages/core/ui/page/index.android.ts +++ b/packages/core/ui/page/index.android.ts @@ -1,4 +1,5 @@ import { PageBase, actionBarHiddenProperty, statusBarStyleProperty, androidStatusBarBackgroundProperty } from './page-common'; +import { CoreTypes } from '../../core-types'; import { View } from '../core/view'; import { Color } from '../../color'; import { ActionBar } from '../action-bar'; @@ -143,7 +144,9 @@ export class Page extends PageBase { } if (this.actionBarHidden || this.accessibilityLabel) { - this.androidSendAccessibilityEvent(AndroidAccessibilityEvent.WINDOW_STATE_CHANGED); + this.sendAccessibilityEvent({ + androidAccessibilityEvent: AndroidAccessibilityEvent.WINDOW_STATE_CHANGED, + }); return; } diff --git a/packages/core/ui/scroll-view/scroll-view-common.ts b/packages/core/ui/scroll-view/scroll-view-common.ts index 7cffdeee8..3e25fb098 100644 --- a/packages/core/ui/scroll-view/scroll-view-common.ts +++ b/packages/core/ui/scroll-view/scroll-view-common.ts @@ -5,14 +5,14 @@ import { Property, makeParser, makeValidator } from '../core/properties'; import { CSSType } from '../core/view'; import { booleanConverter } from '../core/view-base'; import { EventData } from '../../data/observable'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; @CSSType('ScrollView') export abstract class ScrollViewBase extends ContentView implements ScrollViewDefinition { private _scrollChangeCount = 0; public static scrollEvent = 'scroll'; - public orientation: Enums.OrientationType; + public orientation: CoreTypes.OrientationType; public scrollBarIndicatorVisible: boolean; public isScrollEnabled: boolean; @@ -92,12 +92,12 @@ export interface ScrollViewBase { on(event: 'scroll', callback: (args: ScrollEventData) => void, thisArg?: any); } -const converter = makeParser(makeValidator(Enums.Orientation.horizontal, Enums.Orientation.vertical)); -export const orientationProperty = new Property({ +const converter = makeParser(makeValidator(CoreTypes.Orientation.horizontal, CoreTypes.Orientation.vertical)); +export const orientationProperty = new Property({ name: 'orientation', - defaultValue: Enums.Orientation.vertical, + defaultValue: CoreTypes.Orientation.vertical, affectsLayout: true, - valueChanged: (target: ScrollViewBase, oldValue: Enums.OrientationType, newValue: Enums.OrientationType) => { + valueChanged: (target: ScrollViewBase, oldValue: CoreTypes.OrientationType, newValue: CoreTypes.OrientationType) => { target._onOrientationChanged(); }, valueConverter: converter, diff --git a/packages/core/ui/styling/background-common.ts b/packages/core/ui/styling/background-common.ts index a0086a4f2..9586c419e 100644 --- a/packages/core/ui/styling/background-common.ts +++ b/packages/core/ui/styling/background-common.ts @@ -1,6 +1,6 @@ // Deifinitions. import { Background as BackgroundDefinition } from './background'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { LinearGradient } from './linear-gradient'; // Types. import { Color } from '../../color'; @@ -11,7 +11,7 @@ export class Background implements BackgroundDefinition { public color: Color; public image: string | LinearGradient; - public repeat: Enums.BackgroundRepeatType; + public repeat: CoreTypes.BackgroundRepeatType; public position: string; public size: string; public borderTopColor: Color; @@ -69,7 +69,7 @@ export class Background implements BackgroundDefinition { return clone; } - public withRepeat(value: Enums.BackgroundRepeatType): Background { + public withRepeat(value: CoreTypes.BackgroundRepeatType): Background { const clone = this.clone(); clone.repeat = value; diff --git a/packages/core/ui/styling/background.android.ts b/packages/core/ui/styling/background.android.ts index 73bce2383..f855dcfca 100644 --- a/packages/core/ui/styling/background.android.ts +++ b/packages/core/ui/styling/background.android.ts @@ -1,13 +1,13 @@ import { View } from '../core/view'; import { LinearGradient } from './linear-gradient'; - +import { CoreTypes } from '../../core-types'; import { isDataURI, isFileOrResourcePath, layout, RESOURCE_PREFIX, FILE_PREFIX } from '../../utils'; import { parse } from '../../css-value'; import { path, knownFolders } from '../../file-system'; import * as application from '../../application'; import { profile } from '../../profiling'; import { CSSShadow } from './css-shadow'; -import { Length, LengthType } from './style-properties'; +import { Length } from './style-properties'; export * from './background-common'; interface AndroidView { @@ -93,7 +93,7 @@ export namespace ad { refreshBorderDrawable(view, backgroundDrawable); } else { backgroundDrawable = new org.nativescript.widgets.BorderDrawable(layout.getDisplayDensity(), view.toString()); - refreshBorderDrawable(view, backgroundDrawable); + refreshBorderDrawable(view, backgroundDrawable); nativeView.setBackground(backgroundDrawable); } } else { @@ -247,7 +247,7 @@ function createNativeCSSValueArray(css: string): androidNative.Arrayview.style.borderRadius, 0.0); + const cornerRadius = Length.toDevicePixels(view.style.borderRadius, 0.0); // apply spreadRadius by expanding shadow layer bounds // prettier-ignore diff --git a/packages/core/ui/styling/converters.ts b/packages/core/ui/styling/converters.ts index 2779474b2..1af4b10c5 100644 --- a/packages/core/ui/styling/converters.ts +++ b/packages/core/ui/styling/converters.ts @@ -1,12 +1,12 @@ -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; const STYLE_CURVE_MAP = Object.freeze({ - ease: Enums.AnimationCurve.ease, - linear: Enums.AnimationCurve.linear, - 'ease-in': Enums.AnimationCurve.easeIn, - 'ease-out': Enums.AnimationCurve.easeOut, - 'ease-in-out': Enums.AnimationCurve.easeInOut, - spring: Enums.AnimationCurve.spring, + ease: CoreTypes.AnimationCurve.ease, + linear: CoreTypes.AnimationCurve.linear, + 'ease-in': CoreTypes.AnimationCurve.easeIn, + 'ease-out': CoreTypes.AnimationCurve.easeOut, + 'ease-in-out': CoreTypes.AnimationCurve.easeInOut, + spring: CoreTypes.AnimationCurve.spring, }); export function timeConverter(value: string): number { @@ -19,7 +19,7 @@ export function timeConverter(value: string): number { } export function animationTimingFunctionConverter(value: string): any { - return value ? STYLE_CURVE_MAP[value] || parseCubicBezierCurve(value) : Enums.AnimationCurve.ease; + return value ? STYLE_CURVE_MAP[value] || parseCubicBezierCurve(value) : CoreTypes.AnimationCurve.ease; } function parseCubicBezierCurve(value: string) { @@ -29,7 +29,7 @@ function parseCubicBezierCurve(value: string) { if (value.startsWith('cubic-bezier') && coordsString && coords.length === 4) { const [x1, x2, y1, y2] = [...coords]; - return Enums.AnimationCurve.cubicBezier(x1, x2, y1, y2); + return CoreTypes.AnimationCurve.cubicBezier(x1, x2, y1, y2); } else { throw new Error(`Invalid value for animation: ${value}`); } diff --git a/packages/core/ui/styling/css-shadow.ts b/packages/core/ui/styling/css-shadow.ts index 515b31a1e..69886ef07 100644 --- a/packages/core/ui/styling/css-shadow.ts +++ b/packages/core/ui/styling/css-shadow.ts @@ -1,12 +1,13 @@ +import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; -import { Length, LengthType, zeroLength } from './style-properties'; +import { Length, zeroLength } from './style-properties'; export interface CSSShadow { inset: boolean; - offsetX: LengthType; - offsetY: LengthType; - blurRadius?: LengthType; - spreadRadius?: LengthType; + offsetX: CoreTypes.LengthType; + offsetY: CoreTypes.LengthType; + blurRadius?: CoreTypes.LengthType; + spreadRadius?: CoreTypes.LengthType; color: Color; } diff --git a/packages/core/ui/styling/linear-gradient.ts b/packages/core/ui/styling/linear-gradient.ts index 45c197fae..ddf308a4b 100644 --- a/packages/core/ui/styling/linear-gradient.ts +++ b/packages/core/ui/styling/linear-gradient.ts @@ -1,4 +1,4 @@ -import { LengthPercentUnit } from './style-properties'; +import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; import { ColorStop } from './gradient'; import { LinearGradient as CSSLinearGradient } from '../../css/parser'; @@ -12,7 +12,7 @@ export class LinearGradient { result.angle = value.angle; result.colorStops = value.colors.map((color) => { const offset = color.offset || null; - let offsetUnit: LengthPercentUnit; + let offsetUnit: CoreTypes.LengthPercentUnit; if (offset && offset.unit === '%') { offsetUnit = { diff --git a/packages/core/ui/styling/style-properties.d.ts b/packages/core/ui/styling/style-properties.d.ts index 334c689df..455dc54a8 100644 --- a/packages/core/ui/styling/style-properties.d.ts +++ b/packages/core/ui/styling/style-properties.d.ts @@ -1,50 +1,43 @@ import { TransformFunctionsInfo } from '../animation'; +import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; import { CssProperty, CssAnimationProperty, ShorthandProperty, InheritedCssProperty } from '../core/properties'; import { Style } from '../styling/style'; import { Font, FontStyle, FontWeight } from './font'; import { Background } from './background'; -import { dip, px, percent } from '../core/view'; - -export type LengthDipUnit = { readonly unit: 'dip'; readonly value: dip }; -export type LengthPxUnit = { readonly unit: 'px'; readonly value: px }; -export type LengthPercentUnit = { readonly unit: '%'; readonly value: percent }; - -export type LengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit; -export type PercentLengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit | LengthPercentUnit; export namespace Length { - export function parse(text: string): LengthType; - export function equals(a: LengthType, b: LengthType): boolean; + export function parse(text: string): CoreTypes.LengthType; + export function equals(a: CoreTypes.LengthType, b: CoreTypes.LengthType): boolean; /** * Converts Length unit to device pixels. * @param length The Length to convert. * @param auto Value to use for conversion of "auto". By default is Math.NaN. */ - export function toDevicePixels(length: LengthType, auto?: number): number; - export function convertToString(length: LengthType): string; + export function toDevicePixels(length: CoreTypes.LengthType, auto?: number): number; + export function convertToString(length: CoreTypes.LengthType): string; } export namespace PercentLength { - export function parse(text: string): PercentLengthType; - export function equals(a: PercentLengthType, b: PercentLengthType): boolean; + export function parse(text: string): CoreTypes.PercentLengthType; + export function equals(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType): boolean; /** * Converts PercentLengthType unit to device pixels. * @param length The PercentLengthType to convert. * @param auto Value to use for conversion of "auto". By default is Math.NaN. * @param parentAvailableWidth Value to use as base when converting percent unit. By default is Math.NaN. */ - export function toDevicePixels(length: PercentLengthType, auto?: number, parentAvailableWidth?: px): number; - export function convertToString(length: PercentLengthType): string; + export function toDevicePixels(length: CoreTypes.PercentLengthType, auto?: number, parentAvailableWidth?: CoreTypes.px): number; + export function convertToString(length: CoreTypes.PercentLengthType): string; } -export const zeroLength: LengthType; +export const zeroLength: CoreTypes.LengthType; export const rotateProperty: CssAnimationProperty; export const scaleXProperty: CssAnimationProperty; export const scaleYProperty: CssAnimationProperty; -export const translateXProperty: CssAnimationProperty; -export const translateYProperty: CssAnimationProperty; +export const translateXProperty: CssAnimationProperty; +export const translateYProperty: CssAnimationProperty; export function transformConverter(text: string): TransformFunctionsInfo; @@ -64,38 +57,38 @@ export const borderRightColorProperty: CssProperty; export const borderBottomColorProperty: CssProperty; export const borderLeftColorProperty: CssProperty; -export const borderWidthProperty: ShorthandProperty; -export const borderTopWidthProperty: CssProperty; -export const borderRightWidthProperty: CssProperty; -export const borderBottomWidthProperty: CssProperty; -export const borderLeftWidthProperty: CssProperty; +export const borderWidthProperty: ShorthandProperty; +export const borderTopWidthProperty: CssProperty; +export const borderRightWidthProperty: CssProperty; +export const borderBottomWidthProperty: CssProperty; +export const borderLeftWidthProperty: CssProperty; -export const borderRadiusProperty: ShorthandProperty; -export const borderTopLeftRadiusProperty: CssProperty; -export const borderTopRightRadiusProperty: CssProperty; -export const borderBottomRightRadiusProperty: CssProperty; -export const borderBottomLeftRadiusProperty: CssProperty; +export const borderRadiusProperty: ShorthandProperty; +export const borderTopLeftRadiusProperty: CssProperty; +export const borderTopRightRadiusProperty: CssProperty; +export const borderBottomRightRadiusProperty: CssProperty; +export const borderBottomLeftRadiusProperty: CssProperty; export const zIndexProperty: CssProperty; export const visibilityProperty: CssProperty; export const opacityProperty: CssAnimationProperty; -export const minWidthProperty: CssProperty; -export const minHeightProperty: CssProperty; -export const widthProperty: CssAnimationProperty; -export const heightProperty: CssAnimationProperty; +export const minWidthProperty: CssProperty; +export const minHeightProperty: CssProperty; +export const widthProperty: CssAnimationProperty; +export const heightProperty: CssAnimationProperty; export const lineHeightProperty: CssProperty; -export const marginProperty: ShorthandProperty; -export const marginLeftProperty: CssProperty; -export const marginRightProperty: CssProperty; -export const marginTopProperty: CssProperty; -export const marginBottomProperty: CssProperty; +export const marginProperty: ShorthandProperty; +export const marginLeftProperty: CssProperty; +export const marginRightProperty: CssProperty; +export const marginTopProperty: CssProperty; +export const marginBottomProperty: CssProperty; -export const paddingProperty: ShorthandProperty; -export const paddingLeftProperty: CssProperty; -export const paddingRightProperty: CssProperty; -export const paddingTopProperty: CssProperty; -export const paddingBottomProperty: CssProperty; +export const paddingProperty: ShorthandProperty; +export const paddingLeftProperty: CssProperty; +export const paddingRightProperty: CssProperty; +export const paddingTopProperty: CssProperty; +export const paddingBottomProperty: CssProperty; export const horizontalAlignmentProperty: CssProperty; export const verticalAlignmentProperty: CssProperty; diff --git a/packages/core/ui/styling/style-properties.ts b/packages/core/ui/styling/style-properties.ts index 88b6d32fa..4ee4d25c9 100644 --- a/packages/core/ui/styling/style-properties.ts +++ b/packages/core/ui/styling/style-properties.ts @@ -3,8 +3,6 @@ import { unsetValue, CssProperty, CssAnimationProperty, ShorthandProperty, Inher import { Style } from '../styling/style'; import { Transformation, TransformationValue, TransformFunctionsInfo } from '../animation'; -import { dip, px, percent } from '../core/view'; - import { Color } from '../../color'; import { Font, parseFont, FontStyle, FontWeight } from '../../ui/styling/font'; import { layout, hasDuplicates } from '../../utils'; @@ -14,22 +12,15 @@ import { radiansToDegrees } from '../../utils/number-utils'; import { decompose2DTransformMatrix, getTransformMatrix, matrixArrayToCssMatrix, multiplyAffine2d } from '../../matrix'; import { Trace } from '../../trace'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import * as parser from '../../css/parser'; import { LinearGradient } from './linear-gradient'; import { CSSShadow, parseCSSShadow } from './css-shadow'; -export type LengthDipUnit = { readonly unit: 'dip'; readonly value: dip }; -export type LengthPxUnit = { readonly unit: 'px'; readonly value: px }; -export type LengthPercentUnit = { readonly unit: '%'; readonly value: percent }; - -export type LengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit; -export type PercentLengthType = 'auto' | dip | LengthDipUnit | LengthPxUnit | LengthPercentUnit; - -function equalsCommon(a: LengthType, b: LengthType): boolean; -function equalsCommon(a: PercentLengthType, b: PercentLengthType): boolean; -function equalsCommon(a: PercentLengthType, b: PercentLengthType): boolean { +function equalsCommon(a: CoreTypes.LengthType, b: CoreTypes.LengthType): boolean; +function equalsCommon(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType): boolean; +function equalsCommon(a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType): boolean { if (a == 'auto') { // tslint:disable-line return b == 'auto'; // tslint:disable-line @@ -60,7 +51,7 @@ function equalsCommon(a: PercentLengthType, b: PercentLengthType): boolean { return a.value == b.value && a.unit == b.unit; // tslint:disable-line } -function convertToStringCommon(length: LengthType | PercentLengthType): string { +function convertToStringCommon(length: CoreTypes.LengthType | CoreTypes.PercentLengthType): string { if (length == 'auto') { // tslint:disable-line return 'auto'; @@ -78,7 +69,7 @@ function convertToStringCommon(length: LengthType | PercentLengthType): string { return val + length.unit; } -function toDevicePixelsCommon(length: PercentLengthType, auto: number = Number.NaN, parentAvailableWidth: number = Number.NaN): number { +function toDevicePixelsCommon(length: CoreTypes.PercentLengthType, auto: number = Number.NaN, parentAvailableWidth: number = Number.NaN): number { if (length == 'auto') { // tslint:disable-line return auto; @@ -101,7 +92,7 @@ function toDevicePixelsCommon(length: PercentLengthType, auto: number = Number.N } export namespace PercentLength { - export function parse(fromValue: string | LengthType): PercentLengthType { + export function parse(fromValue: string | CoreTypes.LengthType): CoreTypes.PercentLengthType { if (fromValue == 'auto') { // tslint:disable-line return 'auto'; @@ -110,7 +101,7 @@ export namespace PercentLength { let stringValue = fromValue.trim(); const percentIndex = stringValue.indexOf('%'); if (percentIndex !== -1) { - let value: percent; + let value: CoreTypes.percent; // if only % or % is not last we treat it as invalid value. if (percentIndex !== stringValue.length - 1 || percentIndex === 0) { value = Number.NaN; @@ -126,14 +117,14 @@ export namespace PercentLength { return { unit: '%', value }; } else if (stringValue.indexOf('px') !== -1) { stringValue = stringValue.replace('px', '').trim(); - const value: px = parseFloat(stringValue); + const value: CoreTypes.px = parseFloat(stringValue); if (isNaN(value) || !isFinite(value)) { throw new Error(`Invalid value: ${fromValue}`); } return { unit: 'px', value }; } else { - const value: dip = parseFloat(stringValue); + const value: CoreTypes.dip = parseFloat(stringValue); if (isNaN(value) || !isFinite(value)) { throw new Error(`Invalid value: ${fromValue}`); } @@ -146,18 +137,18 @@ export namespace PercentLength { } export const equals: { - (a: PercentLengthType, b: PercentLengthType): boolean; + (a: CoreTypes.PercentLengthType, b: CoreTypes.PercentLengthType): boolean; } = equalsCommon; export const toDevicePixels: { - (length: PercentLengthType, auto: number, parentAvailableWidth: number): number; + (length: CoreTypes.PercentLengthType, auto: number, parentAvailableWidth: number): number; } = toDevicePixelsCommon; export const convertToString: { - (length: PercentLengthType): string; + (length: CoreTypes.PercentLengthType): string; } = convertToStringCommon; } export namespace Length { - export function parse(fromValue: string | LengthType): LengthType { + export function parse(fromValue: string | CoreTypes.LengthType): CoreTypes.LengthType { if (fromValue == 'auto') { // tslint:disable-line return 'auto'; @@ -166,14 +157,14 @@ export namespace Length { let stringValue = fromValue.trim(); if (stringValue.indexOf('px') !== -1) { stringValue = stringValue.replace('px', '').trim(); - const value: px = parseFloat(stringValue); + const value: CoreTypes.px = parseFloat(stringValue); if (isNaN(value) || !isFinite(value)) { throw new Error(`Invalid value: ${stringValue}`); } return { unit: 'px', value }; } else { - const value: dip = parseFloat(stringValue); + const value: CoreTypes.dip = parseFloat(stringValue); if (isNaN(value) || !isFinite(value)) { throw new Error(`Invalid value: ${stringValue}`); } @@ -184,18 +175,18 @@ export namespace Length { return fromValue; } } - export const equals: { (a: LengthType, b: LengthType): boolean } = equalsCommon; + export const equals: { (a: CoreTypes.LengthType, b: CoreTypes.LengthType): boolean } = equalsCommon; export const toDevicePixels: { - (length: LengthType, auto?: number): number; + (length: CoreTypes.LengthType, auto?: number): number; } = toDevicePixelsCommon; export const convertToString: { - (length: LengthType): string; + (length: CoreTypes.LengthType): string; } = convertToStringCommon; } -export const zeroLength: LengthType = { value: 0, unit: 'px' }; +export const zeroLength: CoreTypes.LengthType = { value: 0, unit: 'px' }; -export const minWidthProperty = new CssProperty({ +export const minWidthProperty = new CssProperty({ name: 'minWidth', cssName: 'min-width', defaultValue: zeroLength, @@ -213,7 +204,7 @@ export const minWidthProperty = new CssProperty({ }); minWidthProperty.register(Style); -export const minHeightProperty = new CssProperty({ +export const minHeightProperty = new CssProperty({ name: 'minHeight', cssName: 'min-height', defaultValue: zeroLength, @@ -231,7 +222,7 @@ export const minHeightProperty = new CssProperty({ }); minHeightProperty.register(Style); -export const widthProperty = new CssAnimationProperty({ +export const widthProperty = new CssAnimationProperty({ name: 'width', cssName: 'width', defaultValue: 'auto', @@ -250,7 +241,7 @@ export const widthProperty = new CssAnimationProperty( }); widthProperty.register(Style); -export const heightProperty = new CssAnimationProperty({ +export const heightProperty = new CssAnimationProperty({ name: 'height', cssName: 'height', defaultValue: 'auto', @@ -269,7 +260,7 @@ export const heightProperty = new CssAnimationProperty }); heightProperty.register(Style); -const marginProperty = new ShorthandProperty({ +const marginProperty = new ShorthandProperty({ name: 'margin', cssName: 'margin', getter: function (this: Style) { @@ -283,7 +274,7 @@ const marginProperty = new ShorthandProperty( }); marginProperty.register(Style); -export const marginLeftProperty = new CssProperty({ +export const marginLeftProperty = new CssProperty({ name: 'marginLeft', cssName: 'margin-left', defaultValue: zeroLength, @@ -293,7 +284,7 @@ export const marginLeftProperty = new CssProperty({ }); marginLeftProperty.register(Style); -export const marginRightProperty = new CssProperty({ +export const marginRightProperty = new CssProperty({ name: 'marginRight', cssName: 'margin-right', defaultValue: zeroLength, @@ -303,7 +294,7 @@ export const marginRightProperty = new CssProperty({ }); marginRightProperty.register(Style); -export const marginTopProperty = new CssProperty({ +export const marginTopProperty = new CssProperty({ name: 'marginTop', cssName: 'margin-top', defaultValue: zeroLength, @@ -313,7 +304,7 @@ export const marginTopProperty = new CssProperty({ }); marginTopProperty.register(Style); -export const marginBottomProperty = new CssProperty({ +export const marginBottomProperty = new CssProperty({ name: 'marginBottom', cssName: 'margin-bottom', defaultValue: zeroLength, @@ -323,7 +314,7 @@ export const marginBottomProperty = new CssProperty({ }); marginBottomProperty.register(Style); -const paddingProperty = new ShorthandProperty({ +const paddingProperty = new ShorthandProperty({ name: 'padding', cssName: 'padding', getter: function (this: Style) { @@ -337,7 +328,7 @@ const paddingProperty = new ShorthandProperty({ }); paddingProperty.register(Style); -export const paddingLeftProperty = new CssProperty({ +export const paddingLeftProperty = new CssProperty({ name: 'paddingLeft', cssName: 'padding-left', defaultValue: zeroLength, @@ -355,7 +346,7 @@ export const paddingLeftProperty = new CssProperty({ }); paddingLeftProperty.register(Style); -export const paddingRightProperty = new CssProperty({ +export const paddingRightProperty = new CssProperty({ name: 'paddingRight', cssName: 'padding-right', defaultValue: zeroLength, @@ -373,7 +364,7 @@ export const paddingRightProperty = new CssProperty({ }); paddingRightProperty.register(Style); -export const paddingTopProperty = new CssProperty({ +export const paddingTopProperty = new CssProperty({ name: 'paddingTop', cssName: 'padding-top', defaultValue: zeroLength, @@ -391,7 +382,7 @@ export const paddingTopProperty = new CssProperty({ }); paddingTopProperty.register(Style); -export const paddingBottomProperty = new CssProperty({ +export const paddingBottomProperty = new CssProperty({ name: 'paddingBottom', cssName: 'padding-bottom', defaultValue: zeroLength, @@ -409,21 +400,21 @@ export const paddingBottomProperty = new CssProperty({ }); paddingBottomProperty.register(Style); -export const horizontalAlignmentProperty = new CssProperty({ +export const horizontalAlignmentProperty = new CssProperty({ name: 'horizontalAlignment', cssName: 'horizontal-align', - defaultValue: Enums.HorizontalAlignment.stretch, + defaultValue: CoreTypes.HorizontalAlignment.stretch, affectsLayout: global.isIOS, - valueConverter: Enums.HorizontalAlignment.parse, + valueConverter: CoreTypes.HorizontalAlignment.parse, }); horizontalAlignmentProperty.register(Style); -export const verticalAlignmentProperty = new CssProperty({ +export const verticalAlignmentProperty = new CssProperty({ name: 'verticalAlignment', cssName: 'vertical-align', - defaultValue: Enums.VerticalAlignmentText.stretch, + defaultValue: CoreTypes.VerticalAlignmentText.stretch, affectsLayout: global.isIOS, - valueConverter: Enums.VerticalAlignmentText.parse, + valueConverter: CoreTypes.VerticalAlignmentText.parse, }); verticalAlignmentProperty.register(Style); @@ -478,7 +469,7 @@ function parseThickness(value: string): Thickness { } } -function convertToMargins(this: void, value: string | PercentLengthType): [CssProperty, any][] { +function convertToMargins(this: void, value: string | CoreTypes.PercentLengthType): [CssProperty, any][] { if (typeof value === 'string' && value !== 'auto') { const thickness = parseThickness(value); @@ -498,7 +489,7 @@ function convertToMargins(this: void, value: string | PercentLengthType): [CssPr } } -function convertToPaddings(this: void, value: string | LengthType): [CssProperty, any][] { +function convertToPaddings(this: void, value: string | CoreTypes.LengthType): [CssProperty, any][] { if (typeof value === 'string' && value !== 'auto') { const thickness = parseThickness(value); @@ -566,7 +557,7 @@ export const scaleYProperty = new CssAnimationProperty({ }); scaleYProperty.register(Style); -function parseDIPs(value: string): dip { +function parseDIPs(value: string): CoreTypes.dip { if (value.indexOf('px') !== -1) { return layout.toDeviceIndependentPixels(parseFloat(value.replace('px', '').trim())); } else { @@ -574,7 +565,7 @@ function parseDIPs(value: string): dip { } } -export const translateXProperty = new CssAnimationProperty({ +export const translateXProperty = new CssAnimationProperty({ name: 'translateX', cssName: 'translateX', defaultValue: 0, @@ -582,7 +573,7 @@ export const translateXProperty = new CssAnimationProperty({ }); translateXProperty.register(Style); -export const translateYProperty = new CssAnimationProperty({ +export const translateYProperty = new CssAnimationProperty({ name: 'translateY', cssName: 'translateY', defaultValue: 0, @@ -810,10 +801,10 @@ export const backgroundColorProperty = new CssAnimationProperty({ }); backgroundColorProperty.register(Style); -export const backgroundRepeatProperty = new CssProperty({ +export const backgroundRepeatProperty = new CssProperty({ name: 'backgroundRepeat', cssName: 'background-repeat', - valueConverter: Enums.BackgroundRepeat.parse, + valueConverter: CoreTypes.BackgroundRepeat.parse, valueChanged: (target, oldValue, newValue) => { target.backgroundInternal = target.backgroundInternal.withRepeat(newValue); }, @@ -998,7 +989,7 @@ export const borderLeftColorProperty = new CssProperty({ borderLeftColorProperty.register(Style); // Border Width properties. -const borderWidthProperty = new ShorthandProperty({ +const borderWidthProperty = new ShorthandProperty({ name: 'borderWidth', cssName: 'border-width', getter: function (this: Style) { @@ -1030,7 +1021,7 @@ const borderWidthProperty = new ShorthandProperty({ }); borderWidthProperty.register(Style); -export const borderTopWidthProperty = new CssProperty({ +export const borderTopWidthProperty = new CssProperty({ name: 'borderTopWidth', cssName: 'border-top-width', defaultValue: zeroLength, @@ -1054,7 +1045,7 @@ export const borderTopWidthProperty = new CssProperty({ }); borderTopWidthProperty.register(Style); -export const borderRightWidthProperty = new CssProperty({ +export const borderRightWidthProperty = new CssProperty({ name: 'borderRightWidth', cssName: 'border-right-width', defaultValue: zeroLength, @@ -1078,7 +1069,7 @@ export const borderRightWidthProperty = new CssProperty({ }); borderRightWidthProperty.register(Style); -export const borderBottomWidthProperty = new CssProperty({ +export const borderBottomWidthProperty = new CssProperty({ name: 'borderBottomWidth', cssName: 'border-bottom-width', defaultValue: zeroLength, @@ -1102,7 +1093,7 @@ export const borderBottomWidthProperty = new CssProperty({ }); borderBottomWidthProperty.register(Style); -export const borderLeftWidthProperty = new CssProperty({ +export const borderLeftWidthProperty = new CssProperty({ name: 'borderLeftWidth', cssName: 'border-left-width', defaultValue: zeroLength, @@ -1127,7 +1118,7 @@ export const borderLeftWidthProperty = new CssProperty({ borderLeftWidthProperty.register(Style); // Border Radius properties. -const borderRadiusProperty = new ShorthandProperty({ +const borderRadiusProperty = new ShorthandProperty({ name: 'borderRadius', cssName: 'border-radius', getter: function (this: Style) { @@ -1159,7 +1150,7 @@ const borderRadiusProperty = new ShorthandProperty({ }); borderRadiusProperty.register(Style); -export const borderTopLeftRadiusProperty = new CssProperty({ +export const borderTopLeftRadiusProperty = new CssProperty({ name: 'borderTopLeftRadius', cssName: 'border-top-left-radius', defaultValue: 0, @@ -1175,7 +1166,7 @@ export const borderTopLeftRadiusProperty = new CssProperty({ }); borderTopLeftRadiusProperty.register(Style); -export const borderTopRightRadiusProperty = new CssProperty({ +export const borderTopRightRadiusProperty = new CssProperty({ name: 'borderTopRightRadius', cssName: 'border-top-right-radius', defaultValue: 0, @@ -1191,7 +1182,7 @@ export const borderTopRightRadiusProperty = new CssProperty({ }); borderTopRightRadiusProperty.register(Style); -export const borderBottomRightRadiusProperty = new CssProperty({ +export const borderBottomRightRadiusProperty = new CssProperty({ name: 'borderBottomRightRadius', cssName: 'border-bottom-right-radius', defaultValue: 0, @@ -1207,7 +1198,7 @@ export const borderBottomRightRadiusProperty = new CssProperty({ +export const borderBottomLeftRadiusProperty = new CssProperty({ name: 'borderBottomLeftRadius', cssName: 'border-bottom-left-radius', defaultValue: 0, @@ -1423,16 +1414,16 @@ const fontProperty = new ShorthandProperty({ }); fontProperty.register(Style); -export const visibilityProperty = new CssProperty({ +export const visibilityProperty = new CssProperty({ name: 'visibility', cssName: 'visibility', - defaultValue: Enums.Visibility.visible, + defaultValue: CoreTypes.Visibility.visible, affectsLayout: global.isIOS, - valueConverter: Enums.Visibility.parse, + valueConverter: CoreTypes.Visibility.parse, valueChanged: (target, oldValue, newValue) => { const view = target.viewRef.get(); if (view) { - view.isCollapsed = newValue === Enums.Visibility.collapse; + view.isCollapsed = newValue === CoreTypes.Visibility.collapse; } else { Trace.write(`${newValue} not set to view's property because ".viewRef" is cleared`, Trace.categories.Style, Trace.messageType.warn); } diff --git a/packages/core/ui/styling/style/index.ts b/packages/core/ui/styling/style/index.ts index 2ae44c2af..48134afec 100644 --- a/packages/core/ui/styling/style/index.ts +++ b/packages/core/ui/styling/style/index.ts @@ -2,15 +2,13 @@ import { Style as StyleDefinition } from '.'; import { Color } from '../../../color'; import { Font, FontStyle, FontWeight } from '../font'; import { Background } from '../background'; -import { dip } from '../../core/view'; import { ViewBase } from '../../core/view-base'; -import { LengthType, PercentLengthType } from '../../styling/style-properties'; import { LinearGradient } from '../../styling/linear-gradient'; import { Observable } from '../../../data/observable'; import { FlexDirection, FlexWrap, JustifyContent, AlignItems, AlignContent, Order, FlexGrow, FlexShrink, FlexWrapBefore, AlignSelf } from '../../layouts/flexbox-layout'; import { Trace } from '../../../trace'; -import { Enums } from '../../enums'; +import { CoreTypes } from '../../../core-types'; import { AccessibilityLiveRegion, AccessibilityRole, AccessibilityState } from '../../../accessibility/accessibility-types'; import { CSSShadow } from '../css-shadow'; @@ -31,8 +29,8 @@ export interface CommonLayoutParams { rightMarginPercent: number; bottomMarginPercent: number; - horizontalAlignment: Enums.HorizontalAlignmentType; - verticalAlignment: Enums.VerticalAlignmentType; + horizontalAlignment: CoreTypes.HorizontalAlignmentType; + verticalAlignment: CoreTypes.VerticalAlignmentType; } export class Style extends Observable implements StyleDefinition { @@ -109,8 +107,8 @@ export class Style extends Observable implements StyleDefinition { public scaleX: number; public scaleY: number; - public translateX: dip; - public translateY: dip; + public translateX: CoreTypes.dip; + public translateY: CoreTypes.dip; public clipPath: string; public color: Color; @@ -120,7 +118,7 @@ export class Style extends Observable implements StyleDefinition { public background: string; public backgroundColor: Color; public backgroundImage: string | LinearGradient; - public backgroundRepeat: Enums.BackgroundRepeatType; + public backgroundRepeat: CoreTypes.BackgroundRepeatType; public backgroundSize: string; public backgroundPosition: string; @@ -129,16 +127,16 @@ export class Style extends Observable implements StyleDefinition { public borderRightColor: Color; public borderBottomColor: Color; public borderLeftColor: Color; - public borderWidth: string | LengthType; - public borderTopWidth: LengthType; - public borderRightWidth: LengthType; - public borderBottomWidth: LengthType; - public borderLeftWidth: LengthType; - public borderRadius: string | LengthType; - public borderTopLeftRadius: LengthType; - public borderTopRightRadius: LengthType; - public borderBottomRightRadius: LengthType; - public borderBottomLeftRadius: LengthType; + public borderWidth: string | CoreTypes.LengthType; + public borderTopWidth: CoreTypes.LengthType; + public borderRightWidth: CoreTypes.LengthType; + public borderBottomWidth: CoreTypes.LengthType; + public borderLeftWidth: CoreTypes.LengthType; + public borderRadius: string | CoreTypes.LengthType; + public borderTopLeftRadius: CoreTypes.LengthType; + public borderTopRightRadius: CoreTypes.LengthType; + public borderBottomRightRadius: CoreTypes.LengthType; + public borderBottomLeftRadius: CoreTypes.LengthType; public boxShadow: CSSShadow; @@ -152,32 +150,32 @@ export class Style extends Observable implements StyleDefinition { public androidDynamicElevationOffset: number; public zIndex: number; public opacity: number; - public visibility: Enums.VisibilityType; + public visibility: CoreTypes.VisibilityType; public letterSpacing: number; public lineHeight: number; - public textAlignment: Enums.TextAlignmentType; - public textDecoration: Enums.TextDecorationType; - public textTransform: Enums.TextTransformType; + public textAlignment: CoreTypes.TextAlignmentType; + public textDecoration: CoreTypes.TextDecorationType; + public textTransform: CoreTypes.TextTransformType; public textShadow: CSSShadow; - public whiteSpace: Enums.WhiteSpaceType; + public whiteSpace: CoreTypes.WhiteSpaceType; - public minWidth: LengthType; - public minHeight: LengthType; - public width: PercentLengthType; - public height: PercentLengthType; - public margin: string | PercentLengthType; - public marginLeft: PercentLengthType; - public marginTop: PercentLengthType; - public marginRight: PercentLengthType; - public marginBottom: PercentLengthType; - public padding: string | LengthType; - public paddingLeft: LengthType; - public paddingTop: LengthType; - public paddingRight: LengthType; - public paddingBottom: LengthType; - public horizontalAlignment: Enums.HorizontalAlignmentType; - public verticalAlignment: Enums.VerticalAlignmentType; + public minWidth: CoreTypes.LengthType; + public minHeight: CoreTypes.LengthType; + public width: CoreTypes.PercentLengthType; + public height: CoreTypes.PercentLengthType; + public margin: string | CoreTypes.PercentLengthType; + public marginLeft: CoreTypes.PercentLengthType; + public marginTop: CoreTypes.PercentLengthType; + public marginRight: CoreTypes.PercentLengthType; + public marginBottom: CoreTypes.PercentLengthType; + public padding: string | CoreTypes.LengthType; + public paddingLeft: CoreTypes.LengthType; + public paddingTop: CoreTypes.LengthType; + public paddingRight: CoreTypes.LengthType; + public paddingBottom: CoreTypes.LengthType; + public horizontalAlignment: CoreTypes.HorizontalAlignmentType; + public verticalAlignment: CoreTypes.VerticalAlignmentType; // TabView-specific props public tabTextFontSize: number; @@ -197,9 +195,9 @@ export class Style extends Observable implements StyleDefinition { public androidStatusBarBackground: Color; // ActionBar-specific props - public androidContentInset: string | LengthType; - public androidContentInsetLeft: LengthType; - public androidContentInsetRight: LengthType; + public androidContentInset: string | CoreTypes.LengthType; + public androidContentInsetLeft: CoreTypes.LengthType; + public androidContentInsetRight: CoreTypes.LengthType; //flexbox layout properties public flexDirection: FlexDirection; diff --git a/packages/core/ui/tab-view/index.android.ts b/packages/core/ui/tab-view/index.android.ts index 40ab0c65f..cb00f1d16 100644 --- a/packages/core/ui/tab-view/index.android.ts +++ b/packages/core/ui/tab-view/index.android.ts @@ -3,7 +3,7 @@ import { Font } from '../styling/font'; import { TabViewBase, TabViewItemBase, itemsProperty, selectedIndexProperty, tabTextColorProperty, tabBackgroundColorProperty, tabTextFontSizeProperty, selectedTabTextColorProperty, androidSelectedTabHighlightColorProperty, androidOffscreenTabLimitProperty, traceCategory, traceMissingIcon } from './tab-view-common'; import { textTransformProperty, getTransformedText } from '../text-base'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { ImageSource } from '../../image-source'; import { Trace } from '../../trace'; import { Color } from '../../color'; @@ -407,7 +407,7 @@ export class TabViewItem extends TabViewItemBase { [textTransformProperty.getDefault](): 'default' { return 'default'; } - [textTransformProperty.setNative](value: Enums.TextTransformType | 'default') { + [textTransformProperty.setNative](value: CoreTypes.TextTransformType | 'default') { const tv = this.nativeViewProtected; if (value === 'default') { tv.setTransformationMethod(this._defaultTransformationMethod); diff --git a/packages/core/ui/tab-view/index.ios.ts b/packages/core/ui/tab-view/index.ios.ts index 1f39fe920..82741cb9a 100644 --- a/packages/core/ui/tab-view/index.ios.ts +++ b/packages/core/ui/tab-view/index.ios.ts @@ -8,7 +8,7 @@ import { Color } from '../../color'; import { Trace } from '../../trace'; import { fontInternalProperty } from '../styling/style-properties'; import { textTransformProperty, getTransformedText } from '../text-base'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { ImageSource } from '../../image-source'; import { profile } from '../../profiling'; import { Frame } from '../frame'; @@ -280,7 +280,7 @@ export class TabViewItem extends TabViewItemBase { updateTitleAndIconPositions(this, this.__controller.tabBarItem, this.__controller); } - [textTransformProperty.setNative](value: Enums.TextTransformType) { + [textTransformProperty.setNative](value: CoreTypes.TextTransformType) { this._update(); } } diff --git a/packages/core/ui/tab-view/tab-view-common.ts b/packages/core/ui/tab-view/tab-view-common.ts index 3bc04b958..0639c8273 100644 --- a/packages/core/ui/tab-view/tab-view-common.ts +++ b/packages/core/ui/tab-view/tab-view-common.ts @@ -5,7 +5,7 @@ import { Style } from '../styling/style'; import { EventData } from '../../data/observable'; import { Color } from '../../color'; import { Property, CssProperty, CoercibleProperty } from '../core/properties'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { Trace } from '../../trace'; export const traceCategory = 'TabView'; @@ -16,10 +16,10 @@ export abstract class TabViewItemBase extends ViewBase implements TabViewItemDef private _view: View; private _iconSource: string; - get textTransform(): Enums.TextTransformType { + get textTransform(): CoreTypes.TextTransformType { return this.style.textTransform; } - set textTransform(value: Enums.TextTransformType) { + set textTransform(value: CoreTypes.TextTransformType) { this.style.textTransform = value; } diff --git a/packages/core/ui/text-base/formatted-string.d.ts b/packages/core/ui/text-base/formatted-string.d.ts index 1c2745d22..6eb1ff90a 100644 --- a/packages/core/ui/text-base/formatted-string.d.ts +++ b/packages/core/ui/text-base/formatted-string.d.ts @@ -7,7 +7,7 @@ import { ObservableArray } from '../../data/observable-array'; import { ViewBase } from '../core/view-base'; import { Color } from '../../color'; import { FontStyle, FontWeight } from '../styling/font'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; /** * A class used to create a formatted (rich text) string. @@ -46,7 +46,7 @@ export class FormattedString extends ViewBase { /** * Gets or sets text decorations which will be used for all spans that doesn't have a specific value. */ - public textDecoration: Enums.TextDecorationType; + public textDecoration: CoreTypes.TextDecorationType; /** * Gets or sets the font foreground color which will be used for all spans that doesn't have a specific value. diff --git a/packages/core/ui/text-base/formatted-string.ts b/packages/core/ui/text-base/formatted-string.ts index 5f5c43451..f18d678ea 100644 --- a/packages/core/ui/text-base/formatted-string.ts +++ b/packages/core/ui/text-base/formatted-string.ts @@ -6,7 +6,7 @@ import { AddArrayFromBuilder, AddChildFromBuilder } from '../core/view'; import { ViewBase } from '../core/view-base'; import { Color } from '../../color'; import { FontStyle, FontWeight } from '../styling/font'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; export class FormattedString extends ViewBase implements FormattedStringDefinition, AddArrayFromBuilder, AddChildFromBuilder { private _spans: ObservableArray; @@ -45,10 +45,10 @@ export class FormattedString extends ViewBase implements FormattedStringDefiniti this.style.fontWeight = value; } - get textDecoration(): Enums.TextDecorationType { + get textDecoration(): CoreTypes.TextDecorationType { return this.style.textDecoration; } - set textDecoration(value: Enums.TextDecorationType) { + set textDecoration(value: CoreTypes.TextDecorationType) { this.style.textDecoration = value; } diff --git a/packages/core/ui/text-base/index.android.ts b/packages/core/ui/text-base/index.android.ts index 8ef522e50..f405d7cee 100644 --- a/packages/core/ui/text-base/index.android.ts +++ b/packages/core/ui/text-base/index.android.ts @@ -7,10 +7,10 @@ import { Font } from '../styling/font'; import { backgroundColorProperty } from '../styling/style-properties'; import { TextBaseCommon, formattedTextProperty, textAlignmentProperty, textDecorationProperty, textProperty, textTransformProperty, textShadowProperty, letterSpacingProperty, whiteSpaceProperty, lineHeightProperty, isBold, resetSymbol } from './text-base-common'; import { Color } from '../../color'; -import { colorProperty, fontSizeProperty, fontInternalProperty, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length, LengthType } from '../styling/style-properties'; +import { colorProperty, fontSizeProperty, fontInternalProperty, paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length } from '../styling/style-properties'; import { FormattedString } from './formatted-string'; import { Span } from './span'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { layout } from '../../utils'; import { isString, isNullOrUndefined } from '../../utils/types'; @@ -95,7 +95,7 @@ function initializeClickableSpan(): void { } interface BaselineAdjustedSpan { - new (fontSize: number, align?: Enums.VerticalAlignmentTextType): android.text.style.MetricAffectingSpan; + new (fontSize: number, align?: CoreTypes.VerticalAlignmentTextType): android.text.style.MetricAffectingSpan; } let BaselineAdjustedSpan: BaselineAdjustedSpan; @@ -107,9 +107,9 @@ function initializeBaselineAdjustedSpan(): void { @NativeClass class BaselineAdjustedSpanImpl extends android.text.style.MetricAffectingSpan { fontSize: number; - align: Enums.VerticalAlignmentTextType = 'baseline'; + align: CoreTypes.VerticalAlignmentTextType = 'baseline'; - constructor(fontSize: number, align?: Enums.VerticalAlignmentTextType) { + constructor(fontSize: number, align?: CoreTypes.VerticalAlignmentTextType) { super(); this.align = align; @@ -261,7 +261,7 @@ export class TextBase extends TextBaseCommon { } } - [textTransformProperty.setNative](value: Enums.TextTransformType) { + [textTransformProperty.setNative](value: CoreTypes.TextTransformType) { if (value === 'initial') { this.nativeTextViewProtected.setTransformationMethod(this._defaultTransformationMethod); @@ -276,10 +276,10 @@ export class TextBase extends TextBaseCommon { this.nativeTextViewProtected.setTransformationMethod(new TextTransformation(this)); } - [textAlignmentProperty.getDefault](): Enums.TextAlignmentType { + [textAlignmentProperty.getDefault](): CoreTypes.TextAlignmentType { return 'initial'; } - [textAlignmentProperty.setNative](value: Enums.TextAlignmentType) { + [textAlignmentProperty.setNative](value: CoreTypes.TextAlignmentType) { const verticalGravity = this.nativeTextViewProtected.getGravity() & android.view.Gravity.VERTICAL_GRAVITY_MASK; switch (value) { case 'initial': @@ -299,7 +299,7 @@ export class TextBase extends TextBaseCommon { // Overridden in TextField because setSingleLine(false) will remove methodTransformation. // and we don't want to allow TextField to be multiline - [whiteSpaceProperty.setNative](value: Enums.WhiteSpaceType) { + [whiteSpaceProperty.setNative](value: CoreTypes.WhiteSpaceType) { const nativeView = this.nativeTextViewProtected; switch (value) { case 'initial': @@ -360,7 +360,7 @@ export class TextBase extends TextBaseCommon { return (this._paintFlags = this.nativeTextViewProtected.getPaintFlags()); } - [textDecorationProperty.setNative](value: number | Enums.TextDecorationType) { + [textDecorationProperty.setNative](value: number | CoreTypes.TextDecorationType) { switch (value) { case 'none': this.nativeTextViewProtected.setPaintFlags(0); @@ -400,31 +400,31 @@ export class TextBase extends TextBaseCommon { org.nativescript.widgets.ViewHelper.setLetterspacing(this.nativeTextViewProtected, value); } - [paddingTopProperty.getDefault](): LengthType { + [paddingTopProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingTop, unit: 'px' }; } - [paddingTopProperty.setNative](value: LengthType) { + [paddingTopProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingTop(this.nativeTextViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderTopWidth, 0)); } - [paddingRightProperty.getDefault](): LengthType { + [paddingRightProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingRight, unit: 'px' }; } - [paddingRightProperty.setNative](value: LengthType) { + [paddingRightProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingRight(this.nativeTextViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderRightWidth, 0)); } - [paddingBottomProperty.getDefault](): LengthType { + [paddingBottomProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingBottom, unit: 'px' }; } - [paddingBottomProperty.setNative](value: LengthType) { + [paddingBottomProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingBottom(this.nativeTextViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderBottomWidth, 0)); } - [paddingLeftProperty.getDefault](): LengthType { + [paddingLeftProperty.getDefault](): CoreTypes.LengthType { return { value: this._defaultPaddingLeft, unit: 'px' }; } - [paddingLeftProperty.setNative](value: LengthType) { + [paddingLeftProperty.setNative](value: CoreTypes.LengthType) { org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeTextViewProtected, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0)); } @@ -471,7 +471,7 @@ function getCapitalizedString(str: string): string { return newWords.join(' '); } -export function getTransformedText(text: string, textTransform: Enums.TextTransformType): string { +export function getTransformedText(text: string, textTransform: CoreTypes.TextTransformType): string { if (!text || !isString(text)) { return ''; } @@ -567,7 +567,7 @@ function setSpanModifiers(ssb: android.text.SpannableStringBuilder, span: Span, ssb.setSpan(new android.text.style.BackgroundColorSpan(backgroundColor.android), start, end, android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } - const textDecoration: Enums.TextDecorationType = getClosestPropertyValue(textDecorationProperty, span); + const textDecoration: CoreTypes.TextDecorationType = getClosestPropertyValue(textDecorationProperty, span); if (textDecoration) { const underline = textDecoration.indexOf('underline') !== -1; diff --git a/packages/core/ui/text-base/index.d.ts b/packages/core/ui/text-base/index.d.ts index 8dc350b34..f2463ced7 100644 --- a/packages/core/ui/text-base/index.d.ts +++ b/packages/core/ui/text-base/index.d.ts @@ -3,7 +3,7 @@ import { FormattedString } from './formatted-string'; import { Style } from '../styling/style'; import { Length } from '../styling/style-properties'; import { Property, CssProperty, InheritedCssProperty } from '../core/properties'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { CSSShadow } from '../styling/css-shadow'; export class TextBase extends View implements AddChildFromBuilder { @@ -41,17 +41,17 @@ export class TextBase extends View implements AddChildFromBuilder { /** * Gets or sets text-alignment style property. */ - textAlignment: Enums.TextAlignmentType; + textAlignment: CoreTypes.TextAlignmentType; /** * Gets or sets text decorations style property. */ - textDecoration: Enums.TextDecorationType; + textDecoration: CoreTypes.TextDecorationType; /** * Gets or sets text transform style property. */ - textTransform: Enums.TextTransformType; + textTransform: CoreTypes.TextTransformType; /** * Gets or sets text shadow style property. @@ -61,7 +61,7 @@ export class TextBase extends View implements AddChildFromBuilder { /** * Gets or sets white space style property. */ - whiteSpace: Enums.WhiteSpaceType; + whiteSpace: CoreTypes.WhiteSpaceType; /** * Gets or sets padding style property. @@ -123,15 +123,15 @@ export interface TextTransformation { export const textProperty: Property; export const formattedTextProperty: Property; -export const textAlignmentProperty: InheritedCssProperty; -export const textDecorationProperty: CssProperty; -export const textTransformProperty: CssProperty; +export const textAlignmentProperty: InheritedCssProperty; +export const textDecorationProperty: CssProperty; +export const textTransformProperty: CssProperty; export const textShadowProperty: CssProperty; -export const whiteSpaceProperty: CssProperty; +export const whiteSpaceProperty: CssProperty; export const letterSpacingProperty: CssProperty; export const lineHeightProperty: CssProperty; //Used by tab view -export function getTransformedText(text: string, textTransform: Enums.TextTransformType): string; +export function getTransformedText(text: string, textTransform: CoreTypes.TextTransformType): string; export const resetSymbol: symbol; diff --git a/packages/core/ui/text-base/index.ios.ts b/packages/core/ui/text-base/index.ios.ts index f984900fc..febe06304 100644 --- a/packages/core/ui/text-base/index.ios.ts +++ b/packages/core/ui/text-base/index.ios.ts @@ -12,7 +12,7 @@ import { colorProperty, fontInternalProperty, Length } from '../styling/style-pr import { isString, isNullOrUndefined } from '../../utils/types'; import { iOSNativeHelper } from '../../utils'; import { Trace } from '../../trace'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; export * from './text-base-common'; @@ -158,7 +158,7 @@ export class TextBase extends TextBaseCommon { } } - [textAlignmentProperty.setNative](value: Enums.TextAlignmentType) { + [textAlignmentProperty.setNative](value: CoreTypes.TextAlignmentType) { const nativeView = this.nativeTextViewProtected; switch (value) { case 'initial': @@ -174,11 +174,11 @@ export class TextBase extends TextBaseCommon { } } - [textDecorationProperty.setNative](value: Enums.TextDecorationType) { + [textDecorationProperty.setNative](value: CoreTypes.TextDecorationType) { this._setNativeText(); } - [textTransformProperty.setNative](value: Enums.TextTransformType) { + [textTransformProperty.setNative](value: CoreTypes.TextTransformType) { this._setNativeText(); } @@ -410,7 +410,7 @@ export class TextBase extends TextBaseCommon { return mas; } - getBaselineOffset(font: UIFont, align?: Enums.VerticalAlignmentTextType): number { + getBaselineOffset(font: UIFont, align?: CoreTypes.VerticalAlignmentTextType): number { if (!align || ['stretch', 'baseline'].includes(align)) { return 0; } @@ -465,7 +465,7 @@ export class TextBase extends TextBaseCommon { attrDict[NSBackgroundColorAttributeName] = backgroundColor.ios; } - const textDecoration: Enums.TextDecorationType = getClosestPropertyValue(textDecorationProperty, span); + const textDecoration: CoreTypes.TextDecorationType = getClosestPropertyValue(textDecorationProperty, span); if (textDecoration) { const underline = textDecoration.indexOf('underline') !== -1; @@ -487,7 +487,7 @@ export class TextBase extends TextBaseCommon { } } -export function getTransformedText(text: string, textTransform: Enums.TextTransformType): string { +export function getTransformedText(text: string, textTransform: CoreTypes.TextTransformType): string { if (!text || !isString(text)) { return ''; } diff --git a/packages/core/ui/text-base/span.d.ts b/packages/core/ui/text-base/span.d.ts index dd8478538..e77b2c79d 100644 --- a/packages/core/ui/text-base/span.d.ts +++ b/packages/core/ui/text-base/span.d.ts @@ -1,7 +1,7 @@ import { Color } from '../../color'; import { ViewBase } from '../core/view-base'; import { FontStyle, FontWeight } from '../styling/font'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; /** * A class used to create a single part of formatted string with a common text properties. @@ -30,7 +30,7 @@ export class Span extends ViewBase { /** * Gets or sets text decorations for the span. */ - public textDecoration: Enums.TextDecorationType; + public textDecoration: CoreTypes.TextDecorationType; /** * Gets or sets the font foreground color of the span. diff --git a/packages/core/ui/text-base/span.ts b/packages/core/ui/text-base/span.ts index f4fc8ceb8..fed0202ff 100644 --- a/packages/core/ui/text-base/span.ts +++ b/packages/core/ui/text-base/span.ts @@ -2,7 +2,7 @@ import { Span as SpanDefinition } from './span'; import { ViewBase } from '../core/view-base'; import { FontStyle, FontWeight } from '../styling/font'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { EventData } from '../../data/observable'; import { isNullOrUndefined, isString } from '../../utils/types'; @@ -41,10 +41,10 @@ export class Span extends ViewBase implements SpanDefinition { this.style.fontWeight = value; } - get textDecoration(): Enums.TextDecorationType { + get textDecoration(): CoreTypes.TextDecorationType { return this.style.textDecoration; } - set textDecoration(value: Enums.TextDecorationType) { + set textDecoration(value: CoreTypes.TextDecorationType) { this.style.textDecoration = value; } diff --git a/packages/core/ui/text-base/text-base-common.ts b/packages/core/ui/text-base/text-base-common.ts index 9e375d974..b3b0b941d 100644 --- a/packages/core/ui/text-base/text-base-common.ts +++ b/packages/core/ui/text-base/text-base-common.ts @@ -9,9 +9,8 @@ import { Span } from './span'; import { View } from '../core/view'; import { Property, CssProperty, InheritedCssProperty, makeValidator, makeParser } from '../core/properties'; import { Style } from '../styling/style'; -import { Length, LengthType } from '../styling/style-properties'; import { Observable } from '../../data/observable'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; import { TextBase as TextBaseDefinition } from '.'; import { Color } from '../../color'; import { CSSShadow, parseCSSShadow } from '../styling/css-shadow'; @@ -91,24 +90,24 @@ export abstract class TextBaseCommon extends View implements TextBaseDefinition this.style.lineHeight = value; } - get textAlignment(): Enums.TextAlignmentType { + get textAlignment(): CoreTypes.TextAlignmentType { return this.style.textAlignment; } - set textAlignment(value: Enums.TextAlignmentType) { + set textAlignment(value: CoreTypes.TextAlignmentType) { this.style.textAlignment = value; } - get textDecoration(): Enums.TextDecorationType { + get textDecoration(): CoreTypes.TextDecorationType { return this.style.textDecoration; } - set textDecoration(value: Enums.TextDecorationType) { + set textDecoration(value: CoreTypes.TextDecorationType) { this.style.textDecoration = value; } - get textTransform(): Enums.TextTransformType { + get textTransform(): CoreTypes.TextTransformType { return this.style.textTransform; } - set textTransform(value: Enums.TextTransformType) { + set textTransform(value: CoreTypes.TextTransformType) { this.style.textTransform = value; } @@ -119,45 +118,45 @@ export abstract class TextBaseCommon extends View implements TextBaseDefinition this.style.textShadow = value; } - get whiteSpace(): Enums.WhiteSpaceType { + get whiteSpace(): CoreTypes.WhiteSpaceType { return this.style.whiteSpace; } - set whiteSpace(value: Enums.WhiteSpaceType) { + set whiteSpace(value: CoreTypes.WhiteSpaceType) { this.style.whiteSpace = value; } - get padding(): string | LengthType { + get padding(): string | CoreTypes.LengthType { return this.style.padding; } - set padding(value: string | LengthType) { + set padding(value: string | CoreTypes.LengthType) { this.style.padding = value; } - get paddingTop(): LengthType { + get paddingTop(): CoreTypes.LengthType { return this.style.paddingTop; } - set paddingTop(value: LengthType) { + set paddingTop(value: CoreTypes.LengthType) { this.style.paddingTop = value; } - get paddingRight(): LengthType { + get paddingRight(): CoreTypes.LengthType { return this.style.paddingRight; } - set paddingRight(value: LengthType) { + set paddingRight(value: CoreTypes.LengthType) { this.style.paddingRight = value; } - get paddingBottom(): LengthType { + get paddingBottom(): CoreTypes.LengthType { return this.style.paddingBottom; } - set paddingBottom(value: LengthType) { + set paddingBottom(value: CoreTypes.LengthType) { this.style.paddingBottom = value; } - get paddingLeft(): LengthType { + get paddingLeft(): CoreTypes.LengthType { return this.style.paddingLeft; } - set paddingLeft(value: LengthType) { + set paddingLeft(value: CoreTypes.LengthType) { this.style.paddingLeft = value; } @@ -247,8 +246,8 @@ export function getClosestPropertyValue(property: CssProperty, span: } } -const textAlignmentConverter = makeParser(makeValidator('initial', 'left', 'center', 'right')); -export const textAlignmentProperty = new InheritedCssProperty({ +const textAlignmentConverter = makeParser(makeValidator('initial', 'left', 'center', 'right')); +export const textAlignmentProperty = new InheritedCssProperty({ name: 'textAlignment', cssName: 'text-align', defaultValue: 'initial', @@ -256,8 +255,8 @@ export const textAlignmentProperty = new InheritedCssProperty(makeValidator('initial', 'none', 'capitalize', 'uppercase', 'lowercase')); -export const textTransformProperty = new CssProperty({ +const textTransformConverter = makeParser(makeValidator('initial', 'none', 'capitalize', 'uppercase', 'lowercase')); +export const textTransformProperty = new CssProperty({ name: 'textTransform', cssName: 'text-transform', defaultValue: 'initial', @@ -275,8 +274,8 @@ export const textShadowProperty = new CssProperty({ }); textShadowProperty.register(Style); -const whiteSpaceConverter = makeParser(makeValidator('initial', 'normal', 'nowrap')); -export const whiteSpaceProperty = new CssProperty({ +const whiteSpaceConverter = makeParser(makeValidator('initial', 'normal', 'nowrap')); +export const whiteSpaceProperty = new CssProperty({ name: 'whiteSpace', cssName: 'white-space', defaultValue: 'initial', @@ -285,8 +284,8 @@ export const whiteSpaceProperty = new CssProperty({ }); whiteSpaceProperty.register(Style); -const textDecorationConverter = makeParser(makeValidator('none', 'underline', 'line-through', 'underline line-through')); -export const textDecorationProperty = new CssProperty({ +const textDecorationConverter = makeParser(makeValidator('none', 'underline', 'line-through', 'underline line-through')); +export const textDecorationProperty = new CssProperty({ name: 'textDecoration', cssName: 'text-decoration', defaultValue: 'none', diff --git a/packages/core/ui/text-field/index.android.ts b/packages/core/ui/text-field/index.android.ts index 62b5956d5..c08f82368 100644 --- a/packages/core/ui/text-field/index.android.ts +++ b/packages/core/ui/text-field/index.android.ts @@ -1,7 +1,7 @@ import { TextFieldBase, secureProperty } from './text-field-common'; import { whiteSpaceProperty } from '../text-base'; import { keyboardTypeProperty } from '../editable-text-base'; -import { Enums } from '../enums'; +import { CoreTypes } from '../../core-types'; export * from './text-field-common'; @@ -97,10 +97,10 @@ export class TextField extends TextFieldBase { this._setInputType(inputType); } - [whiteSpaceProperty.getDefault](): Enums.WhiteSpaceType { + [whiteSpaceProperty.getDefault](): CoreTypes.WhiteSpaceType { return 'nowrap'; } - [whiteSpaceProperty.setNative](value: Enums.WhiteSpaceType) { + [whiteSpaceProperty.setNative](value: CoreTypes.WhiteSpaceType) { // Don't change it otherwise TextField will go to multiline mode. } } diff --git a/packages/core/ui/text-field/index.ios.ts b/packages/core/ui/text-field/index.ios.ts index c69fc0b1a..2b188b866 100644 --- a/packages/core/ui/text-field/index.ios.ts +++ b/packages/core/ui/text-field/index.ios.ts @@ -1,14 +1,15 @@ import { TextFieldBase, secureProperty } from './text-field-common'; import { textProperty } from '../text-base'; import { hintProperty, placeholderColorProperty, _updateCharactersInRangeReplacementString } from '../editable-text-base'; +import { CoreTypes } from '../../core-types'; import { Color } from '../../color'; -import { colorProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, LengthType } from '../styling/style-properties'; +import { colorProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty } from '../styling/style-properties'; import { layout } from '../../utils'; import { profile } from '../../profiling'; export * from './text-field-common'; -const zeroLength: LengthType = { +const zeroLength: CoreTypes.LengthType = { value: 0, unit: 'px', }; @@ -284,31 +285,31 @@ export class TextField extends TextFieldBase { this.nativeTextViewProtected.attributedPlaceholder = attributedPlaceholder; } - [paddingTopProperty.getDefault](): LengthType { + [paddingTopProperty.getDefault](): CoreTypes.LengthType { return zeroLength; } - [paddingTopProperty.setNative](value: LengthType) { + [paddingTopProperty.setNative](value: CoreTypes.LengthType) { // Padding is realized via UITextFieldImpl.textRectForBounds method } - [paddingRightProperty.getDefault](): LengthType { + [paddingRightProperty.getDefault](): CoreTypes.LengthType { return zeroLength; } - [paddingRightProperty.setNative](value: LengthType) { + [paddingRightProperty.setNative](value: CoreTypes.LengthType) { // Padding is realized via UITextFieldImpl.textRectForBounds method } - [paddingBottomProperty.getDefault](): LengthType { + [paddingBottomProperty.getDefault](): CoreTypes.LengthType { return zeroLength; } - [paddingBottomProperty.setNative](value: LengthType) { + [paddingBottomProperty.setNative](value: CoreTypes.LengthType) { // Padding is realized via UITextFieldImpl.textRectForBounds method } - [paddingLeftProperty.getDefault](): LengthType { + [paddingLeftProperty.getDefault](): CoreTypes.LengthType { return zeroLength; } - [paddingLeftProperty.setNative](value: LengthType) { + [paddingLeftProperty.setNative](value: CoreTypes.LengthType) { // Padding is realized via UITextFieldImpl.textRectForBounds method } } diff --git a/packages/core/ui/text-view/index.ios.ts b/packages/core/ui/text-view/index.ios.ts index 939afc428..8385e1baf 100644 --- a/packages/core/ui/text-view/index.ios.ts +++ b/packages/core/ui/text-view/index.ios.ts @@ -2,9 +2,10 @@ import { ScrollEventData } from '../scroll-view'; import { textProperty } from '../text-base'; import { TextViewBase as TextViewBaseCommon, maxLinesProperty } from './text-view-common'; import { editableProperty, hintProperty, placeholderColorProperty, _updateCharactersInRangeReplacementString } from '../editable-text-base'; +import { CoreTypes } from '../../core-types'; import { CSSType } from '../core/view'; import { Color } from '../../color'; -import { colorProperty, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, Length, LengthType } from '../styling/style-properties'; +import { colorProperty, borderTopWidthProperty, borderRightWidthProperty, borderBottomWidthProperty, borderLeftWidthProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, paddingLeftProperty, Length } from '../styling/style-properties'; import { iOSNativeHelper, layout } from '../../utils'; import { profile } from '../../profiling'; @@ -269,13 +270,13 @@ export class TextView extends TextViewBaseCommon { this._refreshColor(); } - [borderTopWidthProperty.getDefault](): LengthType { + [borderTopWidthProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeTextViewProtected.textContainerInset.top, unit: 'px', }; } - [borderTopWidthProperty.setNative](value: LengthType) { + [borderTopWidthProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeTextViewProtected.textContainerInset; const top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth); this.nativeTextViewProtected.textContainerInset = { @@ -286,13 +287,13 @@ export class TextView extends TextViewBaseCommon { }; } - [borderRightWidthProperty.getDefault](): LengthType { + [borderRightWidthProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeTextViewProtected.textContainerInset.right, unit: 'px', }; } - [borderRightWidthProperty.setNative](value: LengthType) { + [borderRightWidthProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeTextViewProtected.textContainerInset; const right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth); this.nativeTextViewProtected.textContainerInset = { @@ -303,13 +304,13 @@ export class TextView extends TextViewBaseCommon { }; } - [borderBottomWidthProperty.getDefault](): LengthType { + [borderBottomWidthProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeTextViewProtected.textContainerInset.bottom, unit: 'px', }; } - [borderBottomWidthProperty.setNative](value: LengthType) { + [borderBottomWidthProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeTextViewProtected.textContainerInset; const bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth); this.nativeTextViewProtected.textContainerInset = { @@ -320,13 +321,13 @@ export class TextView extends TextViewBaseCommon { }; } - [borderLeftWidthProperty.getDefault](): LengthType { + [borderLeftWidthProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeTextViewProtected.textContainerInset.left, unit: 'px', }; } - [borderLeftWidthProperty.setNative](value: LengthType) { + [borderLeftWidthProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeTextViewProtected.textContainerInset; const left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth); this.nativeTextViewProtected.textContainerInset = { @@ -337,13 +338,13 @@ export class TextView extends TextViewBaseCommon { }; } - [paddingTopProperty.getDefault](): LengthType { + [paddingTopProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeTextViewProtected.textContainerInset.top, unit: 'px', }; } - [paddingTopProperty.setNative](value: LengthType) { + [paddingTopProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeTextViewProtected.textContainerInset; const top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth); this.nativeTextViewProtected.textContainerInset = { @@ -354,13 +355,13 @@ export class TextView extends TextViewBaseCommon { }; } - [paddingRightProperty.getDefault](): LengthType { + [paddingRightProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeTextViewProtected.textContainerInset.right, unit: 'px', }; } - [paddingRightProperty.setNative](value: LengthType) { + [paddingRightProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeTextViewProtected.textContainerInset; const right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth); this.nativeTextViewProtected.textContainerInset = { @@ -371,13 +372,13 @@ export class TextView extends TextViewBaseCommon { }; } - [paddingBottomProperty.getDefault](): LengthType { + [paddingBottomProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeTextViewProtected.textContainerInset.bottom, unit: 'px', }; } - [paddingBottomProperty.setNative](value: LengthType) { + [paddingBottomProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeTextViewProtected.textContainerInset; const bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth); this.nativeTextViewProtected.textContainerInset = { @@ -387,13 +388,13 @@ export class TextView extends TextViewBaseCommon { right: inset.right, }; } - [paddingLeftProperty.getDefault](): LengthType { + [paddingLeftProperty.getDefault](): CoreTypes.LengthType { return { value: this.nativeTextViewProtected.textContainerInset.left, unit: 'px', }; } - [paddingLeftProperty.setNative](value: LengthType) { + [paddingLeftProperty.setNative](value: CoreTypes.LengthType) { const inset = this.nativeTextViewProtected.textContainerInset; const left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth); this.nativeTextViewProtected.textContainerInset = {