| import { Insets } from '@/types/misc'; |
| import { ViewSettings } from '@/types/book'; |
|
|
| export const getViewInsets = (viewSettings: ViewSettings) => { |
| const showHeader = viewSettings.showHeader!; |
| const showFooter = viewSettings.showFooter!; |
| const isVertical = viewSettings.vertical || viewSettings.writingMode.includes('vertical'); |
| const fullMarginTopPx = viewSettings.marginPx || viewSettings.marginTopPx; |
| const compactMarginTopPx = viewSettings.compactMarginPx || viewSettings.compactMarginTopPx; |
| const fullMarginBottomPx = viewSettings.marginBottomPx; |
| const compactMarginBottomPx = viewSettings.compactMarginBottomPx; |
| const fullMarginLeftPx = viewSettings.marginLeftPx; |
| const fullMarginRightPx = viewSettings.marginRightPx; |
| const compactMarginLeftPx = viewSettings.compactMarginLeftPx; |
| const compactMarginRightPx = viewSettings.compactMarginRightPx; |
|
|
| return { |
| top: showHeader && !isVertical ? fullMarginTopPx : compactMarginTopPx, |
| right: showHeader && isVertical ? fullMarginRightPx : compactMarginRightPx, |
| bottom: showFooter && !isVertical ? fullMarginBottomPx : compactMarginBottomPx, |
| left: showFooter && isVertical ? fullMarginLeftPx : compactMarginLeftPx, |
| } as Insets; |
| }; |
|
|