2022-08-12 16:44:28 +02:00
|
|
|
import { useNavigation } from '@react-navigation/native'
|
|
|
|
import initQuery from '@utils/initQuery'
|
|
|
|
import { InstanceLatest } from '@utils/migrations/instances/migration'
|
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
|
|
|
import React from 'react'
|
|
|
|
import Button from './Button'
|
|
|
|
import haptics from './haptics'
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
instance: InstanceLatest
|
|
|
|
selected?: boolean
|
|
|
|
additionalActions?: () => void
|
|
|
|
}
|
|
|
|
|
2022-12-09 21:09:00 +01:00
|
|
|
const AccountButton: React.FC<Props> = ({ instance, selected = false, additionalActions }) => {
|
2022-08-12 16:44:28 +02:00
|
|
|
const navigation = useNavigation()
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
type='text'
|
|
|
|
selected={selected}
|
|
|
|
style={{
|
|
|
|
marginBottom: StyleConstants.Spacing.M,
|
|
|
|
marginRight: StyleConstants.Spacing.M
|
|
|
|
}}
|
2022-12-09 21:09:00 +01:00
|
|
|
content={`@${instance.account.acct}@${instance.uri}${selected ? ' ✓' : ''}`}
|
2022-08-12 16:44:28 +02:00
|
|
|
onPress={() => {
|
|
|
|
haptics('Light')
|
2022-12-09 21:09:00 +01:00
|
|
|
initQuery({ instance })
|
2022-08-12 16:44:28 +02:00
|
|
|
navigation.goBack()
|
|
|
|
if (additionalActions) {
|
|
|
|
additionalActions()
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AccountButton
|