Skip to content

Commit

Permalink
SelectableOptionRow [nfc]: Add, to replace LanguagePickerItem.
Browse files Browse the repository at this point in the history
Created by copy-pasting `LanguagePickerItem`.

In the next several commits, we'll make this into a more
general-purpose component that may be useful to represent a checkbox
or a radio button.

Then we'll switch `LanguagePickerItem`'s caller to use this
component instead, and remove `LanguagePickerItem`. We'll also use
it for the items on `UserStatusScreen`, which now incorrectly show
right-facing arrows, as though they'll navigate somewhere.

Future uses of this component (e.g., we may want it for zulip#4009) can
help refine its interface. For now, just let that process start --
and make it easier to provide a consistent look-and-feel -- by
making a reusable component.
  • Loading branch information
chrisbobbe committed Jun 25, 2021
1 parent b9907d6 commit a8babdc
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/common/SelectableOptionRow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* @flow strict-local */
import React from 'react';
import { View } from 'react-native';

import { RawLabel, Touchable } from '.';
import { BRAND_COLOR, createStyleSheet } from '../styles';
import { IconDone } from './Icons';

const styles = createStyleSheet({
languageWrapper: {
flex: 1,
flexDirection: 'column',
},
name: {
fontWeight: '300',
fontSize: 13,
},
listItem: {
flexDirection: 'row',
alignItems: 'center',
paddingTop: 12,
paddingBottom: 12,
paddingLeft: 16,
paddingRight: 16,
},
});

type Props = $ReadOnly<{|
locale: string,
name: string,
nativeName: string,
selected: boolean,
onValueChange: (locale: string) => void,
|}>;

// Not ready to use.
export default function LanguagePickerItem(props: Props) {
const { locale, name, nativeName, selected, onValueChange } = props;

return (
<Touchable onPress={() => onValueChange(locale)}>
<View style={styles.listItem}>
<View style={styles.languageWrapper}>
<RawLabel text={nativeName} />
<RawLabel text={name} style={styles.name} />
</View>
<View>{selected && <IconDone size={16} color={BRAND_COLOR} />}</View>
</View>
</Touchable>
);
}

0 comments on commit a8babdc

Please sign in to comment.