feat(book reader): background color settings

closes #113
This commit is contained in:
Gauthier Roebroeck 2020-03-18 10:57:26 +08:00
parent a90b47cee9
commit 2c87e7bba6

View file

@ -134,7 +134,9 @@
:transition="animations ? undefined : false" :transition="animations ? undefined : false"
:reverse-transition="animations ? undefined : false" :reverse-transition="animations ? undefined : false"
> >
<div class="full-height d-flex flex-column justify-center reader-background"> <div class="full-height d-flex flex-column justify-center"
:style="`background-color: ${backgroundColor}`"
>
<div :class="`d-flex flex-row${flipDirection ? '-reverse' : ''} justify-center px-0 mx-0` "> <div :class="`d-flex flex-row${flipDirection ? '-reverse' : ''} justify-center px-0 mx-0` ">
<img :src="getPageUrl(p)" <img :src="getPageUrl(p)"
:height="maxHeight" :height="maxHeight"
@ -180,6 +182,16 @@
<v-list-item> <v-list-item>
<settings-switch v-model="animations" label="Page Transitions"></settings-switch> <settings-switch v-model="animations" label="Page Transitions"></settings-switch>
</v-list-item> </v-list-item>
<v-list-item>
<settings-select
:items="backgroundColors"
v-model="backgroundColor"
label="Background color"
>
</settings-select>
</v-list-item>
<v-list-item> <v-list-item>
<settings-select <settings-select
:items="readingDirs" :items="readingDirs"
@ -246,6 +258,7 @@ const cookieFit = 'webreader.fit'
const cookieReadingDirection = 'webreader.readingDirection' const cookieReadingDirection = 'webreader.readingDirection'
const cookieDoublePages = 'webreader.doublePages' const cookieDoublePages = 'webreader.doublePages'
const cookieAnimations = 'webreader.animations' const cookieAnimations = 'webreader.animations'
const cookieBackground = 'webreader.background'
enum ImageFit { enum ImageFit {
WIDTH = 'width', WIDTH = 'width',
@ -280,7 +293,8 @@ export default Vue.extend({
imageFits: Object.values(ImageFit), imageFits: Object.values(ImageFit),
fit: ImageFit.HEIGHT, fit: ImageFit.HEIGHT,
readingDirection: ReadingDirection.LEFT_TO_RIGHT, readingDirection: ReadingDirection.LEFT_TO_RIGHT,
animations: true animations: true,
backgroundColor: 'black'
}, },
readingDirs: [ readingDirs: [
{ text: 'Left to right', value: ReadingDirection.LEFT_TO_RIGHT }, { text: 'Left to right', value: ReadingDirection.LEFT_TO_RIGHT },
@ -290,6 +304,10 @@ export default Vue.extend({
{ text: 'Fit to height', value: ImageFit.HEIGHT }, { text: 'Fit to height', value: ImageFit.HEIGHT },
{ text: 'Fit to width', value: ImageFit.WIDTH }, { text: 'Fit to width', value: ImageFit.WIDTH },
{ text: 'Original', value: ImageFit.ORIGINAL } { text: 'Original', value: ImageFit.ORIGINAL }
],
backgroundColors: [
{ text: 'White', value: 'white' },
{ text: 'Black', value: 'black' }
] ]
} }
}, },
@ -318,6 +336,11 @@ export default Vue.extend({
this.imageFit = v this.imageFit = v
} }
}) })
this.loadFromCookie(cookieBackground, (v) => {
if (v) {
this.backgroundColor = v
}
})
}, },
destroyed () { destroyed () {
window.removeEventListener('keydown', this.keyPressed) window.removeEventListener('keydown', this.keyPressed)
@ -422,6 +445,15 @@ export default Vue.extend({
this.$cookies.set(cookieFit, fit, Infinity) this.$cookies.set(cookieFit, fit, Infinity)
} }
}, },
backgroundColor: {
get: function (): string {
return this.settings.backgroundColor
},
set: function (color: string): void {
this.settings.backgroundColor = color
this.$cookies.set(cookieBackground, color, Infinity)
}
},
doublePages: { doublePages: {
get: function (): boolean { get: function (): boolean {
return this.settings.doublePages return this.settings.doublePages
@ -601,11 +633,6 @@ export default Vue.extend({
</script> </script>
<style scoped> <style scoped>
.reader-background {
background-color: white; /* TODO add a setting for this, some books might not be white */
}
.settings { .settings {
/*position: absolute;*/ /*position: absolute;*/
z-index: 2; z-index: 2;