mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {useCallback} 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 {useSetMinimalShellMode} from '#/state/shell' 14import {MyLists} from '#/view/com/lists/MyLists' 15import {atoms as a} from '#/alf' 16import {Button, ButtonIcon, ButtonText} from '#/components/Button' 17import {useDialogControl} from '#/components/Dialog' 18import {CreateOrEditListDialog} from '#/components/dialogs/lists/CreateOrEditListDialog' 19import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus' 20import * as Layout from '#/components/Layout' 21 22type Props = NativeStackScreenProps<CommonNavigatorParams, 'ModerationModlists'> 23export function ModerationModlistsScreen({}: Props) { 24 const {_} = useLingui() 25 const setMinimalShellMode = useSetMinimalShellMode() 26 const navigation = useNavigation<NavigationProp>() 27 const requireEmailVerification = useRequireEmailVerification() 28 const createListDialogControl = useDialogControl() 29 30 useFocusEffect( 31 useCallback(() => { 32 setMinimalShellMode(false) 33 }, [setMinimalShellMode]), 34 ) 35 36 const onPressNewList = useCallback(() => { 37 createListDialogControl.open() 38 }, [createListDialogControl]) 39 40 const wrappedOnPressNewList = requireEmailVerification(onPressNewList, { 41 instructions: [ 42 <Trans key="modlist"> 43 Before creating a list, you must first verify your email. 44 </Trans>, 45 ], 46 }) 47 48 const onCreateList = useCallback( 49 (uri: string) => { 50 try { 51 const urip = new AtUri(uri) 52 navigation.navigate('ProfileList', { 53 name: urip.hostname, 54 rkey: urip.rkey, 55 }) 56 } catch {} 57 }, 58 [navigation], 59 ) 60 61 return ( 62 <Layout.Screen testID="moderationModlistsScreen"> 63 <Layout.Header.Outer> 64 <Layout.Header.BackButton /> 65 <Layout.Header.Content align="left"> 66 <Layout.Header.TitleText> 67 <Trans>Moderation Lists</Trans> 68 </Layout.Header.TitleText> 69 </Layout.Header.Content> 70 <Button 71 label={_(msg`New list`)} 72 testID="newModListBtn" 73 color="secondary" 74 variant="solid" 75 size="small" 76 onPress={wrappedOnPressNewList}> 77 <ButtonIcon icon={PlusIcon} /> 78 <ButtonText> 79 <Trans context="action">New</Trans> 80 </ButtonText> 81 </Button> 82 </Layout.Header.Outer> 83 84 <MyLists filter="mod" style={a.flex_grow} /> 85 86 <CreateOrEditListDialog 87 purpose="app.bsky.graph.defs#modlist" 88 control={createListDialogControl} 89 onSave={onCreateList} 90 /> 91 </Layout.Screen> 92 ) 93}