Skip to content

removeIconBackground prop added to TimeLine, fixed Icon size #2923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions demo/src/screens/componentScreens/TimelineScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const contents = [
'SUCCESS state with label.',
'ERROR state with icon.',
'Custom color with icon and outline.\nAligned to title',
'Icon without background.',
'NEXT state with outline.',
'NEXT state with circle point and entry point.'
];
Expand All @@ -27,8 +28,10 @@ const TimelineScreen = () => {
const renderExtraContent = () => {
return (
<View style={{flex: 1, marginTop: 10, backgroundColor: Colors.grey70}}>
<Text>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum is simply dummy text of the printing and typesetting industry</Text>
<Text>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum is simply dummy text of
the printing and typesetting industry
</Text>
</View>
);
};
Expand Down Expand Up @@ -62,7 +65,7 @@ const TimelineScreen = () => {
<Timeline
// key={String(expand)}
// topLine={{
// type: Timeline.lineTypes.DASHED,
// type: Timeline.lineTypes.DASHED,
// entry: true
// }}
bottomLine={{type: Timeline.lineTypes.DASHED}}
Expand Down Expand Up @@ -107,10 +110,23 @@ const TimelineScreen = () => {
>
{renderContent(3)}
</Timeline>
<Timeline
topLine={{type: Timeline.lineTypes.DASHED, color: Colors.purple30}}
bottomLine={{
type: Timeline.lineTypes.DASHED,
color: Colors.blue30
}}
point={{
icon: Assets.icons.demo.camera,
removeIconBackground: true
}}
>
{renderContent(4)}
</Timeline>
<Timeline
topLine={{
type: Timeline.lineTypes.DASHED,
color: Colors.purple30
color: Colors.blue30
}}
bottomLine={{
state: Timeline.states.NEXT,
Expand All @@ -121,7 +137,7 @@ const TimelineScreen = () => {
type: Timeline.pointTypes.OUTLINE
}}
>
{renderContent(4)}
{renderContent(5)}
</Timeline>

<Timeline
Expand All @@ -138,7 +154,7 @@ const TimelineScreen = () => {
type: Timeline.pointTypes.CIRCLE
}}
>
{renderContent(5)}
{renderContent(6)}
</Timeline>
</ScrollView>
</>
Expand Down
13 changes: 8 additions & 5 deletions src/components/timeline/Point.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const POINT_MARGINS = Spacings.s1;
const CIRCLE_WIDTH = 2;
const OUTLINE_WIDTH = 4;
const OUTLINE_TINT = 70;
const ICON_SIZE = 12;
const ICON_SIZE = 16;

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

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

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

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

const renderPointContent = () => {
const {removeIconBackground} = props;
const tintColor = removeIconBackground ? Colors.$iconDefault : Colors.$iconDefaultLight;
const iconSize = removeIconBackground ? undefined : ICON_SIZE;
if (icon) {
return <Icon size={ICON_SIZE} tintColor={Colors.$iconDefaultLight} {...iconProps} source={icon}/>;
return <Icon tintColor={tintColor} {...iconProps} size={iconSize} source={icon}/>;
} else if (label) {
return <Text recorderTag={'unmask'} $textDefaultLight subtextBold>{label}</Text>;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/timeline/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type PointProps = {
color?: string;
icon?: ImageRequireSource;
iconProps?: IconProps;
removeIconBackground?: boolean;
label?: number;
/** to align point to this view's center */
anchorRef?: React.MutableRefObject<undefined>;
Expand Down