mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup for es2017 build
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nativescript",
|
||||
"version": "7.0.0-rc.24",
|
||||
"version": "7.0.0-rc.25",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"start": "nps"
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 = <Array<View>>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 = <Array<View>>rootView._getRootModalViews();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
105
packages/core/css/system-classes.d.ts
vendored
105
packages/core/css/system-classes.d.ts
vendored
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
5
packages/core/index.d.ts
vendored
5
packages/core/index.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 = <android.app.Application>appModule.android.nativeApp;
|
||||
const nativeApp = <android.app.Application>AndroidApplication.nativeApp;
|
||||
this._uuid = android.provider.Settings.Secure.getString(nativeApp.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ViewBase, string>({
|
||||
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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
(<any>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);
|
||||
|
||||
@@ -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 = (<any>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 = (<any>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<string>, grantResults: Array<number>): void {
|
||||
@@ -58,7 +60,7 @@ const NativeScriptActivity = (<any>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);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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 = (<any>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));
|
||||
}
|
||||
|
||||
|
||||
2
packages/core/ui/index.d.ts
vendored
2
packages/core/ui/index.d.ts
vendored
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -108,6 +108,9 @@ export const fontWeightProperty: InheritedCssProperty<Style, FontWeight>;
|
||||
export const backgroundInternalProperty: CssProperty<Style, Background>;
|
||||
export const fontInternalProperty: InheritedCssProperty<Style, Font>;
|
||||
|
||||
export const androidElevationProperty: CssProperty<Style, number>;
|
||||
export const androidDynamicElevationOffsetProperty: CssProperty<Style, number>;
|
||||
|
||||
export type BackgroundRepeat = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
|
||||
export type Visibility = 'visible' | 'hidden' | 'collapse';
|
||||
export type HorizontalAlignment = 'left' | 'center' | 'right' | 'stretch';
|
||||
|
||||
Reference in New Issue
Block a user