Skip to content

Commit ddbb824

Browse files
authored
Merge pull request #311 from SharfMohiuddin/master
PresentationStyle
2 parents 43a2c73 + b3eab65 commit ddbb824

File tree

5 files changed

+65
-15
lines changed

5 files changed

+65
-15
lines changed

docusaurus/docs/date-picker/input-date-picker.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function App() {
1919

2020
return (
2121
<SafeAreaProvider>
22-
<View style={{justifyContent: 'center', flex: 1, alignItems: 'center'}}>
22+
<View style={{ justifyContent: 'center', flex: 1, alignItems: 'center' }}>
2323
<DatePickerInput
2424
locale="en"
2525
label="Birthdate"
@@ -29,7 +29,7 @@ export default function App() {
2929
/>
3030
</View>
3131
</SafeAreaProvider>
32-
);
32+
)
3333
}
3434
```
3535

@@ -103,4 +103,15 @@ The end year when the component is rendered. Defaults to `2200`.
103103
`Type: boolean | undefined`
104104
Flag indicating if the component should be enabled or not. Behavior similarly to `disabled`. Defaults to `true`.
105105

106-
* Other [react-native TextInput props](https://reactnative.dev/docs/textinput#props).*
106+
**presentationStyle**
107+
`Type: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen'`
108+
Determines the visual presentation style of the date picker modal. This prop allows you to define how the modal appears on the screen when it is displayed.
109+
110+
- `'fullScreen'`: Presents the modal as a full-screen overlay.
111+
- `'pageSheet'`: Displays the modal as a card-style sheet that covers a portion of the screen.
112+
- `'formSheet'`: Renders the modal as a smaller form-style sheet.
113+
- `'overFullScreen'`: Overlays the modal on top of the content, allowing interaction with the underlying content.
114+
115+
For example, if you set `presentationStyle` to `'pageSheet'`, the modal will be presented as a card-like sheet.
116+
117+
- Other [react-native TextInput props](https://reactnative.dev/docs/textinput#props).\*

docusaurus/docs/date-picker/multiple-dates-picker.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function App() {
3131

3232
return (
3333
<SafeAreaProvider>
34-
<View style={{justifyContent: 'center', flex: 1, alignItems: 'center'}}>
34+
<View style={{ justifyContent: 'center', flex: 1, alignItems: 'center' }}>
3535
<Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
3636
Pick multiple dates
3737
</Button>
@@ -45,7 +45,7 @@ export default function App() {
4545
/>
4646
</View>
4747
</SafeAreaProvider>
48-
);
48+
)
4949
}
5050
```
5151

@@ -142,3 +142,14 @@ The edit icon used to toggle between calendar and input. Defaults to `pencil`. Y
142142
**calendarIcon**
143143
`Type: string | undefined`
144144
The edit icon used to toggle between input and calendar. Defaults to `calendar`. You can pass the name of an icon from [MaterialCommunityIcons](https://materialdesignicons.com/).
145+
146+
**presentationStyle**
147+
`Type: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen'`
148+
Determines the visual presentation style of the date picker modal. This prop allows you to define how the modal appears on the screen when it is displayed.
149+
150+
- `'fullScreen'`: Presents the modal as a full-screen overlay.
151+
- `'pageSheet'`: Displays the modal as a card-style sheet that covers a portion of the screen.
152+
- `'formSheet'`: Renders the modal as a smaller form-style sheet.
153+
- `'overFullScreen'`: Overlays the modal on top of the content, allowing interaction with the underlying content.
154+
155+
For example, if you set `presentationStyle` to `'pageSheet'`, the modal will be presented as a card-like sheet.

docusaurus/docs/date-picker/range-date-picker.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export default function App() {
1919
const [range, setRange] = React.useState({ startDate: undefined, endDate: undefined });
2020
const [open, setOpen] = React.useState(false);
2121

22-
const onDismiss = React.useCallback(() => {
22+
const onDismiss = React.useCallback(() => {
2323
setOpen(false);
2424
}, [setOpen]);
2525

26-
const onConfirm = React.useCallback(
26+
const onConfirm = React.useCallback(
2727
({ startDate, endDate }) => {
2828
setOpen(false);
2929
setRange({ startDate, endDate });
@@ -33,7 +33,7 @@ export default function App() {
3333

3434
return (
3535
<SafeAreaProvider>
36-
<View style={{justifyContent: 'center', flex: 1, alignItems: 'center'}}>
36+
<View style={{ justifyContent: 'center', flex: 1, alignItems: 'center' }}>
3737
<Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
3838
Pick range
3939
</Button>
@@ -48,7 +48,7 @@ export default function App() {
4848
/>
4949
</View>
5050
</SafeAreaProvider>
51-
);
51+
)
5252
}
5353
```
5454

@@ -149,3 +149,14 @@ The edit icon used to toggle between input and calendar. Defaults to `calendar`.
149149
**inputEnabled**
150150
`Type: boolean | undefined`
151151
Flag indicating if the component should be enabled or not. Defaults to `true`.
152+
153+
**presentationStyle**
154+
`Type: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen'`
155+
Determines the visual presentation style of the date picker modal. This prop allows you to define how the modal appears on the screen when it is displayed.
156+
157+
- `'fullScreen'`: Presents the modal as a full-screen overlay.
158+
- `'pageSheet'`: Displays the modal as a card-style sheet that covers a portion of the screen.
159+
- `'formSheet'`: Renders the modal as a smaller form-style sheet.
160+
- `'overFullScreen'`: Overlays the modal on top of the content, allowing interaction with the underlying content.
161+
162+
For example, if you set `presentationStyle` to `'pageSheet'`, the modal will be presented as a card-like sheet.

docusaurus/docs/date-picker/single-date-picker.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function App() {
3333

3434
return (
3535
<SafeAreaProvider>
36-
<View style={{justifyContent: 'center', flex: 1, alignItems: 'center'}}>
36+
<View style={{ justifyContent: 'center', flex: 1, alignItems: 'center' }}>
3737
<Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
3838
Pick single date
3939
</Button>
@@ -47,7 +47,7 @@ export default function App() {
4747
/>
4848
</View>
4949
</SafeAreaProvider>
50-
);
50+
)
5151
}
5252
```
5353

@@ -136,3 +136,14 @@ The edit icon used to toggle between input and calendar. Defaults to `calendar`.
136136
**inputEnabled**
137137
`Type: boolean | undefined`
138138
Flag indicating if the component should be enabled or not. Defaults to `true`.
139+
140+
**presentationStyle**
141+
`Type: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen'`
142+
Determines the visual presentation style of the date picker modal. This prop allows you to define how the modal appears on the screen when it is displayed.
143+
144+
- `'fullScreen'`: Presents the modal as a full-screen overlay.
145+
- `'pageSheet'`: Displays the modal as a card-style sheet that covers a portion of the screen.
146+
- `'formSheet'`: Renders the modal as a smaller form-style sheet.
147+
- `'overFullScreen'`: Overlays the modal on top of the content, allowing interaction with the underlying content.
148+
149+
For example, if you set `presentationStyle` to `'pageSheet'`, the modal will be presented as a card-like sheet.

src/Date/DatePickerModal.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
Platform,
99
StatusBar,
1010
} from 'react-native'
11-
1211
import { useTheme } from 'react-native-paper'
1312
import DatePickerModalContent, {
1413
DatePickerModalContentMultiProps,
@@ -24,6 +23,11 @@ interface DatePickerModalProps {
2423
disableStatusBar?: boolean
2524
disableStatusBarPadding?: boolean
2625
inputEnabled?: boolean
26+
presentationStyle?:
27+
| 'fullScreen'
28+
| 'pageSheet'
29+
| 'formSheet'
30+
| 'overFullScreen'
2731
}
2832

2933
export interface DatePickerModalSingleProps
@@ -52,6 +56,7 @@ export function DatePickerModal(
5256
disableStatusBar,
5357
disableStatusBarPadding,
5458
inputEnabled,
59+
presentationStyle,
5560
...rest
5661
} = props
5762
const animationTypeCalculated =
@@ -64,15 +69,15 @@ export function DatePickerModal(
6469
const isLight = useHeaderColorIsLight()
6570
const headerBackgroundColor = useHeaderBackgroundColor()
6671
const insets = useSafeAreaInsets()
67-
72+
const isTransparent = presentationStyle === 'pageSheet' ? false : true
6873
return (
6974
<View style={[StyleSheet.absoluteFill]} pointerEvents="box-none">
7075
<Modal
7176
animationType={animationTypeCalculated}
72-
transparent={true}
77+
transparent={isTransparent}
7378
visible={visible}
7479
onRequestClose={rest.onDismiss}
75-
presentationStyle="overFullScreen"
80+
presentationStyle={presentationStyle || 'overFullScreen'}
7681
supportedOrientations={supportedOrientations}
7782
//@ts-ignore
7883
statusBarTranslucent={true}
@@ -126,6 +131,7 @@ export function DatePickerModal(
126131
</View>
127132
)
128133
}
134+
129135
const supportedOrientations: any = [
130136
'portrait',
131137
'portrait-upside-down',

0 commit comments

Comments
 (0)