Skip to content

Commit 4856e59

Browse files
presentationStyle
Added the prop for presentationStyle also removed the warning of transparent if presentationStyle === 'pageSheet'
1 parent 7227977 commit 4856e59

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

src/Date/DatePickerModal.tsx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as React from 'react'
1+
import * as React from 'react';
22
import {
33
Modal,
44
StyleSheet,
@@ -7,23 +7,24 @@ import {
77
View,
88
Platform,
99
StatusBar,
10-
} from 'react-native'
10+
} from 'react-native';
1111

12-
import { useTheme } from 'react-native-paper'
12+
import { useTheme } from 'react-native-paper';
1313
import DatePickerModalContent, {
1414
DatePickerModalContentMultiProps,
1515
DatePickerModalContentRangeProps,
1616
DatePickerModalContentSingleProps,
17-
} from './DatePickerModalContent'
18-
import { useHeaderBackgroundColor, useHeaderColorIsLight } from '../utils'
19-
import { useSafeAreaInsets } from 'react-native-safe-area-context'
17+
} from './DatePickerModalContent';
18+
import { useHeaderBackgroundColor, useHeaderColorIsLight } from '../utils';
19+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
2020

2121
interface DatePickerModalProps {
22-
visible: boolean
23-
animationType?: 'slide' | 'fade' | 'none'
24-
disableStatusBar?: boolean
25-
disableStatusBarPadding?: boolean
26-
inputEnabled?: boolean
22+
visible: boolean;
23+
animationType?: 'slide' | 'fade' | 'none';
24+
disableStatusBar?: boolean;
25+
disableStatusBarPadding?: boolean;
26+
inputEnabled?: boolean;
27+
presentationStyle?: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen';
2728
}
2829

2930
export interface DatePickerModalSingleProps
@@ -44,35 +45,36 @@ export function DatePickerModal(
4445
| DatePickerModalSingleProps
4546
| DatePickerModalMultiProps
4647
) {
47-
const theme = useTheme()
48-
const dimensions = useWindowDimensions()
48+
const theme = useTheme();
49+
const dimensions = useWindowDimensions();
4950
const {
5051
visible,
5152
animationType,
5253
disableStatusBar,
5354
disableStatusBarPadding,
5455
inputEnabled,
56+
presentationStyle,
5557
...rest
56-
} = props
58+
} = props;
5759
const animationTypeCalculated =
5860
animationType ||
5961
Platform.select({
6062
web: 'none',
6163
default: 'slide',
62-
})
63-
64-
const isLight = useHeaderColorIsLight()
65-
const headerBackgroundColor = useHeaderBackgroundColor()
66-
const insets = useSafeAreaInsets()
64+
});
6765

66+
const isLight = useHeaderColorIsLight();
67+
const headerBackgroundColor = useHeaderBackgroundColor();
68+
const insets = useSafeAreaInsets();
69+
const isTransparent = presentationStyle === 'pageSheet' ? false : true;
6870
return (
6971
<View style={[StyleSheet.absoluteFill]} pointerEvents="box-none">
7072
<Modal
7173
animationType={animationTypeCalculated}
72-
transparent={false}
74+
transparent={isTransparent}
7375
visible={visible}
7476
onRequestClose={rest.onDismiss}
75-
presentationStyle="pageSheet"
77+
presentationStyle={presentationStyle || "overFullScreen"}
7678
supportedOrientations={supportedOrientations}
7779
//@ts-ignore
7880
statusBarTranslucent={true}
@@ -124,15 +126,16 @@ export function DatePickerModal(
124126
</>
125127
</Modal>
126128
</View>
127-
)
129+
);
128130
}
131+
129132
const supportedOrientations: any = [
130133
'portrait',
131134
'portrait-upside-down',
132135
'landscape',
133136
'landscape-left',
134137
'landscape-right',
135-
]
138+
];
136139

137140
const styles = StyleSheet.create({
138141
modalRoot: {
@@ -154,6 +157,6 @@ const styles = StyleSheet.create({
154157
width: '100%',
155158
overflow: 'hidden',
156159
},
157-
})
160+
});
158161

159-
export default React.memo(DatePickerModal)
162+
export default React.memo(DatePickerModal);

0 commit comments

Comments
 (0)