refactor: Application modules to classes

This commit is contained in:
Igor Randjelovic
2023-05-10 22:08:01 +02:00
parent 7650cdd890
commit fc01f8e79f
50 changed files with 5438 additions and 2985 deletions

View File

@ -1,6 +1,7 @@
// Types
import { EventData } from '../data/observable';
import { View } from '../ui/core/view';
import type { AndroidApplication, iOSApplication, ApplicationCommon } from '.';
import type { EventData } from '../data/observable';
import type { View } from '../ui/core/view';
/**
* An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code.
@ -12,100 +13,198 @@ export interface NativeScriptError extends Error {
nativeError: any;
}
/**
* Event data containing information for the application events.
*/
export interface ApplicationEventData extends EventData {
/**
* UIApplication or undefined, unless otherwise specified. Prefer explicit
* properties where possible.
* Gets the native iOS event arguments. Valid only when running on iOS.
*/
ios?: any;
ios?: any; // iOSApplication;
/**
* androidx.appcompat.app.AppCompatActivity or undefined, unless otherwise
* specified. Prefer explicit properties where possible.
* Gets the native Android event arguments. Valid only when running on Android.
*/
android?: any;
android?: any; // AndroidApplication;
/**
* Careful with this messy type. A significant refactor is needed to make it
* strictly extend EventData['object'], which is an Observable. It's used in
* various ways:
* - By font-scale: the Application module, typeof import('.')
* - Within index.android.ts: AndroidApplication
* - Within index.ios.ts: iOSApplication
* The instance that has raised the event.
*/
object: any;
object: ApplicationCommon;
}
export interface LaunchEventData extends ApplicationEventData {
/**
* Event data containing information for launch event.
*/
export interface LaunchEventData extends EventData {
/**
* The value stored into didFinishLaunchingWithOptions notification's
* userInfo under 'UIApplicationLaunchOptionsLocalNotificationKey';
* otherwise, null.
* The root view for this Window on iOS or Activity for Android.
* If not set a new Frame will be created as a root view in order to maintain backwards compatibility.
* If explicitly set to null, there will be no root view.
*/
ios: unknown;
root?: View | null;
savedInstanceState?: any /* android.os.Bundle */;
android?: android.content.Intent;
ios?: any /* UIApplicationLaunchOptions */;
}
/**
* Event data containing information for orientation changed event.
*/
export interface OrientationChangedEventData extends ApplicationEventData {
android: any /* globalAndroid.app.Application */;
/**
* New orientation value.
*/
newValue: 'portrait' | 'landscape' | 'unknown';
}
/**
* Event data containing information for system appearance changed event.
*/
export interface SystemAppearanceChangedEventData extends ApplicationEventData {
android: any /* globalAndroid.app.Application */;
/**
* New system appearance value.
*/
newValue: 'light' | 'dark';
}
export interface UnhandledErrorEventData extends ApplicationEventData {
/**
* Event data containing information for font scale changed event.
*/
export interface FontScaleChangedEventData extends ApplicationEventData {
/**
* New font scale value.
*/
newValue: number;
}
/**
* Event data containing information about unhandled application errors.
*/
export interface UnhandledErrorEventData extends EventData {
ios?: NativeScriptError;
android?: NativeScriptError;
error: NativeScriptError;
}
export interface DiscardedErrorEventData extends ApplicationEventData {
/**
* Event data containing information about discarded application errors.
*/
export interface DiscardedErrorEventData extends EventData {
error: NativeScriptError;
}
/**
* Event data containing information about application css change.
*/
export interface CssChangedEventData extends ApplicationEventData {
cssFile?: string;
cssText?: string;
}
export interface AndroidActivityEventData extends ApplicationEventData {
activity: any /* androidx.appcompat.app.AppCompatActivity */;
object: any /* AndroidApplication */;
/**
* Data for the Android activity events.
*/
export interface AndroidActivityEventData {
/**
* The activity.
*/
activity: androidx.appcompat.app.AppCompatActivity;
/**
* The name of the event.
*/
eventName: string;
/**
* The instance that has raised the event.
*/
object: any;
}
/**
* Data for the Android activity events with bundle.
*/
export interface AndroidActivityBundleEventData extends AndroidActivityEventData {
bundle: any /* android.os.Bundle */;
/**
* The bundle.
*/
bundle: android.os.Bundle;
}
export interface AndroidActivityRequestPermissionsEventData extends AndroidActivityEventData {
/**
* Data for the Android activity onRequestPermissions callback
*/
export interface AndroidActivityRequestPermissionsEventData
extends AndroidActivityEventData {
/**
* The request code.
*/
requestCode: number;
/**
* The Permissions.
*/
permissions: Array<string>;
/**
* The Granted.
*/
grantResults: Array<number>;
}
/**
* Data for the Android activity result event.
*/
export interface AndroidActivityResultEventData extends AndroidActivityEventData {
/**
* The request code.
*/
requestCode: number;
/**
* The result code.
*/
resultCode: number;
intent: any /* android.content.Intent */;
/**
* The intent.
*/
intent: android.content.Intent;
}
/**
* Data for the Android activity newIntent event.
*/
export interface AndroidActivityNewIntentEventData extends AndroidActivityEventData {
/**
* The intent.
*/
intent: any /* android.content.Intent */;
}
/**
* Data for the Android activity back pressed event.
*/
export interface AndroidActivityBackPressedEventData extends AndroidActivityEventData {
/**
* In the event handler, set this value to true if you want to cancel the back navigation and do something else instead.
*/
cancel: boolean;
}
export interface LoadAppCSSEventData extends ApplicationEventData {
cssFile: string;
}
//////////////////////////////
/**
* @deprecated
*/
export interface RootViewControllerImpl {
contentController: any;
}
export interface LoadAppCSSEventData extends ApplicationEventData {
cssFile: string;
}