Skip to content

Commit 6f4b179

Browse files
committed
NestedNavRow [nfc]: Allow passing icon color
1 parent 082d361 commit 6f4b179

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/common/NestedNavRow.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import type { SpecificIconType } from './Icons';
1111
import globalStyles, { ThemeContext, createStyleSheet } from '../styles';
1212

1313
type Props = $ReadOnly<{|
14-
Icon?: SpecificIconType,
14+
icon?: {|
15+
+Component: SpecificIconType,
16+
+color?: string,
17+
|},
18+
1519
label: LocalizableReactText,
1620

1721
// TODO: Should we make this unconfigurable? Should we have two reusable
@@ -29,7 +33,7 @@ type Props = $ReadOnly<{|
2933
* selectable option row instead, use `SelectableOptionRow`.
3034
*/
3135
export default function NestedNavRow(props: Props): Node {
32-
const { label, labelBoldUppercase, onPress, Icon } = props;
36+
const { label, labelBoldUppercase, onPress, icon } = props;
3337

3438
const themeContext = useContext(ThemeContext);
3539

@@ -49,7 +53,7 @@ export default function NestedNavRow(props: Props): Node {
4953
iconFromProps: {
5054
textAlign: 'center',
5155
marginRight: 8,
52-
color: themeContext.color,
56+
color: icon?.color ?? themeContext.color,
5357
},
5458
label: {
5559
...(labelBoldUppercase ? { textTransform: 'uppercase', fontWeight: '500' } : undefined),
@@ -60,13 +64,13 @@ export default function NestedNavRow(props: Props): Node {
6064
color: themeContext.color,
6165
},
6266
}),
63-
[themeContext, labelBoldUppercase],
67+
[themeContext, icon, labelBoldUppercase],
6468
);
6569

6670
return (
6771
<Touchable onPress={onPress}>
6872
<View style={styles.container}>
69-
{!!Icon && <Icon size={24} style={styles.iconFromProps} />}
73+
{!!icon && <icon.Component size={24} style={styles.iconFromProps} />}
7074
<ZulipTextIntl style={styles.label} text={label} />
7175
<View style={globalStyles.rightItem}>
7276
<IconRight size={24} style={styles.iconRightFacingArrow} />

src/settings/SettingsScreen.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,28 @@ export default function SettingsScreen(props: Props): Node {
6868
}}
6969
/>
7070
<NestedNavRow
71-
Icon={IconNotifications}
71+
icon={{ Component: IconNotifications }}
7272
label="Notifications"
7373
onPress={() => {
7474
navigation.push('notifications');
7575
}}
7676
/>
7777
<NestedNavRow
78-
Icon={IconLanguage}
78+
icon={{ Component: IconLanguage }}
7979
label="Language"
8080
onPress={() => {
8181
navigation.push('language');
8282
}}
8383
/>
8484
<NestedNavRow
85-
Icon={IconDiagnostics}
85+
icon={{ Component: IconDiagnostics }}
8686
label="Diagnostics"
8787
onPress={() => {
8888
navigation.push('diagnostics');
8989
}}
9090
/>
9191
<NestedNavRow
92-
Icon={IconMoreHorizontal}
92+
icon={{ Component: IconMoreHorizontal }}
9393
label="Legal"
9494
onPress={() => {
9595
navigation.push('legal');

0 commit comments

Comments
 (0)