diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-03-22 15:36:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-22 15:36:10 +0000 |
commit | b27a0b8c97c1b82cc8a5f4318735d14a2358e979 (patch) | |
tree | 6d6f7ad4674e8b659f84bb6908378306142ebdb7 /src/view/com/util/layouts/LoggedOutLayout.tsx | |
parent | 772d528145e346273e8064624359da2e8db212ad (diff) | |
parent | 4ec434926e70e90cdca3e5f3205b834c62859dde (diff) | |
download | voidsky-b27a0b8c97c1b82cc8a5f4318735d14a2358e979.tar.zst |
Merge pull request #3337 from bluesky-social/samuel/scrollable-loggedoutlayout
Move scrollview to `LoggedOutLayout` to fix scrolling on web
Diffstat (limited to 'src/view/com/util/layouts/LoggedOutLayout.tsx')
-rw-r--r-- | src/view/com/util/layouts/LoggedOutLayout.tsx | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/src/view/com/util/layouts/LoggedOutLayout.tsx b/src/view/com/util/layouts/LoggedOutLayout.tsx index 9424a7154..0272a44c6 100644 --- a/src/view/com/util/layouts/LoggedOutLayout.tsx +++ b/src/view/com/util/layouts/LoggedOutLayout.tsx @@ -1,19 +1,24 @@ import React from 'react' -import {StyleSheet, View} from 'react-native' -import {Text} from '../text/Text' +import {ScrollView, StyleSheet, View} from 'react-native' + +import {isWeb} from '#/platform/detection' +import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle' import {usePalette} from 'lib/hooks/usePalette' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' -import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle' +import {atoms as a} from '#/alf' +import {Text} from '../text/Text' export const LoggedOutLayout = ({ leadin, title, description, children, + scrollable, }: React.PropsWithChildren<{ leadin: string title: string description: string + scrollable?: boolean }>) => { const {isMobile, isTabletOrMobile} = useWebMediaQueries() const pal = usePalette('default') @@ -25,7 +30,18 @@ export const LoggedOutLayout = ({ }) if (isMobile) { - return <View style={{paddingTop: 10}}>{children}</View> + if (scrollable) { + return ( + <ScrollView + style={styles.scrollview} + keyboardShouldPersistTaps="handled" + keyboardDismissMode="on-drag"> + <View style={a.pt_md}>{children}</View> + </ScrollView> + ) + } else { + return <View style={a.pt_md}>{children}</View> + } } return ( <View style={styles.container}> @@ -50,9 +66,23 @@ export const LoggedOutLayout = ({ {description} </Text> </View> - <View style={[styles.content, contentBg]}> - <View style={styles.contentWrapper}>{children}</View> - </View> + {scrollable ? ( + <View style={[styles.scrollableContent, contentBg]}> + <ScrollView + style={styles.scrollview} + contentContainerStyle={styles.scrollViewContentContainer} + keyboardShouldPersistTaps="handled" + keyboardDismissMode="on-drag"> + <View style={[styles.contentWrapper, isWeb && a.my_auto]}> + {children} + </View> + </ScrollView> + </View> + ) : ( + <View style={[styles.content, contentBg]}> + <View style={styles.contentWrapper}>{children}</View> + </View> + )} </View> ) } @@ -74,7 +104,16 @@ const styles = StyleSheet.create({ paddingHorizontal: 40, justifyContent: 'center', }, - + scrollableContent: { + flex: 2, + }, + scrollview: { + flex: 1, + }, + scrollViewContentContainer: { + flex: 1, + paddingHorizontal: 40, + }, leadinText: { fontSize: 36, fontWeight: '800', |