forked from vergnet/application-amicale
Update Options Dialog to support Icon
This commit is contained in:
parent
a9a2b9150b
commit
2f94be64e5
1 changed files with 12 additions and 2 deletions
|
@ -6,6 +6,7 @@ import {FlatList} from 'react-native';
|
||||||
|
|
||||||
export type OptionsDialogButtonType = {
|
export type OptionsDialogButtonType = {
|
||||||
title: string,
|
title: string,
|
||||||
|
icon?: string,
|
||||||
onPress: () => void,
|
onPress: () => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,10 +20,19 @@ type PropsType = {
|
||||||
|
|
||||||
class OptionsDialog extends React.PureComponent<PropsType> {
|
class OptionsDialog extends React.PureComponent<PropsType> {
|
||||||
getButtonRender = ({item}: {item: OptionsDialogButtonType}): React.Node => {
|
getButtonRender = ({item}: {item: OptionsDialogButtonType}): React.Node => {
|
||||||
return <Button onPress={item.onPress}>{item.title}</Button>;
|
return (
|
||||||
|
<Button onPress={item.onPress} icon={item.icon}>
|
||||||
|
{item.title}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
keyExtractor = (item: OptionsDialogButtonType): string => item.title;
|
keyExtractor = (item: OptionsDialogButtonType): string => {
|
||||||
|
if (item.icon != null) {
|
||||||
|
return item.title + item.icon;
|
||||||
|
}
|
||||||
|
return item.title;
|
||||||
|
};
|
||||||
|
|
||||||
render(): React.Node {
|
render(): React.Node {
|
||||||
const {props} = this;
|
const {props} = this;
|
||||||
|
|
Loading…
Reference in a new issue