Yedidya Kennard 8 years ago
parent
commit
0f6cb60259

BIN
img/icon_format_bold.png View File


BIN
img/icon_format_bold@2x.png View File


BIN
img/icon_format_bold@3x.png View File


BIN
img/icon_format_italic.png View File


BIN
img/icon_format_italic@2x.png View File


BIN
img/icon_format_italic@3x.png View File


BIN
img/icon_format_link.png View File


BIN
img/icon_format_link@2x.png View File


BIN
img/icon_format_link@3x.png View File


BIN
img/icon_format_media.png View File


BIN
img/icon_format_media@2x.png View File


BIN
img/icon_format_media@3x.png View File


BIN
img/icon_format_ol.png View File


BIN
img/icon_format_ol@2x.png View File


BIN
img/icon_format_ol@3x.png View File


BIN
img/icon_format_ul.png View File


BIN
img/icon_format_ul@2x.png View File


BIN
img/icon_format_ul@3x.png View File


+ 22
- 12
src/RichTextToolbar.js View File

@@ -1,5 +1,5 @@
1 1
 import React, {Component, PropTypes} from 'react';
2
-import {ListView, View, TouchableOpacity, Text, StyleSheet} from 'react-native';
2
+import {ListView, View, TouchableOpacity, Image, StyleSheet} from 'react-native';
3 3
 import {actions} from './const';
4 4
 
5 5
 const defaultActions = [
@@ -11,14 +11,14 @@ const defaultActions = [
11 11
   actions.insertLink
12 12
 ];
13 13
 
14
-function getDefaultIconText() {
14
+function getDefaultIcon() {
15 15
   const texts = {};
16
-  texts[actions.insertImage] = 'IMG';
17
-  texts[actions.setBold] = 'B';
18
-  texts[actions.setItalic] = 'I';
19
-  texts[actions.insertBulletsList] = '0';
20
-  texts[actions.insertOrderedList] = '1';
21
-  texts[actions.insertLink] = '<a>';
16
+  texts[actions.insertImage] = require('../img/icon_format_media.png');
17
+  texts[actions.setBold] = require('../img/icon_format_bold.png');
18
+  texts[actions.setItalic] = require('../img/icon_format_italic.png');
19
+  texts[actions.insertBulletsList] = require('../img/icon_format_ul.png');
20
+  texts[actions.insertOrderedList] = require('../img/icon_format_ol.png');
21
+  texts[actions.insertLink] = require('../img/icon_format_link.png');
22 22
   return texts;
23 23
 }
24 24
 
@@ -32,7 +32,8 @@ export default class RichTextToolbar extends Component {
32 32
     onPressAddImage: PropTypes.func,
33 33
     selectedButtonStyle: PropTypes.object,
34 34
     unselectedButtonStyle: PropTypes.object,
35
-    renderAction: PropTypes.func
35
+    renderAction: PropTypes.func,
36
+    iconMap: PropTypes.object
36 37
   };
37 38
 
38 39
   constructor(props) {
@@ -85,7 +86,18 @@ export default class RichTextToolbar extends Component {
85 86
     return this.props.unselectedButtonStyle ? this.props.unselectedButtonStyle : styles.defaultUnselectedButton;
86 87
   }
87 88
 
89
+  _getButtonIcon(action) {
90
+    if (this.props.iconMap && this.props.iconMap[action]) {
91
+      return this.props.iconMap[action];
92
+    } else if (getDefaultIcon()[action]){
93
+      return getDefaultIcon()[action];
94
+    } else {
95
+      return undefined;
96
+    }
97
+  }
98
+
88 99
   _defaultRenderAction(action, selected) {
100
+    const icon = this._getButtonIcon(action);
89 101
     return (
90 102
       <TouchableOpacity
91 103
           key={action}
@@ -95,9 +107,7 @@ export default class RichTextToolbar extends Component {
95 107
           ]}
96 108
           onPress={() => this._onPress(action)}
97 109
       >
98
-        <Text style={{textAlign: 'center'}}>
99
-          {getDefaultIconText()[action] ? getDefaultIconText()[action] : action.slice(0,1)}
100
-        </Text>
110
+        {icon ? <Image source={icon}/> : null}
101 111
       </TouchableOpacity>
102 112
     );
103 113
   }