feat(application): expose inBackground and suspended (#9897)

For IOSApplication to be like AndroidApplication
This commit is contained in:
farfromrefuge
2022-05-14 05:57:44 +00:00
committed by Nathan Walker
parent 665009b863
commit 8987babb08
3 changed files with 18 additions and 1 deletions

View File

@@ -20,7 +20,7 @@ import { profile } from '../profiling';
import { iOSNativeHelper } from '../utils';
import { initAccessibilityCssHelper } from '../accessibility/accessibility-css-helper';
import { initAccessibilityFontScale } from '../accessibility/font-scale';
import { setInBackground, setSuspended } from './application-common';
import { inBackground, setInBackground, setSuspended, suspended } from './application-common';
const IOS_PLATFORM = 'ios';
@@ -138,6 +138,13 @@ export class iOSApplication implements iOSApplicationDefinition {
private _rootView: View;
private _systemAppearance: 'light' | 'dark';
get paused() {
return suspended;
}
get backgrounded() {
return inBackground;
}
constructor() {
this._observers = new Array<NotificationObserver>();
this.addNotificationObserver(UIApplicationDidFinishLaunchingNotification, this.didFinishLaunchingWithOptions.bind(this));

View File

@@ -44,6 +44,8 @@ export declare const Application: {
setAutoSystemAppearanceChanged: typeof setAutoSystemAppearanceChanged;
android: AndroidApplication;
ios: iOSApplication;
suspended: boolean;
inBackground: boolean;
};
import { setString, getString, clear, flush, getAllKeys, getBoolean, getNumber, hasKey, remove, setBoolean, setNumber } from './application-settings';
export declare const ApplicationSettings: {

View File

@@ -6,6 +6,8 @@ export { iOSApplication, AndroidApplication } from './application';
export type { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, SystemAppearanceChangedEventData } from './application';
import { fontScaleChangedEvent, launchEvent, displayedEvent, uncaughtErrorEvent, discardedErrorEvent, suspendEvent, resumeEvent, exitEvent, lowMemoryEvent, orientationChangedEvent, systemAppearanceChanged, systemAppearanceChangedEvent, getMainEntry, getRootView, _resetRootView, getResources, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, notify, hasListeners, run, orientation, getNativeApplication, hasLaunched, android as appAndroid, ios as iosApp, systemAppearance, setAutoSystemAppearanceChanged, ensureNativeApplication, setMaxRefreshRate } from './application';
import { inBackground, suspended } from 'application/application-common';
export const Application = {
launchEvent,
displayedEvent,
@@ -48,6 +50,12 @@ export const Application = {
ensureNativeApplication();
return iosApp;
},
get suspended() {
return suspended;
},
get inBackground() {
return inBackground;
},
};
// Export all methods from "application-settings" as ApplicationSettings