Another set of UI updates (FAB returns, a few others) (#281)

* Bring back the FAB and move compose out of the footer

* Increase the touch target sizes of the header back btns (close #279)

* Trigger 'load more' sooner (close #280)
This commit is contained in:
Paul Frazee 2023-03-07 17:17:44 -06:00 committed by GitHub
parent e74f94bc72
commit 181121b451
10 changed files with 54 additions and 60 deletions

View file

@ -665,37 +665,21 @@ export function ComposeIcon2({
style, style,
size, size,
strokeWidth = 1.5, strokeWidth = 1.5,
backgroundColor,
}: { }: {
style?: StyleProp<TextStyle> style?: StyleProp<TextStyle>
size?: string | number size?: string | number
strokeWidth?: number strokeWidth?: number
backgroundColor: string
}) { }) {
return ( return (
<Svg <Svg
viewBox="0 0 24 24" viewBox="0 0 24 24"
strokeWidth={strokeWidth}
stroke="currentColor" stroke="currentColor"
width={size || 24} width={size || 24}
height={size || 24} height={size || 24}
style={style}> style={style}>
<Rect <Path
d="M 20 9 L 20 16 C 20 18.209 18.209 20 16 20 L 8 20 C 5.791 20 4 18.209 4 16 L 4 8 C 4 5.791 5.791 4 8 4 L 15 4"
strokeWidth={strokeWidth} strokeWidth={strokeWidth}
x="4"
y="4"
width="16"
height="16"
rx="4"
ry="4"
/>
<Line
x1="10"
y1="14"
x2="22"
y2="2"
strokeWidth={strokeWidth * 4}
stroke={backgroundColor}
/> />
<Line <Line
strokeLinecap="round" strokeLinecap="round"

View file

@ -101,6 +101,7 @@ export const Feed = observer(function Feed({
refreshing={view.isRefreshing} refreshing={view.isRefreshing}
onRefresh={onRefresh} onRefresh={onRefresh}
onEndReached={onEndReached} onEndReached={onEndReached}
onEndReachedThreshold={0.6}
onScroll={onScroll} onScroll={onScroll}
contentContainerStyle={s.contentContainer} contentContainerStyle={s.contentContainer}
/> />

View file

@ -168,7 +168,7 @@ export const Feed = observer(function Feed({
onScroll={onScroll} onScroll={onScroll}
onRefresh={onRefresh} onRefresh={onRefresh}
onEndReached={onEndReached} onEndReached={onEndReached}
onEndReachedThreshold={0.25} onEndReachedThreshold={0.6}
removeClippedSubviews={true} removeClippedSubviews={true}
contentInset={{top: headerOffset}} contentInset={{top: headerOffset}}
contentOffset={{x: 0, y: headerOffset * -1}} contentOffset={{x: 0, y: headerOffset * -1}}

View file

@ -29,6 +29,8 @@ import {UserBanner} from '../util/UserBanner'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
import {useAnalytics} from 'lib/analytics' import {useAnalytics} from 'lib/analytics'
const BACK_HITSLOP = {left: 30, top: 30, right: 30, bottom: 30}
export const ProfileHeader = observer(function ProfileHeader({ export const ProfileHeader = observer(function ProfileHeader({
view, view,
onRefreshAll, onRefreshAll,
@ -285,10 +287,12 @@ export const ProfileHeader = observer(function ProfileHeader({
</View> </View>
) : undefined} ) : undefined}
</View> </View>
<TouchableWithoutFeedback onPress={onPressBack}> <TouchableWithoutFeedback onPress={onPressBack} hitSlop={BACK_HITSLOP}>
<BlurView style={styles.backBtn} blurType="dark"> <View style={styles.backBtnWrapper}>
<FontAwesomeIcon size={18} icon="angle-left" style={s.white} /> <BlurView style={styles.backBtn} blurType="dark">
</BlurView> <FontAwesomeIcon size={18} icon="angle-left" style={s.white} />
</BlurView>
</View>
</TouchableWithoutFeedback> </TouchableWithoutFeedback>
<TouchableWithoutFeedback <TouchableWithoutFeedback
testID="profileHeaderAviButton" testID="profileHeaderAviButton"
@ -312,12 +316,16 @@ const styles = StyleSheet.create({
width: '100%', width: '100%',
height: 120, height: 120,
}, },
backBtn: { backBtnWrapper: {
position: 'absolute', position: 'absolute',
top: 10, top: 10,
left: 10, left: 10,
width: 30, width: 30,
height: 30, height: 30,
},
backBtn: {
width: 30,
height: 30,
borderRadius: 15, borderRadius: 15,
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',

View file

@ -7,9 +7,7 @@ import {
TouchableWithoutFeedback, TouchableWithoutFeedback,
} from 'react-native' } from 'react-native'
import LinearGradient from 'react-native-linear-gradient' import LinearGradient from 'react-native-linear-gradient'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {gradients} from 'lib/styles'
import {IconProp} from '@fortawesome/fontawesome-svg-core'
import {colors, gradients} from 'lib/styles'
import {useAnimatedValue} from 'lib/hooks/useAnimatedValue' import {useAnimatedValue} from 'lib/hooks/useAnimatedValue'
import {useStores} from 'state/index' import {useStores} from 'state/index'
@ -21,7 +19,7 @@ export const FAB = observer(
onPress, onPress,
}: { }: {
testID?: string testID?: string
icon: IconProp icon: JSX.Element
onPress: OnPress onPress: OnPress
}) => { }) => {
const store = useStores() const store = useStores()
@ -45,7 +43,7 @@ export const FAB = observer(
start={{x: 0, y: 0}} start={{x: 0, y: 0}}
end={{x: 1, y: 1}} end={{x: 1, y: 1}}
style={styles.inner}> style={styles.inner}>
<FontAwesomeIcon size={24} icon={icon} color={colors.white} /> {icon}
</LinearGradient> </LinearGradient>
</Animated.View> </Animated.View>
</TouchableWithoutFeedback> </TouchableWithoutFeedback>
@ -57,7 +55,7 @@ const styles = StyleSheet.create({
outer: { outer: {
position: 'absolute', position: 'absolute',
zIndex: 1, zIndex: 1,
right: 22, right: 28,
bottom: 94, bottom: 94,
width: 60, width: 60,
height: 60, height: 60,

View file

@ -10,7 +10,7 @@ import {useAnimatedValue} from 'lib/hooks/useAnimatedValue'
import {useAnalytics} from 'lib/analytics' import {useAnalytics} from 'lib/analytics'
import {isDesktopWeb} from '../../../platform/detection' import {isDesktopWeb} from '../../../platform/detection'
const BACK_HITSLOP = {left: 10, top: 10, right: 30, bottom: 10} const BACK_HITSLOP = {left: 20, top: 20, right: 50, bottom: 20}
export const ViewHeader = observer(function ViewHeader({ export const ViewHeader = observer(function ViewHeader({
title, title,

View file

@ -100,6 +100,7 @@ export function ViewSelector({
onScroll={onScroll} onScroll={onScroll}
onRefresh={onRefresh} onRefresh={onRefresh}
onEndReached={onEndReached} onEndReached={onEndReached}
onEndReachedThreshold={0.6}
contentContainerStyle={s.contentContainer} contentContainerStyle={s.contentContainer}
removeClippedSubviews={true} removeClippedSubviews={true}
/> />

View file

@ -6,18 +6,21 @@ import {ViewHeader} from '../com/util/ViewHeader'
import {Feed} from '../com/posts/Feed' import {Feed} from '../com/posts/Feed'
import {LoadLatestBtn} from '../com/util/LoadLatestBtn' import {LoadLatestBtn} from '../com/util/LoadLatestBtn'
import {WelcomeBanner} from '../com/util/WelcomeBanner' import {WelcomeBanner} from '../com/util/WelcomeBanner'
import {FAB} from '../com/util/FAB'
import {useStores} from 'state/index' import {useStores} from 'state/index'
import {ScreenParams} from '../routes' import {ScreenParams} from '../routes'
import {s} from 'lib/styles' import {s, colors} from 'lib/styles'
import {useOnMainScroll} from 'lib/hooks/useOnMainScroll' import {useOnMainScroll} from 'lib/hooks/useOnMainScroll'
import {useAnalytics} from 'lib/analytics' import {useAnalytics} from 'lib/analytics'
import {usePalette} from 'lib/hooks/usePalette'
import {ComposeIcon2} from 'lib/icons'
const HEADER_HEIGHT = 42 const HEADER_HEIGHT = 42
export const Home = observer(function Home({navIdx, visible}: ScreenParams) { export const Home = observer(function Home({navIdx, visible}: ScreenParams) {
const store = useStores() const store = useStores()
const onMainScroll = useOnMainScroll(store) const onMainScroll = useOnMainScroll(store)
const {screen} = useAnalytics() const {screen, track} = useAnalytics()
const scrollElRef = React.useRef<FlatList>(null) const scrollElRef = React.useRef<FlatList>(null)
const [wasVisible, setWasVisible] = React.useState<boolean>(false) const [wasVisible, setWasVisible] = React.useState<boolean>(false)
const {appState} = useAppState({ const {appState} = useAppState({
@ -84,13 +87,17 @@ export const Home = observer(function Home({navIdx, visible}: ScreenParams) {
screen, screen,
]) ])
const onPressTryAgain = () => { const onPressCompose = React.useCallback(() => {
track('HomeScreen:PressCompose')
store.shell.openComposer({})
}, [store, track])
const onPressTryAgain = React.useCallback(() => {
store.me.mainFeed.refresh() store.me.mainFeed.refresh()
} }, [store])
const onPressLoadLatest = () => { const onPressLoadLatest = React.useCallback(() => {
store.me.mainFeed.refresh() store.me.mainFeed.refresh()
scrollToTop() scrollToTop()
} }, [store, scrollToTop])
return ( return (
<View style={s.hContentRegion}> <View style={s.hContentRegion}>
@ -112,6 +119,11 @@ export const Home = observer(function Home({navIdx, visible}: ScreenParams) {
{store.me.mainFeed.hasNewLatest && !store.me.mainFeed.isRefreshing && ( {store.me.mainFeed.hasNewLatest && !store.me.mainFeed.isRefreshing && (
<LoadLatestBtn onPress={onPressLoadLatest} /> <LoadLatestBtn onPress={onPressLoadLatest} />
)} )}
<FAB
testID="composeFAB"
onPress={onPressCompose}
icon={<ComposeIcon2 strokeWidth={1.5} size={29} style={s.white} />}
/>
</View> </View>
) )
}) })

View file

@ -13,9 +13,11 @@ import {ErrorScreen} from '../com/util/error/ErrorScreen'
import {ErrorMessage} from '../com/util/error/ErrorMessage' import {ErrorMessage} from '../com/util/error/ErrorMessage'
import {EmptyState} from '../com/util/EmptyState' import {EmptyState} from '../com/util/EmptyState'
import {Text} from '../com/util/text/Text' import {Text} from '../com/util/text/Text'
import {FAB} from '../com/util/FAB'
import {s, colors} from 'lib/styles' import {s, colors} from 'lib/styles'
import {useOnMainScroll} from 'lib/hooks/useOnMainScroll' import {useOnMainScroll} from 'lib/hooks/useOnMainScroll'
import {useAnalytics} from 'lib/analytics' import {useAnalytics} from 'lib/analytics'
import {ComposeIcon2} from 'lib/icons'
const LOADING_ITEM = {_reactKey: '__loading__'} const LOADING_ITEM = {_reactKey: '__loading__'}
const END_ITEM = {_reactKey: '__end__'} const END_ITEM = {_reactKey: '__end__'}
@ -23,7 +25,7 @@ const EMPTY_ITEM = {_reactKey: '__empty__'}
export const Profile = observer(({navIdx, visible, params}: ScreenParams) => { export const Profile = observer(({navIdx, visible, params}: ScreenParams) => {
const store = useStores() const store = useStores()
const {screen} = useAnalytics() const {screen, track} = useAnalytics()
useEffect(() => { useEffect(() => {
screen('Profile') screen('Profile')
@ -65,6 +67,10 @@ export const Profile = observer(({navIdx, visible, params}: ScreenParams) => {
// events // events
// = // =
const onPressCompose = React.useCallback(() => {
track('ProfileScreen:PressCompose')
store.shell.openComposer({})
}, [store, track])
const onSelectView = (index: number) => { const onSelectView = (index: number) => {
uiState.setSelectedViewIndex(index) uiState.setSelectedViewIndex(index)
} }
@ -186,6 +192,11 @@ export const Profile = observer(({navIdx, visible, params}: ScreenParams) => {
) : ( ) : (
<CenteredView>{renderHeader()}</CenteredView> <CenteredView>{renderHeader()}</CenteredView>
)} )}
<FAB
testID="composeFAB"
onPress={onPressCompose}
icon={<ComposeIcon2 strokeWidth={1.5} size={29} style={s.white} />}
/>
</View> </View>
) )
}) })

View file

@ -19,7 +19,6 @@ import {
HomeIconSolid, HomeIconSolid,
MagnifyingGlassIcon2, MagnifyingGlassIcon2,
MagnifyingGlassIcon2Solid, MagnifyingGlassIcon2Solid,
ComposeIcon2,
BellIcon, BellIcon,
BellIconSolid, BellIconSolid,
UserIcon, UserIcon,
@ -85,10 +84,6 @@ export const BottomBar = observer(() => {
} }
} }
}, [store, track]) }, [store, track])
const onPressCompose = React.useCallback(() => {
track('MobileShell:ComposeButtonPressed')
store.shell.openComposer({})
}, [store, track])
const onPressNotifications = React.useCallback(() => { const onPressNotifications = React.useCallback(() => {
track('MobileShell:NotificationsButtonPressed') track('MobileShell:NotificationsButtonPressed')
if (store.nav.tab.fixedTabPurpose === TabPurpose.Notifs) { if (store.nav.tab.fixedTabPurpose === TabPurpose.Notifs) {
@ -161,19 +156,6 @@ export const BottomBar = observer(() => {
} }
onPress={onPressSearch} onPress={onPressSearch}
/> />
<Btn
icon={
<View style={styles.ctrlIconSizingWrapper}>
<ComposeIcon2
strokeWidth={1.5}
size={29}
style={[styles.ctrlIcon, pal.text, styles.composeIcon]}
backgroundColor={pal.colors.background}
/>
</View>
}
onPress={onPressCompose}
/>
<Btn <Btn
icon={ icon={
isAtNotifications ? ( isAtNotifications ? (
@ -254,7 +236,7 @@ const styles = StyleSheet.create({
}, },
notificationCount: { notificationCount: {
position: 'absolute', position: 'absolute',
left: '56%', left: '52%',
top: 10, top: 10,
backgroundColor: colors.blue3, backgroundColor: colors.blue3,
paddingHorizontal: 4, paddingHorizontal: 4,
@ -283,9 +265,6 @@ const styles = StyleSheet.create({
bellIcon: { bellIcon: {
top: -2.5, top: -2.5,
}, },
composeIcon: {
top: -4.5,
},
profileIcon: { profileIcon: {
top: -4, top: -4,
}, },