Skip to content
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

Create different files for HTML Render and fix scroll width #27769

Merged
merged 10 commits into from
Sep 22, 2023
20 changes: 5 additions & 15 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ import variables from '../styles/variables';
import * as Session from '../libs/actions/Session';
import Hoverable from './Hoverable';
import useWindowDimensions from '../hooks/useWindowDimensions';
import RenderHTML from './RenderHTML';
import getPlatform from '../libs/getPlatform';

const platform = getPlatform();
const isNative = platform === CONST.PLATFORM.IOS || platform === CONST.PLATFORM.ANDROID;
import MenuItemRenderHTMLTitle from './MenuItemRenderHTMLTitle';

const propTypes = menuItemPropTypes;

Expand Down Expand Up @@ -251,16 +247,10 @@ const MenuItem = React.forwardRef((props, ref) => {
</Text>
)}
<View style={[styles.flexRow, styles.alignItemsCenter]}>
{Boolean(props.title) &&
(Boolean(props.shouldRenderAsHTML) || (Boolean(props.shouldParseTitle) && Boolean(html.length))) &&
(isNative ? (
<RenderHTML html={getProcessedTitle} />
) : (
<View style={styles.chatItemMessage}>
<RenderHTML html={getProcessedTitle} />
</View>
))}
{!props.shouldRenderAsHTML && !html.length && Boolean(props.title) && (
{Boolean(props.title) && (Boolean(props.shouldRenderAsHTML) || (Boolean(props.shouldParseTitle) && Boolean(html.length))) && (
<MenuItemRenderHTMLTitle title={getProcessedTitle} />
)}
{!props.shouldRenderAsHTML && !props.shouldParseTitle && Boolean(props.title) && (
<Text
style={titleTextStyle}
numberOfLines={props.numberOfLinesTitle || undefined}
Expand Down
23 changes: 23 additions & 0 deletions src/components/MenuItemRenderHTMLTitle/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import {View} from 'react-native';
import styles from '../../styles/styles';
import RenderHTML from '../RenderHTML';
import menuItemRenderHTMLTitlePropTypes from './propTypes';

const propTypes = menuItemRenderHTMLTitlePropTypes;

const defaultProps = {};

function MenuItemRenderHTMLTitle(props) {
return (
<View style={styles.renderHTMLTitle}>
<RenderHTML html={props.title} />
</View>
);
}

MenuItemRenderHTMLTitle.propTypes = propTypes;
MenuItemRenderHTMLTitle.defaultProps = defaultProps;
MenuItemRenderHTMLTitle.displayName = 'MenuItemRenderHTMLTitle';

export default MenuItemRenderHTMLTitle;
17 changes: 17 additions & 0 deletions src/components/MenuItemRenderHTMLTitle/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import RenderHTML from '../RenderHTML';
import menuItemRenderHTMLTitlePropTypes from './propTypes';

const propTypes = menuItemRenderHTMLTitlePropTypes;

const defaultProps = {};

function MenuItemRenderHTMLTitle(props) {
return <RenderHTML html={props.title} />;
}

MenuItemRenderHTMLTitle.propTypes = propTypes;
MenuItemRenderHTMLTitle.defaultProps = defaultProps;
MenuItemRenderHTMLTitle.displayName = 'MenuItemRenderHTMLTitle';

export default MenuItemRenderHTMLTitle;
8 changes: 8 additions & 0 deletions src/components/MenuItemRenderHTMLTitle/propTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import PropTypes from 'prop-types';

const propTypes = {
/** Processed title to display for the MenuItem */
title: PropTypes.string.isRequired,
};

export default propTypes;
90 changes: 47 additions & 43 deletions src/pages/tasks/NewTaskPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useEffect, useMemo, useState} from 'react';
import {View} from 'react-native';
import {ScrollView, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -149,50 +149,54 @@ function NewTaskPage(props) {
Navigation.goBack(ROUTES.NEW_TASK_DETAILS);
}}
/>
<View style={[styles.containerWithSpaceBetween]}>
<View style={styles.mb5}>
<MenuItemWithTopDescription
description={props.translate('task.title')}
title={title}
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_TITLE)}
shouldShowRightIcon
/>
<MenuItemWithTopDescription
description={props.translate('task.description')}
title={description}
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_DESCRIPTION)}
shouldShowRightIcon
shouldParseTitle
numberOfLinesTitle={2}
titleStyle={styles.flex1}
/>
<MenuItem
label={assignee.displayName ? props.translate('task.assignee') : ''}
title={assignee.displayName || ''}
description={assignee.displayName ? LocalePhoneNumber.formatPhoneNumber(assignee.subtitle) : props.translate('task.assignee')}
icon={assignee.icons}
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_ASSIGNEE)}
shouldShowRightIcon
/>
<MenuItem
label={shareDestination.displayName ? props.translate('newTaskPage.shareSomewhere') : ''}
title={shareDestination.displayName || ''}
description={shareDestination.displayName ? shareDestination.subtitle : props.translate('newTaskPage.shareSomewhere')}
icon={shareDestination.icons}
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_SHARE_DESTINATION)}
interactive={!props.task.parentReportID}
shouldShowRightIcon={!props.task.parentReportID}
<ScrollView contentContainerStyle={styles.flexGrow1}>
<View style={[styles.flex1]}>
<View style={styles.mb5}>
<MenuItemWithTopDescription
description={props.translate('task.title')}
title={title}
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_TITLE)}
shouldShowRightIcon
/>
<MenuItemWithTopDescription
description={props.translate('task.description')}
title={description}
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_DESCRIPTION)}
shouldShowRightIcon
shouldParseTitle
numberOfLinesTitle={2}
titleStyle={styles.flex1}
/>
<MenuItem
label={assignee.displayName ? props.translate('task.assignee') : ''}
title={assignee.displayName || ''}
description={assignee.displayName ? LocalePhoneNumber.formatPhoneNumber(assignee.subtitle) : props.translate('task.assignee')}
icon={assignee.icons}
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_ASSIGNEE)}
shouldShowRightIcon
/>
<MenuItem
label={shareDestination.displayName ? props.translate('newTaskPage.shareSomewhere') : ''}
title={shareDestination.displayName || ''}
description={shareDestination.displayName ? shareDestination.subtitle : props.translate('newTaskPage.shareSomewhere')}
icon={shareDestination.icons}
onPress={() => Navigation.navigate(ROUTES.NEW_TASK_SHARE_DESTINATION)}
interactive={!props.task.parentReportID}
shouldShowRightIcon={!props.task.parentReportID}
/>
</View>
</View>
<View style={[styles.flexShrink0]}>
<FormAlertWithSubmitButton
isAlertVisible={!_.isEmpty(errorMessage)}
message={errorMessage}
onSubmit={() => onSubmit()}
enabledWhenOffline
buttonText={props.translate('newTaskPage.confirmTask')}
containerStyles={[styles.mh0, styles.mt5, styles.flex1, styles.ph5]}
/>
</View>
<FormAlertWithSubmitButton
isAlertVisible={!_.isEmpty(errorMessage)}
message={errorMessage}
onSubmit={() => onSubmit()}
enabledWhenOffline
buttonText={props.translate('newTaskPage.confirmTask')}
containerStyles={[styles.mh0, styles.mt5, styles.flex1, styles.ph5]}
/>
</View>
</ScrollView>
</FullPageNotFoundView>
</ScreenWrapper>
);
Expand Down
10 changes: 10 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,16 @@ const styles = (theme) => ({
...wordBreak.breakWord,
},

renderHTMLTitle: {
color: theme.text,
fontSize: variables.fontSizeNormal,
fontFamily: fontFamily.EXP_NEUE,
lineHeight: variables.lineHeightXLarge,
maxWidth: '100%',
...whiteSpace.preWrap,
...wordBreak.breakWord,
},

chatItemComposeWithFirstRow: {
minHeight: 90,
},
Expand Down
Loading