Refactor the scroll-to-top UX
This commit is contained in:
parent
9673225f78
commit
4e1876fe85
9 changed files with 102 additions and 100 deletions
|
@ -154,6 +154,7 @@ export const Feed = observer(function Feed({
|
|||
onEndReached={onEndReached}
|
||||
onEndReachedThreshold={0.6}
|
||||
onScroll={onScroll}
|
||||
scrollEventThrottle={100}
|
||||
contentContainerStyle={s.contentContainer}
|
||||
/>
|
||||
) : null}
|
||||
|
|
|
@ -14,7 +14,7 @@ import {ErrorMessage} from '../util/error/ErrorMessage'
|
|||
import {PostsFeedModel} from 'state/models/feeds/posts'
|
||||
import {FeedSlice} from './FeedSlice'
|
||||
import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn'
|
||||
import {OnScrollCb, onMomentumScrollEndCb} from 'lib/hooks/useOnMainScroll'
|
||||
import {OnScrollCb} from 'lib/hooks/useOnMainScroll'
|
||||
import {s} from 'lib/styles'
|
||||
import {useAnalytics} from 'lib/analytics'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
|
@ -47,7 +47,6 @@ export const Feed = observer(function Feed({
|
|||
onPressTryAgain?: () => void
|
||||
onScroll?: OnScrollCb
|
||||
scrollEventThrottle?: number
|
||||
onMomentumScrollEnd?: onMomentumScrollEndCb
|
||||
renderEmptyState?: () => JSX.Element
|
||||
testID?: string
|
||||
headerOffset?: number
|
||||
|
|
|
@ -47,7 +47,7 @@ const styles = StyleSheet.create({
|
|||
outer: {
|
||||
position: 'absolute',
|
||||
zIndex: 1,
|
||||
right: 28,
|
||||
right: 24,
|
||||
bottom: 94,
|
||||
width: 60,
|
||||
height: 60,
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
import React from 'react'
|
||||
import {StyleSheet, TouchableOpacity} from 'react-native'
|
||||
import {observer} from 'mobx-react-lite'
|
||||
import LinearGradient from 'react-native-linear-gradient'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||
import {Text} from '../text/Text'
|
||||
import {colors, gradients} from 'lib/styles'
|
||||
import {clamp} from 'lodash'
|
||||
import {useStores} from 'state/index'
|
||||
import {usePalette} from 'lib/hooks/usePalette'
|
||||
|
||||
const HITSLOP = {left: 20, top: 20, right: 20, bottom: 20}
|
||||
|
||||
export const LoadLatestBtn = observer(
|
||||
({onPress, label}: {onPress: () => void; label: string}) => {
|
||||
const store = useStores()
|
||||
const pal = usePalette('default')
|
||||
const safeAreaInsets = useSafeAreaInsets()
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={[
|
||||
styles.loadLatest,
|
||||
pal.borderDark,
|
||||
pal.view,
|
||||
!store.shell.minimalShellMode && {
|
||||
bottom: 60 + clamp(safeAreaInsets.bottom, 15, 30),
|
||||
},
|
||||
|
@ -26,16 +28,8 @@ export const LoadLatestBtn = observer(
|
|||
hitSlop={HITSLOP}
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={label}
|
||||
accessibilityHint={label}>
|
||||
<LinearGradient
|
||||
colors={[gradients.blueLight.start, gradients.blueLight.end]}
|
||||
start={{x: 0, y: 0}}
|
||||
end={{x: 1, y: 1}}
|
||||
style={styles.loadLatestInner}>
|
||||
<Text type="md-bold" style={styles.loadLatestText}>
|
||||
{label}
|
||||
</Text>
|
||||
</LinearGradient>
|
||||
accessibilityHint="">
|
||||
<FontAwesomeIcon icon="angle-up" color={pal.colors.text} size={19} />
|
||||
</TouchableOpacity>
|
||||
)
|
||||
},
|
||||
|
@ -44,19 +38,14 @@ export const LoadLatestBtn = observer(
|
|||
const styles = StyleSheet.create({
|
||||
loadLatest: {
|
||||
position: 'absolute',
|
||||
left: 20,
|
||||
left: 18,
|
||||
bottom: 35,
|
||||
shadowColor: '#000',
|
||||
shadowOpacity: 0.3,
|
||||
shadowOffset: {width: 0, height: 1},
|
||||
},
|
||||
loadLatestInner: {
|
||||
borderWidth: 1,
|
||||
width: 52,
|
||||
height: 52,
|
||||
borderRadius: 26,
|
||||
flexDirection: 'row',
|
||||
paddingHorizontal: 14,
|
||||
paddingVertical: 10,
|
||||
borderRadius: 30,
|
||||
},
|
||||
loadLatestText: {
|
||||
color: colors.white,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue