about summary refs log tree commit diff
path: root/src/view/com/util/PostMuted.tsx
blob: d8573bd56a5a9a36d8d6489c8893470771192bb0 (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
import React from 'react'
import {StyleSheet, TouchableOpacity, View} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {usePalette} from 'lib/hooks/usePalette'
import {Text} from './text/Text'

export function PostMutedWrapper({
  isMuted,
  children,
}: React.PropsWithChildren<{isMuted: boolean}>) {
  const pal = usePalette('default')
  const [override, setOverride] = React.useState(false)
  if (!isMuted || override) {
    return <>{children}</>
  }
  return (
    <View style={[styles.container, pal.view, pal.border]}>
      <FontAwesomeIcon
        icon={['far', 'eye-slash']}
        style={[styles.icon, pal.text]}
      />
      <Text type="md" style={pal.textLight}>
        Post from an account you muted.
      </Text>
      <TouchableOpacity
        style={styles.showBtn}
        onPress={() => setOverride(true)}>
        <Text type="md" style={pal.link}>
          Show post
        </Text>
      </TouchableOpacity>
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    flexDirection: 'row',
    alignItems: 'center',
    paddingVertical: 14,
    paddingHorizontal: 18,
    borderTopWidth: 1,
  },
  icon: {
    marginRight: 10,
  },
  showBtn: {
    marginLeft: 'auto',
  },
})