- Features
- Built With
- Pending Items
- Getting Started
- Example Code
- Picker Types (iOS)
- Picker Types (Android)
- Changelog
- ✅ iOS/Android
- ✅ Dark Mode
- ✅ Built with TypeScript
- ✅ Built with React Hooks
- TypeScript - Programming Language
- React Native - Mobile (iOS/Android) Framework
- React Native Modal - Modal
- React Native Picker - Native Picker
- React Native Datetime Picker - Native Date/Time Picker
- React Hooks - Functional Component State/Lifecycle Methods
- [ ]
1. Install Package:
npm i react-native-ultimate-modal-picker
2. Add Pod (For iOS)
Add the following line to ios/podfile:
pod 'RNDateTimePicker', :path => '../node_modules/@react-native-community/datetimepicker/RNDateTimePicker.podspec'
3. Install Pods (For iOS)
cd ios
pod install
4. Add Dependencies (For Android)
Add the following lines to android/settings.gradle:
include ':react-native-datetimepicker'
project(':react-native-datetimepicker').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/datetimepicker/android')
Add the following line to android/app/build.gradle:
dependencies {
...
implementation project(':react-native-datetimepicker')
}
5. Run Project:
react-native run-ios
// Imports: Dependencies
import React from 'react';
import { SafeAreaView } from 'react-native';
import {
DateRangePicker,
DatePicker,
TimePicker,
DateTimePicker,
ListPicker,
NumberPicker,
CookingAmountPicker,
StatePicker,
StatePickerSmall,
TextField,
} from 'react-native-ultimate-modal-picker';
// React Native App
const App = () => {
// Test Data
const items: any = [
{ 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 }}>
{/* Date Picker (Modes: spinner/calendar) */}
<DatePicker
title="Date"
onChange={(date) => console.log(date)}
mode="spinner"
/>
{/* Time Picker (Modes: spinner/clock) */}
<TimePicker
title="Time"
onChange={(date) => console.log(date)}
mode="spinner"
/>
{/* Date Time Picker (iOS Only) */}
<DateTimePicker
title="Date/Time"
onChange={(date) => console.log(date)}
/>
{/* List Picker */}
<ListPicker
title="List"
items={items}
onChange={(item) => console.log(item)}
/>
{/* Number Picker */}
<NumberPicker
title="Number"
onChange={(item) => console.log(item)}
/>
{/* Cooking Measurement Picker */}
<CookingAmountPicker
title="Measurement"
onChange={(item) => console.log(item)}
/>
{/* State Picker */}
<StatePicker
title="State"
onChange={(state) => console.log(state)}
/>
{/* State Picker (Small) */}
<StatePickerSmall
title="State"
onChange={(state) => console.log(state)}
/>
{/* Date Range Picker */}
<DateRangePicker
title="Date Range"
onFromChange={(date) => console.log(date)}
onToChange={(date) => console.log(date)}
mode="spinner"
/>
{/* Text Field */}
<TextField
title="Text"
value={(text: string | number) => console.log(text)}
/>
</SafeAreaView>
);
};
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
to 2.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 to 12px.
Changed
- Fixed
@react-native-community/datetimepicker
^2.1.1 vs 2.1.1 issue.
Changed
- Updated
@react-native-community/datetimepicker
to 2.1.1. - Changing backdrop opacity to 30%.
- Increased
TouchableOpacity
size forDateRangePicker
. - Increased
pickerHeaderContainer
height to 45px. - 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 now disabled unless new date is picked.
- Increased Picker container size for iOS.
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 to
toggleModal()
.
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 on README.
- Added props to App.tsx for testing.
- Title props can be added to any Picker. Default titles are shown if no prop 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 to README. - Added cancel button for iOS modals.
Changed
- Fixed if/else toggle issue.
- Fixed undefined date issue.
- Fixed
onChange
issue. - Changed if statements for Platform to else/if so only one would ever run.