From c08d85ebae8ab7fcd9d51ab855931af2e053c5d9 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sat, 25 Jul 2020 19:38:13 -0700 Subject: [PATCH] chore: cleanup for es2017 build --- package.json | 2 +- packages/core-compat/package.json | 2 +- .../core/application/application-common.ts | 16 +-- packages/core/application/index.ios.ts | 18 +-- packages/core/css/system-classes.d.ts | 105 +++++++++--------- packages/core/css/system-classes.ts | 66 +++++------ packages/core/index.d.ts | 5 +- packages/core/index.ts | 6 +- packages/core/package.json | 2 +- packages/core/platform/index.android.ts | 4 +- packages/core/ui/core/view-base/index.ts | 12 +- packages/core/ui/core/view/view-common.ts | 6 +- .../ui/core/view/view-helper/index.ios.ts | 8 +- packages/core/ui/frame/activity.android.ts | 26 +++-- packages/core/ui/frame/index.android.ts | 25 +++-- packages/core/ui/index.d.ts | 2 +- packages/core/ui/index.ts | 3 +- .../core/ui/styling/style-properties.d.ts | 3 + 18 files changed, 169 insertions(+), 142 deletions(-) diff --git a/package.json b/package.json index fbd35c7ca..db6f99a38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "7.0.0-rc.24", + "version": "7.0.0-rc.25", "license": "MIT", "scripts": { "start": "nps" diff --git a/packages/core-compat/package.json b/packages/core-compat/package.json index e5b396d42..45bc6dd7b 100644 --- a/packages/core-compat/package.json +++ b/packages/core-compat/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "Compatibility with old style tns-core-modules imports for NativeScript.", - "version": "7.0.0-rc.24", + "version": "7.0.0-rc.25", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/core/application/application-common.ts b/packages/core/application/application-common.ts index 7087ad393..d149a03ec 100644 --- a/packages/core/application/application-common.ts +++ b/packages/core/application/application-common.ts @@ -15,8 +15,8 @@ import { View } from '../ui/core/view'; import { Observable } from '../data/observable'; import { trace as profilingTrace, time, uptime, level as profilingLevel } from '../profiling'; import * as bindableResources from '../ui/core/bindable/bindable-resources'; -import { CLASS_PREFIX, pushToSystemCssClasses, removeSystemCssClass } from '../css/system-classes'; -import { DeviceOrientation, SystemAppearance } from '../ui/enums'; +import { CSSUtils } from '../css/system-classes'; +import { Enums } from '../ui/enums'; export * from './application-interfaces'; @@ -52,9 +52,9 @@ export const discardedErrorEvent = 'discardedError'; export const orientationChangedEvent = 'orientationChanged'; export const systemAppearanceChangedEvent = 'systemAppearanceChanged'; -const ORIENTATION_CSS_CLASSES = [`${CLASS_PREFIX}${DeviceOrientation.portrait}`, `${CLASS_PREFIX}${DeviceOrientation.landscape}`, `${CLASS_PREFIX}${DeviceOrientation.unknown}`]; +const ORIENTATION_CSS_CLASSES = [`${CSSUtils.CLASS_PREFIX}${Enums.DeviceOrientation.portrait}`, `${CSSUtils.CLASS_PREFIX}${Enums.DeviceOrientation.landscape}`, `${CSSUtils.CLASS_PREFIX}${Enums.DeviceOrientation.unknown}`]; -const SYSTEM_APPEARANCE_CSS_CLASSES = [`${CLASS_PREFIX}${SystemAppearance.light}`, `${CLASS_PREFIX}${SystemAppearance.dark}`]; +const SYSTEM_APPEARANCE_CSS_CLASSES = [`${CSSUtils.CLASS_PREFIX}${Enums.SystemAppearance.light}`, `${CSSUtils.CLASS_PREFIX}${Enums.SystemAppearance.dark}`]; let cssFile: string = './app.css'; @@ -126,12 +126,12 @@ export function loadAppCss(): void { } function addCssClass(rootView: View, cssClass: string) { - pushToSystemCssClasses(cssClass); + CSSUtils.pushToSystemCssClasses(cssClass); rootView.cssClasses.add(cssClass); } function removeCssClass(rootView: View, cssClass: string) { - removeSystemCssClass(cssClass); + CSSUtils.removeSystemCssClass(cssClass); rootView.cssClasses.delete(cssClass); } @@ -157,7 +157,7 @@ export function orientationChanged(rootView: View, newOrientation: 'portrait' | return; } - const newOrientationCssClass = `${CLASS_PREFIX}${newOrientation}`; + const newOrientationCssClass = `${CSSUtils.CLASS_PREFIX}${newOrientation}`; applyCssClass(rootView, ORIENTATION_CSS_CLASSES, newOrientationCssClass); const rootModalViews = >rootView._getRootModalViews(); @@ -171,7 +171,7 @@ export function systemAppearanceChanged(rootView: View, newSystemAppearance: 'da return; } - const newSystemAppearanceCssClass = `${CLASS_PREFIX}${newSystemAppearance}`; + const newSystemAppearanceCssClass = `${CSSUtils.CLASS_PREFIX}${newSystemAppearance}`; applyCssClass(rootView, SYSTEM_APPEARANCE_CSS_CLASSES, newSystemAppearanceCssClass); const rootModalViews = >rootView._getRootModalViews(); diff --git a/packages/core/application/index.ios.ts b/packages/core/application/index.ios.ts index cb723fbbf..a47e94fd4 100644 --- a/packages/core/application/index.ios.ts +++ b/packages/core/application/index.ios.ts @@ -11,7 +11,7 @@ import { View } from '../ui/core/view'; import { NavigationEntry } from '../ui/frame/frame-interfaces'; // TODO: Remove this and get it from global to decouple builder for angular import { Builder } from '../ui/builder'; -import { CLASS_PREFIX, getSystemCssClasses, pushToSystemCssClasses, ROOT_VIEW_CSS_CLASS } from '../css/system-classes'; +import { CSSUtils } from '../css/system-classes'; import { IOSHelper } from '../ui/core/view/view-helper'; import { Device } from '../platform'; import { profile } from '../profiling'; @@ -362,9 +362,11 @@ function createRootView(v?: View) { if (!mainEntry) { throw new Error('Main entry is missing. App cannot be started. Verify app bootstrap.'); } else { + // console.log('createRootView mainEntry:', mainEntry); rootView = Builder.createViewFromEntry(mainEntry); } } + // console.log('createRootView rootView:', rootView); setRootViewsCssClasses(rootView); @@ -493,19 +495,19 @@ function setViewControllerView(view: View): void { function setRootViewsCssClasses(rootView: View): void { const deviceType = Device.deviceType.toLowerCase(); - pushToSystemCssClasses(`${CLASS_PREFIX}${IOS_PLATFORM}`); - pushToSystemCssClasses(`${CLASS_PREFIX}${deviceType}`); - pushToSystemCssClasses(`${CLASS_PREFIX}${iosApp.orientation}`); + CSSUtils.pushToSystemCssClasses(`${CSSUtils.CLASS_PREFIX}${IOS_PLATFORM}`); + CSSUtils.pushToSystemCssClasses(`${CSSUtils.CLASS_PREFIX}${deviceType}`); + CSSUtils.pushToSystemCssClasses(`${CSSUtils.CLASS_PREFIX}${iosApp.orientation}`); - rootView.cssClasses.add(ROOT_VIEW_CSS_CLASS); - const rootViewCssClasses = getSystemCssClasses(); + rootView.cssClasses.add(CSSUtils.ROOT_VIEW_CSS_CLASS); + const rootViewCssClasses = CSSUtils.getSystemCssClasses(); rootViewCssClasses.forEach((c) => rootView.cssClasses.add(c)); } function setRootViewsSystemAppearanceCssClass(rootView: View): void { if (majorVersion >= 13) { - const systemAppearanceCssClass = `${CLASS_PREFIX}${iosApp.systemAppearance}`; - pushToSystemCssClasses(systemAppearanceCssClass); + const systemAppearanceCssClass = `${CSSUtils.CLASS_PREFIX}${iosApp.systemAppearance}`; + CSSUtils.pushToSystemCssClasses(systemAppearanceCssClass); rootView.cssClasses.add(systemAppearanceCssClass); } } diff --git a/packages/core/css/system-classes.d.ts b/packages/core/css/system-classes.d.ts index 91d1b7a07..62154ca51 100644 --- a/packages/core/css/system-classes.d.ts +++ b/packages/core/css/system-classes.d.ts @@ -1,61 +1,66 @@ /** - * String value "ns-" used for CSS system class prefix. + * Various framework wide css utilities */ -export const CLASS_PREFIX: string; +export namespace CSSUtils { + /** + * String value "ns-" used for CSS system class prefix. + */ + export const CLASS_PREFIX: string; -/** - * Gets CSS system class for modal root view. - */ -export const MODAL_ROOT_VIEW_CSS_CLASS; + /** + * Gets CSS system class for modal root view. + */ + export const MODAL_ROOT_VIEW_CSS_CLASS; -/** - * Gets CSS system classes for root view. - */ -export const ROOT_VIEW_CSS_CLASS; + /** + * Gets CSS system classes for root view. + */ + export const ROOT_VIEW_CSS_CLASS; -/** - * Gets a list of the current system classes. - * Intended for internal use only - */ -export function getSystemCssClasses(): string[]; + /** + * Gets a list of the current system classes. + * Intended for internal use only + */ + export function getSystemCssClasses(): string[]; -/** - * Pushes to the list of the current system classes. - * Intended for internal use only - */ -export function pushToSystemCssClasses(value: string): number; + /** + * Pushes to the list of the current system classes. + * Intended for internal use only + */ + export function pushToSystemCssClasses(value: string): number; -/** - * Removes value from the list of current system classes - * Intended for internal use only - * @param value - */ -export function removeSystemCssClass(value: string): string; + /** + * Removes value from the list of current system classes + * Intended for internal use only + * @param value + */ + export function removeSystemCssClass(value: string): string; -/** - * Same as MODAL_ROOT_VIEW_CSS_CLASS - */ -export function getModalRootViewCssClass(): string; + /** + * Same as MODAL_ROOT_VIEW_CSS_CLASS + */ + export function getModalRootViewCssClass(): string; -/** - * Gets CSS system classes for root view. Same as ROOT_VIEW_CSS_CLASS + _getCssClasses - * Intended for internal use only - * @deprecated Use ROOT_VIEW_CSS_CLASS or getCssClasses() instead - */ -export function getRootViewCssClasses(): string[]; + /** + * Gets CSS system classes for root view. Same as ROOT_VIEW_CSS_CLASS + _getCssClasses + * Intended for internal use only + * @deprecated Use ROOT_VIEW_CSS_CLASS or getCssClasses() instead + */ + export function getRootViewCssClasses(): string[]; -/** - * Appends new CSS class to the system classes and returns the new length of the array. - * Intended for internal use only - * @deprecated Use pushToCssClasses() instead - * @param value New CSS system class. - */ -export function pushToRootViewCssClasses(value: string): number; + /** + * Appends new CSS class to the system classes and returns the new length of the array. + * Intended for internal use only + * @deprecated Use pushToCssClasses() instead + * @param value New CSS system class. + */ + export function pushToRootViewCssClasses(value: string): number; -/** - * Removes CSS class from the system classes and returns it. - * Intended for internal use only - * @deprecated Use removeCssClass() instead - * @param value - */ -export function removeFromRootViewCssClasses(value: string): string; + /** + * Removes CSS class from the system classes and returns it. + * Intended for internal use only + * @deprecated Use removeCssClass() instead + * @param value + */ + export function removeFromRootViewCssClasses(value: string): string; +} diff --git a/packages/core/css/system-classes.ts b/packages/core/css/system-classes.ts index 9440894bb..cff35f495 100644 --- a/packages/core/css/system-classes.ts +++ b/packages/core/css/system-classes.ts @@ -2,43 +2,45 @@ const MODAL = 'modal'; const ROOT = 'root'; const cssClasses = []; -export const CLASS_PREFIX = 'ns-'; -export const MODAL_ROOT_VIEW_CSS_CLASS = `${CLASS_PREFIX}${MODAL}`; -export const ROOT_VIEW_CSS_CLASS = `${CLASS_PREFIX}${ROOT}`; +export namespace CSSUtils { + export const CLASS_PREFIX = 'ns-'; + export const MODAL_ROOT_VIEW_CSS_CLASS = `${CLASS_PREFIX}${MODAL}`; + export const ROOT_VIEW_CSS_CLASS = `${CLASS_PREFIX}${ROOT}`; -export function getSystemCssClasses(): string[] { - return cssClasses; -} - -export function pushToSystemCssClasses(value: string): number { - cssClasses.push(value); - - return cssClasses.length; -} - -export function removeSystemCssClass(value: string): string { - const index = cssClasses.indexOf(value); - let removedElement; - - if (index > -1) { - removedElement = cssClasses.splice(index, 1); + export function getSystemCssClasses(): string[] { + return cssClasses; } - return removedElement; -} + export function pushToSystemCssClasses(value: string): number { + cssClasses.push(value); -export function getModalRootViewCssClass(): string { - return MODAL_ROOT_VIEW_CSS_CLASS; -} + return cssClasses.length; + } -export function getRootViewCssClasses(): string[] { - return [ROOT_VIEW_CSS_CLASS, ...cssClasses]; -} + export function removeSystemCssClass(value: string): string { + const index = cssClasses.indexOf(value); + let removedElement; -export function pushToRootViewCssClasses(value: string): number { - return pushToSystemCssClasses(value) + 1; // because of ROOT_VIEW_CSS_CLASS -} + if (index > -1) { + removedElement = cssClasses.splice(index, 1); + } -export function removeFromRootViewCssClasses(value: string): string { - return removeSystemCssClass(value); + return removedElement; + } + + export function getModalRootViewCssClass(): string { + return MODAL_ROOT_VIEW_CSS_CLASS; + } + + export function getRootViewCssClasses(): string[] { + return [ROOT_VIEW_CSS_CLASS, ...cssClasses]; + } + + export function pushToRootViewCssClasses(value: string): number { + return pushToSystemCssClasses(value) + 1; // because of ROOT_VIEW_CSS_CLASS + } + + export function removeFromRootViewCssClasses(value: string): string { + return removeSystemCssClass(value); + } } diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts index 0cc400a60..02238aeeb 100644 --- a/packages/core/index.d.ts +++ b/packages/core/index.d.ts @@ -51,6 +51,7 @@ export declare const Connectivity: { startMonitoring: typeof startMonitoring; stopMonitoring: typeof stopMonitoring; }; +export { CSSUtils } from './css/system-classes'; export { ObservableArray, ChangeType, ChangedData } from './data/observable-array'; export { Observable, PropertyChangeData, EventData, WrappedValue, fromObject, fromObjectRecursive } from './data/observable'; export { VirtualArray, ItemsLoading } from './data/virtual-array'; @@ -74,10 +75,12 @@ export { encoding } from './text'; export * from './trace'; export * from './ui'; -import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, iOSNativeHelper as iosUtils, Source } from './utils'; +import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, iOSNativeHelper as iosUtils, Source, RESOURCE_PREFIX, FILE_PREFIX } from './utils'; import { ClassInfo, getClass, getBaseClasses, getClassInfo, isBoolean, isDefined, isFunction, isNullOrUndefined, isNumber, isObject, isString, isUndefined, toUIString, verifyCallback } from './utils/types'; export declare const Utils: { GC: typeof GC; + RESOURCE_PREFIX: typeof RESOURCE_PREFIX; + FILE_PREFIX: typeof FILE_PREFIX; isFontIconURI: typeof isFontIconURI; isDataURI: typeof isDataURI; isFileOrResourcePath: typeof isFileOrResourcePath; diff --git a/packages/core/index.ts b/packages/core/index.ts index eca90f35a..3c0cf5f68 100644 --- a/packages/core/index.ts +++ b/packages/core/index.ts @@ -66,6 +66,8 @@ export const Connectivity = { stopMonitoring, }; +export { CSSUtils } from './css/system-classes'; + export { ObservableArray, ChangeType, ChangedData } from './data/observable-array'; export { Observable, PropertyChangeData, EventData, WrappedValue, fromObject, fromObjectRecursive } from './data/observable'; export { VirtualArray, ItemsLoading } from './data/virtual-array'; @@ -98,11 +100,13 @@ export * from './trace'; export * from './ui'; -import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, iOSNativeHelper as iosUtils, Source } from './utils'; +import { GC, isFontIconURI, isDataURI, isFileOrResourcePath, executeOnMainThread, mainThreadify, isMainThread, dispatchToMainThread, releaseNativeObject, getModuleName, openFile, openUrl, isRealDevice, layout, ad as androidUtils, iOSNativeHelper as iosUtils, Source, RESOURCE_PREFIX, FILE_PREFIX } from './utils'; import { ClassInfo, getClass, getBaseClasses, getClassInfo, isBoolean, isDefined, isFunction, isNullOrUndefined, isNumber, isObject, isString, isUndefined, toUIString, verifyCallback } from './utils/types'; export const Utils = { GC, + RESOURCE_PREFIX, + FILE_PREFIX, isFontIconURI, isDataURI, isFileOrResourcePath, diff --git a/packages/core/package.json b/packages/core/package.json index 9bacc10cf..e19c38886 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": "7.0.0-rc.24", + "version": "7.0.0-rc.25", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/core/platform/index.android.ts b/packages/core/platform/index.android.ts index 265e6db4e..27d733f5b 100644 --- a/packages/core/platform/index.android.ts +++ b/packages/core/platform/index.android.ts @@ -1,5 +1,5 @@ /* tslint:disable:class-name */ -import { getNativeApplication, on, off, orientationChangedEvent } from '../application'; +import { getNativeApplication, on, off, orientationChangedEvent, android as AndroidApplication } from '../application'; const MIN_TABLET_PIXELS = 600; @@ -119,7 +119,7 @@ class DeviceRef { get uuid(): string { if (!this._uuid) { - const nativeApp = appModule.android.nativeApp; + const nativeApp = AndroidApplication.nativeApp; this._uuid = android.provider.Settings.Secure.getString(nativeApp.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); } diff --git a/packages/core/ui/core/view-base/index.ts b/packages/core/ui/core/view-base/index.ts index ea790a631..b9abed739 100644 --- a/packages/core/ui/core/view-base/index.ts +++ b/packages/core/ui/core/view-base/index.ts @@ -4,7 +4,7 @@ import { Page } from '../../page'; // Types. import { Property, CssProperty, CssAnimationProperty, InheritedProperty, clearInheritedProperties, propagateInheritableProperties, propagateInheritableCssProperties, initNativeView } from '../properties'; -import { getSystemCssClasses, MODAL_ROOT_VIEW_CSS_CLASS, ROOT_VIEW_CSS_CLASS } from '../../../css/system-classes'; +import { CSSUtils } from '../../../css/system-classes'; import { Source } from '../../../utils/debug'; import { Binding, BindingOptions } from '../bindable'; import { Trace } from '../../../trace'; @@ -1104,17 +1104,17 @@ export const classNameProperty = new Property({ name: 'className', valueChanged(view: ViewBase, oldValue: string, newValue: string) { const cssClasses = view.cssClasses; - const rootViewsCssClasses = getSystemCssClasses(); + const rootViewsCssClasses = CSSUtils.getSystemCssClasses(); - const shouldAddModalRootViewCssClasses = cssClasses.has(MODAL_ROOT_VIEW_CSS_CLASS); - const shouldAddRootViewCssClasses = cssClasses.has(ROOT_VIEW_CSS_CLASS); + const shouldAddModalRootViewCssClasses = cssClasses.has(CSSUtils.MODAL_ROOT_VIEW_CSS_CLASS); + const shouldAddRootViewCssClasses = cssClasses.has(CSSUtils.ROOT_VIEW_CSS_CLASS); cssClasses.clear(); if (shouldAddModalRootViewCssClasses) { - cssClasses.add(MODAL_ROOT_VIEW_CSS_CLASS); + cssClasses.add(CSSUtils.MODAL_ROOT_VIEW_CSS_CLASS); } else if (shouldAddRootViewCssClasses) { - cssClasses.add(ROOT_VIEW_CSS_CLASS); + cssClasses.add(CSSUtils.ROOT_VIEW_CSS_CLASS); } rootViewsCssClasses.forEach((c) => cssClasses.add(c)); diff --git a/packages/core/ui/core/view/view-common.ts b/packages/core/ui/core/view/view-common.ts index 57873d375..3ee2d3d2e 100644 --- a/packages/core/ui/core/view/view-common.ts +++ b/packages/core/ui/core/view/view-common.ts @@ -14,7 +14,7 @@ import { HorizontalAlignment, VerticalAlignment, Visibility, Length, PercentLeng import { observe as gestureObserve, GesturesObserver, GestureTypes, GestureEventData, fromString as gestureFromString } from '../../gestures'; -import { getSystemCssClasses, MODAL_ROOT_VIEW_CSS_CLASS } from '../../../css/system-classes'; +import { CSSUtils } from '../../../css/system-classes'; import { Builder } from '../../builder'; import { sanitizeModuleName } from '../../builder/module-name-sanitizer'; import { StyleScope } from '../../styling/style-scope'; @@ -355,8 +355,8 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { protected _showNativeModalView(parent: ViewCommon, options: ShowModalOptions) { _rootModalViews.push(this); - this.cssClasses.add(MODAL_ROOT_VIEW_CSS_CLASS); - const modalRootViewCssClasses = getSystemCssClasses(); + this.cssClasses.add(CSSUtils.MODAL_ROOT_VIEW_CSS_CLASS); + const modalRootViewCssClasses = CSSUtils.getSystemCssClasses(); modalRootViewCssClasses.forEach((c) => this.cssClasses.add(c)); parent._modal = this; diff --git a/packages/core/ui/core/view/view-helper/index.ios.ts b/packages/core/ui/core/view/view-helper/index.ios.ts index 863defece..6801ee879 100644 --- a/packages/core/ui/core/view/view-helper/index.ios.ts +++ b/packages/core/ui/core/view/view-helper/index.ios.ts @@ -112,7 +112,7 @@ class UILayoutViewController extends UIViewController { const owner = this.owner.get(); if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) { owner.notify({ - eventName: traitCollectionColorAppearanceChangedEvent, + eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent, object: owner, }); } @@ -167,7 +167,7 @@ class UIPopoverPresentationControllerDelegateImp extends NSObject implements UIP } export class IOSHelper { - traitCollectionColorAppearanceChangedEvent = 'traitCollectionColorAppearanceChanged'; + static traitCollectionColorAppearanceChangedEvent = 'traitCollectionColorAppearanceChanged'; static UILayoutViewController = UILayoutViewController; static UIAdaptivePresentationControllerDelegateImp = UIAdaptivePresentationControllerDelegateImp; static UIPopoverPresentationControllerDelegateImp = UIPopoverPresentationControllerDelegateImp; @@ -194,7 +194,7 @@ export class IOSHelper { static updateConstraints(controller: UIViewController, owner: View): void { if (majorVersion <= 10) { - const layoutGuide = initLayoutGuide(controller); + const layoutGuide = IOSHelper.initLayoutGuide(controller); (controller.view).safeAreaLayoutGuide = layoutGuide; } } @@ -213,7 +213,7 @@ export class IOSHelper { if (!layoutGuide) { Trace.write(`safeAreaLayoutGuide during layout of ${owner}. Creating fallback constraints, but layout might be wrong.`, Trace.categories.Layout, Trace.messageType.error); - layoutGuide = initLayoutGuide(controller); + layoutGuide = IOSHelper.initLayoutGuide(controller); } const safeArea = layoutGuide.layoutFrame; let position = IOSHelper.getPositionFromFrame(safeArea); diff --git a/packages/core/ui/frame/activity.android.ts b/packages/core/ui/frame/activity.android.ts index dc2212892..9f92d2c5c 100644 --- a/packages/core/ui/frame/activity.android.ts +++ b/packages/core/ui/frame/activity.android.ts @@ -6,13 +6,15 @@ if (global.__snapshot) { initGlobal(); } -//@ts-ignore -@JavaProxy('com.tns.NativeScriptActivity') +const superProto = androidx.appcompat.app.AppCompatActivity.prototype; +// @JavaProxy('com.tns.NativeScriptActivity') const NativeScriptActivity = (androidx.appcompat.app.AppCompatActivity).extend('com.tns.NativeScriptActivity', { init() { - return global.__native(this); + // superProto(); + // return global.__native(this); }, onCreate(savedInstanceState: android.os.Bundle): void { + console.log('onCreate this.getApplication():', this.getApplication()); appModule.android.init(this.getApplication()); // Set isNativeScriptActivity in onCreate. @@ -22,35 +24,35 @@ const NativeScriptActivity = (androidx.appcompat.app.AppCompatActivity).ext setActivityCallbacks(this); } - this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), super.onCreate); + this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate); }, onNewIntent(intent: android.content.Intent): void { - this._callbacks.onNewIntent(this, intent, super.setIntent, super.onNewIntent); + this._callbacks.onNewIntent(this, intent, superProto.setIntent, superProto.onNewIntent); }, onSaveInstanceState(outState: android.os.Bundle): void { - this._callbacks.onSaveInstanceState(this, outState, super.onSaveInstanceState); + this._callbacks.onSaveInstanceState(this, outState, superProto.onSaveInstanceState); }, onStart(): void { - this._callbacks.onStart(this, super.onStart); + this._callbacks.onStart(this, superProto.onStart); }, onStop(): void { - this._callbacks.onStop(this, super.onStop); + this._callbacks.onStop(this, superProto.onStop); }, onDestroy(): void { - this._callbacks.onDestroy(this, super.onDestroy); + this._callbacks.onDestroy(this, superProto.onDestroy); }, onPostResume(): void { - this._callbacks.onPostResume(this, super.onPostResume); + this._callbacks.onPostResume(this, superProto.onPostResume); }, onBackPressed(): void { - this._callbacks.onBackPressed(this, super.onBackPressed); + this._callbacks.onBackPressed(this, superProto.onBackPressed); }, onRequestPermissionsResult(requestCode: number, permissions: Array, grantResults: Array): void { @@ -58,7 +60,7 @@ const NativeScriptActivity = (androidx.appcompat.app.AppCompatActivity).ext }, onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void { - this._callbacks.onActivityResult(this, requestCode, resultCode, data, super.onActivityResult); + this._callbacks.onActivityResult(this, requestCode, resultCode, data, superProto.onActivityResult); }, }); diff --git a/packages/core/ui/frame/index.android.ts b/packages/core/ui/frame/index.android.ts index 45d1f6fb8..61d212ca9 100644 --- a/packages/core/ui/frame/index.android.ts +++ b/packages/core/ui/frame/index.android.ts @@ -16,7 +16,7 @@ import { _setAndroidFragmentTransitions, _getAnimatedEntries, _updateTransitions // TODO: Remove this and get it from global to decouple builder for angular import { Builder } from '../builder'; -import { CLASS_PREFIX, getSystemCssClasses, pushToSystemCssClasses, ROOT_VIEW_CSS_CLASS } from '../../css/system-classes'; +import { CSSUtils } from '../../css/system-classes'; import { Device } from '../../platform'; import { profile } from '../../profiling'; @@ -48,14 +48,18 @@ export let attachStateChangeListener: android.view.View.OnAttachStateChangeListe function getAttachListener(): android.view.View.OnAttachStateChangeListener { if (!attachStateChangeListener) { - @Interfaces([android.view.View.OnAttachStateChangeListener]) - const AttachListener = java.lang.Object.extend('AttachListener', { + const AttachListener = (java.lang.Object).extend({ + interfaces: [android.view.View.OnAttachStateChangeListener], init() { - return global.__native(this); + // this.super(this); + // return global.__native(this); }, onViewAttachedToWindow(view: android.view.View): void { + // console.log('onViewAttachedToWindow') const owner: View = view[ownerSymbol]; + // console.log('owner:', owner) if (owner) { + // console.log('owner._onAttachedToWindow:', owner._onAttachedToWindow) owner._onAttachedToWindow(); } }, @@ -504,6 +508,7 @@ export class Frame extends FrameBase { public initNativeView(): void { super.initNativeView(); const listener = getAttachListener(); + console.log('listener:', listener); this.nativeViewProtected.addOnAttachStateChangeListener(listener); this.nativeViewProtected[ownerSymbol] = this; this._android.rootViewGroup = this.nativeViewProtected; @@ -1333,13 +1338,13 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { const deviceType = Device.deviceType.toLowerCase(); - pushToSystemCssClasses(`${CLASS_PREFIX}${ANDROID_PLATFORM}`); - pushToSystemCssClasses(`${CLASS_PREFIX}${deviceType}`); - pushToSystemCssClasses(`${CLASS_PREFIX}${application.android.orientation}`); - pushToSystemCssClasses(`${CLASS_PREFIX}${application.android.systemAppearance}`); + CSSUtils.pushToSystemCssClasses(`${CSSUtils.CLASS_PREFIX}${ANDROID_PLATFORM}`); + CSSUtils.pushToSystemCssClasses(`${CSSUtils.CLASS_PREFIX}${deviceType}`); + CSSUtils.pushToSystemCssClasses(`${CSSUtils.CLASS_PREFIX}${application.android.orientation}`); + CSSUtils.pushToSystemCssClasses(`${CSSUtils.CLASS_PREFIX}${application.android.systemAppearance}`); - this._rootView.cssClasses.add(ROOT_VIEW_CSS_CLASS); - const rootViewCssClasses = getSystemCssClasses(); + this._rootView.cssClasses.add(CSSUtils.ROOT_VIEW_CSS_CLASS); + const rootViewCssClasses = CSSUtils.getSystemCssClasses(); rootViewCssClasses.forEach((c) => this._rootView.cssClasses.add(c)); } diff --git a/packages/core/ui/index.d.ts b/packages/core/ui/index.d.ts index f4a180d5d..d3efaf35f 100644 --- a/packages/core/ui/index.d.ts +++ b/packages/core/ui/index.d.ts @@ -20,7 +20,7 @@ export * from './editable-text-base'; export { Enums } from './enums'; export { Frame, NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry, AndroidActivityCallbacks, setActivityCallbacks } from './frame'; -export { GestureEventData, GestureEventDataWithState, GestureStateTypes, GestureTypes, GesturesObserver, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeDirection, SwipeGestureEventData, TouchGestureEventData } from './gestures'; +export { GestureEventData, GestureEventDataWithState, GestureStateTypes, GestureTypes, GesturesObserver, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeDirection, SwipeGestureEventData, TouchGestureEventData, TouchAction } from './gestures'; export { HtmlView } from './html-view'; export { Image } from './image'; diff --git a/packages/core/ui/index.ts b/packages/core/ui/index.ts index f4a180d5d..a18274083 100644 --- a/packages/core/ui/index.ts +++ b/packages/core/ui/index.ts @@ -7,6 +7,7 @@ export { sanitizeModuleName } from './builder/module-name-sanitizer'; export { Button } from './button'; export { ContentView } from './content-view'; export { Binding, BindingOptions } from './core/bindable'; +export { ControlStateChangeListener } from './core/control-state-change'; export { ViewBase, ShowModalOptions, eachDescendant, getAncestor, getViewById, booleanConverter } from './core/view-base'; export { View, Template, KeyedTemplate, ShownModallyData, CSSType, ContainerView, ViewHelper, IOSHelper } from './core/view'; export { Property, CoercibleProperty, InheritedProperty, CssProperty, InheritedCssProperty, ShorthandProperty, CssAnimationProperty, unsetValue, makeParser, makeValidator } from './core/properties'; @@ -20,7 +21,7 @@ export * from './editable-text-base'; export { Enums } from './enums'; export { Frame, NavigationEntry, NavigationContext, NavigationTransition, BackstackEntry, ViewEntry, AndroidActivityCallbacks, setActivityCallbacks } from './frame'; -export { GestureEventData, GestureEventDataWithState, GestureStateTypes, GestureTypes, GesturesObserver, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeDirection, SwipeGestureEventData, TouchGestureEventData } from './gestures'; +export { GestureEventData, GestureEventDataWithState, GestureStateTypes, GestureTypes, GesturesObserver, TapGestureEventData, PanGestureEventData, PinchGestureEventData, RotationGestureEventData, SwipeDirection, SwipeGestureEventData, TouchGestureEventData, TouchAction } from './gestures'; export { HtmlView } from './html-view'; export { Image } from './image'; diff --git a/packages/core/ui/styling/style-properties.d.ts b/packages/core/ui/styling/style-properties.d.ts index 961885883..5295f71d3 100644 --- a/packages/core/ui/styling/style-properties.d.ts +++ b/packages/core/ui/styling/style-properties.d.ts @@ -108,6 +108,9 @@ export const fontWeightProperty: InheritedCssProperty; export const backgroundInternalProperty: CssProperty; export const fontInternalProperty: InheritedCssProperty; +export const androidElevationProperty: CssProperty; +export const androidDynamicElevationOffsetProperty: CssProperty; + export type BackgroundRepeat = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat'; export type Visibility = 'visible' | 'hidden' | 'collapse'; export type HorizontalAlignment = 'left' | 'center' | 'right' | 'stretch';