mirror of
https://github.com/sawyerf/Castafiore.git
synced 2026-03-24 12:57:47 +08:00
26 lines
926 B
JavaScript
26 lines
926 B
JavaScript
import React from 'react'
|
|
import { Pressable, StyleSheet } from 'react-native'
|
|
import Icon from 'react-native-vector-icons/FontAwesome'
|
|
|
|
import { useTheme } from '~/contexts/theme'
|
|
import mainStyles from '~/styles/main'
|
|
|
|
const IconButton = ({ icon, size = 23, color = undefined, style = {}, styleIcon = {}, pressEffect = true, onPress, onLongPress = null, delayLongPress = 200 }) => {
|
|
const theme = useTheme()
|
|
return (
|
|
<Pressable
|
|
style={({ pressed }) => ([mainStyles.opacity({ pressed, enable: pressEffect }), { justifyContent: 'center' }, StyleSheet.flatten(style)])}
|
|
onLongPress={onLongPress}
|
|
delayLongPress={delayLongPress}
|
|
onPress={onPress}
|
|
onContextMenu={(ev) => {
|
|
ev.preventDefault()
|
|
if (onLongPress) onLongPress()
|
|
}}
|
|
>
|
|
<Icon name={icon} size={size} color={color ? color : theme.primaryTouch} style={styleIcon} />
|
|
</Pressable>
|
|
)
|
|
}
|
|
|
|
export default IconButton |