@@ -21,7 +21,6 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
21
21
} ;
22
22
23
23
const hideModal = ( ) => {
24
- setStatusBarColor ( previousStatusBarColor ) ;
25
24
onModalHide ( ) ;
26
25
if ( ( window . history . state as WindowState ) ?. shouldGoBack ) {
27
26
window . history . back ( ) ;
@@ -33,6 +32,21 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
33
32
} ) ;
34
33
35
34
const showModal = ( ) => {
35
+ if ( shouldHandleNavigationBack ) {
36
+ window . history . pushState ( { shouldGoBack : true } , '' , null ) ;
37
+ window . addEventListener ( 'popstate' , handlePopStateRef . current ) ;
38
+ }
39
+ onModalShow ?.( ) ;
40
+ } ;
41
+
42
+ useEffect (
43
+ ( ) => ( ) => {
44
+ window . removeEventListener ( 'popstate' , handlePopStateRef . current ) ;
45
+ } ,
46
+ [ ] ,
47
+ ) ;
48
+
49
+ const onModalWillShow = ( ) => {
36
50
const statusBarColor = StatusBar . getBackgroundColor ( ) ?? theme . appBG ;
37
51
38
52
const isFullScreenModal =
@@ -46,27 +60,22 @@ function Modal({fullscreen = true, onModalHide = () => {}, type, onModalShow = (
46
60
// If it is a full screen modal then match it with appBG, otherwise we use the backdrop color
47
61
setStatusBarColor ( isFullScreenModal ? theme . appBG : StyleUtils . getThemeBackgroundColor ( statusBarColor ) ) ;
48
62
}
49
-
50
- if ( shouldHandleNavigationBack ) {
51
- window . history . pushState ( { shouldGoBack : true } , '' , null ) ;
52
- window . addEventListener ( 'popstate' , handlePopStateRef . current ) ;
53
- }
54
- onModalShow ?.( ) ;
63
+ rest . onModalWillShow ?.( ) ;
55
64
} ;
56
65
57
- useEffect (
58
- ( ) => ( ) => {
59
- window . removeEventListener ( 'popstate' , handlePopStateRef . current ) ;
60
- } ,
61
- [ ] ,
62
- ) ;
66
+ const onModalWillHide = ( ) => {
67
+ setStatusBarColor ( previousStatusBarColor ) ;
68
+ rest . onModalWillHide ?.( ) ;
69
+ } ;
63
70
64
71
return (
65
72
< BaseModal
66
73
// eslint-disable-next-line react/jsx-props-no-spreading
67
74
{ ...rest }
68
75
onModalHide = { hideModal }
69
76
onModalShow = { showModal }
77
+ onModalWillShow = { onModalWillShow }
78
+ onModalWillHide = { onModalWillHide }
70
79
avoidKeyboard = { false }
71
80
fullscreen = { fullscreen }
72
81
useNativeDriver = { false }
0 commit comments