about summary refs log tree commit diff
path: root/src/view/com/util/LoadLatestBtn.tsx
blob: fd05ecc9ccc5bcd1e0b680e42047f683a647a1d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React from 'react'
import {StyleSheet, TouchableOpacity} from 'react-native'
import {observer} from 'mobx-react-lite'
import LinearGradient from 'react-native-linear-gradient'
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'

const HITSLOP = {left: 20, top: 20, right: 20, bottom: 20}

export const LoadLatestBtn = observer(({onPress}: {onPress: () => void}) => {
  const store = useStores()
  const safeAreaInsets = useSafeAreaInsets()
  return (
    <TouchableOpacity
      style={[
        styles.loadLatest,
        !store.shell.minimalShellMode && {
          bottom: 60 + clamp(safeAreaInsets.bottom, 15, 30),
        },
      ]}
      onPress={onPress}
      hitSlop={HITSLOP}>
      <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}>
          Load new posts
        </Text>
      </LinearGradient>
    </TouchableOpacity>
  )
})

const styles = StyleSheet.create({
  loadLatest: {
    position: 'absolute',
    left: 20,
    bottom: 35,
    shadowColor: '#000',
    shadowOpacity: 0.3,
    shadowOffset: {width: 0, height: 1},
  },
  loadLatestInner: {
    flexDirection: 'row',
    paddingHorizontal: 14,
    paddingVertical: 10,
    borderRadius: 30,
  },
  loadLatestText: {
    color: colors.white,
  },
})