diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 58e2a0c5..7be02440 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -123,6 +123,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: key: tauri-cargo + cache-all-crates: 'true' - name: install system dependencies run: | diff --git a/apps/readest-app/src/app/reader/components/FoliateViewer.tsx b/apps/readest-app/src/app/reader/components/FoliateViewer.tsx index 3915812e..ea68c66f 100644 --- a/apps/readest-app/src/app/reader/components/FoliateViewer.tsx +++ b/apps/readest-app/src/app/reader/components/FoliateViewer.tsx @@ -103,6 +103,7 @@ const FoliateViewer: React.FC<{ const doubleClickDisabled = useRef(!!viewSettings?.disableDoubleClick); const [toastMessage, setToastMessage] = useState(''); const [loading, setLoading] = useState(false); + const [scrollMargins, setScrollMargins] = useState({ top: 0, bottom: 0 }); const docLoaded = useRef(false); useAutoFocus({ ref: containerRef }); @@ -537,7 +538,7 @@ const FoliateViewer: React.FC<{ const ttsBarHeight = viewState?.ttsEnabled && viewSettings.showTTSBar ? 52 + gridInsets.bottom * 0.33 : 0; const moreBottomInset = showBottomFooter - ? Math.max(0, Math.max(ttsBarHeight, 44) - insets.bottom) + ? Math.max(0, Math.max(ttsBarHeight, 52) - insets.bottom) : Math.max(0, ttsBarHeight); const moreRightInset = showDoubleBorderHeader ? 32 : 0; const moreLeftInset = showDoubleBorderFooter ? 32 : 0; @@ -551,6 +552,18 @@ const FoliateViewer: React.FC<{ viewRef.current?.renderer.setAttribute('margin-right', `${rightMargin}px`); viewRef.current?.renderer.setAttribute('margin-bottom', `${viewMargins ? 0 : bottomMargin}px`); viewRef.current?.renderer.setAttribute('margin-left', `${leftMargin}px`); + if (viewMargins) { + const showBarsOnScroll = viewSettings.showBarsOnScroll; + const headerVisible = showTopHeader && showBarsOnScroll; + const footerVisible = showBottomFooter && showBarsOnScroll; + const safeBottomPadding = appService?.hasSafeAreaInset ? gridInsets.bottom * 0.33 : 0; + const footerBarHeight = 52 + safeBottomPadding; + const scrollTop = headerVisible ? gridInsets.top + 44 : 0; + const scrollBottom = footerVisible ? Math.max(footerBarHeight, ttsBarHeight) : ttsBarHeight; + setScrollMargins({ top: scrollTop, bottom: scrollBottom }); + } else { + setScrollMargins({ top: 0, bottom: 0 }); + } viewRef.current?.renderer.setAttribute('gap', `${viewSettings.gapPercent}%`); if (viewSettings.scrolled) { viewRef.current?.renderer.setAttribute('flow', 'scrolled'); @@ -627,11 +640,12 @@ const FoliateViewer: React.FC<{ viewSettings?.showHeader, viewSettings?.showFooter, viewSettings?.showTTSBar, + viewSettings?.showBarsOnScroll, + viewSettings?.showMarginsOnScroll, + viewSettings?.scrolled, viewState?.ttsEnabled, ]); - const showViewMargins = viewSettings?.showMarginsOnScroll && viewSettings?.scrolled; - return ( <> {selectedImage && ( @@ -661,8 +675,8 @@ const FoliateViewer: React.FC<{ viewState?.loading && 'bg-base-100', )} style={{ - paddingTop: showViewMargins ? insets.top : 0, - paddingBottom: showViewMargins ? insets.bottom : 0, + paddingTop: scrollMargins.top, + paddingBottom: scrollMargins.bottom, }} {...mouseHandlers} {...touchHandlers}