Fix:Back button to close modal #267 and back button to minimize fullscreen player #267

This commit is contained in:
advplyr 2022-07-04 15:42:59 -05:00
parent 6a8d901ce1
commit b4bb6bf81b
7 changed files with 64 additions and 22 deletions

View file

@ -139,8 +139,9 @@ export default {
} }
}, },
watch: { watch: {
showFullscreen() { showFullscreen(val) {
this.updateScreenSize() this.updateScreenSize()
this.$store.commit('setPlayerFullscreen', !!val)
} }
}, },
computed: { computed: {
@ -712,6 +713,10 @@ export default {
var coverHeight = this.fullscreenBookCoverWidth * this.bookCoverAspectRatio var coverHeight = this.fullscreenBookCoverWidth * this.bookCoverAspectRatio
document.documentElement.style.setProperty('--cover-image-width', this.fullscreenBookCoverWidth + 'px') document.documentElement.style.setProperty('--cover-image-width', this.fullscreenBookCoverWidth + 'px')
document.documentElement.style.setProperty('--cover-image-height', coverHeight + 'px') document.documentElement.style.setProperty('--cover-image-height', coverHeight + 'px')
},
minimizePlayerEvt() {
console.log('Minimize Player Evt')
this.showFullscreen = false
} }
}, },
mounted() { mounted() {
@ -719,6 +724,8 @@ export default {
if (screen.orientation) { if (screen.orientation) {
screen.orientation.addEventListener('change', this.screenOrientationChange) screen.orientation.addEventListener('change', this.screenOrientationChange)
} }
this.$eventBus.$on('minimize-player', this.minimizePlayerEvt)
document.body.addEventListener('touchstart', this.touchstart) document.body.addEventListener('touchstart', this.touchstart)
document.body.addEventListener('touchend', this.touchend) document.body.addEventListener('touchend', this.touchend)
document.body.addEventListener('touchmove', this.touchmove) document.body.addEventListener('touchmove', this.touchmove)
@ -735,6 +742,7 @@ export default {
} }
this.forceCloseDropdownMenu() this.forceCloseDropdownMenu()
this.$eventBus.$off('minimize-player', this.minimizePlayerEvt)
document.body.removeEventListener('touchstart', this.touchstart) document.body.removeEventListener('touchstart', this.touchstart)
document.body.removeEventListener('touchend', this.touchend) document.body.removeEventListener('touchend', this.touchend)
document.body.removeEventListener('touchmove', this.touchmove) document.body.removeEventListener('touchmove', this.touchmove)

View file

@ -77,6 +77,8 @@ export default {
} }
}, },
setShow() { setShow() {
this.$store.commit('globals/setIsModalOpen', true)
document.body.appendChild(this.el) document.body.appendChild(this.el)
setTimeout(() => { setTimeout(() => {
this.content.style.transform = 'scale(1)' this.content.style.transform = 'scale(1)'
@ -84,18 +86,28 @@ export default {
document.documentElement.classList.add('modal-open') document.documentElement.classList.add('modal-open')
}, },
setHide() { setHide() {
this.$store.commit('globals/setIsModalOpen', false)
this.content.style.transform = 'scale(0)' this.content.style.transform = 'scale(0)'
this.el.remove() this.el.remove()
document.documentElement.classList.remove('modal-open') document.documentElement.classList.remove('modal-open')
},
closeModalEvt() {
console.log('Close modal event')
this.show = false
} }
}, },
mounted() { mounted() {
this.$eventBus.$on('close-modal', this.closeModalEvt)
this.el = this.$refs.wrapper this.el = this.$refs.wrapper
this.content = this.$refs.content this.content = this.$refs.content
this.content.style.transform = 'scale(0)' this.content.style.transform = 'scale(0)'
this.content.style.transition = 'transform 0.25s cubic-bezier(0.16, 1, 0.3, 1)' this.content.style.transition = 'transform 0.25s cubic-bezier(0.16, 1, 0.3, 1)'
this.el.style.opacity = 1 this.el.style.opacity = 1
this.el.remove() this.el.remove()
},
beforeDestroy() {
this.$eventBus.$off('close-modal', this.closeModalEvt)
} }
} }
</script> </script>

View file

@ -9,12 +9,12 @@ install! 'cocoapods', :disable_input_output_paths => true
def capacitor_pods def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app' pod 'CapacitorApp', :path => '..\..\node_modules\@capacitor\app'
pod 'CapacitorDialog', :path => '../../node_modules/@capacitor/dialog' pod 'CapacitorDialog', :path => '..\..\node_modules\@capacitor\dialog'
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics' pod 'CapacitorHaptics', :path => '..\..\node_modules\@capacitor\haptics'
pod 'CapacitorNetwork', :path => '../../node_modules/@capacitor/network' pod 'CapacitorNetwork', :path => '..\..\node_modules\@capacitor\network'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar' pod 'CapacitorStatusBar', :path => '..\..\node_modules\@capacitor\status-bar'
pod 'CapacitorStorage', :path => '../../node_modules/@capacitor/storage' pod 'CapacitorStorage', :path => '..\..\node_modules\@capacitor\storage'
end end
target 'App' do target 'App' do

View file

@ -131,6 +131,11 @@ class AbsAudioPlayerWeb extends WebPlugin {
} }
} }
// PluginMethod
async getIsCastAvailable() {
return false
}
initializePlayer() { initializePlayer() {
if (document.getElementById('audio-player')) { if (document.getElementById('audio-player')) {
document.getElementById('audio-player').remove() document.getElementById('audio-player').remove()

View file

@ -14,21 +14,6 @@ if (Capacitor.getPlatform() != 'web') {
setStatusBarStyleDark() setStatusBarStyleDark()
} }
App.addListener('backButton', async ({ canGoBack }) => {
if (!canGoBack) {
const { value } = await Dialog.confirm({
title: 'Confirm',
message: `Did you want to exit the app?`,
})
if (value) {
App.exitApp()
}
} else {
window.history.back()
}
})
Vue.prototype.$isDev = process.env.NODE_ENV !== 'production' Vue.prototype.$isDev = process.env.NODE_ENV !== 'production'
Vue.prototype.$dateDistanceFromNow = (unixms) => { Vue.prototype.$dateDistanceFromNow = (unixms) => {
@ -135,6 +120,30 @@ Vue.prototype.$encode = encode
const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toString() const decode = (text) => Buffer.from(decodeURIComponent(text), 'base64').toString()
Vue.prototype.$decode = decode Vue.prototype.$decode = decode
export default ({ store }) => {
App.addListener('backButton', async ({ canGoBack }) => {
if (store.state.globals.isModalOpen) {
Vue.prototype.$eventBus.$emit('close-modal')
return
}
if (store.state.playerIsFullscreen) {
Vue.prototype.$eventBus.$emit('minimize-player')
return
}
if (!canGoBack) {
const { value } = await Dialog.confirm({
title: 'Confirm',
message: `Did you want to exit the app?`,
})
if (value) {
App.exitApp()
}
} else {
window.history.back()
}
})
}
export { export {
encode, encode,
decode decode

View file

@ -1,4 +1,5 @@
export const state = () => ({ export const state = () => ({
isModalOpen: false,
itemDownloads: [], itemDownloads: [],
bookshelfListView: false, bookshelfListView: false,
series: null, series: null,
@ -93,6 +94,9 @@ export const actions = {
} }
export const mutations = { export const mutations = {
setIsModalOpen(state, val) {
state.isModalOpen = val
},
addUpdateItemDownload(state, downloadItem) { addUpdateItemDownload(state, downloadItem) {
var index = state.itemDownloads.findIndex(i => i.id == downloadItem.id) var index = state.itemDownloads.findIndex(i => i.id == downloadItem.id)
if (index >= 0) { if (index >= 0) {

View file

@ -6,6 +6,7 @@ export const state = () => ({
playerEpisodeId: null, playerEpisodeId: null,
playerIsLocal: false, playerIsLocal: false,
playerIsPlaying: false, playerIsPlaying: false,
playerIsFullscreen: false,
isCasting: false, isCasting: false,
isCastAvailable: false, isCastAvailable: false,
socketConnected: false, socketConnected: false,
@ -93,6 +94,9 @@ export const mutations = {
setPlayerPlaying(state, val) { setPlayerPlaying(state, val) {
state.playerIsPlaying = val state.playerIsPlaying = val
}, },
setPlayerFullscreen(state, val) {
state.playerIsFullscreen = val
},
setHasStoragePermission(state, val) { setHasStoragePermission(state, val) {
state.hasStoragePermission = val state.hasStoragePermission = val
}, },