digitalfabrik/integreat-app

View on GitHub
native/src/components/base/Pressable.tsx

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import React, { ReactElement } from 'react'
import { Pressable as RNPressable, PressableProps as RNPressableProps, Role, StyleProp, ViewStyle } from 'react-native'

const ON_PRESS_OPACITY = 0.5

type PressableProps = {
  style?: StyleProp<ViewStyle>
  role: Role
} & RNPressableProps

const Pressable = ({ style, ...props }: PressableProps): ReactElement => (
  <RNPressable {...props} style={({ pressed }) => [{ opacity: pressed ? ON_PRESS_OPACITY : 1 }, style]} />
)

export default Pressable