0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-25 12:45:17 +00:00

native haptics

This commit is contained in:
Nikita Krupin 2022-03-31 19:33:39 -04:00
parent b612cc1887
commit 84ac0c7595
9 changed files with 33 additions and 11 deletions

View file

@ -105,7 +105,10 @@
flat flat
class="d-flex flex-row justify-between mx-8 mb-4 px-4 background rounded-lg" class="d-flex flex-row justify-between mx-8 mb-4 px-4 background rounded-lg"
:class="$vuetify.theme.dark ? 'lighten-1' : 'darken-1'" :class="$vuetify.theme.dark ? 'lighten-1' : 'darken-1'"
@click="$vuetify.theme.dark = !$vuetify.theme.dark" @click="
($vuetify.theme.dark = !$vuetify.theme.dark),
$vuetube.haptics.hapticsImpactLight(1)
"
> >
<div class="my-auto"> <div class="my-auto">
<div>Dark Mode</div> <div>Dark Mode</div>
@ -207,9 +210,6 @@ export default {
this.$vuetify.theme.currentTheme.background = this.experimentalLight; this.$vuetify.theme.currentTheme.background = this.experimentalLight;
}, 0); }, 0);
}, },
saveTheme() {
navigator.vibrate([10, 100, 5]);
},
}, },
}; };
</script> </script>

View file

@ -3,6 +3,7 @@
<v-card <v-card
flat flat
class="px-6 ma-4 mt-2 background" class="px-6 ma-4 mt-2 background"
style="transition-duration: 0.3s; transition-property: border-radius"
:class="$vuetify.theme.dark ? 'lighten-1' : 'darken-1'" :class="$vuetify.theme.dark ? 'lighten-1' : 'darken-1'"
:style="{ :style="{
borderRadius: `${roundTweak / 2}rem`, borderRadius: `${roundTweak / 2}rem`,
@ -26,7 +27,7 @@
:max="4" :max="4"
step="1" step="1"
thumb-size="64" thumb-size="64"
@input="vibrate()" @input="$vuetube.haptics.hapticsImpactLight(1)"
> >
<template #thumb-label="{ value }"> <template #thumb-label="{ value }">
<div <div
@ -51,10 +52,5 @@ export default {
}, },
}, },
}, },
methods: {
vibrate() {
navigator.vibrate(10);
},
},
}; };
</script> </script>

View file

@ -4,6 +4,7 @@ import { StatusBar, Style } from "@capacitor/status-bar";
import { NavigationBar } from "@hugotomazi/capacitor-navigation-bar"; import { NavigationBar } from "@hugotomazi/capacitor-navigation-bar";
import constants from "./constants"; import constants from "./constants";
import { hexToRgb, rgbToHex } from "./utils"; import { hexToRgb, rgbToHex } from "./utils";
import { Haptics, ImpactStyle } from "@capacitor/haptics";
const module = { const module = {
//--- Get GitHub Commits ---// //--- Get GitHub Commits ---//
@ -37,6 +38,21 @@ const module = {
}); });
}, },
haptics: {
async hapticsImpactHeavy(x) {
await Haptics.impact({ style: ImpactStyle.Heavy, duration: x });
},
async hapticsImpactMedium(x) {
await Haptics.impact({ style: ImpactStyle.Medium, duration: x });
},
async hapticsImpactLight(x) {
await Haptics.impact({ style: ImpactStyle.Light, duration: x });
},
async hapticsVibrate(x) {
await Haptics.vibrate(x);
},
},
statusBar: { statusBar: {
async hide() { async hide() {
return await StatusBar.hide(); return await StatusBar.hide();

View file

@ -12,6 +12,6 @@
</deviceKey> </deviceKey>
</Target> </Target>
</targetSelectedWithDropDown> </targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-03-31T17:44:52.270258Z" /> <timeTargetWasSelectedWithDropDown value="2022-03-31T22:44:20.197073Z" />
</component> </component>
</project> </project>

View file

@ -13,6 +13,7 @@ dependencies {
implementation project(':capacitor-app') implementation project(':capacitor-app')
implementation project(':capacitor-browser') implementation project(':capacitor-browser')
implementation project(':capacitor-device') implementation project(':capacitor-device')
implementation project(':capacitor-haptics')
implementation project(':capacitor-share') implementation project(':capacitor-share')
implementation project(':capacitor-splash-screen') implementation project(':capacitor-splash-screen')
implementation project(':capacitor-status-bar') implementation project(':capacitor-status-bar')

View file

@ -15,6 +15,10 @@
"pkg": "@capacitor/device", "pkg": "@capacitor/device",
"classpath": "com.capacitorjs.plugins.device.DevicePlugin" "classpath": "com.capacitorjs.plugins.device.DevicePlugin"
}, },
{
"pkg": "@capacitor/haptics",
"classpath": "com.capacitorjs.plugins.haptics.HapticsPlugin"
},
{ {
"pkg": "@capacitor/share", "pkg": "@capacitor/share",
"classpath": "com.capacitorjs.plugins.share.SharePlugin" "classpath": "com.capacitorjs.plugins.share.SharePlugin"

View file

@ -14,6 +14,9 @@ project(':capacitor-browser').projectDir = new File('../node_modules/@capacitor/
include ':capacitor-device' include ':capacitor-device'
project(':capacitor-device').projectDir = new File('../node_modules/@capacitor/device/android') project(':capacitor-device').projectDir = new File('../node_modules/@capacitor/device/android')
include ':capacitor-haptics'
project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')
include ':capacitor-share' include ':capacitor-share'
project(':capacitor-share').projectDir = new File('../node_modules/@capacitor/share/android') project(':capacitor-share').projectDir = new File('../node_modules/@capacitor/share/android')

View file

@ -13,6 +13,7 @@ def capacitor_pods
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app' pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
pod 'CapacitorBrowser', :path => '../../node_modules/@capacitor/browser' pod 'CapacitorBrowser', :path => '../../node_modules/@capacitor/browser'
pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device' pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device'
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share' pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share'
pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen' pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar' pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'

View file

@ -7,6 +7,7 @@
"@capacitor/cli": "^3.4.0", "@capacitor/cli": "^3.4.0",
"@capacitor/core": "^3.4.0", "@capacitor/core": "^3.4.0",
"@capacitor/device": "^1.1.2", "@capacitor/device": "^1.1.2",
"@capacitor/haptics": "^1.1.4",
"@capacitor/share": "^1.1.2", "@capacitor/share": "^1.1.2",
"@capacitor/splash-screen": "^1.2.2", "@capacitor/splash-screen": "^1.2.2",
"@capacitor/status-bar": "^1.0.8", "@capacitor/status-bar": "^1.0.8",