Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PresentationStyle #311

Merged
merged 7 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions docusaurus/docs/date-picker/input-date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function App() {

return (
<SafeAreaProvider>
<View style={{justifyContent: 'center', flex: 1, alignItems: 'center'}}>
<View style={{ justifyContent: 'center', flex: 1, alignItems: 'center' }}>
<DatePickerInput
locale="en"
label="Birthdate"
Expand All @@ -29,7 +29,7 @@ export default function App() {
/>
</View>
</SafeAreaProvider>
);
)
}
```

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

* Other [react-native TextInput props](https://reactnative.dev/docs/textinput#props).*
**presentationStyle**
`Type: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen'`
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.

- `'fullScreen'`: Presents the modal as a full-screen overlay.
- `'pageSheet'`: Displays the modal as a card-style sheet that covers a portion of the screen.
- `'formSheet'`: Renders the modal as a smaller form-style sheet.
- `'overFullScreen'`: Overlays the modal on top of the content, allowing interaction with the underlying content.

For example, if you set `presentationStyle` to `'pageSheet'`, the modal will be presented as a card-like sheet.

- Other [react-native TextInput props](https://reactnative.dev/docs/textinput#props).\*
15 changes: 13 additions & 2 deletions docusaurus/docs/date-picker/multiple-dates-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default function App() {

return (
<SafeAreaProvider>
<View style={{justifyContent: 'center', flex: 1, alignItems: 'center'}}>
<View style={{ justifyContent: 'center', flex: 1, alignItems: 'center' }}>
<Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
Pick multiple dates
</Button>
Expand All @@ -45,7 +45,7 @@ export default function App() {
/>
</View>
</SafeAreaProvider>
);
)
}
```

Expand Down Expand Up @@ -142,3 +142,14 @@ The edit icon used to toggle between calendar and input. Defaults to `pencil`. Y
**calendarIcon**
`Type: string | undefined`
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/).

**presentationStyle**
`Type: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen'`
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.

- `'fullScreen'`: Presents the modal as a full-screen overlay.
- `'pageSheet'`: Displays the modal as a card-style sheet that covers a portion of the screen.
- `'formSheet'`: Renders the modal as a smaller form-style sheet.
- `'overFullScreen'`: Overlays the modal on top of the content, allowing interaction with the underlying content.

For example, if you set `presentationStyle` to `'pageSheet'`, the modal will be presented as a card-like sheet.
19 changes: 15 additions & 4 deletions docusaurus/docs/date-picker/range-date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export default function App() {
const [range, setRange] = React.useState({ startDate: undefined, endDate: undefined });
const [open, setOpen] = React.useState(false);

const onDismiss = React.useCallback(() => {
const onDismiss = React.useCallback(() => {
setOpen(false);
}, [setOpen]);

const onConfirm = React.useCallback(
const onConfirm = React.useCallback(
({ startDate, endDate }) => {
setOpen(false);
setRange({ startDate, endDate });
Expand All @@ -33,7 +33,7 @@ export default function App() {

return (
<SafeAreaProvider>
<View style={{justifyContent: 'center', flex: 1, alignItems: 'center'}}>
<View style={{ justifyContent: 'center', flex: 1, alignItems: 'center' }}>
<Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
Pick range
</Button>
Expand All @@ -48,7 +48,7 @@ export default function App() {
/>
</View>
</SafeAreaProvider>
);
)
}
```

Expand Down Expand Up @@ -149,3 +149,14 @@ The edit icon used to toggle between input and calendar. Defaults to `calendar`.
**inputEnabled**
`Type: boolean | undefined`
Flag indicating if the component should be enabled or not. Defaults to `true`.

**presentationStyle**
`Type: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen'`
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.

- `'fullScreen'`: Presents the modal as a full-screen overlay.
- `'pageSheet'`: Displays the modal as a card-style sheet that covers a portion of the screen.
- `'formSheet'`: Renders the modal as a smaller form-style sheet.
- `'overFullScreen'`: Overlays the modal on top of the content, allowing interaction with the underlying content.

For example, if you set `presentationStyle` to `'pageSheet'`, the modal will be presented as a card-like sheet.
15 changes: 13 additions & 2 deletions docusaurus/docs/date-picker/single-date-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function App() {

return (
<SafeAreaProvider>
<View style={{justifyContent: 'center', flex: 1, alignItems: 'center'}}>
<View style={{ justifyContent: 'center', flex: 1, alignItems: 'center' }}>
<Button onPress={() => setOpen(true)} uppercase={false} mode="outlined">
Pick single date
</Button>
Expand All @@ -47,7 +47,7 @@ export default function App() {
/>
</View>
</SafeAreaProvider>
);
)
}
```

Expand Down Expand Up @@ -136,3 +136,14 @@ The edit icon used to toggle between input and calendar. Defaults to `calendar`.
**inputEnabled**
`Type: boolean | undefined`
Flag indicating if the component should be enabled or not. Defaults to `true`.

**presentationStyle**
`Type: 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen'`
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.

- `'fullScreen'`: Presents the modal as a full-screen overlay.
- `'pageSheet'`: Displays the modal as a card-style sheet that covers a portion of the screen.
- `'formSheet'`: Renders the modal as a smaller form-style sheet.
- `'overFullScreen'`: Overlays the modal on top of the content, allowing interaction with the underlying content.

For example, if you set `presentationStyle` to `'pageSheet'`, the modal will be presented as a card-like sheet.
14 changes: 10 additions & 4 deletions src/Date/DatePickerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Platform,
StatusBar,
} from 'react-native'

import { useTheme } from 'react-native-paper'
import DatePickerModalContent, {
DatePickerModalContentMultiProps,
Expand All @@ -24,6 +23,11 @@ interface DatePickerModalProps {
disableStatusBar?: boolean
disableStatusBarPadding?: boolean
inputEnabled?: boolean
presentationStyle?:
| 'fullScreen'
| 'pageSheet'
| 'formSheet'
| 'overFullScreen'
}

export interface DatePickerModalSingleProps
Expand Down Expand Up @@ -52,6 +56,7 @@ export function DatePickerModal(
disableStatusBar,
disableStatusBarPadding,
inputEnabled,
presentationStyle,
...rest
} = props
const animationTypeCalculated =
Expand All @@ -64,15 +69,15 @@ export function DatePickerModal(
const isLight = useHeaderColorIsLight()
const headerBackgroundColor = useHeaderBackgroundColor()
const insets = useSafeAreaInsets()

const isTransparent = presentationStyle === 'pageSheet' ? false : true
return (
<View style={[StyleSheet.absoluteFill]} pointerEvents="box-none">
<Modal
animationType={animationTypeCalculated}
transparent={true}
transparent={isTransparent}
visible={visible}
onRequestClose={rest.onDismiss}
presentationStyle="overFullScreen"
presentationStyle={presentationStyle || 'overFullScreen'}
supportedOrientations={supportedOrientations}
//@ts-ignore
statusBarTranslucent={true}
Expand Down Expand Up @@ -126,6 +131,7 @@ export function DatePickerModal(
</View>
)
}

const supportedOrientations: any = [
'portrait',
'portrait-upside-down',
Expand Down