/** * In the Web build, we center all content so that it mirrors the * mobile experience (a single narrow column). We then place a UI * shell around the content if you're in desktop. * * Because scrolling is handled by components deep in the hierarchy, * we can't just wrap the top-level element with a max width. The * centering has to be done at the ScrollView. * * These components wrap the RN ScrollView-based components to provide * consistent layout. It also provides for views that * need to match layout but which aren't scrolled. */ import React from 'react' import { FlatList as RNFlatList, FlatListProps, ScrollView as RNScrollView, ScrollViewProps, StyleSheet, View, ViewProps, } from 'react-native' import {useTheme} from 'lib/ThemeContext' import {addStyle, colors} from 'lib/styles' export function CenteredView({ style, ...props }: React.PropsWithChildren) { style = addStyle(style, styles.container) return } export function FlatList({ contentContainerStyle, ...props }: React.PropsWithChildren>) { const theme = useTheme() contentContainerStyle = addStyle( contentContainerStyle, styles.containerScroll, ) contentContainerStyle = addStyle( contentContainerStyle, theme.colorScheme === 'dark' ? styles.containerDark : styles.containerLight, ) return } export function ScrollView({ contentContainerStyle, ...props }: React.PropsWithChildren) { const theme = useTheme() contentContainerStyle = addStyle( contentContainerStyle, styles.containerScroll, ) contentContainerStyle = addStyle( contentContainerStyle, theme.colorScheme === 'dark' ? styles.containerDark : styles.containerLight, ) return ( ) } const styles = StyleSheet.create({ container: { width: '100%', maxWidth: 600, marginLeft: 'auto', marginRight: 'auto', }, containerScroll: { width: '100%', height: '100%', maxWidth: 600, marginLeft: 'auto', marginRight: 'auto', }, containerLight: { backgroundColor: colors.gray1, }, containerDark: { backgroundColor: colors.gray7, }, })