diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-02-25 09:20:37 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-25 09:20:37 -0800 |
commit | cc8369e868ec684120a220dfa66845dad324b4a1 (patch) | |
tree | 9a5abaaa526644d16785e3a530a16010ab2b0107 /src/components/Layout/index.tsx | |
parent | 04378386494fac38002fa7459464952040b58d55 (diff) | |
download | voidsky-cc8369e868ec684120a220dfa66845dad324b4a1.tar.zst |
Better tablet layout (#7656)
* better tablet layout * adjust left nav spacing * add right nav to pwi * clearer logic * fix a couple screens that don't need the tablet layout * fix horiz scroll bar * fix double trending * fix ts-ignore * fix labeller screen * don't offset things within dialogs * fix load latest button (and add scale animation) * center loader on home screen * adjust break points * adjust left nav spacing * fix load latest btn (again) * add lang select to right nav if left nav is minimal * fix double scrollbar on tiny screens * fix scrollbar * fix type errors
Diffstat (limited to 'src/components/Layout/index.tsx')
-rw-r--r-- | src/components/Layout/index.tsx | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx index 489ebb225..623478a6a 100644 --- a/src/components/Layout/index.tsx +++ b/src/components/Layout/index.tsx @@ -13,7 +13,15 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context' import {isWeb} from '#/platform/detection' import {useShellLayout} from '#/state/shell/shell-layout' -import {atoms as a, useBreakpoints, useTheme, web} from '#/alf' +import { + atoms as a, + useBreakpoints, + useLayoutBreakpoints, + useTheme, + web, +} from '#/alf' +import {useDialogContext} from '#/components/Dialog' +import {SCROLLBAR_OFFSET} from '#/components/Layout/const' import {ScrollbarOffsetContext} from '#/components/Layout/context' export * from '#/components/Layout/const' @@ -47,6 +55,7 @@ export const Screen = React.memo(function Screen({ export type ContentProps = AnimatedScrollViewProps & { style?: StyleProp<ViewStyle> contentContainerStyle?: StyleProp<ViewStyle> + ignoreTabletLayoutOffset?: boolean } /** @@ -56,6 +65,7 @@ export const Content = React.memo(function Content({ children, style, contentContainerStyle, + ignoreTabletLayoutOffset, ...props }: ContentProps) { const t = useTheme() @@ -84,8 +94,10 @@ export const Content = React.memo(function Content({ ]} {...props}> {isWeb ? ( - // @ts-ignore web only -esb - <Center>{children}</Center> + <Center ignoreTabletLayoutOffset={ignoreTabletLayoutOffset}> + {/* @ts-expect-error web only -esb */} + {children} + </Center> ) : ( children )} @@ -138,10 +150,13 @@ export const KeyboardAwareContent = React.memo(function LayoutScrollView({ export const Center = React.memo(function LayoutContent({ children, style, + ignoreTabletLayoutOffset, ...props -}: ViewProps) { +}: ViewProps & {ignoreTabletLayoutOffset?: boolean}) { const {isWithinOffsetView} = useContext(ScrollbarOffsetContext) const {gtMobile} = useBreakpoints() + const {centerColumnOffset} = useLayoutBreakpoints() + const {isWithinDialog} = useDialogContext() const ctx = useMemo(() => ({isWithinOffsetView: true}), []) return ( <View @@ -151,8 +166,20 @@ export const Center = React.memo(function LayoutContent({ gtMobile && { maxWidth: 600, }, + !isWithinOffsetView && { + transform: [ + { + translateX: + centerColumnOffset && + !ignoreTabletLayoutOffset && + !isWithinDialog + ? -150 + : 0, + }, + {translateX: web(SCROLLBAR_OFFSET) ?? 0}, + ], + }, style, - !isWithinOffsetView && a.scrollbar_offset, ]} {...props}> <ScrollbarOffsetContext.Provider value={ctx}> @@ -168,6 +195,7 @@ export const Center = React.memo(function LayoutContent({ const WebCenterBorders = React.memo(function LayoutContent() { const t = useTheme() const {gtMobile} = useBreakpoints() + const {centerColumnOffset} = useLayoutBreakpoints() return gtMobile ? ( <View style={[ @@ -180,9 +208,8 @@ const WebCenterBorders = React.memo(function LayoutContent() { width: 602, left: '50%', transform: [ - { - translateX: '-50%', - }, + {translateX: '-50%'}, + {translateX: centerColumnOffset ? -150 : 0}, ...a.scrollbar_offset.transform, ], }), |