mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import {StyleSheet, TextProps} from 'react-native'
2import type {SvgProps, PathProps} from 'react-native-svg'
3
4import {tokens} from '#/alf'
5
6export type Props = {
7 fill?: PathProps['fill']
8 style?: TextProps['style']
9 size?: keyof typeof sizes
10} & Omit<SvgProps, 'style' | 'size'>
11
12export const sizes = {
13 xs: 12,
14 sm: 16,
15 md: 20,
16 lg: 24,
17 xl: 28,
18}
19
20export function useCommonSVGProps(props: Props) {
21 const {fill, size, ...rest} = props
22 const style = StyleSheet.flatten(rest.style)
23 const _fill = fill || style?.color || tokens.color.blue_500
24 const _size = Number(size ? sizes[size] : rest.width || sizes.md)
25
26 return {
27 fill: _fill,
28 size: _size,
29 style,
30 ...rest,
31 }
32}