From 081594e20db4be40a93843db431b9de29f81c346 Mon Sep 17 00:00:00 2001 From: jinzelin Date: Fri, 10 May 2024 11:41:23 +0800 Subject: [PATCH] fix: ListItem titleNoHeight --- .../src/components/ListItem/renderInfo.tsx | 7 +--- .../src/themeConfig/listItem.tsx | 33 +++++++++++++------ 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/packages/hippy_ui_react/src/components/ListItem/renderInfo.tsx b/packages/hippy_ui_react/src/components/ListItem/renderInfo.tsx index bae950d..65654f4 100644 --- a/packages/hippy_ui_react/src/components/ListItem/renderInfo.tsx +++ b/packages/hippy_ui_react/src/components/ListItem/renderInfo.tsx @@ -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'; @@ -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); @@ -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, diff --git a/packages/hippy_ui_react/src/themeConfig/listItem.tsx b/packages/hippy_ui_react/src/themeConfig/listItem.tsx index 2b603b1..d2fe9dd 100644 --- a/packages/hippy_ui_react/src/themeConfig/listItem.tsx +++ b/packages/hippy_ui_react/src/themeConfig/listItem.tsx @@ -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;