Skip to content

Adds Vibration #2

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,11 @@ export default combineReducers({
connect: (state = null) => state
})
```

## Vibration

Error toasts will vibrate the device if vibration is supported. For compatibility with Android add the following to `AndroidManifest.xml`

```xml
<uses-permission android:name="android.permission.VIBRATE"/>
```
5 changes: 4 additions & 1 deletion src/Toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
Animated,
TouchableWithoutFeedback,
View,
Text
Text,
Vibration
} from 'react-native'
import ToastStyles from './ToastStyles'

Expand Down Expand Up @@ -49,6 +50,8 @@ class Toast extends Component {
.timing(animatedValue, { toValue: 1, duration: 350 })
.start()

Vibration.vibrate()

const { duration, onShow } = this.props
const timeoutId = setTimeout(() => this.hideToast(), duration + 350)

Expand Down