Use square covers for audiobook-only libraries (#2945)
This commit is contained in:
@@ -312,6 +312,7 @@
|
|||||||
[isSeriesCollapsed]="seriesCollapseFilter.isSeriesCollapsed"
|
[isSeriesCollapsed]="seriesCollapseFilter.isSeriesCollapsed"
|
||||||
(checkboxClick)="onCheckboxClicked($event)"
|
(checkboxClick)="onCheckboxClicked($event)"
|
||||||
[isSelected]="selectedBooks.has(book.id)"
|
[isSelected]="selectedBooks.has(book.id)"
|
||||||
|
[useSquareCovers]="isAudiobookOnlyLibrary"
|
||||||
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
||||||
</app-book-card>
|
</app-book-card>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+19
-5
@@ -196,7 +196,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
const totalGaps = (columns - 1) * this.MOBILE_GAP;
|
const totalGaps = (columns - 1) * this.MOBILE_GAP;
|
||||||
const availableWidth = this.screenWidth - totalGaps - this.MOBILE_PADDING;
|
const availableWidth = this.screenWidth - totalGaps - this.MOBILE_PADDING;
|
||||||
const cardWidth = Math.floor(availableWidth / columns);
|
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;
|
const cardHeight = coverHeight + this.MOBILE_TITLE_BAR_HEIGHT;
|
||||||
return {width: cardWidth, height: cardHeight};
|
return {width: cardWidth, height: cardHeight};
|
||||||
}
|
}
|
||||||
@@ -209,23 +209,31 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
if (this.isMobile) {
|
if (this.isMobile) {
|
||||||
return this.mobileCardSize;
|
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 {
|
get gridColumnMinWidth(): string {
|
||||||
if (this.isMobile) {
|
if (this.isMobile) {
|
||||||
return `${this.mobileCardSize.width}px`;
|
return `${this.mobileCardSize.width}px`;
|
||||||
}
|
}
|
||||||
|
if (this.isAudiobookOnlyLibrary) {
|
||||||
|
return `${this.currentCardSize.width}px`;
|
||||||
|
}
|
||||||
return this.coverScalePreferenceService.gridColumnMinWidth;
|
return this.coverScalePreferenceService.gridColumnMinWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
getCardHeight(_book: Book): number {
|
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) {
|
if (this.isMobile) {
|
||||||
return this.mobileCardSize.height;
|
return this.mobileCardSize.height;
|
||||||
}
|
}
|
||||||
|
if (this.isAudiobookOnlyLibrary) {
|
||||||
|
return this.currentCardSize.height;
|
||||||
|
}
|
||||||
return this.coverScalePreferenceService.getCardHeight(_book);
|
return this.coverScalePreferenceService.getCardHeight(_book);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,6 +275,12 @@ export class BookBrowserComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
: filterSummary;
|
: 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 {
|
get seriesViewEnabled(): boolean {
|
||||||
return Boolean(this.userService.getCurrentUser()?.userSettings?.enableSeriesView);
|
return Boolean(this.userService.getCurrentUser()?.userSettings?.enableSeriesView);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2,12 +2,12 @@
|
|||||||
[class.selected]="isSelected"
|
[class.selected]="isSelected"
|
||||||
(click)="onCardClick($event)">
|
(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
|
<img
|
||||||
[src]="coverImageUrl"
|
[src]="coverImageUrl"
|
||||||
class="book-cover"
|
class="book-cover"
|
||||||
[class.loaded]="isImageLoaded"
|
[class.loaded]="isImageLoaded"
|
||||||
[class.square-cover]="_isAudiobook"
|
[class.square-cover]="_isAudiobook || useSquareCovers"
|
||||||
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle })"
|
[alt]="('book.card.alt.cover' | transloco: { title: displayTitle })"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
|
|||||||
+5
@@ -56,6 +56,11 @@
|
|||||||
background-color: var(--surface-ground);
|
background-color: var(--surface-ground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cover-container.square-library-cover {
|
||||||
|
aspect-ratio: 1/1;
|
||||||
|
background-color: var(--surface-ground);
|
||||||
|
}
|
||||||
|
|
||||||
.book-cover {
|
.book-cover {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|||||||
+2
-1
@@ -53,6 +53,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
@Input() isSeriesCollapsed: boolean = false;
|
@Input() isSeriesCollapsed: boolean = false;
|
||||||
@Input() overlayPreferenceService?: BookCardOverlayPreferenceService;
|
@Input() overlayPreferenceService?: BookCardOverlayPreferenceService;
|
||||||
@Input() forceEbookMode: boolean = false;
|
@Input() forceEbookMode: boolean = false;
|
||||||
|
@Input() useSquareCovers: boolean = false;
|
||||||
|
|
||||||
@ViewChild('checkboxElem') checkboxElem!: ElementRef<HTMLInputElement>;
|
@ViewChild('checkboxElem') checkboxElem!: ElementRef<HTMLInputElement>;
|
||||||
|
|
||||||
@@ -138,7 +139,7 @@ export class BookCardComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
if (changes['book'] || changes['forceEbookMode']) {
|
if (changes['book'] || changes['forceEbookMode'] || changes['useSquareCovers']) {
|
||||||
this.computeAllMemoizedValues();
|
this.computeAllMemoizedValues();
|
||||||
if (changes['book'] && !changes['book'].firstChange && this.menuInitialized) {
|
if (changes['book'] && !changes['book'].firstChange && this.menuInitialized) {
|
||||||
this.additionalFilesLoaded = false;
|
this.additionalFilesLoaded = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user