tooot/src/components/AccountButton.tsx

38 lines
929 B
TypeScript
Raw Normal View History

2022-08-12 16:44:28 +02:00
import { useNavigation } from '@react-navigation/native'
2023-01-08 16:59:35 +01:00
import { ReadableAccountType, setAccount } from '@utils/storage/actions'
2022-08-12 16:44:28 +02:00
import { StyleConstants } from '@utils/styles/constants'
import React from 'react'
import Button from './Button'
import haptics from './haptics'
interface Props {
2023-01-08 16:59:35 +01:00
account: ReadableAccountType
2022-08-12 16:44:28 +02:00
additionalActions?: () => void
}
2023-01-08 16:59:35 +01:00
const AccountButton: React.FC<Props> = ({ account, additionalActions }) => {
2022-08-12 16:44:28 +02:00
const navigation = useNavigation()
return (
<Button
type='text'
2023-01-08 16:59:35 +01:00
selected={account.active}
2022-08-12 16:44:28 +02:00
style={{
marginBottom: StyleConstants.Spacing.M,
marginRight: StyleConstants.Spacing.M
}}
2023-01-08 16:59:35 +01:00
content={account.acct}
2022-08-12 16:44:28 +02:00
onPress={() => {
haptics('Light')
2023-01-08 16:59:35 +01:00
setAccount(account.key)
2022-08-12 16:44:28 +02:00
navigation.goBack()
if (additionalActions) {
additionalActions()
}
}}
/>
)
}
export default AccountButton