From 9659625e8e35ad1321d1febaac78f41bdba372f7 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 26 Jan 2023 20:16:37 -0600 Subject: [PATCH] Fix background in web scroll elements and update settings screen for web --- src/view/com/util/Views.web.tsx | 35 ++++++- src/view/screens/Settings.tsx | 170 ++++++++++++++++---------------- 2 files changed, 119 insertions(+), 86 deletions(-) diff --git a/src/view/com/util/Views.web.tsx b/src/view/com/util/Views.web.tsx index 313dda9c..2df53414 100644 --- a/src/view/com/util/Views.web.tsx +++ b/src/view/com/util/Views.web.tsx @@ -22,7 +22,9 @@ import { View, ViewProps, } from 'react-native' +import {useTheme} from '../../lib/ThemeContext' import {addStyle} from '../../lib/addStyle' +import {colors} from '../../lib/styles' export function CenteredView({ style, @@ -36,7 +38,15 @@ export function FlatList({ contentContainerStyle, ...props }: React.PropsWithChildren>) { - contentContainerStyle = addStyle(contentContainerStyle, styles.container) + const theme = useTheme() + contentContainerStyle = addStyle( + contentContainerStyle, + styles.containerScroll, + ) + contentContainerStyle = addStyle( + contentContainerStyle, + theme.colorScheme === 'dark' ? styles.containerDark : styles.containerLight, + ) return } @@ -44,7 +54,15 @@ export function ScrollView({ contentContainerStyle, ...props }: React.PropsWithChildren) { - contentContainerStyle = addStyle(contentContainerStyle, styles.container) + const theme = useTheme() + contentContainerStyle = addStyle( + contentContainerStyle, + styles.containerScroll, + ) + contentContainerStyle = addStyle( + contentContainerStyle, + theme.colorScheme === 'dark' ? styles.containerDark : styles.containerLight, + ) return ( ) @@ -57,4 +75,17 @@ const styles = StyleSheet.create({ marginLeft: 'auto', marginRight: 'auto', }, + containerScroll: { + width: '100%', + height: '100%', + maxWidth: 600, + marginLeft: 'auto', + marginRight: 'auto', + }, + containerLight: { + backgroundColor: colors.gray1, + }, + containerDark: { + backgroundColor: colors.gray7, + }, }) diff --git a/src/view/screens/Settings.tsx b/src/view/screens/Settings.tsx index d659d25d..c2953b59 100644 --- a/src/view/screens/Settings.tsx +++ b/src/view/screens/Settings.tsx @@ -1,7 +1,6 @@ import React, {useEffect} from 'react' import { ActivityIndicator, - ScrollView, StyleSheet, TouchableOpacity, View, @@ -11,6 +10,7 @@ import {observer} from 'mobx-react-lite' import {useStores} from '../../state' import {ScreenParams} from '../routes' import {s} from '../lib/styles' +import {ScrollView} from '../com/util/Views' import {ViewHeader} from '../com/util/ViewHeader' import {Link} from '../com/util/Link' import {Text} from '../com/util/text/Text' @@ -56,109 +56,111 @@ export const Settings = observer(function Settings({ return ( - - - - Signed in as - - - - - Sign out + + + + + Signed in as - - - {isSwitching ? ( - - + + + + Sign out + + - ) : ( - + {isSwitching ? ( + + + ) : ( + + + + + + {store.me.displayName || store.me.handle} + + @{store.me.handle} + + + + )} + + Switch to: + + {store.session.switchableAccounts.map(account => ( + onPressSwitchAccount(account) + }> - {store.me.displayName || store.me.handle} + {account.displayName || account.handle} - @{store.me.handle} + @{account.handle} - - - )} - - Switch to: - - {store.session.switchableAccounts.map(account => ( + + ))} onPressSwitchAccount(account) - }> - - - - {account.displayName || account.handle} + onPress={isSwitching ? undefined : onPressAddAccount}> + + + + Add account - @{account.handle} - ))} - - - - - Add account - - - - - - Developer tools - - - System log - - - Storybook - - + + + Developer tools + + + System log + + + Storybook + + + )