- Features
- Built With
- Pending Items
- Picker Types (iOS)
- Picker Types (Android)
- Getting Started
- Props
- Building & Publishing
- Changelog
- âś… iOS/Android
- âś… Dark Mode
- âś… Custom Styles
- âś… Built with TypeScript
- âś… Built with React Hooks
- TypeScript - Programming Language
- React Native - Mobile (iOS/Android) Framework
- React Native Slide Modal - Modal
- React Native Picker - Native Picker
- React Native Datetime Picker - Native Date/Time Picker
- React Hooks - Functional Component State/Lifecycle Methods
- Fix Android issues
1. Install Package:
npm i react-native-ultimate-modal-picker
2. Install additional dependencies:
Note: This NPM Package uses the Native Modules @react-native-community/datetimepicker
and @react-native-picker/picker
, so it must be installed in your project.
npm i @react-native-community/datetimepicker @react-native-picker/picker
3. Install Cocoapods:
cd ios
pod install
4. Add Example Code:
// Imports: Dependencies
import React, { useState } from 'react';
import { SafeAreaView, ScrollView } from 'react-native';
import {
// Pickers
PickerTime,
PickerDate,
PickerDateTime,
PickerDateRange,
// Dropdowns
DropdownList,
DropdownMeasurements,
DropdownNumber,
DropdownState,
// TypeScript Types
PickerItem,
} from 'react-native-ultimate-modal-picker';
// React Native App
const App: React.FC = (): JSX.Element => {
// React Hooks: State
// Pickers
const [ date, setDate ] = useState<Date>(new Date());
const [ time, setTime ] = useState<Date>(new Date());
const [ dateTime, setDateTime ] = useState<Date>(new Date());
const [ fromDate, setFromDate ] = useState<Date>(new Date());
const [ toDate, setToDate ] = useState<Date>(new Date());
// Dropdowns
const [ listValue, setListValue ] = useState<string>('');
const [ numberValue, setNumberValue ] = useState<string>('');
const [ measurementValue, setMeasurementValue ] = useState<string>('');
const [ stateValue, setStateValue ] = useState<string>('');
// Items
const items: Array<PickerItem> = [
{ label: '1', value: '1' },
{ label: '2', value: '2' },
{ label: '3', value: '3' },
{ label: '4', value: '4' },
{ label: '5', value: '5' },
{ label: '6', value: '6' },
{ label: '7', value: '7' },
{ label: '8', value: '8' },
{ label: '9', value: '9' },
{ label: '10', value: '10' },
];
return (
<SafeAreaView style={{ display: 'flex', flex: 1 }}>
<ScrollView>
{/* Picker: Date (Modes: spinner/calendar) */}
<PickerDate
title="Date"
onChange={(date: Date) => setDate(date)}
mode="spinner"
/>
{/* Picker: Time (Modes: spinner/clock) */}
<PickerTime
title="Time"
onChange={(date: Date) => setTime(date)}
mode="spinner"
/>
{/* Picker: Date Time (iOS Only) */}
<PickerDateTime
title="Date/Time"
onChange={(date: Date) => setDateTime(date)}
/>
{/* Picker (Date Range) */}
<PickerDateRange
title="Date Range"
onFromChange={(date: Date) => setFromDate(date)}
onToChange={(date: Date) => setToDate(date)}
mode="spinner"
/>
{/* Dropdown: List */}
<DropdownList
title="List"
items={items}
onChange={(value: string) => setListValue(value)}
/>
{/* Dropdown: Number */}
<DropdownNumber
title="Number"
onChange={(value: string) => setNumberValue(value)}
/>
{/* Dropdown: Measurements */}
<DropdownMeasurements
title="Measurement"
onChange={(value: string) => setMeasurementValue(value)}
/>
{/* Dropdown: State */}
<DropdownState
title="State"
onChange={(value: string) => setStateValue(value)}
/>
{/* Picker: Date (Custom Styles) */}
<PickerDate
title="Date (Custom Styles)"
onChange={(date: Date) => setDate(date)}
mode="spinner"
customStyleContainer={{
containerLight: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
containerDark: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleLabelText={{
labelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
labelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
/>
{/* Picker: Time (Custom Styles) */}
<PickerTime
title="Time (Custom Styles)"
onChange={(date: Date) => setTime(date)}
mode="spinner"
customStyleContainer={{
containerLight: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
containerDark: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleLabelText={{
labelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
labelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
/>
{/* Picker: Date Time (Custom Styles) */}
<PickerDateTime
title="Date/Time (Custom Styles)"
onChange={(date: Date) => setDateTime(date)}
customStyleContainer={{
containerLight: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
containerDark: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleLabelText={{
labelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
labelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
/>
{/* Picker (Custom Styles) */}
<PickerDateRange
title="Date Range"
onFromChange={(date: Date) => setFromDate(date)}
onToChange={(date: Date) => setToDate(date)}
mode="spinner"
customStyleContainer={{
containerLight: {
backgroundColor: '#000000',
},
containerDark: {
backgroundColor: '#000000',
},
}}
customStyleTitleText={{
titleTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
titleTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleLabelText={{
labelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
labelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleDivider={{
dividerLight: {
marginTop: 16,
marginBottom: 16,
borderBottomWidth: 2,
borderColor: 'red',
},
dividerDark: {
marginTop: 16,
marginBottom: 16,
borderBottomWidth: 2,
borderColor: 'red',
},
}}
/>
{/* Dropdown: List (Custom Styles) */}
<DropdownList
title="List (Custom Styles)"
items={items}
onChange={(value: string) => setListValue(value)}
customStyleContainer={{
containerLight: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
containerDark: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleLabelText={{
labelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
labelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleFieldText={{
fieldTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
fieldTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleModalHeaderContainer={{
modalHeaderContainerLight: {
height: 55,
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
modalHeaderContainerDark: {
height: 55,
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleCancelText={{
cancelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
color: 'red',
},
cancelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
color: 'red',
},
}}
customStyleDoneText={{
doneTextLight: {
color: 'red',
},
doneTextDark: {
color: 'red',
},
}}
customStyleModalContentContainer={{
modalContentContainerLight: {
height: 400,
backgroundColor: '#000000',
},
modalContentContainerDark: {
height: 400,
backgroundColor: '#000000',
},
}}
customStylePickerItemText={{
pickerItemTextLight: {
color: 'red',
},
pickerItemTextDark: {
color: 'red',
}
}}
/>
{/* Dropdown: Number (Custom Styles) */}
<DropdownNumber
title="Number"
onChange={(value: string) => setNumberValue(value)}
customStyleContainer={{
containerLight: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
containerDark: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleLabelText={{
labelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
labelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleFieldText={{
fieldTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
fieldTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleModalHeaderContainer={{
modalHeaderContainerLight: {
height: 55,
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
modalHeaderContainerDark: {
height: 55,
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleCancelText={{
cancelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
color: 'red',
},
cancelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
color: 'red',
},
}}
customStyleDoneText={{
doneTextLight: {
color: 'red',
},
doneTextDark: {
color: 'red',
},
}}
customStyleModalContentContainer={{
modalContentContainerLight: {
height: 400,
backgroundColor: '#000000',
},
modalContentContainerDark: {
height: 400,
backgroundColor: '#000000',
},
}}
customStylePickerItemText={{
pickerItemTextLight: {
color: 'red',
},
pickerItemTextDark: {
color: 'red',
}
}}
/>
{/* Dropdown: Measurements (Custom Styles) */}
<DropdownMeasurements
title="Measurement"
onChange={(value: string) => setMeasurementValue(value)}
customStyleContainer={{
containerLight: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
containerDark: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleLabelText={{
labelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
labelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleFieldText={{
fieldTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
fieldTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleModalHeaderContainer={{
modalHeaderContainerLight: {
height: 55,
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
modalHeaderContainerDark: {
height: 55,
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleCancelText={{
cancelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
color: 'red',
},
cancelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
color: 'red',
},
}}
customStyleDoneText={{
doneTextLight: {
color: 'red',
},
doneTextDark: {
color: 'red',
},
}}
customStyleModalContentContainer={{
modalContentContainerLight: {
height: 400,
backgroundColor: '#000000',
},
modalContentContainerDark: {
height: 400,
backgroundColor: '#000000',
},
}}
customStylePickerItemText={{
pickerItemTextLight: {
color: 'red',
},
pickerItemTextDark: {
color: 'red',
}
}}
/>
{/* Dropdown: State (Custom Styles) */}
<DropdownState
title="State"
onChange={(value: string) => setStateValue(value)}
customStyleContainer={{
containerLight: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
containerDark: {
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleLabelText={{
labelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
labelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleFieldText={{
fieldTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
fieldTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
textTransform: 'lowercase',
color: 'red',
},
}}
customStyleModalHeaderContainer={{
modalHeaderContainerLight: {
height: 55,
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
modalHeaderContainerDark: {
height: 55,
backgroundColor: '#000000',
borderColor: '#000000',
borderBottomWidth: 2,
},
}}
customStyleCancelText={{
cancelTextLight: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
color: 'red',
},
cancelTextDark: {
fontFamily: 'System',
fontSize: 22,
fontWeight: '800',
color: 'red',
},
}}
customStyleDoneText={{
doneTextLight: {
color: 'red',
},
doneTextDark: {
color: 'red',
},
}}
customStyleModalContentContainer={{
modalContentContainerLight: {
height: 400,
backgroundColor: '#000000',
},
modalContentContainerDark: {
height: 400,
backgroundColor: '#000000',
},
}}
customStylePickerItemText={{
pickerItemTextLight: {
color: 'red',
},
pickerItemTextDark: {
color: 'red',
}
}}
/>
</ScrollView>
</SafeAreaView>
);
};
// Exports
export default App;
6. Run Project:
Android
react-native run-android
iOS
react-native run-ios
Build
npm run build
Publish
npm publish
Changed
- Added
cancelText
anddoneText
optional props to alldropdowns
.
Changed
- Changed
import React from 'react
toimport * as React from 'react
. - Updated example code in
README
.
Added
- Added
@react-native-picker/picker
as apeerDependency
.
Changed
- Changed
"jsx": "react-native"
to"jsx": "react-jsx"
intsconfig.json
.
Changed
- Updated Getting Started in
README
.
Added
- Added
@react-native-picker/picker
as adevDependency
andpeerDependency
.
Changed
- Updated Getting Started in
README
.
Added
- Added
react-native-community/datetimepicker
as adevDependency
.
Added
- Added
@react-native-community/datetimepicker
as apeerDependency
.
Added
- Added support to
src/components/pickers
foriOS 14
. - Added
react-native-slide-modal
topackage.json
.
Changed
- Changed
peerDependency
react
from"react": "*"
to"react": ">=16.8.3"
. - Changed
peerDependency
react-native
from"react-native": "*"
to"react-native": ">=0.60"
. - Updated example code in
README
.
Added
- Added
react-native-slide-modal
dependency. - Added
.npmignore
. - Added Props section to
README
.
Changed
- Changed
src/index.js
tosrc/index.tsx
. - Changed
package.json
build script tocd src && tsc && cp ../package.json && Echo Build completed!
. - Updated
package.json
dependencies. - Updated
tsconfig.json
. - Fixed
peerDependencies
issue.
Removed
- Removed
react-native-modal
dependency. - Removed React Native dependencies.
Changed
- Fixed
peerDependencies
issue.
Changed
- Changed
@react-native-community/datetimepicker
topeerDependency
. - Changed
@react-native-picker/picker
topeerDependency
. - Changed
react-native-modal
topeerDependency
. - Updated
README
Getting Started foriOS
pods. - Updated
README
Getting Started forAndroid
dependencies.
Added
- Added
useState
toApp.tsx
and state management fro dropdowns and pickers.
Changed
- Changed
onChange(item: string)
toonChange(item: value)
. - Changed
onChange(state: string)
toonChange(item: value)
.
Changed
- Fixed
onChange
,onFromChange
,onToChange
issues.
Changed
- Fixed
onChange
,onFromChange
,onToChange
issues.
Added
- Added custom style prop
customStyleContainer
. - Added custom style prop
customStyleTitleText
. - Added custom style prop
customStyleLabelText
. - Added custom style prop
customStyleFieldText
. - Added custom style prop
customStyleModalHeaderContainer
. - Added custom style prop
customStyleCancelText
. - Added custom style prop
customStyleDoneText
. - Added custom style prop
customStyleModalContentContainer
. - Added custom style prop
customStylePickerItemText
. - Added custom style prop
customStyleDivider
.
Changed
- Updated to
iOS 14
styling. - Updated
react
dependency toReact 17
. - Updated
react-native
dependency toReact 0.64
. - Updated
react-native-modal
dependency. - Updated
@react-native-community/datetimepicker
dependency. - Updated
@react-native-community/picker
dependency with@react-native-picker/picker
. - Changed
DatePicker
toPickerDate
. - Changed
DateTimePicker
toPickerDateTime
. - Changed
DateRangePicker
toPickerDateRange
. - Changed
TimePicker
toPickerTime
. - Changed
ListPicker
toDropdownList
. - Changed
CookingMeasurementsPicker
toDropdownMeasurements
. - Changed
NumberPicker
toDropdownNumber
. - Changed
StatePicker
toDropdownState
.
Removed
- Removed to
StatePickerSmall
.
Added
- Added Dark Mode support. Please upgrade to
React Native 0.62
for this to work. - Added
@react-native-community/picker
dependency (Picker
is soon to be deprecated).
Changed
- Updated
react
dependency. - Updated
react-native
dependency. - Updated
react-native-modal
dependency.
Removed
- Removed
moment
dependency.
Changed
- Updated
@react-native-community/datetimepicker
to2.3.2
. - Removed unnecessary
try/catch
blocks.
Changed
- Updated dependencies.
Changed
- Changed
CookingAmountPicker
toCookingAmountPicker
. - Fixed
defaultValue
prop forCookingAmountPicker
andListPicker
.
Added
- Added
defaultValue
prop forCookingAmountPicker
andListPicker
.
Changed
- Fixed
selectItem
string/number type issue.
Added
- Added
NumberPicker
. - Added
CookingAmountPicker
.
Changed
- Increased
inputTitleContainer
width
.
Changed
- Increased
fieldTextContainer
marginBottom
to12px
.
Changed
- Fixed
@react-native-community/datetimepicker
^2.1.1
vs2.1.1
issue.
Changed
- Updated
@react-native-community/datetimepicker
to2.1.1
. - Changing backdrop
opacity
to30%
. - Increased
TouchableOpacity
size forDateRangePicker
. - Increased
pickerHeaderContainer
height
to45px
. - Fixed
README
podspec
issue.
Removed
- Removed
react-native-vector-icons
.
Changed
- Fixed
onChange
issue. - Done button is now
disabled
unless a new item or state is picked.
Added
- Adding typings for
onChange
. - Passing initial date to parent component (
useEffect
) for Date, Time, Datetime, and Date Range Pickers.
Changed
- Date Range's
toDate
is now defaulted to "Select."
Changed
- Fixed
Picker
Done button issue. Done button is nowdisabled
unless new date is picked. - Increased
Picker
container size foriOS
.
Removed
- Removed
async/await
due to that it was not the root cause of the issue.
Changed
- Fixed
onChange
TypeScript typings.
Changed
- Fixed React Hook state +
onValueChange
issue due to having the same name of "state."
Changed
- Added
Keyboard.dismiss()
totoggleModal()
.
Added
- Added
Keyboard.dismiss()
to work better with form fields.
Changed
- Fixed
README
Formatting.
Added
- Added cancel button to
iOS
ListPicker
. - Added test data items for
ListPicker
onREADME
. - Added
props
toApp.tsx
for testing. - Title
props
can be added to anyPicker
. Default titles are shown if noprop
is added.
Changed
- Reformatted
App.tsx
for when testing. - Fixed
onChange
TypeScript Typings. - Updated
README
screenshot GIFs.
Changed
- Updated
README
for NPM package.
Added
- Added
podfile
installation instructions toREADME
. - Added cancel button for
iOS
modals.
Changed
- Fixed
if/else
toggle issue. - Fixed
undefined
date issue. - Fixed
onChange
issue. - Changed if statements for
Platform
toif/else
, so only one would ever run.