Skip to content

Commit ea2319b

Browse files
authored
removeIconBackground prop added to TimeLine, fixed Icon size (#2923)
1 parent e8dec33 commit ea2319b

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

demo/src/screens/componentScreens/TimelineScreen.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const contents = [
77
'SUCCESS state with label.',
88
'ERROR state with icon.',
99
'Custom color with icon and outline.\nAligned to title',
10+
'Icon without background.',
1011
'NEXT state with outline.',
1112
'NEXT state with circle point and entry point.'
1213
];
@@ -27,8 +28,10 @@ const TimelineScreen = () => {
2728
const renderExtraContent = () => {
2829
return (
2930
<View style={{flex: 1, marginTop: 10, backgroundColor: Colors.grey70}}>
30-
<Text>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
31-
Lorem Ipsum is simply dummy text of the printing and typesetting industry</Text>
31+
<Text>
32+
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of
33+
the printing and typesetting industry
34+
</Text>
3235
</View>
3336
);
3437
};
@@ -62,7 +65,7 @@ const TimelineScreen = () => {
6265
<Timeline
6366
// key={String(expand)}
6467
// topLine={{
65-
// type: Timeline.lineTypes.DASHED,
68+
// type: Timeline.lineTypes.DASHED,
6669
// entry: true
6770
// }}
6871
bottomLine={{type: Timeline.lineTypes.DASHED}}
@@ -107,10 +110,23 @@ const TimelineScreen = () => {
107110
>
108111
{renderContent(3)}
109112
</Timeline>
113+
<Timeline
114+
topLine={{type: Timeline.lineTypes.DASHED, color: Colors.purple30}}
115+
bottomLine={{
116+
type: Timeline.lineTypes.DASHED,
117+
color: Colors.blue30
118+
}}
119+
point={{
120+
icon: Assets.icons.demo.camera,
121+
removeIconBackground: true
122+
}}
123+
>
124+
{renderContent(4)}
125+
</Timeline>
110126
<Timeline
111127
topLine={{
112128
type: Timeline.lineTypes.DASHED,
113-
color: Colors.purple30
129+
color: Colors.blue30
114130
}}
115131
bottomLine={{
116132
state: Timeline.states.NEXT,
@@ -121,7 +137,7 @@ const TimelineScreen = () => {
121137
type: Timeline.pointTypes.OUTLINE
122138
}}
123139
>
124-
{renderContent(4)}
140+
{renderContent(5)}
125141
</Timeline>
126142

127143
<Timeline
@@ -138,7 +154,7 @@ const TimelineScreen = () => {
138154
type: Timeline.pointTypes.CIRCLE
139155
}}
140156
>
141-
{renderContent(5)}
157+
{renderContent(6)}
142158
</Timeline>
143159
</ScrollView>
144160
</>

src/components/timeline/Point.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ const POINT_MARGINS = Spacings.s1;
1313
const CIRCLE_WIDTH = 2;
1414
const OUTLINE_WIDTH = 4;
1515
const OUTLINE_TINT = 70;
16-
const ICON_SIZE = 12;
16+
const ICON_SIZE = 16;
1717

1818
type PointPropsInternal = PointProps & {
1919
onLayout?: (event: LayoutChangeEvent) => void;
2020
};
2121

2222
const Point = (props: PointPropsInternal) => {
23-
const {icon, iconProps, label, type, color, onLayout} = props;
23+
const {icon, iconProps, removeIconBackground, label, type, color, onLayout} = props;
2424

2525
const pointStyle = useMemo(() => {
2626
const hasOutline = type === PointTypes.OUTLINE;
@@ -38,12 +38,15 @@ const Point = (props: PointPropsInternal) => {
3838
const circleStyle = !hasContent && isCircle &&
3939
{backgroundColor: 'transparent', borderWidth: CIRCLE_WIDTH, borderColor: color};
4040

41-
return [styles.point, pointSizeStyle, pointColorStyle, outlineStyle, circleStyle];
42-
}, [type, color, label, icon]);
41+
return [styles.point, pointSizeStyle, !removeIconBackground && pointColorStyle, outlineStyle, circleStyle];
42+
}, [type, color, label, removeIconBackground, icon]);
4343

4444
const renderPointContent = () => {
45+
const {removeIconBackground} = props;
46+
const tintColor = removeIconBackground ? Colors.$iconDefault : Colors.$iconDefaultLight;
47+
const iconSize = removeIconBackground ? undefined : ICON_SIZE;
4548
if (icon) {
46-
return <Icon size={ICON_SIZE} tintColor={Colors.$iconDefaultLight} {...iconProps} source={icon}/>;
49+
return <Icon tintColor={tintColor} {...iconProps} size={iconSize} source={icon}/>;
4750
} else if (label) {
4851
return <Text recorderTag={'unmask'} $textDefaultLight subtextBold>{label}</Text>;
4952
}

src/components/timeline/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export type PointProps = {
3535
color?: string;
3636
icon?: ImageRequireSource;
3737
iconProps?: IconProps;
38+
removeIconBackground?: boolean;
3839
label?: number;
3940
/** to align point to this view's center */
4041
anchorRef?: React.MutableRefObject<undefined>;

0 commit comments

Comments
 (0)