2022-04-28 17:19:02 -05:00
< template >
< div class = "w-full h-full p-8" >
2023-01-08 15:32:15 -06:00
<!-- Display settings -- >
< p class = "uppercase text-xs font-semibold text-gray-300 mb-2" > User Interface Settings < / p >
2022-07-27 12:58:06 -05:00
< div class = "flex items-center py-3" @click ="toggleEnableAltView" >
< div class = "w-10 flex justify-center" >
< ui-toggle-switch v-model = "settings.enableAltView" @input="saveSettings" / >
< / div >
2022-08-07 09:13:10 -05:00
< p class = "pl-4" > Alternative bookshelf view < / p >
2022-07-27 12:58:06 -05:00
< / div >
2022-12-04 10:41:09 -06:00
< div class = "flex items-center py-3" @click.stop ="toggleLockOrientation" >
2023-01-08 15:38:34 -06:00
< div class = "w-10 flex justify-center pointer-events-none" >
< ui-toggle-switch v-model = "lockCurrentOrientation" / >
2022-12-04 10:41:09 -06:00
< / div >
< p class = "pl-4" > Lock orientation < / p >
< / div >
2023-01-08 15:32:15 -06:00
< div class = "py-3 flex items-center" >
< p class = "pr-4" > Haptic feedback < / p >
< ui-dropdown v-model = "settings.hapticFeedback" :items="hapticFeedbackItems" style="max-width: 105px" @input="hapticFeedbackUpdated" / >
< / div >
2022-08-07 09:13:10 -05:00
2023-01-08 15:32:15 -06:00
<!-- Playback settings -- >
2022-08-07 09:13:10 -05:00
< p class = "uppercase text-xs font-semibold text-gray-300 mb-2 mt-6" > Playback Settings < / p >
< div v-if = "!isiOS" class="flex items-center py-3" @click="toggleDisableAutoRewind" >
2022-07-27 18:21:10 -05:00
< div class = "w-10 flex justify-center" >
< ui-toggle-switch v-model = "settings.disableAutoRewind" @input="saveSettings" / >
< / div >
2022-08-07 09:13:10 -05:00
< p class = "pl-4" > Disable auto rewind < / p >
2022-07-27 18:21:10 -05:00
< / div >
2022-04-28 17:19:02 -05:00
< div class = "flex items-center py-3" @click ="toggleJumpBackwards" >
< div class = "w-10 flex justify-center" >
< span class = "material-icons text-4xl" > { { currentJumpBackwardsTimeIcon } } < / span >
< / div >
< p class = "pl-4" > Jump backwards time < / p >
< / div >
2022-07-01 20:05:11 -05:00
< div class = "flex items-center py-3" @click ="toggleJumpForward" >
2022-04-28 17:19:02 -05:00
< div class = "w-10 flex justify-center" >
2022-07-01 20:05:11 -05:00
< span class = "material-icons text-4xl" > { { currentJumpForwardTimeIcon } } < / span >
2022-04-28 17:19:02 -05:00
< / div >
< p class = "pl-4" > Jump forwards time < / p >
< / div >
2022-08-07 09:13:10 -05:00
2023-01-08 15:32:15 -06:00
<!-- Sleep timer settings -- >
2022-08-07 09:13:10 -05:00
< p v-if = "!isiOS" class="uppercase text-xs font-semibold text-gray-300 mb-2 mt-6" > Sleep Timer Settings < / p >
< div v-if = "!isiOS" class="flex items-center py-3" @click="toggleDisableShakeToResetSleepTimer" >
< div class = "w-10 flex justify-center" >
< ui-toggle-switch v-model = "settings.disableShakeToResetSleepTimer" @input="saveSettings" / >
< / div >
< p class = "pl-4" > Disable shake to reset < / p >
< span class = "material-icons-outlined ml-2" @click.stop ="showInfo('disableShakeToResetSleepTimer')" > info < / span >
< / div >
2022-04-28 17:19:02 -05:00
< / div >
< / template >
< script >
2022-08-07 09:13:10 -05:00
import { Dialog } from '@capacitor/dialog'
2022-04-28 17:19:02 -05:00
export default {
data ( ) {
return {
2022-07-01 20:05:11 -05:00
deviceData : null ,
2022-04-28 17:19:02 -05:00
settings : {
disableAutoRewind : false ,
2022-07-27 12:58:06 -05:00
enableAltView : false ,
2022-07-01 20:05:11 -05:00
jumpForwardTime : 10 ,
2022-08-07 09:13:10 -05:00
jumpBackwardsTime : 10 ,
2022-12-04 10:41:09 -06:00
disableShakeToResetSleepTimer : false ,
2023-01-08 15:32:15 -06:00
lockOrientation : 0 ,
hapticFeedback : 'LIGHT'
2022-08-07 09:13:10 -05:00
} ,
settingInfo : {
disableShakeToResetSleepTimer : {
name : 'Disable shake to reset sleep timer' ,
message : 'The sleep timer will start fading out when 30s is remaining. Shaking your device will reset the timer if it is within 30s OR has finished less than 2 mintues ago. Enable this setting to disable that feature.'
}
2022-12-04 10:41:09 -06:00
} ,
2023-01-08 15:32:15 -06:00
lockCurrentOrientation : false ,
hapticFeedbackItems : [
{
text : 'Off' ,
value : 'OFF'
} ,
{
text : 'Light' ,
value : 'LIGHT'
} ,
{
text : 'Medium' ,
value : 'MEDIUM'
} ,
{
text : 'Heavy' ,
value : 'HEAVY'
}
]
2022-04-28 17:19:02 -05:00
}
} ,
computed : {
2022-08-07 09:13:10 -05:00
isiOS ( ) {
return this . $platform === 'ios'
} ,
2022-07-01 20:05:11 -05:00
jumpForwardItems ( ) {
return this . $store . state . globals . jumpForwardItems || [ ]
2022-04-28 17:19:02 -05:00
} ,
2022-07-01 20:05:11 -05:00
jumpBackwardsItems ( ) {
return this . $store . state . globals . jumpBackwardsItems || [ ]
} ,
currentJumpForwardTimeIcon ( ) {
return this . jumpForwardItems [ this . currentJumpForwardTimeIndex ] . icon
} ,
currentJumpForwardTimeIndex ( ) {
var index = this . jumpForwardItems . findIndex ( ( jfi ) => jfi . value === this . settings . jumpForwardTime )
return index >= 0 ? index : 1
2022-04-28 17:19:02 -05:00
} ,
currentJumpBackwardsTimeIcon ( ) {
return this . jumpBackwardsItems [ this . currentJumpBackwardsTimeIndex ] . icon
} ,
currentJumpBackwardsTimeIndex ( ) {
2022-07-01 20:05:11 -05:00
var index = this . jumpBackwardsItems . findIndex ( ( jfi ) => jfi . value === this . settings . jumpBackwardsTime )
return index >= 0 ? index : 1
2022-04-28 17:19:02 -05:00
}
} ,
methods : {
2023-01-08 15:32:15 -06:00
hapticFeedbackUpdated ( val ) {
this . $store . commit ( 'globals/setHapticFeedback' , val )
this . saveSettings ( )
} ,
2022-08-07 09:13:10 -05:00
showInfo ( setting ) {
if ( this . settingInfo [ setting ] ) {
Dialog . alert ( {
title : this . settingInfo [ setting ] . name ,
message : this . settingInfo [ setting ] . message
} )
}
} ,
toggleDisableShakeToResetSleepTimer ( ) {
this . settings . disableShakeToResetSleepTimer = ! this . settings . disableShakeToResetSleepTimer
this . saveSettings ( )
} ,
2022-04-28 17:19:02 -05:00
toggleDisableAutoRewind ( ) {
this . settings . disableAutoRewind = ! this . settings . disableAutoRewind
this . saveSettings ( )
} ,
2022-07-27 12:58:06 -05:00
toggleEnableAltView ( ) {
this . settings . enableAltView = ! this . settings . enableAltView
this . saveSettings ( )
} ,
2022-12-04 10:41:09 -06:00
getCurrentOrientation ( ) {
const orientation = window . screen ? window . screen . orientation || { } : { }
const type = orientation . type || ''
if ( type . includes ( 'landscape' ) ) return 'LANDSCAPE'
return 'PORTRAIT' // default
} ,
toggleLockOrientation ( ) {
this . lockCurrentOrientation = ! this . lockCurrentOrientation
if ( this . lockCurrentOrientation ) {
this . settings . lockOrientation = this . getCurrentOrientation ( )
} else {
this . settings . lockOrientation = 'NONE'
}
this . $setOrientationLock ( this . settings . lockOrientation )
this . saveSettings ( )
} ,
2022-07-01 20:05:11 -05:00
toggleJumpForward ( ) {
var next = ( this . currentJumpForwardTimeIndex + 1 ) % 3
this . settings . jumpForwardTime = this . jumpForwardItems [ next ] . value
2022-04-28 17:19:02 -05:00
this . saveSettings ( )
} ,
toggleJumpBackwards ( ) {
var next = ( this . currentJumpBackwardsTimeIndex + 4 ) % 3
if ( next > 2 ) return
this . settings . jumpBackwardsTime = this . jumpBackwardsItems [ next ] . value
this . saveSettings ( )
} ,
2022-07-01 20:05:11 -05:00
async saveSettings ( ) {
2023-01-08 15:32:15 -06:00
await this . $hapticsImpact ( )
2022-07-01 20:05:11 -05:00
const updatedDeviceData = await this . $db . updateDeviceSettings ( { ... this . settings } )
console . log ( 'Saved device data' , updatedDeviceData )
if ( updatedDeviceData ) {
this . $store . commit ( 'setDeviceData' , updatedDeviceData )
this . init ( )
}
} ,
async init ( ) {
this . deviceData = await this . $db . getDeviceData ( )
this . $store . commit ( 'setDeviceData' , this . deviceData )
const deviceSettings = this . deviceData . deviceSettings || { }
this . settings . disableAutoRewind = ! ! deviceSettings . disableAutoRewind
2022-07-27 12:58:06 -05:00
this . settings . enableAltView = ! ! deviceSettings . enableAltView
2022-07-01 20:05:11 -05:00
this . settings . jumpForwardTime = deviceSettings . jumpForwardTime || 10
this . settings . jumpBackwardsTime = deviceSettings . jumpBackwardsTime || 10
2022-08-07 09:13:10 -05:00
this . settings . disableShakeToResetSleepTimer = ! ! deviceSettings . disableShakeToResetSleepTimer
2022-12-04 10:41:09 -06:00
this . settings . lockOrientation = deviceSettings . lockOrientation || 'NONE'
this . lockCurrentOrientation = this . settings . lockOrientation !== 'NONE'
2023-01-08 15:32:15 -06:00
this . settings . hapticFeedback = deviceSettings . hapticFeedback || 'LIGHT'
2022-04-28 17:19:02 -05:00
}
} ,
mounted ( ) {
2022-07-01 20:05:11 -05:00
this . init ( )
2022-04-28 17:19:02 -05:00
}
}
2022-12-08 00:28:28 -05:00
< / script >