1- import React , { useCallback , useEffect , useRef , useState } from 'react' ;
2- import { Alert , AppState , BackHandler , Linking , Platform } from 'react-native' ;
1+ import React , { JSX , useCallback , useEffect , useRef , useState } from 'react' ;
2+ import {
3+ Alert ,
4+ AppState ,
5+ BackHandler ,
6+ KeyboardAvoidingView ,
7+ Linking ,
8+ Platform ,
9+ View ,
10+ } from 'react-native' ;
311import Show from './src/components/ui/Show' ;
412import {
5- currentUrl ,
613 CustomWebView ,
714 CustomWebViewRef ,
815} from './src/components/CustomWebView' ;
9- import { CustomVideo , CustomVideoRef } from './src/components/ui/CustomVideo' ;
16+ import { CustomVideo , CustomVideoRef } from './src/components/ui/CustomVideo' ;
1017import TrackPlayer from 'react-native-track-player' ;
1118
1219import {
@@ -17,11 +24,11 @@ import {
1724import messaging , {
1825 FirebaseMessagingTypes ,
1926} from '@react-native-firebase/messaging' ;
20- import notifee , { EventType , Notification } from '@notifee/react-native' ;
21- import { getLatestRelease , Release } from './src/githubApi' ;
27+ import notifee , { EventType , Notification } from '@notifee/react-native' ;
28+ import { getLatestRelease , Release } from './src/githubApi' ;
2229import env from './src/env' ;
23- import { dmChannelMatch , serverChannelMatch } from './src/UrlPatternMatchers ' ;
24- import { openDMChannelRequest } from './src/services/UserService ' ;
30+ import { openDMChannelRequest } from './src/services/UserService ' ;
31+ import { SafeAreaView } from 'react-native-safe-area-context ' ;
2532
2633TrackPlayer . setupPlayer ( ) ;
2734
@@ -36,8 +43,8 @@ messaging().onMessage(e => onMessageReceived(e, false));
3643messaging ( ) . setBackgroundMessageHandler ( e => onMessageReceived ( e , true ) ) ;
3744
3845let backgroundClickedNotification : Notification | undefined ;
39- notifee . onBackgroundEvent ( async ( { type, detail} ) => {
40- const { notification} = detail ;
46+ notifee . onBackgroundEvent ( async ( { type, detail } ) => {
47+ const { notification } = detail ;
4148 if ( type === EventType . PRESS ) {
4249 backgroundClickedNotification = notification ;
4350 }
@@ -93,7 +100,7 @@ function App(): JSX.Element {
93100 } ) ;
94101
95102 const disposeForegroundEvent = notifee . onForegroundEvent (
96- ( { type, detail} ) => {
103+ ( { type, detail } ) => {
97104 if ( type === EventType . PRESS ) {
98105 handleNotificationClick ( detail . notification ) ;
99106 }
@@ -114,7 +121,9 @@ function App(): JSX.Element {
114121 } , [ handleNotificationClick ] ) ;
115122
116123 const onAndroidBackPress = useCallback ( ( ) => {
124+ console . log ( 'close 2' ) ;
117125 if ( videoUrl ) {
126+ console . log ( 'close 1' ) ;
118127 videoRef . current ?. stopVideo ( ) ;
119128 return true ;
120129 }
@@ -123,34 +132,41 @@ function App(): JSX.Element {
123132
124133 useEffect ( ( ) => {
125134 if ( Platform . OS === 'android' ) {
126- BackHandler . addEventListener ( 'hardwareBackPress' , onAndroidBackPress ) ;
135+ const sub = BackHandler . addEventListener (
136+ 'hardwareBackPress' ,
137+ onAndroidBackPress ,
138+ ) ;
127139 return ( ) => {
128- BackHandler . removeEventListener (
129- 'hardwareBackPress' ,
130- onAndroidBackPress ,
131- ) ;
140+ sub . remove ( ) ;
132141 } ;
133142 }
134143 } , [ onAndroidBackPress ] ) ;
135144
136145 return (
137- < >
138- < CustomWebView
139- onAuthenticated = { ( ) => setAuthenticated ( true ) }
140- ref = { webViewRef }
141- url = { url || 'https://nerimity.com/login' }
142- onVideoClick = { setVideoUrl }
143- />
144- < Show when = { videoUrl } >
145- < CustomVideo
146- ref = { videoRef }
147- videoUrl = { videoUrl ! }
148- onVideoEnd = { ( ) => {
149- setVideoUrl ( null ) ;
150- } }
151- />
152- </ Show >
153- </ >
146+ < View style = { { flex : 1 , backgroundColor : 'black' } } >
147+ < SafeAreaView style = { { flex : 1 } } >
148+ < KeyboardAvoidingView
149+ behavior = { Platform . OS === 'ios' ? 'padding' : undefined }
150+ style = { { flex : 1 } }
151+ >
152+ < CustomWebView
153+ onAuthenticated = { ( ) => setAuthenticated ( true ) }
154+ ref = { webViewRef }
155+ url = { url || 'https://nerimity.com/login' }
156+ onVideoClick = { setVideoUrl }
157+ />
158+ < Show when = { videoUrl } >
159+ < CustomVideo
160+ ref = { videoRef }
161+ videoUrl = { videoUrl ! }
162+ onVideoEnd = { ( ) => {
163+ setVideoUrl ( null ) ;
164+ } }
165+ />
166+ </ Show >
167+ </ KeyboardAvoidingView >
168+ </ SafeAreaView >
169+ </ View >
154170 ) ;
155171}
156172
@@ -167,7 +183,7 @@ function useUpdateChecker() {
167183 'Update Available' ,
168184 `Current: ${ env . APP_VERSION } \nLatest: ${ release . tag_name } ` ,
169185 [
170- { text : 'Later' } ,
186+ { text : 'Later' } ,
171187 {
172188 text : 'View Changelog' ,
173189 onPress : onViewChangelog ,
0 commit comments