-
-
Notifications
You must be signed in to change notification settings - Fork 812
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Shopping list UI overhaul - add wakelock (#4236)
Co-authored-by: Kuchenpirat <[email protected]>
- Loading branch information
1 parent
8fe1b0c
commit 28b0190
Showing
3 changed files
with
52 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<template> | ||
<div | ||
v-if="wakeIsSupported" | ||
class="d-print-none d-flex px-2" | ||
:class="$vuetify.breakpoint.smAndDown ? 'justify-center' : 'justify-end'" | ||
> | ||
<v-switch v-model="wakeLock" small :label="$t('recipe.screen-awake')" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, computed, onMounted, onUnmounted } from "@nuxtjs/composition-api"; | ||
import { useWakeLock } from "@vueuse/core"; | ||
export default defineComponent({ | ||
setup() { | ||
const { isSupported: wakeIsSupported, isActive, request, release } = useWakeLock(); | ||
const wakeLock = computed({ | ||
get: () => isActive, | ||
set: () => { | ||
if (isActive.value) { | ||
unlockScreen(); | ||
} else { | ||
lockScreen(); | ||
} | ||
}, | ||
}); | ||
async function lockScreen() { | ||
if (wakeIsSupported) { | ||
console.log("Wake Lock Requested"); | ||
await request("screen"); | ||
} | ||
} | ||
async function unlockScreen() { | ||
if (wakeIsSupported || isActive) { | ||
console.log("Wake Lock Released"); | ||
await release(); | ||
} | ||
} | ||
onMounted(() => lockScreen()); | ||
onUnmounted(() => unlockScreen()); | ||
return { | ||
wakeLock, | ||
wakeIsSupported, | ||
}; | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,6 +278,7 @@ | |
/> | ||
</div> | ||
</v-lazy> | ||
<WakelockSwitch/> | ||
</v-container> | ||
</template> | ||
|
||
|