Add android app state events "blur", "focus" (#42423)

* fix: add android app state events

* trigger ci

* remove trailing space
This commit is contained in:
Mohamed Shaban
2020-02-19 14:46:20 +01:00
committed by GitHub
parent 9306d15154
commit 6c59e79d0c
2 changed files with 14 additions and 6 deletions
+12 -6
View File
@@ -33,6 +33,7 @@
// Daiki Ihara <https://github.com/sasurau4>
// Abe Dolinger <https://github.com/256hz>
// Dominique Richard <https://github.com/doumart>
// Mohamed Shaban <https://github.com/drmas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -6875,22 +6876,27 @@ export interface AlertStatic {
export type AlertType = 'default' | 'plain-text' | 'secure-text' | 'login-password';
/**
* AppStateIOS can tell you if the app is in the foreground or background,
* AppState can tell you if the app is in the foreground or background,
* and notify you when the state changes.
*
* AppStateIOS is frequently used to determine the intent and proper behavior
* AppState is frequently used to determine the intent and proper behavior
* when handling push notifications.
*
* iOS App States
* App State Events
* change - This even is received when the app state has changed.
* focus [Android] - Received when the app gains focus (the user is interacting with the app).
* blur [Android] - Received when the user is not actively interacting with the app.
*
* App States
* active - The app is running in the foreground
* background - The app is running in the background. The user is either in another app or on the home screen
* inactive - This is a transition state that currently never happens for typical React Native apps.
* inactive [iOS] - This is a transition state that currently never happens for typical React Native apps.
*
* For more information, see Apple's documentation: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html
*
* @see https://facebook.github.io/react-native/docs/appstateios.html#content
* @see https://facebook.github.io/react-native/docs/appstate#app-states
*/
export type AppStateEvent = 'change' | 'memoryWarning';
export type AppStateEvent = 'change' | 'memoryWarning' | 'blur' | 'focus';
export type AppStateStatus = 'active' | 'background' | 'inactive';
export interface AppStateStatic {
+2
View File
@@ -372,6 +372,8 @@ function appStateListener(state: string) {
function appStateTest() {
console.log("Current state: " + AppState.currentState);
AppState.addEventListener("change", appStateListener);
AppState.addEventListener("blur", appStateListener);
AppState.addEventListener("focus", appStateListener);
}
// ViewPagerAndroid