Skip to content

Commit

Permalink
feat: explicit animation type
Browse files Browse the repository at this point in the history
Closes #21
  • Loading branch information
ykliuiev committed Nov 10, 2020
1 parent 31184da commit 2df57d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -67,6 +67,7 @@ function SingleDatePage() {
onConfirm={onChange}
saveLabel={'Save'} // optional
label={'Select period'} // optional
animationType={'slide'} // optional
/>
<Button onPress={()=> setVisible(true)}>
Pick date
Expand Down Expand Up @@ -107,6 +108,7 @@ export default function RangeDatePage() {
label={'Select period'} // optional
startLabel={'From'} // optional
endLabel={'To'} // optional
animationType={'slide'} // optional
/>
<Button onPress={()=> setVisible(true)}>
Pick range
Expand Down
8 changes: 8 additions & 0 deletions example/src/App.tsx
Expand Up @@ -106,6 +106,10 @@ function App({
label={'Select period'} // optional
startLabel={'From'} // optional
endLabel={'To'} // optional
animationType={Platform.select({
web: 'none',
default: 'slide',
})} // optional
/>
<DatePickerModal
mode="single"
Expand All @@ -115,6 +119,10 @@ function App({
onConfirm={onChangeSingle}
saveLabel={'Save'} // optional
label={'Select date'} // optional
animationType={Platform.select({
web: 'none',
default: 'slide',
})} // optional
/>

<TimePickerModal
Expand Down
5 changes: 3 additions & 2 deletions src/Date/DatePickerModal.tsx
Expand Up @@ -26,6 +26,7 @@ interface DatePickerModalProps extends HeaderPickProps, BaseCalendarProps {
visible: boolean
onDismiss: () => any
inputFormat?: string
animationType?: 'slide' | 'fade' | 'none'
}

export type LocalState = {
Expand Down Expand Up @@ -57,7 +58,7 @@ export function DatePickerModal(
) {
const theme = useTheme()
const dimensions = useWindowDimensions()
const { visible, onDismiss, mode, onChange, onConfirm } = props
const { visible, onDismiss, mode, onChange, onConfirm, animationType } = props
const anyProps = props as any

// use local state to add only onConfirm state changes
Expand Down Expand Up @@ -101,7 +102,7 @@ export function DatePickerModal(

return (
<Modal
animationType="slide"
animationType={animationType}
transparent={true}
visible={visible}
onRequestClose={onDismiss}
Expand Down

0 comments on commit 2df57d3

Please sign in to comment.