2021-10-30 13:31:21 -05:00
|
|
|
<template>
|
|
|
|
<modals-modal v-model="show" :width="200" height="100%">
|
|
|
|
<template #outer>
|
2021-11-02 19:44:42 -05:00
|
|
|
<div class="absolute top-5 left-4 z-40">
|
2021-10-30 13:31:21 -05:00
|
|
|
<p class="text-white text-2xl truncate">Sleep Timer</p>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<div class="w-full h-full overflow-hidden absolute top-0 left-0 flex items-center justify-center" @click="show = false">
|
|
|
|
<div class="w-full overflow-x-hidden overflow-y-auto bg-primary rounded-lg border border-white border-opacity-20" style="max-height: 75%" @click.stop>
|
|
|
|
<ul v-if="!sleepTimerRunning" class="h-full w-full" role="listbox" aria-labelledby="listbox-label">
|
|
|
|
<template v-for="timeout in timeouts">
|
2021-10-31 14:35:34 -05:00
|
|
|
<li :key="timeout" class="text-gray-50 select-none relative py-4 cursor-pointer hover:bg-black-400" role="option" @click="clickedOption(timeout)">
|
2021-10-30 13:31:21 -05:00
|
|
|
<div class="flex items-center justify-center">
|
2021-10-31 14:35:34 -05:00
|
|
|
<span class="font-normal block truncate text-lg">{{ timeout }} min</span>
|
2021-10-30 13:31:21 -05:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</template>
|
2021-10-31 14:35:34 -05:00
|
|
|
<li v-if="currentEndOfChapterTime" class="text-gray-50 select-none relative py-4 cursor-pointer hover:bg-black-400" role="option" @click="clickedChapterOption(timeout)">
|
|
|
|
<div class="flex items-center justify-center">
|
|
|
|
<span class="font-normal block truncate text-lg text-center">End of Chapter</span>
|
|
|
|
</div>
|
|
|
|
</li>
|
2021-10-30 13:31:21 -05:00
|
|
|
</ul>
|
|
|
|
<div v-else class="px-2 py-4">
|
2021-10-31 14:35:34 -05:00
|
|
|
<p v-if="endOfChapterTimeSet" class="mb-4 text-2xl font-mono text-center">EOC: {{ endOfChapterTimePretty }}</p>
|
|
|
|
<p v-else class="mb-4 text-2xl font-mono text-center">{{ timeRemainingPretty }}</p>
|
2021-10-30 13:31:21 -05:00
|
|
|
<ui-btn @click="cancelSleepTimer" class="w-full">Cancel Timer</ui-btn>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</modals-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: Boolean,
|
|
|
|
currentTime: Number,
|
2021-10-31 14:35:34 -05:00
|
|
|
sleepTimerRunning: Boolean,
|
2021-11-01 21:06:51 -05:00
|
|
|
currentEndOfChapterTime: Number,
|
2021-10-31 14:35:34 -05:00
|
|
|
endOfChapterTimeSet: Number
|
2021-10-30 13:31:21 -05:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
show: {
|
|
|
|
get() {
|
|
|
|
return this.value
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('input', val)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
timeouts() {
|
|
|
|
return [1, 15, 30, 45, 60, 75, 90, 120]
|
|
|
|
},
|
|
|
|
timeRemainingPretty() {
|
|
|
|
return this.$secondsToTimestamp(this.currentTime / 1000)
|
2021-10-31 14:35:34 -05:00
|
|
|
},
|
|
|
|
endOfChapterTimePretty() {
|
|
|
|
return this.$secondsToTimestamp(this.endOfChapterTimeSet / 1000)
|
2021-10-30 13:31:21 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2021-10-31 14:35:34 -05:00
|
|
|
clickedChapterOption() {
|
|
|
|
this.show = false
|
|
|
|
this.$nextTick(() => this.$emit('change', { time: this.currentEndOfChapterTime * 1000, isChapterTime: true }))
|
|
|
|
},
|
2021-10-30 13:31:21 -05:00
|
|
|
clickedOption(timeoutMin) {
|
|
|
|
var timeout = timeoutMin * 1000 * 60
|
|
|
|
this.show = false
|
2021-10-31 14:35:34 -05:00
|
|
|
this.$nextTick(() => this.$emit('change', { time: timeout, isChapterTime: false }))
|
2021-10-30 13:31:21 -05:00
|
|
|
},
|
|
|
|
cancelSleepTimer() {
|
|
|
|
this.$emit('cancel')
|
|
|
|
this.show = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|