Skip to content

Commit 08167fb

Browse files
committed
Merge branch 'main' into merge_from_akylas
# Conflicts: # apps/automated/package.json # apps/toolbox/package.json # apps/toolbox/src/pages/box-shadow.ts # nx.json # package-lock.json # package.json # packages/core/application/application-common.ts # packages/core/application/application-interfaces.ts # packages/core/application/application.android.ts # packages/core/application/application.ios.ts # packages/core/application/helpers.android.ts # packages/core/core-types/index.ts # packages/core/image-asset/image-asset-common.ts # packages/core/tsconfig.lib.json # packages/core/ui/animation/index.d.ts # packages/core/ui/core/view/index.android.ts # packages/core/ui/core/view/view-common.ts # packages/core/ui/frame/fragment.transitions.android.ts # packages/core/ui/frame/index.ios.ts # packages/core/ui/page/index.android.ts # packages/core/ui/scroll-view/index.ios.ts # packages/core/ui/styling/background-common.ts # packages/core/ui/styling/style-properties.ts # packages/core/ui/tab-view/index.ios.ts # packages/core/ui/text-base/text-base-common.ts # packages/types-android/src/lib/android/org.nativescript.widgets.d.ts # packages/webpack5/package-lock.json
2 parents 5813bce + 75dd54c commit 08167fb

File tree

25 files changed

+172
-140
lines changed

25 files changed

+172
-140
lines changed

apps/toolbox/src/pages/box-shadow.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export class BoxShadowModel extends Observable {
137137
width: originalWidth,
138138
duration: animationDuration,
139139
curve,
140-
})
140+
}),
141141
)
142142
.catch((err) => {
143143
console.error('animation error', err);
@@ -155,7 +155,7 @@ export class BoxShadowModel extends Observable {
155155
height: originalHeight,
156156
duration: animationDuration,
157157
curve,
158-
})
158+
}),
159159
)
160160
.catch((err) => {
161161
console.error('animation error', err);
@@ -178,7 +178,7 @@ export class BoxShadowModel extends Observable {
178178
translate: { x: 0, y: 0 },
179179
duration: animationDuration,
180180
curve,
181-
})
181+
}),
182182
)
183183
.catch((err) => {
184184
console.error('animation error', err);

packages/core/application/application-common.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type { NavigationEntry } from '../ui/frame/frame-interfaces';
1212
import type { StyleScope } from '../ui/styling/style-scope';
1313
import type { AndroidApplication as AndroidApplicationType, iOSApplication as iOSApplicationType } from '.';
1414
import type { ApplicationEventData, CssChangedEventData, DiscardedErrorEventData, FontScaleChangedEventData, InitRootViewEventData, LaunchEventData, LoadAppCSSEventData, NativeScriptError, OrientationChangedEventData, SystemAppearanceChangedEventData, LayoutDirectionChangedEventData, UnhandledErrorEventData } from './application-interfaces';
15-
import { readyInitAccessibilityCssHelper, readyInitFontScale } from '../accessibility/accessibility-common';
1615
import { getAppMainEntry, isAppInBackground, setAppInBackground, setAppMainEntry } from './helpers-common';
1716
import { getNativeScriptGlobals } from '../globals/global-utils';
1817
import { SDK_VERSION } from '../utils/constants';
@@ -376,7 +375,7 @@ export class ApplicationCommon {
376375
rootView.cssClasses.add(CSSUtils.ROOT_VIEW_CSS_CLASS);
377376
const rootViewCssClasses = CSSUtils.getSystemCssClasses();
378377
rootViewCssClasses.forEach((c) => rootView.cssClasses.add(c));
379-
378+
initializeSdkVersionClass(rootView);
380379
this.increaseStyleScopeApplicationCssSelectorVersion(rootView);
381380
rootView._onCssStateChange();
382381

packages/core/application/application-interfaces.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { EventData, Observable } from '../data/observable';
22
import type { View } from '../ui/core/view';
3-
import type { CoreTypes } from '../core-types';
43
import type { ApplicationCommon } from './application-common';
4+
import type { CoreTypes } from '../core-types';
55

66
/**
77
* An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code.
@@ -226,31 +226,6 @@ export interface LoadAppCSSEventData extends ApplicationEventData {
226226
cssFile: string;
227227
}
228228

229-
/**
230-
* iOS Event data containing information for scene lifecycle events (iOS 13+).
231-
*/
232-
export interface SceneEventData extends ApplicationEventData {
233-
/**
234-
* The UIWindowScene instance associated with this event.
235-
*/
236-
scene?: UIWindowScene;
237-
238-
/**
239-
* The UIWindow associated with this scene (if applicable).
240-
*/
241-
window?: UIWindow;
242-
243-
/**
244-
* Scene connection options (for sceneWillConnect event).
245-
*/
246-
connectionOptions?: UISceneConnectionOptions;
247-
248-
/**
249-
* Additional user info from the notification.
250-
*/
251-
userInfo?: NSDictionary<any, any>;
252-
}
253-
254229
/**
255230
* Data for the Android dialog fragment onCreateView event.
256231
*/
@@ -288,3 +263,28 @@ export interface AndroidConfigurationChangeEventData extends ApplicationEventDat
288263
*/
289264
diff?: number;
290265
}
266+
267+
/**
268+
* iOS Event data containing information for scene lifecycle events (iOS 13+).
269+
*/
270+
export interface SceneEventData extends ApplicationEventData {
271+
/**
272+
* The UIWindowScene instance associated with this event.
273+
*/
274+
scene?: UIWindowScene;
275+
276+
/**
277+
* The UIWindow associated with this scene (if applicable).
278+
*/
279+
window?: UIWindow;
280+
281+
/**
282+
* Scene connection options (for sceneWillConnect event).
283+
*/
284+
connectionOptions?: UISceneConnectionOptions;
285+
286+
/**
287+
* Additional user info from the notification.
288+
*/
289+
userInfo?: NSDictionary<any, any>;
290+
}

packages/core/application/application.android.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { CoreTypes } from '../core-types';
21
import * as ApplicationSettings from '../application-settings';
2+
import { CoreTypes } from '../core-types';
33
import { profile } from '../profiling';
44
import type { View } from '../ui/core/view';
55
import { AndroidActivityCallbacks, NavigationEntry } from '../ui/frame/frame-common';
6+
import { SDK_VERSION } from '../utils/constants';
67
import { ApplicationCommon } from './application-common';
7-
import type { AndroidActivityBundleEventData, AndroidActivityEventData, ApplicationEventData } from './application-interfaces';
8+
import type { AndroidActivityBundleEventData, AndroidActivityEventData, AndroidConfigurationChangeEventData, ApplicationEventData } from './application-interfaces';
89
import { fontScaleChanged } from '../accessibility/font-scale.android';
9-
import { androidGetForegroundActivity, androidGetStartActivity, androidPendingReceiverRegistrations, androidRegisterBroadcastReceiver, androidRegisteredReceivers, androidSetForegroundActivity, androidSetStartActivity, androidUnregisterBroadcastReceiver } from './helpers';
10+
import { androidGetForegroundActivity, androidGetStartActivity, androidSetForegroundActivity, androidSetStartActivity } from './helpers';
1011
import { getImageFetcher, getNativeApp, getRootView, initImageCache, setApplicationPropertiesCallback, setAppMainEntry, setNativeApp, setRootView, setToggleApplicationEventListenersCallback } from './helpers-common';
1112
import { getNativeScriptGlobals } from '../globals/global-utils';
1213
import type { AndroidApplication as IAndroidApplication } from './application';
@@ -250,6 +251,35 @@ function initNativeScriptComponentCallbacks() {
250251
return NativeScriptComponentCallbacks_;
251252
}
252253

254+
interface RegisteredReceiverInfo {
255+
receiver: android.content.BroadcastReceiver;
256+
intent: string;
257+
callback: (context: android.content.Context, intent: android.content.Intent) => void;
258+
id: number;
259+
flags: number;
260+
}
261+
262+
const BroadcastReceiver = lazy(() => {
263+
@NativeClass
264+
class BroadcastReceiverImpl extends android.content.BroadcastReceiver {
265+
private _onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void;
266+
267+
constructor(onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void) {
268+
super();
269+
this._onReceiveCallback = onReceiveCallback;
270+
271+
return global.__native(this);
272+
}
273+
274+
public onReceive(context: android.content.Context, intent: android.content.Intent) {
275+
if (this._onReceiveCallback) {
276+
this._onReceiveCallback(context, intent);
277+
}
278+
}
279+
}
280+
return BroadcastReceiverImpl;
281+
});
282+
253283
export class AndroidApplication extends ApplicationCommon {
254284
static readonly fragmentCreateEvent = 'fragmentCreate';
255285
static readonly activityCreateEvent = 'activityCreate';
@@ -357,8 +387,12 @@ export class AndroidApplication extends ApplicationCommon {
357387
fontScaleChanged(Number(configuration.fontScale));
358388

359389
}
390+
if ((diff & 8192) /* ActivityInfo.CONFIG_LAYOUT_DIRECTION */ !== 0) {
391+
this.setLayoutDirection(this.getLayoutDirectionValue(configuration));
392+
}
360393
this.notify(<AndroidConfigurationChangeEventData>{ eventName: this.configurationChangeEvent, configuration, diff });
361394
this._prevConfiguration = new android.content.res.Configuration(configuration);
395+
362396
}
363397

364398
getNativeApplication() {

packages/core/application/application.ios.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import { getWindow } from '../utils/native-helper';
88
import { SDK_VERSION } from '../utils/constants';
99
import { ios as iosUtils, dataSerialize } from '../utils/native-helper';
1010
import { ApplicationCommon, SceneEvents } from './application-common';
11-
import { ApplicationEventData } from './application-interfaces';
11+
import { ApplicationEventData, SceneEventData } from './application-interfaces';
1212
import { Observable } from '../data/observable';
1313
import { Trace } from '../trace';
1414

15-
import { iosAddNotificationObserver, iosRemoveNotificationObserver } from './helpers';
15+
import { CoreTypes } from '../core-types';
1616
import { getiOSWindow, setApplicationPropertiesCallback, setAppMainEntry, setiOSWindow, setRootView, setToggleApplicationEventListenersCallback } from './helpers-common';
1717

1818
@NativeClass
@@ -224,13 +224,13 @@ export class iOSApplication extends ApplicationCommon {
224224
private _delegate: UIApplicationDelegate;
225225
private _delegateHandlers = new Map<string, Array<Function>>();
226226
private _rootView: View;
227+
private _subRootView: View;
227228
private _sceneDelegate: UIWindowSceneDelegate;
228229
private _windowSceneMap = new Map<UIScene, UIWindow>();
229230
private _primaryScene: UIWindowScene | null = null;
230231
private _openedScenesById = new Map<string, UIWindowScene>();
231232

232233
private _notificationObservers: NotificationObserver[] = [];
233-
private _subRootView: View;
234234

235235
displayedOnce = false;
236236
displayedLinkTarget: CADisplayLinkTarget;

packages/core/application/helpers.android.ts

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -27,67 +27,3 @@ export function getApplicationContext(): android.content.Context {
2727
}
2828
return applicationContext;
2929
}
30-
31-
export const androidRegisteredReceivers: { [key: string]: android.content.BroadcastReceiver } = {};
32-
export const androidPendingReceiverRegistrations = new Array<(context: android.content.Context) => void>();
33-
34-
declare class BroadcastReceiver extends android.content.BroadcastReceiver {
35-
constructor(onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void);
36-
}
37-
38-
let BroadcastReceiver_: typeof BroadcastReceiver;
39-
function initBroadcastReceiver() {
40-
if (BroadcastReceiver_) {
41-
return BroadcastReceiver_;
42-
}
43-
44-
@NativeClass
45-
class BroadcastReceiverImpl extends android.content.BroadcastReceiver {
46-
private _onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void;
47-
48-
constructor(onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void) {
49-
super();
50-
this._onReceiveCallback = onReceiveCallback;
51-
52-
return global.__native(this);
53-
}
54-
55-
public onReceive(context: android.content.Context, intent: android.content.Intent) {
56-
if (this._onReceiveCallback) {
57-
this._onReceiveCallback(context, intent);
58-
}
59-
}
60-
}
61-
62-
BroadcastReceiver_ = BroadcastReceiverImpl;
63-
return BroadcastReceiver_;
64-
}
65-
66-
export function androidRegisterBroadcastReceiver(intentFilter: string, onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void, flags = 2): void {
67-
const registerFunc = (context: android.content.Context) => {
68-
const receiver: android.content.BroadcastReceiver = new (initBroadcastReceiver())(onReceiveCallback);
69-
if (SDK_VERSION >= 26) {
70-
context.registerReceiver(receiver, new android.content.IntentFilter(intentFilter), flags);
71-
} else {
72-
context.registerReceiver(receiver, new android.content.IntentFilter(intentFilter));
73-
}
74-
androidRegisteredReceivers[intentFilter] = receiver;
75-
};
76-
77-
if (getApplicationContext()) {
78-
registerFunc(getApplicationContext());
79-
} else {
80-
androidPendingReceiverRegistrations.push(registerFunc);
81-
}
82-
}
83-
84-
export function androidUnregisterBroadcastReceiver(intentFilter: string): void {
85-
const receiver = androidRegisteredReceivers[intentFilter];
86-
if (receiver) {
87-
getApplicationContext().unregisterReceiver(receiver);
88-
androidRegisteredReceivers[intentFilter] = undefined;
89-
delete androidRegisteredReceivers[intentFilter];
90-
}
91-
}
92-
93-
// stubs

packages/core/core-types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export namespace CoreTypes {
124124
export const unknown = 'unknown';
125125
}
126126

127-
export type HorizontalAlignmentType = 'start' | 'left' | 'center' | 'right' | 'end' | 'stretch' | CSSWideKeywords;
127+
export type HorizontalAlignmentType = 'start' | 'left' | 'middle' | 'center' | 'right' | 'end' | 'stretch' | CSSWideKeywords;
128128
export namespace HorizontalAlignment {
129129
export const start = 'start';
130130
export const left = 'left';

packages/core/image-asset/image-asset-common.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,14 @@ export class ImageAssetBase extends Observable implements ImageAssetDefinition {
3939
}
4040

4141
function toPositiveInt(value: any): number {
42-
if (value == null) {
43-
return 0;
44-
}
4542
if (typeof value === 'number') {
4643
return value > 0 ? Math.floor(value) : 0;
4744
}
4845
if (typeof value === 'string') {
4946
const parsed = parseInt(value, 10);
5047
return isNaN(parsed) || parsed <= 0 ? 0 : parsed;
5148
}
52-
return 0;
49+
return null;
5350
}
5451

5552
function normalizeImageAssetOptions(options: ImageAssetOptions): ImageAssetOptions {
@@ -58,6 +55,8 @@ function normalizeImageAssetOptions(options: ImageAssetOptions): ImageAssetOptio
5855
// to trigger default sizing downstream
5956
(normalized as any).width = toPositiveInt((options as any)?.width);
6057
(normalized as any).height = toPositiveInt((options as any)?.height);
58+
(normalized as any).maxWidth = toPositiveInt((options as any)?.maxWidth);
59+
(normalized as any).maxHeight = toPositiveInt((options as any)?.maxHeight);
6160
if (typeof normalized.keepAspectRatio !== 'boolean') {
6261
normalized.keepAspectRatio = true;
6362
}
@@ -79,8 +78,8 @@ export function getAspectSafeDimensions(sourceWidth, sourceHeight, reqWidth, req
7978
}
8079

8180
export function getRequestedImageSize(src: { width: number; height: number }, options: ImageAssetOptions): { width: number; height: number } {
82-
options = normalizeImageAssetOptions(options);
83-
if (options.width || options.height || options.maxWidth || options.maxHeight) {
81+
options = normalizeImageAssetOptions(options);
82+
if (options.width || options.height || options.maxWidth || options.maxHeight) {
8483
let reqWidth = options.width || (options.maxWidth ? Math.min(options.maxWidth, src.width) : src.width);
8584
let reqHeight = options.height || (options.maxHeight ? Math.min(options.maxHeight, src.height) : src.height);
8685

packages/core/ui/animation/animation-shared.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,58 @@ import type { View } from '../core/view';
55
import type { CoreTypes } from '../../core-types';
66
import type { Color } from '../../color';
77

8+
9+
/**
10+
* Defines a key-value pair for css transformation
11+
*/
812
export type Transformation = {
913
property: TransformationType;
1014
value: TransformationValue;
1115
};
1216

17+
/**
18+
* Defines possible css transformations
19+
*/
1320
export type TransformationType = 'rotate' | 'rotate3d' | 'rotateX' | 'rotateY' | 'translate' | 'translate3d' | 'translateX' | 'translateY' | 'scale' | 'scale3d' | 'scaleX' | 'scaleY';
1421

22+
/**
23+
* Defines possible css transformation values
24+
*/
1525
export type TransformationValue = Point3D | Pair | number;
1626

27+
/**
28+
* Defines a point in 3d space (x, y and z) for rotation in 3d animations.
29+
*/
1730
export interface Point3D {
1831
x: number;
1932
y: number;
2033
z: number;
2134
}
2235

36+
/**
37+
* Defines a pair of values (horizontal and vertical) for translate and scale animations.
38+
*/
39+
export interface Pair {
40+
x: number;
41+
y: number;
42+
}
43+
44+
/**
45+
* Defines full information for css transformation
46+
*/
2347
export type TransformFunctionsInfo = {
2448
translate: Pair;
2549
rotate: Point3D;
2650
scale: Pair;
2751
};
2852

29-
export interface Pair {
30-
x: number;
31-
y: number;
32-
}
33-
3453
export interface Cancelable {
3554
cancel(): void;
3655
}
3756

57+
/**
58+
* A Promise that can cancel the animation.
59+
*/
3860
export type AnimationPromise = Promise<void> & Cancelable;
3961

4062

packages/core/ui/animation/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export type { Pair, Transformation, TransformationType, TransformationValue, TransformFunctionsInfo, Point3D, AnimationDefinition, AnimationPromise, Cancelable } from './animation-types';
22
export { KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo } from './keyframe-animation';
3+
import type { AnimationDefinition, AnimationPromise } from './animation-types';
34

45
/**
56
* Defines a animation set.

0 commit comments

Comments
 (0)