mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Add account actions
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { Feather } from '@expo/vector-icons'
|
||||
import React from 'react'
|
||||
import { Pressable, StyleSheet, Text } from 'react-native'
|
||||
import { Pressable, StyleProp, StyleSheet, Text, ViewStyle } from 'react-native'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
|
||||
@ -9,6 +9,7 @@ type PropsBase = {
|
||||
disabled?: boolean
|
||||
buttonSize?: 'S' | 'M'
|
||||
size?: 'S' | 'M' | 'L'
|
||||
style?: StyleProp<ViewStyle>
|
||||
}
|
||||
|
||||
export interface PropsText extends PropsBase {
|
||||
@ -27,7 +28,8 @@ const ButtonRow: React.FC<PropsText | PropsIcon> = ({
|
||||
buttonSize = 'M',
|
||||
text,
|
||||
icon,
|
||||
size = 'M'
|
||||
size = 'M',
|
||||
style: customStyle
|
||||
}) => {
|
||||
const { theme } = useTheme()
|
||||
|
||||
@ -35,8 +37,15 @@ const ButtonRow: React.FC<PropsText | PropsIcon> = ({
|
||||
<Pressable
|
||||
{...(!disabled && { onPress })}
|
||||
style={[
|
||||
customStyle,
|
||||
styles.button,
|
||||
{
|
||||
paddingLeft:
|
||||
StyleConstants.Spacing.M -
|
||||
(icon ? StyleConstants.Font.Size[size] / 2 : 0),
|
||||
paddingRight:
|
||||
StyleConstants.Spacing.M -
|
||||
(icon ? StyleConstants.Font.Size[size] / 2 : 0),
|
||||
borderColor: disabled ? theme.secondary : theme.primary,
|
||||
paddingTop: StyleConstants.Spacing[buttonSize === 'M' ? 'S' : 'XS'],
|
||||
paddingBottom: StyleConstants.Spacing[buttonSize === 'M' ? 'S' : 'XS']
|
||||
@ -68,8 +77,6 @@ const ButtonRow: React.FC<PropsText | PropsIcon> = ({
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
button: {
|
||||
paddingLeft: StyleConstants.Spacing.M,
|
||||
paddingRight: StyleConstants.Spacing.M,
|
||||
borderWidth: 1.25,
|
||||
borderRadius: 100,
|
||||
alignItems: 'center'
|
||||
|
@ -64,7 +64,7 @@ const renderNode = ({
|
||||
m => m.username === username[1]
|
||||
)
|
||||
navigation.push('Screen-Shared-Account', {
|
||||
id: mentions[usernameIndex].id
|
||||
account: mentions[usernameIndex]
|
||||
})
|
||||
}}
|
||||
>
|
||||
|
@ -137,8 +137,9 @@ const TimelineActions: React.FC<Props> = ({
|
||||
navigation.navigate(getCurrentTab(navigation), {
|
||||
screen: 'Screen-Shared-Compose',
|
||||
params: {
|
||||
type: status.visibility === 'direct' ? 'conversation' : 'reply',
|
||||
incomingStatus: status
|
||||
type: 'reply',
|
||||
incomingStatus: status,
|
||||
visibilityLock: status.visibility === 'direct'
|
||||
}
|
||||
})
|
||||
}, [])
|
||||
|
@ -12,10 +12,7 @@ const TimelineAvatar: React.FC<Props> = ({ queryKey, account }) => {
|
||||
const navigation = useNavigation()
|
||||
// Need to fix go back root
|
||||
const onPress = useCallback(() => {
|
||||
queryKey &&
|
||||
navigation.push('Screen-Shared-Account', {
|
||||
id: account.id
|
||||
})
|
||||
queryKey && navigation.push('Screen-Shared-Account', { account })
|
||||
}, [])
|
||||
|
||||
return (
|
||||
|
@ -134,8 +134,7 @@ const TimelineHeaderDefault: React.FC<Props> = ({
|
||||
{!sameAccount && (
|
||||
<HeaderDefaultActionsAccount
|
||||
queryKey={queryKey}
|
||||
accountId={status.account.id}
|
||||
account={status.account.acct}
|
||||
account={status.account}
|
||||
setBottomSheetVisible={setBottomSheetVisible}
|
||||
/>
|
||||
)}
|
||||
|
@ -56,22 +56,20 @@ const fireMutation = async ({
|
||||
}
|
||||
|
||||
export interface Props {
|
||||
queryKey: QueryKey.Timeline
|
||||
accountId: string
|
||||
account: string
|
||||
queryKey?: QueryKey.Timeline
|
||||
account: Mastodon.Account
|
||||
setBottomSheetVisible: React.Dispatch<React.SetStateAction<boolean>>
|
||||
}
|
||||
|
||||
const HeaderDefaultActionsAccount: React.FC<Props> = ({
|
||||
queryKey,
|
||||
accountId,
|
||||
account,
|
||||
setBottomSheetVisible
|
||||
}) => {
|
||||
const queryClient = useQueryClient()
|
||||
const { mutate } = useMutation(fireMutation, {
|
||||
onSettled: () => {
|
||||
queryClient.invalidateQueries(queryKey)
|
||||
queryKey && queryClient.invalidateQueries(queryKey)
|
||||
}
|
||||
})
|
||||
|
||||
@ -83,35 +81,35 @@ const HeaderDefaultActionsAccount: React.FC<Props> = ({
|
||||
setBottomSheetVisible(false)
|
||||
mutate({
|
||||
type: 'mute',
|
||||
id: accountId,
|
||||
id: account.id,
|
||||
stateKey: 'muting'
|
||||
})
|
||||
}}
|
||||
iconFront='eye-off'
|
||||
title={`隐藏 @${account} 的嘟嘟`}
|
||||
title={`隐藏 @${account.acct} 的嘟嘟`}
|
||||
/>
|
||||
<MenuRow
|
||||
onPress={() => {
|
||||
setBottomSheetVisible(false)
|
||||
mutate({
|
||||
type: 'block',
|
||||
id: accountId,
|
||||
id: account.id,
|
||||
stateKey: 'blocking'
|
||||
})
|
||||
}}
|
||||
iconFront='x-circle'
|
||||
title={`屏蔽用户 @${account}`}
|
||||
title={`屏蔽用户 @${account.acct}`}
|
||||
/>
|
||||
<MenuRow
|
||||
onPress={() => {
|
||||
setBottomSheetVisible(false)
|
||||
mutate({
|
||||
type: 'reports',
|
||||
id: accountId
|
||||
id: account.id
|
||||
})
|
||||
}}
|
||||
iconFront='flag'
|
||||
title={`举报 @${account}`}
|
||||
title={`举报 @${account.acct}`}
|
||||
/>
|
||||
</MenuContainer>
|
||||
)
|
||||
|
@ -6,7 +6,6 @@ import {
|
||||
Text,
|
||||
View
|
||||
} from 'react-native'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { Feather } from '@expo/vector-icons'
|
||||
import Emojis from '@components/Timelines/Timeline/Shared/Emojis'
|
||||
import relativeTime from '@utils/relativeTime'
|
||||
@ -29,7 +28,6 @@ const TimelineHeaderNotification: React.FC<Props> = ({ notification }) => {
|
||||
const account = notification.account.acct
|
||||
const { theme } = useTheme()
|
||||
|
||||
const navigation = useNavigation()
|
||||
const [since, setSince] = useState(relativeTime(notification.created_at))
|
||||
|
||||
const { status, data, refetch } = useQuery(
|
||||
|
Reference in New Issue
Block a user