digitalfabrik/integreat-app

View on GitHub
native/src/components/Link.tsx

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import React, { ReactElement } from 'react'
import { StyleProp, TextStyle } from 'react-native'
import styled from 'styled-components/native'

import useSnackbar from '../hooks/useSnackbar'
import openExternalUrl from '../utils/openExternalUrl'

const LinkText = styled.Text`
  padding: 30px 0;
  align-self: center;
  text-decoration: underline;
`

type LinkProps = {
  url: string
  text: string
  style?: StyleProp<TextStyle>
}

const Link = ({ url, text, style }: LinkProps): ReactElement => {
  const showSnackbar = useSnackbar()
  return (
    <LinkText style={style} onPress={() => openExternalUrl(url, showSnackbar)} role='link'>
      {text}
    </LinkText>
  )
}

export default Link