Fix background in web scroll elements and update settings screen for web

zio/stable
Paul Frazee 2023-01-26 20:16:37 -06:00
parent f7e3b1451e
commit 9659625e8e
2 changed files with 119 additions and 86 deletions

View File

@ -22,7 +22,9 @@ import {
View, View,
ViewProps, ViewProps,
} from 'react-native' } from 'react-native'
import {useTheme} from '../../lib/ThemeContext'
import {addStyle} from '../../lib/addStyle' import {addStyle} from '../../lib/addStyle'
import {colors} from '../../lib/styles'
export function CenteredView({ export function CenteredView({
style, style,
@ -36,7 +38,15 @@ export function FlatList<ItemT>({
contentContainerStyle, contentContainerStyle,
...props ...props
}: React.PropsWithChildren<FlatListProps<ItemT>>) { }: React.PropsWithChildren<FlatListProps<ItemT>>) {
contentContainerStyle = addStyle(contentContainerStyle, styles.container) const theme = useTheme()
contentContainerStyle = addStyle(
contentContainerStyle,
styles.containerScroll,
)
contentContainerStyle = addStyle(
contentContainerStyle,
theme.colorScheme === 'dark' ? styles.containerDark : styles.containerLight,
)
return <RNFlatList contentContainerStyle={contentContainerStyle} {...props} /> return <RNFlatList contentContainerStyle={contentContainerStyle} {...props} />
} }
@ -44,7 +54,15 @@ export function ScrollView({
contentContainerStyle, contentContainerStyle,
...props ...props
}: React.PropsWithChildren<ScrollViewProps>) { }: React.PropsWithChildren<ScrollViewProps>) {
contentContainerStyle = addStyle(contentContainerStyle, styles.container) const theme = useTheme()
contentContainerStyle = addStyle(
contentContainerStyle,
styles.containerScroll,
)
contentContainerStyle = addStyle(
contentContainerStyle,
theme.colorScheme === 'dark' ? styles.containerDark : styles.containerLight,
)
return ( return (
<RNScrollView contentContainerStyle={contentContainerStyle} {...props} /> <RNScrollView contentContainerStyle={contentContainerStyle} {...props} />
) )
@ -57,4 +75,17 @@ const styles = StyleSheet.create({
marginLeft: 'auto', marginLeft: 'auto',
marginRight: 'auto', marginRight: 'auto',
}, },
containerScroll: {
width: '100%',
height: '100%',
maxWidth: 600,
marginLeft: 'auto',
marginRight: 'auto',
},
containerLight: {
backgroundColor: colors.gray1,
},
containerDark: {
backgroundColor: colors.gray7,
},
}) })

View File

@ -1,7 +1,6 @@
import React, {useEffect} from 'react' import React, {useEffect} from 'react'
import { import {
ActivityIndicator, ActivityIndicator,
ScrollView,
StyleSheet, StyleSheet,
TouchableOpacity, TouchableOpacity,
View, View,
@ -11,6 +10,7 @@ import {observer} from 'mobx-react-lite'
import {useStores} from '../../state' import {useStores} from '../../state'
import {ScreenParams} from '../routes' import {ScreenParams} from '../routes'
import {s} from '../lib/styles' import {s} from '../lib/styles'
import {ScrollView} from '../com/util/Views'
import {ViewHeader} from '../com/util/ViewHeader' import {ViewHeader} from '../com/util/ViewHeader'
import {Link} from '../com/util/Link' import {Link} from '../com/util/Link'
import {Text} from '../com/util/text/Text' import {Text} from '../com/util/text/Text'
@ -56,109 +56,111 @@ export const Settings = observer(function Settings({
return ( return (
<View style={[s.h100pct]} testID="settingsScreen"> <View style={[s.h100pct]} testID="settingsScreen">
<ViewHeader title="Settings" /> <ViewHeader title="Settings" />
<ScrollView style={[s.mt10, s.pl10, s.pr10, s.h100pct]}> <ScrollView style={s.h100pct}>
<View style={[s.flexRow]}> <View style={[s.mt10, s.pl10, s.pr10]}>
<Text type="xl-bold" style={pal.text}> <View style={[s.flexRow]}>
Signed in as <Text type="xl-bold" style={pal.text}>
</Text> Signed in as
<View style={s.flex1} />
<TouchableOpacity
testID="signOutBtn"
onPress={isSwitching ? undefined : onPressSignout}>
<Text type="xl-medium" style={pal.link}>
Sign out
</Text> </Text>
</TouchableOpacity> <View style={s.flex1} />
</View> <TouchableOpacity
{isSwitching ? ( testID="signOutBtn"
<View style={[pal.view, styles.profile]}> onPress={isSwitching ? undefined : onPressSignout}>
<ActivityIndicator /> <Text type="xl-medium" style={pal.link}>
Sign out
</Text>
</TouchableOpacity>
</View> </View>
) : ( {isSwitching ? (
<Link
href={`/profile/${store.me.handle}`}
title="Your profile"
noFeedback>
<View style={[pal.view, styles.profile]}> <View style={[pal.view, styles.profile]}>
<ActivityIndicator />
</View>
) : (
<Link
href={`/profile/${store.me.handle}`}
title="Your profile"
noFeedback>
<View style={[pal.view, styles.profile]}>
<UserAvatar
size={40}
displayName={store.me.displayName}
handle={store.me.handle || ''}
avatar={store.me.avatar}
/>
<View style={[s.ml10]}>
<Text type="xl-bold" style={pal.text}>
{store.me.displayName || store.me.handle}
</Text>
<Text style={pal.textLight}>@{store.me.handle}</Text>
</View>
</View>
</Link>
)}
<Text type="sm-medium" style={pal.text}>
Switch to:
</Text>
{store.session.switchableAccounts.map(account => (
<TouchableOpacity
testID={`switchToAccountBtn-${account.handle}`}
key={account.did}
style={[
pal.view,
styles.profile,
s.mb2,
isSwitching && styles.dimmed,
]}
onPress={
isSwitching ? undefined : () => onPressSwitchAccount(account)
}>
<UserAvatar <UserAvatar
size={40} size={40}
displayName={store.me.displayName} displayName={account.displayName}
handle={store.me.handle || ''} handle={account.handle || ''}
avatar={store.me.avatar} avatar={account.aviUrl}
/> />
<View style={[s.ml10]}> <View style={[s.ml10]}>
<Text type="xl-bold" style={pal.text}> <Text type="xl-bold" style={pal.text}>
{store.me.displayName || store.me.handle} {account.displayName || account.handle}
</Text> </Text>
<Text style={pal.textLight}>@{store.me.handle}</Text> <Text style={pal.textLight}>@{account.handle}</Text>
</View> </View>
</View> </TouchableOpacity>
</Link> ))}
)}
<Text type="sm-medium" style={pal.text}>
Switch to:
</Text>
{store.session.switchableAccounts.map(account => (
<TouchableOpacity <TouchableOpacity
testID={`switchToAccountBtn-${account.handle}`} testID="switchToNewAccountBtn"
key={account.did}
style={[ style={[
pal.view, pal.view,
styles.profile, styles.profile,
styles.alignCenter,
s.mb2, s.mb2,
isSwitching && styles.dimmed, isSwitching && styles.dimmed,
]} ]}
onPress={ onPress={isSwitching ? undefined : onPressAddAccount}>
isSwitching ? undefined : () => onPressSwitchAccount(account) <FontAwesomeIcon icon="plus" />
}> <View style={[s.ml5]}>
<UserAvatar <Text type="md-medium" style={pal.text}>
size={40} Add account
displayName={account.displayName}
handle={account.handle || ''}
avatar={account.aviUrl}
/>
<View style={[s.ml10]}>
<Text type="xl-bold" style={pal.text}>
{account.displayName || account.handle}
</Text> </Text>
<Text style={pal.textLight}>@{account.handle}</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
))} <View style={styles.spacer} />
<TouchableOpacity <Text type="sm-medium" style={[s.mb5]}>
testID="switchToNewAccountBtn" Developer tools
style={[ </Text>
pal.view, <Link
styles.profile, style={[pal.view, s.p10, s.mb2]}
styles.alignCenter, href="/sys/log"
s.mb2, title="System log">
isSwitching && styles.dimmed, <Text style={pal.link}>System log</Text>
]} </Link>
onPress={isSwitching ? undefined : onPressAddAccount}> <Link
<FontAwesomeIcon icon="plus" /> style={[pal.view, s.p10, s.mb2]}
<View style={[s.ml5]}> href="/sys/debug"
<Text type="md-medium" style={pal.text}> title="Debug tools">
Add account <Text style={pal.link}>Storybook</Text>
</Text> </Link>
</View> <View style={s.footerSpacer} />
</TouchableOpacity> </View>
<View style={styles.spacer} />
<Text type="sm-medium" style={[s.mb5]}>
Developer tools
</Text>
<Link
style={[pal.view, s.p10, s.mb2]}
href="/sys/log"
title="System log">
<Text style={pal.link}>System log</Text>
</Link>
<Link
style={[pal.view, s.p10, s.mb2]}
href="/sys/debug"
title="Debug tools">
<Text style={pal.link}>Storybook</Text>
</Link>
<View style={s.footerSpacer} />
</ScrollView> </ScrollView>
</View> </View>
) )