mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {View} from 'react-native'
3import {useFocusEffect, useNavigation} from '@react-navigation/native'
4import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
5import {AtUri} from '@atproto/api'
6import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types'
7import {MyLists} from '#/view/com/lists/MyLists'
8import {Text} from 'view/com/util/text/Text'
9import {Button} from 'view/com/util/forms/Button'
10import {NavigationProp} from 'lib/routes/types'
11import {usePalette} from 'lib/hooks/usePalette'
12import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
13import {SimpleViewHeader} from 'view/com/util/SimpleViewHeader'
14import {s} from 'lib/styles'
15import {useSetMinimalShellMode} from '#/state/shell'
16import {useModalControls} from '#/state/modals'
17import {Trans} from '@lingui/macro'
18
19type Props = NativeStackScreenProps<CommonNavigatorParams, 'ModerationModlists'>
20export function ModerationModlistsScreen({}: Props) {
21 const pal = usePalette('default')
22 const setMinimalShellMode = useSetMinimalShellMode()
23 const {isMobile} = useWebMediaQueries()
24 const navigation = useNavigation<NavigationProp>()
25 const {openModal} = useModalControls()
26
27 useFocusEffect(
28 React.useCallback(() => {
29 setMinimalShellMode(false)
30 }, [setMinimalShellMode]),
31 )
32
33 const onPressNewList = React.useCallback(() => {
34 openModal({
35 name: 'create-or-edit-list',
36 purpose: 'app.bsky.graph.defs#modlist',
37 onSave: (uri: string) => {
38 try {
39 const urip = new AtUri(uri)
40 navigation.navigate('ProfileList', {
41 name: urip.hostname,
42 rkey: urip.rkey,
43 })
44 } catch {}
45 },
46 })
47 }, [openModal, navigation])
48
49 return (
50 <View style={s.hContentRegion} testID="moderationModlistsScreen">
51 <SimpleViewHeader
52 showBackButton={isMobile}
53 style={
54 !isMobile && [pal.border, {borderLeftWidth: 1, borderRightWidth: 1}]
55 }>
56 <View style={{flex: 1}}>
57 <Text type="title-lg" style={[pal.text, {fontWeight: 'bold'}]}>
58 <Trans>Moderation Lists</Trans>
59 </Text>
60 <Text style={pal.textLight}>
61 <Trans>
62 Public, shareable lists of users to mute or block in bulk.
63 </Trans>
64 </Text>
65 </View>
66 <View style={[{marginLeft: 18}, isMobile && {marginLeft: 12}]}>
67 <Button
68 testID="newModListBtn"
69 type="default"
70 onPress={onPressNewList}
71 style={{
72 flexDirection: 'row',
73 alignItems: 'center',
74 gap: 8,
75 }}>
76 <FontAwesomeIcon icon="plus" color={pal.colors.text} />
77 <Text type="button" style={pal.text}>
78 <Trans>New</Trans>
79 </Text>
80 </Button>
81 </View>
82 </SimpleViewHeader>
83 <MyLists filter="mod" style={s.flexGrow1} />
84 </View>
85 )
86}