mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-06-20 20:05:44 +02:00
62 lines
No EOL
2 KiB
JavaScript
62 lines
No EOL
2 KiB
JavaScript
import Vue from "vue";
|
|
import { Haptics, ImpactStyle, NotificationType } from "@capacitor/haptics"
|
|
|
|
const hapticsImpactHeavy = async () => {
|
|
await Haptics.impact({ style: ImpactStyle.Heavy })
|
|
}
|
|
Vue.prototype.$hapticsImpactHeavy = hapticsImpactHeavy
|
|
|
|
const hapticsImpactMedium = async () => {
|
|
await Haptics.impact({ style: ImpactStyle.Medium })
|
|
}
|
|
Vue.prototype.$hapticsImpactMedium = hapticsImpactMedium
|
|
|
|
const hapticsImpactLight = async () => {
|
|
await Haptics.impact({ style: ImpactStyle.Light })
|
|
}
|
|
Vue.prototype.$hapticsImpactLight = hapticsImpactLight
|
|
|
|
const hapticsVibrate = async () => {
|
|
await Haptics.vibrate()
|
|
}
|
|
Vue.prototype.$hapticsVibrate = hapticsVibrate
|
|
|
|
const hapticsNotificationSuccess = async () => {
|
|
await Haptics.notification({ type: NotificationType.Success })
|
|
}
|
|
Vue.prototype.$hapticsNotificationSuccess = hapticsNotificationSuccess
|
|
|
|
const hapticsNotificationWarning = async () => {
|
|
await Haptics.notification({ type: NotificationType.Warning })
|
|
}
|
|
Vue.prototype.$hapticsNotificationWarning = hapticsNotificationWarning
|
|
|
|
const hapticsNotificationError = async () => {
|
|
await Haptics.notification({ type: NotificationType.Error })
|
|
}
|
|
Vue.prototype.$hapticsNotificationError = hapticsNotificationError
|
|
|
|
const hapticsSelectionStart = async () => {
|
|
await Haptics.selectionStart()
|
|
}
|
|
Vue.prototype.$hapticsSelectionStart = hapticsSelectionStart
|
|
|
|
const hapticsSelectionChanged = async () => {
|
|
await Haptics.selectionChanged()
|
|
}
|
|
Vue.prototype.$hapticsSelectionChanged = hapticsSelectionChanged
|
|
|
|
const hapticsSelectionEnd = async () => {
|
|
await Haptics.selectionEnd()
|
|
}
|
|
Vue.prototype.$hapticsSelectionEnd = hapticsSelectionEnd
|
|
|
|
export default ({ store }, inject) => {
|
|
inject('hapticsImpact', () => {
|
|
const hapticFeedback = store.state.globals.hapticFeedback
|
|
if (hapticFeedback === 'OFF') return
|
|
if (hapticFeedback === 'LIGHT') return hapticsImpactLight()
|
|
if (hapticFeedback === 'MEDIUM') return hapticsImpactMedium()
|
|
return hapticsImpactHeavy()
|
|
})
|
|
} |