@@ -4,43 +4,55 @@ import { Text, View, type ViewStyle } from 'react-native';
4
4
import RNModelIcon from '../ModelIcon' ;
5
5
6
6
export interface RNModelTagProps {
7
- model : string ;
8
- style ?: ViewStyle ;
9
- textStyle ?: ViewStyle ;
10
- type ?: 'color' | 'mono' ;
7
+ model : string ;
8
+ size ?: number ;
9
+ style ?: ViewStyle ;
10
+ textStyle ?: ViewStyle ;
11
+ type ?: 'color' | 'mono' ;
11
12
}
12
13
13
- const RNModelTag = memo < RNModelTagProps > ( ( { type = 'mono' , model, style, textStyle, ...rest } ) => (
14
- < View
14
+ const RNModelTag = memo < RNModelTagProps > (
15
+ ( { type = 'mono' , model, size = 12 , style, textStyle, ...rest } ) => {
16
+ // Calculate text size and padding based on icon size
17
+ const textSize = Math . max ( size * 0.9 , 10 ) ; // Text slightly smaller than icon, minimum 10
18
+ const paddingHorizontal = Math . max ( size * 0.67 , 8 ) ; // Proportional padding, minimum 8
19
+ const paddingVertical = Math . max ( size * 0.33 , 4 ) ; // Proportional padding, minimum 4
20
+ const borderRadius = Math . max ( size , 12 ) ; // Proportional border radius, minimum 12
21
+ const marginLeft = Math . max ( size * 0.33 , 4 ) ; // Proportional margin, minimum 4
22
+
23
+ return (
24
+ < View
15
25
style = { [
16
- {
17
- alignItems : 'center' ,
18
- backgroundColor : '#f5f5f5' ,
19
- borderRadius : 12 ,
20
- flexDirection : 'row' ,
21
- paddingHorizontal : 8 ,
22
- paddingVertical : 4 ,
23
- } ,
24
- style ,
26
+ {
27
+ alignItems : 'center' ,
28
+ backgroundColor : '#f5f5f5' ,
29
+ borderRadius,
30
+ flexDirection : 'row' ,
31
+ paddingHorizontal,
32
+ paddingVertical,
33
+ } ,
34
+ style ,
25
35
] }
26
36
{ ...rest }
27
- >
28
- < RNModelIcon model = { model } size = { 12 } type = { type } />
37
+ >
38
+ < RNModelIcon model = { model } size = { size } type = { type } />
29
39
< Text
30
- style = { [
31
- {
32
- color : '#666' ,
33
- fontSize : 12 ,
34
- marginLeft : 4 ,
35
- } ,
36
- textStyle ,
37
- ] }
40
+ style = { [
41
+ {
42
+ color : '#666' ,
43
+ fontSize : textSize ,
44
+ marginLeft,
45
+ } ,
46
+ textStyle ,
47
+ ] }
38
48
>
39
- { model }
49
+ { model }
40
50
</ Text >
41
- </ View >
42
- ) ) ;
51
+ </ View >
52
+ ) ;
53
+ } ,
54
+ ) ;
43
55
44
56
RNModelTag . displayName = 'RNModelTag' ;
45
57
46
- export default RNModelTag ;
58
+ export default RNModelTag ;
0 commit comments