Desktop styling fixes

zio/stable
Paul Frazee 2023-05-17 22:58:53 -05:00
parent ed7293ea66
commit bec94ed82c
6 changed files with 84 additions and 42 deletions

View File

@ -1,10 +1,10 @@
import React, {useEffect, useCallback} from 'react' import React, {useEffect, useCallback} from 'react'
import {FlatList, RefreshControl, StyleSheet, View} from 'react-native' import {RefreshControl, StyleSheet, View} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {observer} from 'mobx-react-lite' import {observer} from 'mobx-react-lite'
import {useStores} from 'state/index' import {useStores} from 'state/index'
import {CenteredView} from 'view/com/util/Views' import {FlatList} from 'view/com/util/Views'
import {Text} from 'view/com/util/text/Text' import {Text} from 'view/com/util/text/Text'
import {isDesktopWeb} from 'platform/detection' import {isDesktopWeb} from 'platform/detection'
import {s} from 'lib/styles' import {s} from 'lib/styles'
@ -65,31 +65,29 @@ export const SavedFeeds = observer(
) )
return ( return (
<CenteredView style={[s.flex1]}> <FlatList
<FlatList style={[!isDesktopWeb && s.flex1, {paddingTop: headerOffset}]}
style={[!isDesktopWeb && s.flex1, {paddingTop: headerOffset}]} data={store.me.savedFeeds.feeds}
data={store.me.savedFeeds.feeds} keyExtractor={item => item.data.uri}
keyExtractor={item => item.data.uri} refreshing={store.me.savedFeeds.isRefreshing}
refreshing={store.me.savedFeeds.isRefreshing} refreshControl={
refreshControl={ <RefreshControl
<RefreshControl refreshing={store.me.savedFeeds.isRefreshing}
refreshing={store.me.savedFeeds.isRefreshing} onRefresh={() => store.me.savedFeeds.refresh()}
onRefresh={() => store.me.savedFeeds.refresh()} tintColor={pal.colors.text}
tintColor={pal.colors.text} titleColor={pal.colors.text}
titleColor={pal.colors.text} progressViewOffset={headerOffset}
progressViewOffset={headerOffset} />
/> }
} renderItem={renderItem}
renderItem={renderItem} initialNumToRender={10}
initialNumToRender={10} ListFooterComponent={renderListFooterComponent}
ListFooterComponent={renderListFooterComponent} ListEmptyComponent={renderListEmptyComponent}
ListEmptyComponent={renderListEmptyComponent} extraData={store.me.savedFeeds.isLoading}
extraData={store.me.savedFeeds.isLoading} contentOffset={{x: 0, y: headerOffset * -1}}
contentOffset={{x: 0, y: headerOffset * -1}} // @ts-ignore our .web version only -prf
// @ts-ignore our .web version only -prf desktopFixedHeight
desktopFixedHeight />
/>
</CenteredView>
) )
}, },
) )

View File

@ -28,7 +28,12 @@ const FeedsTabBarDesktop = observer(
) => { ) => {
const store = useStores() const store = useStores()
const items = useMemo( const items = useMemo(
() => ['Following', "What's hot", ...store.me.savedFeeds.pinnedFeedNames], () => [
'Following',
"What's hot",
...store.me.savedFeeds.pinnedFeedNames,
'My feeds',
],
[store.me.savedFeeds.pinnedFeedNames], [store.me.savedFeeds.pinnedFeedNames],
) )
const pal = usePalette('default') const pal = usePalette('default')

View File

@ -107,11 +107,12 @@ const styles = isDesktopWeb
? StyleSheet.create({ ? StyleSheet.create({
outer: { outer: {
flexDirection: 'row', flexDirection: 'row',
paddingHorizontal: 18, width: 598,
paddingHorizontal: 14,
}, },
item: { item: {
paddingTop: 14, paddingTop: 14,
paddingBottom: 16, paddingBottom: 12,
paddingHorizontal: 12, paddingHorizontal: 12,
borderBottomWidth: 3, borderBottomWidth: 3,
borderBottomColor: 'transparent', borderBottomColor: 'transparent',

View File

@ -20,12 +20,14 @@ export const ViewHeader = observer(function ({
canGoBack, canGoBack,
hideOnScroll, hideOnScroll,
showOnDesktop, showOnDesktop,
showBorder,
renderButton, renderButton,
}: { }: {
title: string title: string
canGoBack?: boolean canGoBack?: boolean
hideOnScroll?: boolean hideOnScroll?: boolean
showOnDesktop?: boolean showOnDesktop?: boolean
showBorder?: boolean
renderButton?: () => JSX.Element renderButton?: () => JSX.Element
}) { }) {
const pal = usePalette('default') const pal = usePalette('default')
@ -57,7 +59,7 @@ export const ViewHeader = observer(function ({
} }
return ( return (
<Container hideOnScroll={hideOnScroll || false}> <Container hideOnScroll={hideOnScroll || false} showBorder={showBorder}>
<TouchableOpacity <TouchableOpacity
testID="viewHeaderDrawerBtn" testID="viewHeaderDrawerBtn"
onPress={canGoBack ? onPressBack : onPressMenu} onPress={canGoBack ? onPressBack : onPressMenu}
@ -115,9 +117,11 @@ const Container = observer(
({ ({
children, children,
hideOnScroll, hideOnScroll,
showBorder,
}: { }: {
children: React.ReactNode children: React.ReactNode
hideOnScroll: boolean hideOnScroll: boolean
showBorder: boolean
}) => { }) => {
const store = useStores() const store = useStores()
const pal = usePalette('default') const pal = usePalette('default')
@ -145,11 +149,28 @@ const Container = observer(
} }
if (!hideOnScroll) { if (!hideOnScroll) {
return <View style={[styles.header, pal.view]}>{children}</View> return (
<View
style={[
styles.header,
pal.view,
pal.border,
showBorder && styles.border,
]}>
{children}
</View>
)
} }
return ( return (
<Animated.View <Animated.View
style={[styles.header, pal.view, styles.headerFloating, transform]}> style={[
styles.header,
pal.view,
pal.border,
styles.headerFloating,
transform,
showBorder && styles.border,
]}>
{children} {children}
</Animated.View> </Animated.View>
) )
@ -172,6 +193,9 @@ const styles = StyleSheet.create({
borderBottomWidth: 1, borderBottomWidth: 1,
paddingVertical: 12, paddingVertical: 12,
}, },
border: {
borderBottomWidth: 1,
},
titleContainer: { titleContainer: {
marginLeft: 'auto', marginLeft: 'auto',

View File

@ -126,5 +126,6 @@ const styles = StyleSheet.create({
}, },
fixedHeight: { fixedHeight: {
height: '100vh', height: '100vh',
scrollbarGutter: 'stable both-edges',
}, },
}) })

View File

@ -71,8 +71,17 @@ export const SavedFeeds = withAuthRequired(
} }
return ( return (
<CenteredView style={[s.flex1]}> <CenteredView
<ViewHeader title="Edit My Feeds" showOnDesktop /> style={[
s.hContentRegion,
pal.border,
isDesktopWeb && styles.desktopContainer,
]}>
<ViewHeader
title="Edit My Feeds"
showOnDesktop
showBorder={!isDesktopWeb}
/>
<DraggableFlatList <DraggableFlatList
containerStyle={[!isDesktopWeb && s.flex1]} containerStyle={[!isDesktopWeb && s.flex1]}
data={[...savedFeeds.pinned, ...savedFeeds.unpinned]} // make a copy so this FlatList re-renders when pinned changes data={[...savedFeeds.pinned, ...savedFeeds.unpinned]} // make a copy so this FlatList re-renders when pinned changes
@ -92,8 +101,6 @@ export const SavedFeeds = withAuthRequired(
ListEmptyComponent={_ListEmptyComponent} ListEmptyComponent={_ListEmptyComponent}
extraData={savedFeeds.isLoading} extraData={savedFeeds.isLoading}
onDragEnd={({data}) => savedFeeds.reorderPinnedFeeds(data)} onDragEnd={({data}) => savedFeeds.reorderPinnedFeeds(data)}
// @ts-ignore our .web version only -prf
desktopFixedHeight
/> />
</CenteredView> </CenteredView>
) )
@ -126,8 +133,8 @@ const ListItem = observer(
}}> }}>
<FontAwesomeIcon <FontAwesomeIcon
icon="arrow-up" icon="arrow-up"
size={20} size={12}
style={[s.mr10, pal.text, styles.webArrowUpButton]} style={[pal.text, styles.webArrowUpButton]}
/> />
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity <TouchableOpacity
@ -137,8 +144,8 @@ const ListItem = observer(
}}> }}>
<FontAwesomeIcon <FontAwesomeIcon
icon="arrow-down" icon="arrow-down"
size={20} size={12}
style={[s.mr10, pal.text]} style={[pal.text]}
/> />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
@ -173,6 +180,11 @@ const ListItem = observer(
) )
const styles = StyleSheet.create({ const styles = StyleSheet.create({
desktopContainer: {
borderLeftWidth: 1,
borderRightWidth: 1,
minHeight: '100vh',
},
footer: { footer: {
paddingVertical: 20, paddingVertical: 20,
}, },
@ -187,10 +199,11 @@ const styles = StyleSheet.create({
flex: 1, flex: 1,
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
borderTopWidth: 1, borderBottomWidth: 1,
paddingRight: 16, paddingRight: 16,
}, },
webArrowButtonsContainer: { webArrowButtonsContainer: {
paddingLeft: 16,
flexDirection: 'column', flexDirection: 'column',
justifyContent: 'space-around', justifyContent: 'space-around',
}, },