Skip to content

Commit 972115e

Browse files
committed
InputRowRadioButtons [nfc]: Accept icon, like other rows do
(Such as NestedNavRow, which I consulted for this implementation.)
1 parent 09eafec commit 972115e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/common/InputRowRadioButtons.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import ZulipTextIntl from './ZulipTextIntl';
1414
import { IconRight } from './Icons';
1515
import type { AppNavigationMethods } from '../nav/AppNavigator';
1616
import { ThemeContext } from '../styles/theme';
17+
import type { SpecificIconType } from './Icons';
1718

1819
type Item<TKey> = $ReadOnly<{|
1920
key: TKey,
@@ -32,6 +33,11 @@ type Item<TKey> = $ReadOnly<{|
3233
|}>;
3334

3435
type Props<TItemKey> = $ReadOnly<{|
36+
icon?: {|
37+
+Component: SpecificIconType,
38+
+color?: string,
39+
|},
40+
3541
/**
3642
* Component must be under the stack nav with the selectable-options screen.
3743
*
@@ -78,7 +84,7 @@ type Props<TItemKey> = $ReadOnly<{|
7884
export default function InputRowRadioButtons<TItemKey: string | number>(
7985
props: Props<TItemKey>,
8086
): Node {
81-
const { navigation, label, description, valueKey, items, onValueChange, search } = props;
87+
const { navigation, label, description, valueKey, items, onValueChange, search, icon } = props;
8288

8389
const screenKey: string = useRef(`selectable-options-${randString()}`).current;
8490

@@ -153,6 +159,11 @@ export default function InputRowRadioButtons<TItemKey: string | number>(
153159
// https://material.io/design/usability/accessibility.html#layout-and-typography
154160
minHeight: 48,
155161
},
162+
iconFromProps: {
163+
textAlign: 'center',
164+
marginRight: 8,
165+
color: icon?.color ?? themeData.color,
166+
},
156167
textWrapper: {
157168
flex: 1,
158169
flexDirection: 'column',
@@ -169,12 +180,13 @@ export default function InputRowRadioButtons<TItemKey: string | number>(
169180
width: kRightArrowIconSize,
170181
},
171182
}),
172-
[],
183+
[themeData, icon],
173184
);
174185

175186
return (
176187
<Touchable onPress={handleRowPressed}>
177188
<View style={styles.wrapper}>
189+
{!!icon && <icon.Component size={24} style={styles.iconFromProps} />}
178190
<View style={styles.textWrapper}>
179191
<ZulipTextIntl text={label} />
180192
<ZulipTextIntl text={selectedItem.title} style={styles.valueTitle} />

0 commit comments

Comments
 (0)