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
 
7
 export type OptionsDialogButtonType = {
7
 export type OptionsDialogButtonType = {
8
   title: string,
8
   title: string,
9
+  icon?: string,
9
   onPress: () => void,
10
   onPress: () => void,
10
 };
11
 };
11
 
12
 
19
 
20
 
20
 class OptionsDialog extends React.PureComponent<PropsType> {
21
 class OptionsDialog extends React.PureComponent<PropsType> {
21
   getButtonRender = ({item}: {item: OptionsDialogButtonType}): React.Node => {
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
   render(): React.Node {
37
   render(): React.Node {
28
     const {props} = this;
38
     const {props} = this;

Loading…
Cancel
Save