mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
at thread-bug 84 lines 2.8 kB view raw
1import React from 'react' 2import {AtUri} from '@atproto/api' 3import {msg, Trans} from '@lingui/macro' 4import {useLingui} from '@lingui/react' 5import {useFocusEffect, useNavigation} from '@react-navigation/native' 6 7import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification' 8import { 9 type CommonNavigatorParams, 10 type NativeStackScreenProps, 11} from '#/lib/routes/types' 12import {type NavigationProp} from '#/lib/routes/types' 13import {useModalControls} from '#/state/modals' 14import {useSetMinimalShellMode} from '#/state/shell' 15import {MyLists} from '#/view/com/lists/MyLists' 16import {atoms as a} from '#/alf' 17import {Button, ButtonIcon, ButtonText} from '#/components/Button' 18import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus' 19import * as Layout from '#/components/Layout' 20 21type Props = NativeStackScreenProps<CommonNavigatorParams, 'ModerationModlists'> 22export function ModerationModlistsScreen({}: Props) { 23 const {_} = useLingui() 24 const setMinimalShellMode = useSetMinimalShellMode() 25 const navigation = useNavigation<NavigationProp>() 26 const {openModal} = useModalControls() 27 const requireEmailVerification = useRequireEmailVerification() 28 29 useFocusEffect( 30 React.useCallback(() => { 31 setMinimalShellMode(false) 32 }, [setMinimalShellMode]), 33 ) 34 35 const onPressNewList = React.useCallback(() => { 36 openModal({ 37 name: 'create-or-edit-list', 38 purpose: 'app.bsky.graph.defs#modlist', 39 onSave: (uri: string) => { 40 try { 41 const urip = new AtUri(uri) 42 navigation.navigate('ProfileList', { 43 name: urip.hostname, 44 rkey: urip.rkey, 45 }) 46 } catch {} 47 }, 48 }) 49 }, [openModal, navigation]) 50 51 const wrappedOnPressNewList = requireEmailVerification(onPressNewList, { 52 instructions: [ 53 <Trans key="modlist"> 54 Before creating a list, you must first verify your email. 55 </Trans>, 56 ], 57 }) 58 59 return ( 60 <Layout.Screen testID="moderationModlistsScreen"> 61 <Layout.Header.Outer> 62 <Layout.Header.BackButton /> 63 <Layout.Header.Content align="left"> 64 <Layout.Header.TitleText> 65 <Trans>Moderation Lists</Trans> 66 </Layout.Header.TitleText> 67 </Layout.Header.Content> 68 <Button 69 label={_(msg`New list`)} 70 testID="newModListBtn" 71 color="secondary" 72 variant="solid" 73 size="small" 74 onPress={wrappedOnPressNewList}> 75 <ButtonIcon icon={PlusIcon} /> 76 <ButtonText> 77 <Trans context="action">New</Trans> 78 </ButtonText> 79 </Button> 80 </Layout.Header.Outer> 81 <MyLists filter="mod" style={a.flex_grow} /> 82 </Layout.Screen> 83 ) 84}