Use square covers for audiobook-only libraries (#2945)
This commit is contained in:
@@ -312,6 +312,7 @@
|
||||
[isSeriesCollapsed]="seriesCollapseFilter.isSeriesCollapsed"
|
||||
(checkboxClick)="onCheckboxClicked($event)"
|
||||
[isSelected]="selectedBooks.has(book.id)"
|
||||
[useSquareCovers]="isAudiobookOnlyLibrary"
|
||||
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
||||
</app-book-card>
|
||||
</div>
|
||||
|
||||
+19
-5
@@ -196,7 +196,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
const totalGaps = (columns - 1) * this.MOBILE_GAP;
|
||||
const availableWidth = this.screenWidth - totalGaps - this.MOBILE_PADDING;
|
||||
const cardWidth = Math.floor(availableWidth / columns);
|
||||
const coverHeight = Math.floor(cardWidth * this.CARD_ASPECT_RATIO);
|
||||
const coverHeight = this.isAudiobookOnlyLibrary ? cardWidth : Math.floor(cardWidth * this.CARD_ASPECT_RATIO);
|
||||
const cardHeight = coverHeight + this.MOBILE_TITLE_BAR_HEIGHT;
|
||||
return {width: cardWidth, height: cardHeight};
|
||||
}
|
||||
@@ -209,23 +209,31 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (this.isMobile) {
|
||||
return this.mobileCardSize;
|
||||
}
|
||||
return this.coverScalePreferenceService.currentCardSize;
|
||||
const base = this.coverScalePreferenceService.currentCardSize;
|
||||
if (this.isAudiobookOnlyLibrary) {
|
||||
const squareSide = Math.round(base.width * 1.1);
|
||||
return { width: squareSide, height: squareSide + 31 };
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
get gridColumnMinWidth(): string {
|
||||
if (this.isMobile) {
|
||||
return `${this.mobileCardSize.width}px`;
|
||||
}
|
||||
if (this.isAudiobookOnlyLibrary) {
|
||||
return `${this.currentCardSize.width}px`;
|
||||
}
|
||||
return this.coverScalePreferenceService.gridColumnMinWidth;
|
||||
}
|
||||
|
||||
getCardHeight(_book: Book): number {
|
||||
// Use uniform height for all book types to ensure smooth virtual scrolling.
|
||||
// Mixed heights cause choppy/jumpy scrolling because the virtual scroller
|
||||
// cannot accurately estimate positions when item heights vary.
|
||||
if (this.isMobile) {
|
||||
return this.mobileCardSize.height;
|
||||
}
|
||||
if (this.isAudiobookOnlyLibrary) {
|
||||
return this.currentCardSize.height;
|
||||
}
|
||||
return this.coverScalePreferenceService.getCardHeight(_book);
|
||||
}
|
||||
|
||||
@@ -267,6 +275,12 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
: filterSummary;
|
||||
}
|
||||
|
||||
get isAudiobookOnlyLibrary(): boolean {
|
||||
if (!this.entity || this.entityType !== EntityType.LIBRARY) return false;
|
||||
const library = this.entity as Library;
|
||||
return !!library.allowedFormats && library.allowedFormats.length === 1 && library.allowedFormats[0] === 'AUDIOBOOK';
|
||||
}
|
||||
|
||||
get seriesViewEnabled(): boolean {
|
||||
return Boolean(this.userService.getCurrentUser()?.userSettings?.enableSeriesView);
|
||||
}
|
||||
|
||||
+2
-2
@@ -2,12 +2,12 @@
|
||||
[class.selected]="isSelected"
|
||||
(click)="onCardClick($event)">
|
||||
|
||||
<div class="cover-container" [ngClass]="{ 'center-info-btn': _isSeriesViewActive, 'loaded': isImageLoaded, 'audiobook-cover': _isAudiobook }">
|
||||
<div class="cover-container" [ngClass]="{ 'center-info-btn': _isSeriesViewActive, 'loaded': isImageLoaded, 'audiobook-cover': _isAudiobook, 'square-library-cover': useSquareCovers }">
|
||||
<img
|
||||
[src]="coverImageUrl"
|
||||
class="book-cover"
|
||||
[class.loaded]="isImageLoaded"
|
||||
[class.square-cover]="_isAudiobook"
|
||||
[class.square-cover]="_isAudiobook || useSquareCovers"
|
||||
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle })"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
|
||||
+5
@@ -56,6 +56,11 @@
|
||||
background-color: var(--surface-ground);
|
||||
}
|
||||
|
||||
.cover-container.square-library-cover {
|
||||
aspect-ratio: 1/1;
|
||||
background-color: var(--surface-ground);
|
||||
}
|
||||
|
||||
.book-cover {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
+2
-1
@@ -53,6 +53,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
@Input() isSeriesCollapsed: boolean = false;
|
||||
@Input() overlayPreferenceService?: BookCardOverlayPreferenceService;
|
||||
@Input() forceEbookMode: boolean = false;
|
||||
@Input() useSquareCovers: boolean = false;
|
||||
|
||||
@ViewChild('checkboxElem') checkboxElem!: ElementRef<HTMLInputElement>;
|
||||
|
||||
@@ -138,7 +139,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['book'] || changes['forceEbookMode']) {
|
||||
if (changes['book'] || changes['forceEbookMode'] || changes['useSquareCovers']) {
|
||||
this.computeAllMemoizedValues();
|
||||
if (changes['book'] && !changes['book'].firstChange && this.menuInitialized) {
|
||||
this.additionalFilesLoaded = false;
|
||||
|
||||
Reference in New Issue
Block a user