Browse Source

Update Options Dialog to support Icon

docjyJ 3 years ago
parent
commit
2f94be64e5
1 changed files with 12 additions and 2 deletions
  1. 12
    2
      src/components/Dialogs/OptionsDialog.js

+ 12
- 2
src/components/Dialogs/OptionsDialog.js View File

@@ -6,6 +6,7 @@ import {FlatList} from 'react-native';
6 6
 
7 7
 export type OptionsDialogButtonType = {
8 8
   title: string,
9
+  icon?: string,
9 10
   onPress: () => void,
10 11
 };
11 12
 
@@ -19,10 +20,19 @@ type PropsType = {
19 20
 
20 21
 class OptionsDialog extends React.PureComponent<PropsType> {
21 22
   getButtonRender = ({item}: {item: OptionsDialogButtonType}): React.Node => {
22
-    return <Button onPress={item.onPress}>{item.title}</Button>;
23
+    return (
24
+      <Button onPress={item.onPress} icon={item.icon}>
25
+        {item.title}
26
+      </Button>
27
+    );
23 28
   };
24 29
 
25
-  keyExtractor = (item: OptionsDialogButtonType): string => item.title;
30
+  keyExtractor = (item: OptionsDialogButtonType): string => {
31
+    if (item.icon != null) {
32
+      return item.title + item.icon;
33
+    }
34
+    return item.title;
35
+  };
26 36
 
27 37
   render(): React.Node {
28 38
     const {props} = this;

Loading…
Cancel
Save