mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {StyleSheet, TouchableOpacity} from 'react-native'
3import {observer} from 'mobx-react-lite'
4import LinearGradient from 'react-native-linear-gradient'
5import {useSafeAreaInsets} from 'react-native-safe-area-context'
6import {Text} from './text/Text'
7import {colors, gradients} from 'lib/styles'
8import {clamp} from 'lodash'
9import {useStores} from 'state/index'
10
11const HITSLOP = {left: 20, top: 20, right: 20, bottom: 20}
12
13export const LoadLatestBtn = observer(({onPress}: {onPress: () => void}) => {
14 const store = useStores()
15 const safeAreaInsets = useSafeAreaInsets()
16 return (
17 <TouchableOpacity
18 style={[
19 styles.loadLatest,
20 !store.shell.minimalShellMode && {
21 bottom: 60 + clamp(safeAreaInsets.bottom, 15, 30),
22 },
23 ]}
24 onPress={onPress}
25 hitSlop={HITSLOP}>
26 <LinearGradient
27 colors={[gradients.blueLight.start, gradients.blueLight.end]}
28 start={{x: 0, y: 0}}
29 end={{x: 1, y: 1}}
30 style={styles.loadLatestInner}>
31 <Text type="md-bold" style={styles.loadLatestText}>
32 Load new posts
33 </Text>
34 </LinearGradient>
35 </TouchableOpacity>
36 )
37})
38
39const styles = StyleSheet.create({
40 loadLatest: {
41 position: 'absolute',
42 left: 20,
43 bottom: 35,
44 shadowColor: '#000',
45 shadowOpacity: 0.3,
46 shadowOffset: {width: 0, height: 1},
47 },
48 loadLatestInner: {
49 flexDirection: 'row',
50 paddingHorizontal: 14,
51 paddingVertical: 10,
52 borderRadius: 30,
53 },
54 loadLatestText: {
55 color: colors.white,
56 },
57})