tooot/src/screens/Tabs/Me/List/menus.tsx

49 lines
1.5 KiB
TypeScript
Raw Normal View History

import { UseMutationResult } from '@tanstack/react-query'
import navigationRef from '@utils/navigation/navigationRef'
import i18next from 'i18next'
import { Alert } from 'react-native'
2023-01-04 22:39:29 +01:00
export const menuListAccounts = ({ list }: { list: Mastodon.List }) => ({
key: 'list-accounts',
2023-01-04 22:39:29 +01:00
onSelect: () => navigationRef.navigate<any>('Tab-Me-List-Accounts', list),
title: i18next.t('screenTabs:me.listAccounts.heading'),
2023-03-10 14:03:10 +01:00
icon: 'person.crop.circle.fill.badge.checkmark' as any
})
2023-01-04 22:39:29 +01:00
export const menuListEdit = ({ list, key }: { list: Mastodon.List; key: string }) => ({
key: 'list-edit',
onSelect: () =>
navigationRef.navigate<any>('Tab-Me-List-Edit', {
type: 'edit',
2023-01-04 22:39:29 +01:00
payload: list,
key
}),
title: i18next.t('screenTabs:me.listEdit.heading'),
2023-03-10 14:03:10 +01:00
icon: 'square.and.pencil' as any
})
export const menuListDelete = ({
2023-01-04 22:39:29 +01:00
list,
mutation
}: {
2023-01-04 22:39:29 +01:00
list: Mastodon.List
mutation: UseMutationResult<any, any, unknown, unknown>
}) => ({
key: 'list-delete',
onSelect: () =>
Alert.alert(
2023-01-04 22:39:29 +01:00
i18next.t('screenTabs:me.listDelete.confirm.title', { list: list.title.slice(0, 20) }),
i18next.t('screenTabs:me.listDelete.confirm.message'),
[
{
text: i18next.t('common:buttons.delete'),
style: 'destructive',
2023-01-04 22:39:29 +01:00
onPress: () => mutation.mutate({ type: 'delete', payload: list })
},
{ text: i18next.t('common:buttons.cancel') }
]
),
title: i18next.t('screenTabs:me.listDelete.heading'),
2023-03-10 14:03:10 +01:00
icon: 'trash' as any
})