Tile epub reader with global book settings
This commit is contained in:
@@ -20,10 +20,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<p-divider></p-divider>
|
<p-divider></p-divider>
|
||||||
<label for="font-type">Font Type:</label>
|
<label for="font-type">Font Type:</label>
|
||||||
<p-dropdown id="font-type" [options]="fontTypes" [(ngModel)]="selectedFontType" (onChange)="changeFontType($event)"></p-dropdown>
|
<p-select id="font-type" [options]="fontTypes" [(ngModel)]="selectedFontType" (onChange)="changeFontType()"></p-select>
|
||||||
<p-divider></p-divider>
|
<p-divider></p-divider>
|
||||||
<label for="theme">Theme:</label>
|
<label for="theme">Theme:</label>
|
||||||
<p-dropdown id="theme" [options]="themes" [(ngModel)]="selectedTheme" (onChange)="changeThemes($event)"></p-dropdown>
|
<p-select id="theme" [options]="themes" [(ngModel)]="selectedTheme" (onChange)="changeThemes()"></p-select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</p-drawer>
|
</p-drawer>
|
||||||
|
|||||||
@@ -6,17 +6,18 @@ import {Button} from 'primeng/button';
|
|||||||
import {NgForOf} from '@angular/common';
|
import {NgForOf} from '@angular/common';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {Divider} from 'primeng/divider';
|
import {Divider} from 'primeng/divider';
|
||||||
import {DropdownChangeEvent, DropdownModule} from 'primeng/dropdown';
|
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
import {Book} from '../../book/model/book.model';
|
import {Book} from '../../book/model/book.model';
|
||||||
import {BookService} from '../../book/service/book.service';
|
import {BookService} from '../../book/service/book.service';
|
||||||
import {forkJoin} from 'rxjs';
|
import {forkJoin} from 'rxjs';
|
||||||
|
import {AppSettingsService} from '../../core/service/app-settings.service';
|
||||||
|
import {Select} from 'primeng/select';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-epub-viewer',
|
selector: 'app-epub-viewer',
|
||||||
templateUrl: './epub-viewer.component.html',
|
templateUrl: './epub-viewer.component.html',
|
||||||
styleUrls: ['./epub-viewer.component.scss'],
|
styleUrls: ['./epub-viewer.component.scss'],
|
||||||
imports: [Drawer, Button, NgForOf, FormsModule, Divider, DropdownModule]
|
imports: [Drawer, Button, NgForOf, FormsModule, Divider, Select]
|
||||||
})
|
})
|
||||||
export class EpubViewerComponent implements OnInit, OnDestroy {
|
export class EpubViewerComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@@ -49,7 +50,8 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
|||||||
{label: 'Sepia', value: 'sepia'}
|
{label: 'Sepia', value: 'sepia'}
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(private epubService: EpubService, private route: ActivatedRoute, private bookService: BookService) {
|
constructor(private epubService: EpubService, private route: ActivatedRoute,
|
||||||
|
private bookService: BookService, private appSettingsService: AppSettingsService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -89,8 +91,8 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.setupKeyListener();
|
this.setupKeyListener();
|
||||||
this.updateFontSize();
|
|
||||||
this.trackProgress();
|
this.trackProgress();
|
||||||
|
this.subscribeToSettings();
|
||||||
};
|
};
|
||||||
fileReader.readAsArrayBuffer(results[1]);
|
fileReader.readAsArrayBuffer(results[1]);
|
||||||
})
|
})
|
||||||
@@ -98,6 +100,21 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private subscribeToSettings(): void {
|
||||||
|
this.appSettingsService.appSettings$.subscribe((settings) => {
|
||||||
|
if (settings) {
|
||||||
|
if (settings.epub) {
|
||||||
|
this.selectedTheme = settings.epub.theme || 'white';
|
||||||
|
this.selectedFontType = settings.epub.font || 'serif';
|
||||||
|
this.fontSize = parseInt(settings.epub.fontSize, 10) || 120;
|
||||||
|
this.changeFontType();
|
||||||
|
this.updateFontSize();
|
||||||
|
this.changeThemes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private trackProgress(): void {
|
private trackProgress(): void {
|
||||||
if (this.rendition) {
|
if (this.rendition) {
|
||||||
this.rendition.on('relocated', (location: any) => {
|
this.rendition.on('relocated', (location: any) => {
|
||||||
@@ -133,13 +150,13 @@ export class EpubViewerComponent implements OnInit, OnDestroy {
|
|||||||
this.updateFontSize();
|
this.updateFontSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
changeFontType(event: DropdownChangeEvent): void {
|
changeFontType(): void {
|
||||||
if (this.rendition) {
|
if (this.rendition) {
|
||||||
this.rendition.themes.font(this.selectedFontType);
|
this.rendition.themes.font(this.selectedFontType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeThemes($event: DropdownChangeEvent) {
|
changeThemes() {
|
||||||
if (this.rendition) {
|
if (this.rendition) {
|
||||||
this.rendition.themes.select(this.selectedTheme);
|
this.rendition.themes.select(this.selectedTheme);
|
||||||
this.rendition.clear();
|
this.rendition.clear();
|
||||||
|
|||||||
Reference in New Issue
Block a user