tooot/src/utils/navigation/navigators.ts

191 lines
5.8 KiB
TypeScript
Raw Normal View History

2021-08-29 15:25:38 +02:00
import { BottomTabScreenProps } from '@react-navigation/bottom-tabs'
import { NavigatorScreenParams } from '@react-navigation/native'
import { NativeStackScreenProps } from '@react-navigation/native-stack'
2021-08-29 16:08:02 +02:00
import { StackNavigationProp } from '@react-navigation/stack'
2022-12-04 13:26:36 +01:00
import { ComposeState } from '@screens/Compose/utils/types'
2021-08-29 15:25:38 +02:00
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
export type RootStackParamList = {
'Screen-Tabs': NavigatorScreenParams<ScreenTabsStackParamList>
'Screen-Actions':
| {
type: 'notifications_filter'
}
2022-06-03 23:18:24 +02:00
| {
type: 'alt_text'
text: string
}
2021-08-29 15:25:38 +02:00
'Screen-Announcements': { showAll: boolean }
'Screen-Compose':
| {
type: 'edit'
incomingStatus: Mastodon.Status
replyToStatus?: Mastodon.Status
2022-04-30 17:44:39 +02:00
queryKey?: QueryKeyTimeline
rootQueryKey?: QueryKeyTimeline
}
| {
type: 'deleteEdit'
incomingStatus: Mastodon.Status
replyToStatus?: Mastodon.Status
queryKey?: QueryKeyTimeline
2021-08-29 15:25:38 +02:00
}
| {
type: 'reply'
incomingStatus: Mastodon.Status
accts: Mastodon.Account['acct'][]
2022-04-30 17:44:39 +02:00
queryKey?: QueryKeyTimeline
2021-08-29 15:25:38 +02:00
}
| {
type: 'conversation'
accts: Mastodon.Account['acct'][]
2022-12-04 13:26:36 +01:00
visibility: ComposeState['visibility']
2022-11-17 21:48:22 +01:00
text?: string // For contacting tooot only
2021-08-29 15:25:38 +02:00
}
2022-05-02 22:31:22 +02:00
| {
type: 'share'
text?: string
2022-06-09 21:33:10 +02:00
media?: { uri: string; mime: string }[]
2022-05-02 22:31:22 +02:00
}
2021-08-29 15:25:38 +02:00
| undefined
'Screen-ImagesViewer': {
imageUrls: {
id: Mastodon.Attachment['id']
preview_url: Mastodon.AttachmentImage['preview_url']
url: Mastodon.AttachmentImage['url']
remote_url?: Mastodon.AttachmentImage['remote_url']
blurhash: Mastodon.AttachmentImage['blurhash']
width?: number
height?: number
}[]
id: Mastodon.Attachment['id']
}
2022-08-12 16:44:28 +02:00
'Screen-AccountSelection': {
component?: () => JSX.Element | undefined
share?: { text?: string; media?: { uri: string; mime: string }[] }
}
2021-08-29 15:25:38 +02:00
}
export type RootStackScreenProps<T extends keyof RootStackParamList> = NativeStackScreenProps<
RootStackParamList,
T
>
2021-08-29 15:25:38 +02:00
export type ScreenComposeStackParamList = {
'Screen-Compose-Root': undefined
'Screen-Compose-EditAttachment': { index: number }
'Screen-Compose-DraftsList': { timestamp: number }
}
export type ScreenComposeStackScreenProps<T extends keyof ScreenComposeStackParamList> =
NativeStackScreenProps<ScreenComposeStackParamList, T>
2021-08-29 15:25:38 +02:00
export type ScreenTabsStackParamList = {
'Tab-Local': NavigatorScreenParams<TabLocalStackParamList>
'Tab-Public': NavigatorScreenParams<TabPublicStackParamList>
'Tab-Compose': undefined
'Tab-Notifications': NavigatorScreenParams<TabNotificationsStackParamList>
'Tab-Me': NavigatorScreenParams<TabMeStackParamList>
}
export type ScreenTabsScreenProps<T extends keyof ScreenTabsStackParamList> = BottomTabScreenProps<
ScreenTabsStackParamList,
T
>
2021-08-29 15:25:38 +02:00
export type TabSharedStackParamList = {
'Tab-Shared-Account': {
account: Mastodon.Account | Mastodon.Mention
}
2022-12-03 15:50:15 +01:00
'Tab-Shared-Account-In-Lists': {
account: Pick<Mastodon.Account, 'id' | 'username'>
}
2021-08-29 15:25:38 +02:00
'Tab-Shared-Attachments': { account: Mastodon.Account }
'Tab-Shared-Hashtag': {
hashtag: Mastodon.Tag['name']
}
2022-04-29 23:57:18 +02:00
'Tab-Shared-History': {
id: Mastodon.Status['id']
2022-12-17 23:21:56 +01:00
detectedLanguage: string
2022-04-29 23:57:18 +02:00
}
2022-12-04 20:08:55 +01:00
'Tab-Shared-Search': undefined
2021-08-29 15:25:38 +02:00
'Tab-Shared-Toot': {
toot: Mastodon.Status
rootQueryKey?: QueryKeyTimeline
}
'Tab-Shared-Users':
| {
reference: 'accounts'
2022-12-15 01:41:34 +01:00
account: Pick<Mastodon.Account, 'id' | 'username' | 'acct' | 'url'>
2021-08-29 15:25:38 +02:00
type: 'following' | 'followers'
count: number
}
| {
reference: 'statuses'
2022-12-15 01:41:34 +01:00
status: Pick<Mastodon.Status, 'id'>
2021-08-29 15:25:38 +02:00
type: 'reblogged_by' | 'favourited_by'
count: number
}
}
2022-04-29 23:57:18 +02:00
export type TabSharedStackScreenProps<T extends keyof TabSharedStackParamList> =
NativeStackScreenProps<TabSharedStackParamList, T>
2021-08-29 15:25:38 +02:00
export type TabLocalStackParamList = {
'Tab-Local-Root': undefined
} & TabSharedStackParamList
export type TabPublicStackParamList = {
'Tab-Public-Root': undefined
} & TabSharedStackParamList
export type TabNotificationsStackParamList = {
'Tab-Notifications-Root': undefined
'Tab-Notifications-Filters': undefined
2021-08-29 15:25:38 +02:00
} & TabSharedStackParamList
export type TabNotificationsStackScreenProps<T extends keyof TabNotificationsStackParamList> =
NativeStackScreenProps<TabNotificationsStackParamList, T>
2021-08-29 15:25:38 +02:00
export type TabMeStackParamList = {
'Tab-Me-Root': undefined
'Tab-Me-Bookmarks': undefined
'Tab-Me-Conversations': undefined
'Tab-Me-Favourites': undefined
2022-12-10 20:19:18 +01:00
'Tab-Me-FollowedTags': undefined
'Tab-Me-List': Mastodon.List
'Tab-Me-List-Accounts': Omit<Mastodon.List, 'replies_policy'>
'Tab-Me-List-Edit':
| {
type: 'add'
}
| {
type: 'edit'
payload: Mastodon.List
key: string // To update title after successful mutation
}
'Tab-Me-List-List': undefined
2021-08-29 15:25:38 +02:00
'Tab-Me-Profile': undefined
'Tab-Me-Push': undefined
'Tab-Me-Settings': undefined
'Tab-Me-Settings-Fontsize': undefined
'Tab-Me-Settings-Language': undefined
2021-08-29 15:25:38 +02:00
'Tab-Me-Switch': undefined
} & TabSharedStackParamList
export type TabMeStackScreenProps<T extends keyof TabMeStackParamList> = NativeStackScreenProps<
TabMeStackParamList,
T
>
export type TabMeStackNavigationProp<RouteName extends keyof TabMeStackParamList> =
StackNavigationProp<TabMeStackParamList, RouteName>
2021-08-29 15:25:38 +02:00
export type TabMeProfileStackParamList = {
'Tab-Me-Profile-Root': undefined
'Tab-Me-Profile-Name': {
display_name: Mastodon.Account['display_name']
}
'Tab-Me-Profile-Note': {
note: Mastodon.Source['note']
}
'Tab-Me-Profile-Fields': {
fields?: Mastodon.Source['fields']
}
}
export type TabMeProfileStackScreenProps<T extends keyof TabMeProfileStackParamList> =
NativeStackScreenProps<TabMeProfileStackParamList, T>