rn-native-wrapper
v1.0.3
Published
React Native wrapper for native date picker component
Maintainers
Readme
RN Native Wrapper
React Native wrapper package providing:
- RNNativeDatePicker – type-safe interface to
react-native-date-picker - Speech recognition – re-exports from
expo-speech-recognition(APIs, hooks, constants, types) - Permission helpers – internal helpers to check/request microphone and speech recognition permissions
Installation
npm install rn-native-wrapper
# or
yarn add rn-native-wrapperPeer Dependencies
npm install react react-nativeThe package includes react-native-date-picker and expo-speech-recognition as dependencies.
Exports (from index.ts)
| Category | Exports |
|----------|--------|
| Date Picker | RNNativeDatePicker (default + named) |
| Permission helpers | checkSpeechRecognitionPermissions, requestSpeechRecognitionPermissions, checkMicrophonePermission, requestMicrophonePermission, checkSpeechRecognizerPermission, requestSpeechRecognizerPermission, ensureSpeechRecognitionPermissions, SpeechRecognitionPermissionResult |
| Speech recognition | All exports from expo-speech-recognition (e.g. ExpoSpeechRecognitionModule, ExpoWebSpeechRecognition, useSpeechRecognitionEvent, constants, types) |
Usage
RNNativeDatePicker
import React, { useState } from 'react';
import { View, Button } from 'react-native';
import { RNNativeDatePicker } from 'rn-native-wrapper';
export default function App() {
const [date, setDate] = useState(new Date());
const [open, setOpen] = useState(false);
return (
<View>
<Button title="Open Date Picker" onPress={() => setOpen(true)} />
<RNNativeDatePicker
modal
open={open}
date={date}
onConfirm={(selectedDate) => {
setOpen(false);
setDate(selectedDate);
}}
onCancel={() => setOpen(false)}
/>
</View>
);
}Permission helpers (speech / microphone)
Request or check permissions before starting speech recognition:
import {
ensureSpeechRecognitionPermissions,
type SpeechRecognitionPermissionResult,
} from 'rn-native-wrapper';
// Before starting recognition: check, then request if needed
const result = await ensureSpeechRecognitionPermissions();
if (result.granted) {
// Start speech recognition
} else if (!result.canAskAgain) {
// Open app settings
} else {
// User denied; show message
}Available helpers:
checkSpeechRecognitionPermissions()– Check both speech + microphone (no dialog).requestSpeechRecognitionPermissions()– Request both (shows system dialog).ensureSpeechRecognitionPermissions()– Check first; request if not granted.checkMicrophonePermission()/requestMicrophonePermission()– Microphone only.checkSpeechRecognizerPermission()/requestSpeechRecognizerPermission()– Speech recognizer only (mainly iOS).
SpeechRecognitionPermissionResult: { granted, canAskAgain, status, response }.
Speech recognition (expo-speech-recognition)
All APIs from expo-speech-recognition are re-exported. Use them as you would from that package:
import {
ExpoSpeechRecognitionModule,
useSpeechRecognitionEvent,
} from 'rn-native-wrapper';See expo-speech-recognition for full API and setup (e.g. config plugin, permissions in app.json).
API
RNNativeDatePicker
Accepts all props from react-native-date-picker.
| Prop | Type | Description |
|------|------|--------------|
| modal | boolean | Display as modal |
| open | boolean | Modal open state |
| date | Date | Currently selected date |
| onConfirm | (date: Date) => void | Called when date is confirmed |
| onCancel | () => void | Called when picker is cancelled |
| mode | 'date' | 'time' | 'datetime' | Picker mode |
| locale | string | Locale for date formatting |
TypeScript
This package is written in TypeScript and ships with type definitions.
License
MIT © Darshan Padhiyar
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Issues
If you encounter any problems, please file an issue along with a detailed description.
