-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImageItemConfig.ts
127 lines (104 loc) · 3.1 KB
/
ImageItemConfig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import type { Point, PointPreset, DynamicColor } from "./MiscTypes";
import type { EnumValueLiteral } from "./UtilityTypes";
/** Object returned by `Image.resolveAssetSource()` */
export type ImageResolvedAssetSource = {
height: number;
width: number;
scale: number;
uri: string;
};
export enum ImageTypes {
IMAGE_ASSET = 'IMAGE_ASSET' ,
IMAGE_SYSTEM = 'IMAGE_SYSTEM' ,
IMAGE_REQUIRE = 'IMAGE_REQUIRE' ,
IMAGE_EMPTY = 'IMAGE_EMPTY' ,
IMAGE_RECT = 'IMAGE_RECT' ,
IMAGE_GRADIENT = 'IMAGE_GRADIENT',
};
export type ImageRectConfig = {
width: number;
height: number;
fillColor: string;
borderRadius?: number;
};
/** Maps to `UIImage.RenderingMode`*/
export type ImageRenderingModes =
'automatic' | 'alwaysOriginal' | 'alwaysTemplate';
/** `UIImage`-related */
export type UIImageConfig = {
tint?: string | DynamicColor;
renderingMode?: ImageRenderingModes;
};
export type ImageSymbolWeight =
| 'unspecified'
| 'ultraLight'
| 'thin'
| 'light'
| 'regular'
| 'medium'
| 'semibold'
| 'bold'
| 'heavy'
| 'black';
export type ImageSymbolScale =
| 'default'
| 'unspecified'
| 'small'
| 'medium'
| 'large';
/** Maps to `UIImage.SymbolConfiguration` */
type ImageSystemSymbolConfiguration = {
pointSize?: number;
weight?: ImageSymbolWeight;
scale?: ImageSymbolScale;
} & ({
/** Requires iOS 15+ */
hierarchicalColor?: string | DynamicColor;
} | {
/** Requires iOS 15+ */
paletteColors?: [string | DynamicColor];
});
export type ImageSystemConfig = ImageSystemSymbolConfiguration & {
systemName: string;
};
export type ImageGradientConfig = Partial<Pick<ImageRectConfig,
| 'width'
| 'height'
| 'borderRadius'
>> & {
/* An array defining the color of each gradient stop. */
colors: Array<string>;
/* Defines the location of each gradient stop. */
locations?: Array<number>;
/* The start point of the gradient when drawn in the layer’s coordinate space. */
startPoint?: Point | PointPreset;
/* The end point of the gradient when drawn in the layer’s coordinate space. */
endPoint?: Point | PointPreset;
/* Style of gradient drawn by the layer. Defaults to axial. */
type?: 'axial' | 'conic' | 'radial'
};
export type ImageItemConfig = {
type: EnumValueLiteral<typeof ImageTypes, 'IMAGE_ASSET'>;
/** The corresponding key of asset item in the asset catalog */
imageValue: string;
imageOptions?: UIImageConfig;
} | {
type: EnumValueLiteral<typeof ImageTypes, 'IMAGE_SYSTEM'>;
/** The key/name of the SF Symbols system icon */
imageValue: ImageSystemConfig;
imageOptions?: UIImageConfig;
} | {
type: EnumValueLiteral<typeof ImageTypes, 'IMAGE_REQUIRE'>;
/** Object returned by `Image.resolveAssetSource()` */
imageValue: ImageResolvedAssetSource;
imageOptions?: UIImageConfig;
} | {
type: EnumValueLiteral<typeof ImageTypes, 'IMAGE_EMPTY'>;
} | {
type: EnumValueLiteral<typeof ImageTypes, 'IMAGE_RECT'>;
imageValue: ImageRectConfig;
} | {
type: EnumValueLiteral<typeof ImageTypes, 'IMAGE_GRADIENT'>;
imageValue: ImageGradientConfig;
};
export type ImageItemConfigTypes = ImageItemConfig['type'];