mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-05 12:38:55 +08:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { createIconSetFromIcoMoon } from 'react-native-vector-icons'
|
|
import icoMoonConfig from '@/resources/fonts/selection.json'
|
|
import { scaleSizeW } from '@/utils/pixelRatio'
|
|
import { memo, type ComponentProps } from 'react'
|
|
import { useTextShadow, useTheme } from '@/store/theme/hook'
|
|
import { StyleSheet, type StyleProp, type TextStyle } from 'react-native'
|
|
|
|
const IcoMoon = createIconSetFromIcoMoon(icoMoonConfig)
|
|
|
|
|
|
type IconType = ReturnType<typeof createIconSetFromIcoMoon>
|
|
|
|
interface IconProps extends Omit<ComponentProps<IconType>, 'style'> {
|
|
style?: StyleProp<TextStyle>
|
|
rawSize?: number
|
|
}
|
|
|
|
export const Icon = memo(({ size = 15, rawSize, color, style, ...props }: IconProps) => {
|
|
const theme = useTheme()
|
|
const textShadow = useTextShadow()
|
|
const newStyle = textShadow ? StyleSheet.compose({
|
|
textShadowColor: theme['c-primary-dark-300-alpha-800'],
|
|
textShadowOffset: { width: 0.2, height: 0.2 },
|
|
textShadowRadius: 2,
|
|
}, style) : style
|
|
return (
|
|
<IcoMoon
|
|
size={rawSize ?? scaleSizeW(size)}
|
|
color={color ?? theme['c-font']}
|
|
// @ts-expect-error
|
|
style={newStyle}
|
|
{...props}
|
|
/>
|
|
)
|
|
})
|