forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {useCallback} from 'react'
2import {AtUri} from '@atproto/api'
3import {msg} from '@lingui/core/macro'
4import {useLingui} from '@lingui/react'
5import {Trans} from '@lingui/react/macro'
6import {useFocusEffect, useNavigation} from '@react-navigation/native'
7
8import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification'
9import {
10 type CommonNavigatorParams,
11 type NativeStackScreenProps,
12 type NavigationProp,
13} from '#/lib/routes/types'
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 {useDialogControl} from '#/components/Dialog'
19import {CreateOrEditListDialog} from '#/components/dialogs/lists/CreateOrEditListDialog'
20import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus'
21import * as Layout from '#/components/Layout'
22
23type Props = NativeStackScreenProps<CommonNavigatorParams, 'ModerationModlists'>
24export function ModerationModlistsScreen({}: Props) {
25 const {_} = useLingui()
26 const setMinimalShellMode = useSetMinimalShellMode()
27 const navigation = useNavigation<NavigationProp>()
28 const requireEmailVerification = useRequireEmailVerification()
29 const createListDialogControl = useDialogControl()
30
31 useFocusEffect(
32 useCallback(() => {
33 setMinimalShellMode(false)
34 }, [setMinimalShellMode]),
35 )
36
37 const onPressNewList = useCallback(() => {
38 createListDialogControl.open()
39 }, [createListDialogControl])
40
41 const wrappedOnPressNewList = requireEmailVerification(onPressNewList, {
42 instructions: [
43 <Trans key="modlist">
44 Before creating a list, you must first verify your email.
45 </Trans>,
46 ],
47 })
48
49 const onCreateList = useCallback(
50 (uri: string) => {
51 try {
52 const urip = new AtUri(uri)
53 navigation.navigate('ProfileList', {
54 name: urip.hostname,
55 rkey: urip.rkey,
56 })
57 } catch {}
58 },
59 [navigation],
60 )
61
62 return (
63 <Layout.Screen testID="moderationModlistsScreen">
64 <Layout.Header.Outer>
65 <Layout.Header.BackButton />
66 <Layout.Header.Content align="left">
67 <Layout.Header.TitleText>
68 <Trans>Moderation Lists</Trans>
69 </Layout.Header.TitleText>
70 </Layout.Header.Content>
71 <Button
72 label={_(msg`New list`)}
73 testID="newModListBtn"
74 color="secondary"
75 variant="solid"
76 size="small"
77 onPress={wrappedOnPressNewList}>
78 <ButtonIcon icon={PlusIcon} />
79 <ButtonText>
80 <Trans context="action">New</Trans>
81 </ButtonText>
82 </Button>
83 </Layout.Header.Outer>
84
85 <MyLists filter="mod" style={a.flex_grow} />
86
87 <CreateOrEditListDialog
88 purpose="app.bsky.graph.defs#modlist"
89 control={createListDialogControl}
90 onSave={onCreateList}
91 />
92 </Layout.Screen>
93 )
94}