Skip to content

Commit

Permalink
fix: ListItem titleNoHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
linjinze999 committed May 10, 2024
1 parent 5f835df commit 081594e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { isValidElement, cloneElement, ReactElement } from 'react';
import { TextStyle, ViewStyle } from '@hippy/react';
import { ViewStyle } from '@hippy/react';
import { ListItemRenderInfo, ListItemRenderParams } from '../../themeConfig/types/listItem';
import { transferStyle } from '../../utils/Styles';
import { isNullOrUndefined, replenishNum } from '../../utils/Utils';
Expand All @@ -26,7 +26,6 @@ export default function getRenderInfo(params: ListItemRenderParams): ListItemRen
thumb,
rank,
buttonProps,
titleNoHeight,
} = props;
const wrapProps = themeConfig.listItemWrapPropsFn(params);
const rankProps = themeConfig.listItemRankPropsFn(params);
Expand All @@ -35,10 +34,6 @@ export default function getRenderInfo(params: ListItemRenderParams): ListItemRen
const noteProps = themeConfig.listItemNotePropsFn(params);
const moreNoteProps = themeConfig.listItemMoreNotePropsFn(params);

if (titleNoHeight) {
delete (titleProps.style as TextStyle).height;
}

const result: ListItemRenderInfo = {
wrapProps: {
accessible,
Expand Down
33 changes: 23 additions & 10 deletions packages/hippy_ui_react/src/themeConfig/listItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,29 @@ export const listItemConfig: ThemeConfigListItem = {
},
};
},
listItemTitlePropsFn: () => {
return {
numberOfLines: 1,
style: {
fontSize: 16,
flex: 1,
flexShrink: 1,
height: 20,
},
};
listItemTitlePropsFn: (params) => {
const {
props: { titleNoHeight },
} = params;
return titleNoHeight
? {
numberOfLines: 1,
style: {
fontSize: 16,
flex: 1,
flexShrink: 1,
lineHeight: undefined,
},
}
: {
numberOfLines: 1,
style: {
fontSize: 16,
flex: 1,
flexShrink: 1,
height: 20,
},
};
},
listItemNotePropsFn: (params) => {
const { consumerValue } = params;
Expand Down

0 comments on commit 081594e

Please sign in to comment.