@@ -2,7 +2,7 @@ import _ from 'lodash';
2
2
import React , { Component } from 'react' ;
3
3
import { StyleSheet , StyleProp , ViewStyle , ModalPropsIOS , AccessibilityProps } from 'react-native' ;
4
4
import { Colors } from '../../style' ;
5
- import Constants , { orientations } from '../../helpers/Constants' ;
5
+ import Constants from '../../helpers/Constants' ;
6
6
import { AlignmentModifiers , extractAlignmentsValues } from '../../commons/modifiers' ;
7
7
import { asBaseComponent } from '../../commons/new' ;
8
8
import Modal from '../modal' ;
@@ -23,67 +23,66 @@ interface RNPartialProps
23
23
Pick < AccessibilityProps , 'accessibilityLabel' > { }
24
24
25
25
export interface DialogProps extends AlignmentModifiers , RNPartialProps {
26
- /**
27
- * Control visibility of the dialog
28
- */
29
- visible ?: boolean ;
30
- /**
31
- * Dismiss callback for when clicking on the background
32
- */
33
- onDismiss ?: ( props ?: any ) => void ;
34
- /**
35
- * Whether or not to ignore background press
36
- */
37
- ignoreBackgroundPress ?: boolean ;
38
- /**
39
- * The color of the overlay background
40
- */
41
- overlayBackgroundColor ?: string ;
42
- /**
43
- * The dialog width (default: 90%)
44
- */
45
- width ?: string | number ;
46
- /**
47
- * The dialog height (default: undefined)
48
- */
49
- height ?: string | number ;
50
- /**
51
- * The direction of the allowed pan (default is DOWN).
52
- * Types: UP, DOWN, LEFT and RIGHT (using PanningProvider.Directions.###).
53
- * Pass null to remove pan.
54
- */
55
- panDirection ?: PanningDirections ;
56
- /**
57
- * Whether or not to handle SafeArea
58
- */
59
- useSafeArea ?: boolean ;
60
- /**
61
- * Called once the dialog has been dismissed completely
62
- */
63
- onDialogDismissed ?: ( props : any ) => void ;
64
- /**
65
- * If this is added only the header will be pannable;
66
- * this allows for scrollable content (the children of the dialog)
67
- * props are transferred to the renderPannableHeader
68
- */
69
- renderPannableHeader ?: ( props : any ) => JSX . Element ;
70
- /**
71
- * The props that will be passed to the pannable header
72
- */
73
- pannableHeaderProps ?: any ;
74
- /**
75
- * The Dialog`s container style
76
- */
77
- containerStyle ?: StyleProp < ViewStyle > ;
78
- /**
79
- * Used as a testing identifier
80
- */
81
- testID ?: string ;
26
+ /**
27
+ * Control visibility of the dialog
28
+ */
29
+ visible ?: boolean ;
30
+ /**
31
+ * Dismiss callback for when clicking on the background
32
+ */
33
+ onDismiss ?: ( props ?: any ) => void ;
34
+ /**
35
+ * Whether or not to ignore background press
36
+ */
37
+ ignoreBackgroundPress ?: boolean ;
38
+ /**
39
+ * The color of the overlay background
40
+ */
41
+ overlayBackgroundColor ?: string ;
42
+ /**
43
+ * The dialog width (default: 90%)
44
+ */
45
+ width ?: string | number ;
46
+ /**
47
+ * The dialog height (default: undefined)
48
+ */
49
+ height ?: string | number ;
50
+ /**
51
+ * The direction of the allowed pan (default is DOWN).
52
+ * Types: UP, DOWN, LEFT and RIGHT (using PanningProvider.Directions.###).
53
+ * Pass null to remove pan.
54
+ */
55
+ panDirection ?: PanningDirections ;
56
+ /**
57
+ * Whether or not to handle SafeArea
58
+ */
59
+ useSafeArea ?: boolean ;
60
+ /**
61
+ * Called once the dialog has been dismissed completely
62
+ */
63
+ onDialogDismissed ?: ( props : any ) => void ;
64
+ /**
65
+ * If this is added only the header will be pannable;
66
+ * this allows for scrollable content (the children of the dialog)
67
+ * props are transferred to the renderPannableHeader
68
+ */
69
+ renderPannableHeader ?: ( props : any ) => JSX . Element ;
70
+ /**
71
+ * The props that will be passed to the pannable header
72
+ */
73
+ pannableHeaderProps ?: any ;
74
+ /**
75
+ * The Dialog`s container style
76
+ */
77
+ containerStyle ?: StyleProp < ViewStyle > ;
78
+ /**
79
+ * Used as a testing identifier
80
+ */
81
+ testID ?: string ;
82
82
}
83
83
84
84
interface DialogState {
85
85
alignments : AlignmentModifiers ;
86
- orientationKey : orientations ;
87
86
modalVisibility ?: boolean ;
88
87
dialogVisibility ?: boolean ;
89
88
fadeOut ?: boolean ;
@@ -113,7 +112,6 @@ class Dialog extends Component<DialogProps, DialogState> {
113
112
114
113
this . state = {
115
114
alignments : extractAlignmentsValues ( props ) ,
116
- orientationKey : Constants . orientation ,
117
115
modalVisibility : props . visible ,
118
116
dialogVisibility : props . visible
119
117
} ;
@@ -122,14 +120,6 @@ class Dialog extends Component<DialogProps, DialogState> {
122
120
this . setAlignment ( ) ;
123
121
}
124
122
125
- componentDidMount ( ) {
126
- Constants . addDimensionsEventListener ( this . onOrientationChange ) ;
127
- }
128
-
129
- componentWillUnmount ( ) {
130
- Constants . removeDimensionsEventListener ( this . onOrientationChange ) ;
131
- }
132
-
133
123
UNSAFE_componentWillReceiveProps ( nextProps : DialogProps ) {
134
124
const { visible : nexVisible } = nextProps ;
135
125
const { visible} = this . props ;
@@ -141,13 +131,6 @@ class Dialog extends Component<DialogProps, DialogState> {
141
131
}
142
132
}
143
133
144
- onOrientationChange = ( ) => {
145
- const orientationKey = Constants . orientation ;
146
- if ( this . state . orientationKey !== orientationKey ) {
147
- this . setState ( { orientationKey} ) ;
148
- }
149
- } ;
150
-
151
134
setAlignment ( ) {
152
135
const { alignments} = this . state ;
153
136
if ( _ . isEmpty ( alignments ) ) {
@@ -160,11 +143,12 @@ class Dialog extends Component<DialogProps, DialogState> {
160
143
// TODO: revert adding this workaround once RN fixes https://github.com/facebook/react-native/issues/29455
161
144
onFadeDone = ( ) => {
162
145
if ( ! this . state . modalVisibility ) {
163
- setTimeout ( ( ) => { // unfortunately this is needed if a modal needs to open on iOS
146
+ setTimeout ( ( ) => {
147
+ // unfortunately this is needed if a modal needs to open on iOS
164
148
this . props . onDialogDismissed ?.( this . props ) ;
165
149
} , 100 ) ;
166
150
}
167
- }
151
+ } ;
168
152
169
153
_onDismiss = ( ) => {
170
154
this . setState ( { modalVisibility : false , fadeOut : false } , ( ) => {
@@ -177,7 +161,7 @@ class Dialog extends Component<DialogProps, DialogState> {
177
161
props . onDialogDismissed ?.( props ) ;
178
162
}
179
163
} ) ;
180
- }
164
+ } ;
181
165
182
166
onDismiss = ( ) => {
183
167
const fadeOut = Constants . isIOS && this . props . visible ;
@@ -206,7 +190,7 @@ class Dialog extends Component<DialogProps, DialogState> {
206
190
return View ;
207
191
}
208
192
return PanListenerView ;
209
- }
193
+ } ;
210
194
211
195
renderDialogView = ( ) => {
212
196
const { children, panDirection = PanningProvider . Directions . DOWN , containerStyle, testID} = this . props ;
@@ -237,7 +221,7 @@ class Dialog extends Component<DialogProps, DialogState> {
237
221
renderDialogContainer = ( ) => {
238
222
const { modalVisibility, dialogVisibility, fadeOut} = this . state ;
239
223
const { useSafeArea, bottom, overlayBackgroundColor, testID} = this . props ;
240
- const addBottomSafeArea = Constants . isIphoneX && ( useSafeArea && bottom ) ;
224
+ const addBottomSafeArea = Constants . isIphoneX && useSafeArea && bottom ;
241
225
const bottomInsets = Constants . getSafeAreaInsets ( ) . bottom - 8 ; // TODO: should this be here or in the input style?
242
226
const onFadeDone = Constants . isIOS ? this . onFadeDone : undefined ;
243
227
@@ -262,13 +246,12 @@ class Dialog extends Component<DialogProps, DialogState> {
262
246
} ;
263
247
264
248
render = ( ) => {
265
- const { orientationKey , modalVisibility} = this . state ;
249
+ const { modalVisibility} = this . state ;
266
250
const { testID, supportedOrientations, accessibilityLabel, ignoreBackgroundPress} = this . props ;
267
251
const onBackgroundPress = ! ignoreBackgroundPress ? this . hideDialogView : undefined ;
268
252
269
253
return (
270
254
< Modal
271
- key = { orientationKey }
272
255
testID = { `${ testID } .modal` }
273
256
transparent
274
257
visible = { modalVisibility }
0 commit comments