From a34116378d09442888c6169c2d608446513ae294 Mon Sep 17 00:00:00 2001 From: saranshbalyan-1234 Date: Wed, 11 Oct 2023 20:25:49 +0530 Subject: [PATCH 1/2] optionslist-to-selectionslist --- .../Report/NotificationPreferencePage.js | 25 +++---------------- .../settings/Report/WriteCapabilityPage.js | 25 +++---------------- 2 files changed, 7 insertions(+), 43 deletions(-) diff --git a/src/pages/settings/Report/NotificationPreferencePage.js b/src/pages/settings/Report/NotificationPreferencePage.js index 7dc9ff7773de..64e6bdfb4b5b 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.js +++ b/src/pages/settings/Report/NotificationPreferencePage.js @@ -3,8 +3,6 @@ import _ from 'underscore'; import ScreenWrapper from '../../../components/ScreenWrapper'; import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import styles from '../../../styles/styles'; -import OptionsList from '../../../components/OptionsList'; import Navigation from '../../../libs/Navigation/Navigation'; import compose from '../../../libs/compose'; import withReportOrNotFound from '../../home/report/withReportOrNotFound'; @@ -14,8 +12,7 @@ import ROUTES from '../../../ROUTES'; import CONST from '../../../CONST'; import * as Report from '../../../libs/actions/Report'; import * as ReportUtils from '../../../libs/ReportUtils'; -import * as Expensicons from '../../../components/Icon/Expensicons'; -import themeColors from '../../../styles/themes/default'; +import SelectionList from '../../../components/SelectionList'; const propTypes = { ...withLocalizePropTypes, @@ -23,7 +20,6 @@ const propTypes = { /** The report for which we are setting notification preferences */ report: reportPropTypes.isRequired, }; -const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; function NotificationPreferencePage(props) { const shouldDisableNotificationPreferences = ReportUtils.isArchivedRoom(props.report); @@ -33,12 +29,7 @@ function NotificationPreferencePage(props) { value: preference, text: props.translate(`notificationPreferencesPage.notificationPreferences.${preference}`), keyForList: preference, - - // Include the green checkmark icon to indicate the currently selected value - customIcon: preference === props.report.notificationPreference ? greenCheckmark : null, - - // This property will make the currently selected value have bold text - boldStyle: preference === props.report.notificationPreference, + isSelected: preference === props.report.notificationPreference, }), ); @@ -52,18 +43,10 @@ function NotificationPreferencePage(props) { title={props.translate('notificationPreferencesPage.header')} onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID))} /> - Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, option.value, true)} - hideSectionHeaders - optionHoveredStyle={{ - ...styles.hoveredComponentBG, - ...styles.mhn5, - ...styles.ph5, - }} - shouldHaveOptionSeparator - shouldDisableRowInnerPadding - contentContainerStyles={[styles.ph5]} + initiallyFocusedOptionKey={_.find(notificationPreferenceOptions, (locale) => locale.isSelected).keyForList} /> diff --git a/src/pages/settings/Report/WriteCapabilityPage.js b/src/pages/settings/Report/WriteCapabilityPage.js index 9c4814902117..7c4432b51de6 100644 --- a/src/pages/settings/Report/WriteCapabilityPage.js +++ b/src/pages/settings/Report/WriteCapabilityPage.js @@ -6,16 +6,12 @@ import CONST from '../../../CONST'; import ScreenWrapper from '../../../components/ScreenWrapper'; import HeaderWithBackButton from '../../../components/HeaderWithBackButton'; import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; -import styles from '../../../styles/styles'; -import OptionsList from '../../../components/OptionsList'; import Navigation from '../../../libs/Navigation/Navigation'; import compose from '../../../libs/compose'; import withReportOrNotFound from '../../home/report/withReportOrNotFound'; import reportPropTypes from '../../reportPropTypes'; import ROUTES from '../../../ROUTES'; import * as Report from '../../../libs/actions/Report'; -import * as Expensicons from '../../../components/Icon/Expensicons'; -import themeColors from '../../../styles/themes/default'; import * as ReportUtils from '../../../libs/ReportUtils'; import FullPageNotFoundView from '../../../components/BlockingViews/FullPageNotFoundView'; import * as PolicyUtils from '../../../libs/PolicyUtils'; @@ -33,19 +29,12 @@ const defaultProps = { ...policyDefaultProps, }; -const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success}; - function WriteCapabilityPage(props) { const writeCapabilityOptions = _.map(CONST.REPORT.WRITE_CAPABILITIES, (value) => ({ value, text: props.translate(`writeCapabilityPage.writeCapability.${value}`), keyForList: value, - - // Include the green checkmark icon to indicate the currently selected value - customIcon: value === (props.report.writeCapability || CONST.REPORT.WRITE_CAPABILITIES.ALL) ? greenCheckmark : null, - - // This property will make the currently selected value have bold text - boldStyle: value === (props.report.writeCapability || CONST.REPORT.WRITE_CAPABILITIES.ALL), + isSelected: value === (props.report.writeCapability || CONST.REPORT.WRITE_CAPABILITIES.ALL), })); const isAbleToEdit = !ReportUtils.isAdminRoom(props.report) && PolicyUtils.isPolicyAdmin(props.policy) && !ReportUtils.isArchivedRoom(props.report); @@ -61,18 +50,10 @@ function WriteCapabilityPage(props) { shouldShowBackButton onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID))} /> - Report.updateWriteCapabilityAndNavigate(props.report, option.value)} - hideSectionHeaders - optionHoveredStyle={{ - ...styles.hoveredComponentBG, - ...styles.mhn5, - ...styles.ph5, - }} - shouldHaveOptionSeparator - shouldDisableRowInnerPadding - contentContainerStyles={[styles.ph5]} + initiallyFocusedOptionKey={_.find(writeCapabilityOptions, (locale) => locale.isSelected).keyForList} /> From 372bffa79900863eae2cd2587cf8d1eeb62f2614 Mon Sep 17 00:00:00 2001 From: saranshbalyan-1234 Date: Wed, 11 Oct 2023 20:33:58 +0530 Subject: [PATCH 2/2] added missing import --- src/pages/settings/Report/WriteCapabilityPage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/settings/Report/WriteCapabilityPage.js b/src/pages/settings/Report/WriteCapabilityPage.js index 7c4432b51de6..1558d98a830a 100644 --- a/src/pages/settings/Report/WriteCapabilityPage.js +++ b/src/pages/settings/Report/WriteCapabilityPage.js @@ -16,6 +16,7 @@ import * as ReportUtils from '../../../libs/ReportUtils'; import FullPageNotFoundView from '../../../components/BlockingViews/FullPageNotFoundView'; import * as PolicyUtils from '../../../libs/PolicyUtils'; import {policyPropTypes, policyDefaultProps} from '../../workspace/withPolicy'; +import SelectionList from '../../../components/SelectionList'; const propTypes = { ...withLocalizePropTypes,