Browse Source

Enable android load drawable images (#3734)

* Enable android load drawable images

* Add debug check

* Update document
Jing Tai Piao 6 years ago
parent
commit
a43d4ba7b5

+ 19
- 0
docs/docs/styling.md View File

257
 
257
 
258
 * iOS - follow this [guide](https://medium.com/@dabit3/adding-custom-fonts-to-react-native-b266b41bff7f)
258
 * iOS - follow this [guide](https://medium.com/@dabit3/adding-custom-fonts-to-react-native-b266b41bff7f)
259
 
259
 
260
+## Custom tab icons
261
+
262
+* Android - add cooresponding resoltion icons into folders in android/app/src/main/res.
263
+For example, icon_name.png in each drawable-x folder.
264
+* iOS - drag and drop to Images.xcassets in Xcode.
265
+For example, image set icon_name in Images.xcassets with x1, x2, x3.
266
+
267
+Then, the tab icon can be defined by following syntax:
268
+
269
+```js
270
+bottomTab: {
271
+  icon: {
272
+    uri: 'icon_name',
273
+    ...
274
+  },
275
+  ...
276
+}
277
+```
278
+
260
 ## Customizing screen animations
279
 ## Customizing screen animations
261
 Animation used for navigation commands that modify the layout hierarchy can be controlled in options. Animations can be modified per command and it's also possible to change the default animation for each command.
280
 Animation used for navigation commands that modify the layout hierarchy can be controlled in options. Animations can be modified per command and it's also possible to change the default animation for each command.
262
 
281
 

+ 11
- 5
lib/android/app/src/main/java/com/reactnativenavigation/utils/ImageLoader.java View File

56
 
56
 
57
     @NonNull
57
     @NonNull
58
     private Drawable getDrawable(Context context, String source) throws IOException {
58
     private Drawable getDrawable(Context context, String source) throws IOException {
59
-        if (BuildConfig.DEBUG) {
60
-            return readJsDevImage(context, source);
61
-        } else if (isLocalFile(Uri.parse(source))) {
62
-            return loadFile(source);
59
+        Drawable drawable;
60
+
61
+        if (isLocalFile(Uri.parse(source))) {
62
+            drawable = loadFile(source);
63
         } else {
63
         } else {
64
-            return loadResource(source);
64
+            drawable = loadResource(source);
65
+
66
+            if (drawable == null || BuildConfig.DEBUG) {
67
+                drawable = readJsDevImage(context, source);
68
+            }
65
         }
69
         }
70
+
71
+        return drawable;
66
     }
72
     }
67
 
73
 
68
     @NonNull
74
     @NonNull