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