Browse Source

Corrected styling

Yedidya Kennard 8 years ago
parent
commit
c800aa92cd

+ 6
- 10
android/app/src/main/java/com/reactnativenavigation/core/objects/Screen.java View File

1
 package com.reactnativenavigation.core.objects;
1
 package com.reactnativenavigation.core.objects;
2
 
2
 
3
-import android.os.Bundle;
4
 import android.support.annotation.ColorInt;
3
 import android.support.annotation.ColorInt;
5
 import android.support.annotation.NonNull;
4
 import android.support.annotation.NonNull;
6
 import android.support.annotation.Nullable;
5
 import android.support.annotation.Nullable;
48
     public final String navigatorEventId;
47
     public final String navigatorEventId;
49
     public final int icon;
48
     public final int icon;
50
     public final ArrayList<Button> buttons;
49
     public final ArrayList<Button> buttons;
51
-    public final HashMap passedProps;
50
+    public HashMap<String, Object> passedProps = new HashMap<>();
52
 
51
 
53
     // Navigation styling
52
     // Navigation styling
54
     @Nullable @ColorInt public Integer toolBarColor;
53
     @Nullable @ColorInt public Integer toolBarColor;
62
 
61
 
63
     @NonNull
62
     @NonNull
64
     public List<Button> getButtons() {
63
     public List<Button> getButtons() {
65
-        return buttons == null ? Collections.EMPTY_LIST : buttons;
64
+        return buttons == null ? Collections.<Button>emptyList() : buttons;
66
     }
65
     }
67
 
66
 
68
     public Screen(ReadableMap screen) {
67
     public Screen(ReadableMap screen) {
73
         navigatorId = getString(screen, KEY_NAVIGATOR_ID);
72
         navigatorId = getString(screen, KEY_NAVIGATOR_ID);
74
         navigatorEventId = getString(screen, KEY_NAVIGATOR_EVENT_ID);
73
         navigatorEventId = getString(screen, KEY_NAVIGATOR_EVENT_ID);
75
         icon = getInt(screen, KEY_ICON);
74
         icon = getInt(screen, KEY_ICON);
76
-        if(screen.hasKey(KEY_PROPS))
77
-            passedProps = ((ReadableNativeMap)screen.getMap(KEY_PROPS)).toHashMap();
78
-        else
79
-            passedProps = null;
80
-
75
+        if(screen.hasKey(KEY_PROPS)) {
76
+            passedProps = ((ReadableNativeMap) screen.getMap(KEY_PROPS)).toHashMap();
77
+        }
81
         buttons = getButtons(screen);
78
         buttons = getButtons(screen);
82
         setToolbarStyle(screen);
79
         setToolbarStyle(screen);
83
     }
80
     }
84
 
81
 
85
     private ArrayList<Button> getButtons(ReadableMap screen) {
82
     private ArrayList<Button> getButtons(ReadableMap screen) {
86
-        ArrayList<Button> ret = new ArrayList();
83
+        ArrayList<Button> ret = new ArrayList<>();
87
         if (screen.hasKey(KEY_RIGHT_BUTTONS)) {
84
         if (screen.hasKey(KEY_RIGHT_BUTTONS)) {
88
             ReadableArray rightButtons = screen.getArray(KEY_RIGHT_BUTTONS);
85
             ReadableArray rightButtons = screen.getArray(KEY_RIGHT_BUTTONS);
89
             for (int i = 0; i < rightButtons.size(); i++) {
86
             for (int i = 0; i < rightButtons.size(); i++) {
93
         return ret;
90
         return ret;
94
     }
91
     }
95
 
92
 
96
-
97
     public void setToolbarStyle(ReadableMap screen) {
93
     public void setToolbarStyle(ReadableMap screen) {
98
         ReadableMap style = getMap(screen, KEY_TOOL_BAR_STYLE);
94
         ReadableMap style = getMap(screen, KEY_TOOL_BAR_STYLE);
99
         if (style != null) {
95
         if (style != null) {

+ 14
- 10
android/app/src/main/java/com/reactnativenavigation/utils/BridgeUtils.java View File

51
             } else if (arrayList.get(0) instanceof HashMap) {
51
             } else if (arrayList.get(0) instanceof HashMap) {
52
                 bundle.putParcelableArray(key, toBundleArray((ArrayList<HashMap>) arrayList));
52
                 bundle.putParcelableArray(key, toBundleArray((ArrayList<HashMap>) arrayList));
53
             } else if (arrayList.get(0) instanceof ArrayList) {
53
             } else if (arrayList.get(0) instanceof ArrayList) {
54
-                Log.w("RNNNavigation", "Arrays of arrays passed in props are converted to dictionaries with indexes as keys");
54
+                Log.w("RNNavigation", "Arrays of arrays passed in props are converted to dictionaries with indexes as keys");
55
                 Bundle innerArray = new Bundle();
55
                 Bundle innerArray = new Bundle();
56
                 for (int i = 0; i < arrayList.size(); i++) {
56
                 for (int i = 0; i < arrayList.size(); i++) {
57
                     putArray(String.valueOf(i), (ArrayList) arrayList.get(i), innerArray);
57
                     putArray(String.valueOf(i), (ArrayList) arrayList.get(i), innerArray);
62
     }
62
     }
63
 
63
 
64
     private static void verifyArrayListIsSingleType(ArrayList arrayList) {
64
     private static void verifyArrayListIsSingleType(ArrayList arrayList) {
65
-        int i = 1;
66
-        while (i < arrayList.size()) {
67
-            if (!arrayList.get(i - 1).getClass().isInstance(arrayList.get(i)))
65
+        for (int i = 1; i < arrayList.size(); i++) {
66
+            if (!arrayList.get(i - 1).getClass().isInstance(arrayList.get(i))) {
68
                 throw new IllegalArgumentException("Cannot pass array of multiple types via props");
67
                 throw new IllegalArgumentException("Cannot pass array of multiple types via props");
69
-            i++;
68
+            }
70
         }
69
         }
71
     }
70
     }
72
 
71
 
80
 
79
 
81
     private static int[] toIntArray(ArrayList<Integer> arrayList) {
80
     private static int[] toIntArray(ArrayList<Integer> arrayList) {
82
         int[] ret = new int[arrayList.size()];
81
         int[] ret = new int[arrayList.size()];
83
-        for (int i=0; i < ret.length; i++)
82
+        for (int i=0; i < ret.length; i++) {
84
             ret[i] = arrayList.get(i);
83
             ret[i] = arrayList.get(i);
84
+        }
85
         return ret;
85
         return ret;
86
     }
86
     }
87
 
87
 
88
     private static float[] toFloatArray(ArrayList<Float> arrayList) {
88
     private static float[] toFloatArray(ArrayList<Float> arrayList) {
89
         float[] ret = new float[arrayList.size()];
89
         float[] ret = new float[arrayList.size()];
90
-        for (int i=0; i < ret.length; i++)
90
+        for (int i=0; i < ret.length; i++) {
91
             ret[i] = arrayList.get(i);
91
             ret[i] = arrayList.get(i);
92
+        }
92
         return ret;
93
         return ret;
93
     }
94
     }
94
 
95
 
95
     private static double[] toDoubleArray(ArrayList<Double> arrayList) {
96
     private static double[] toDoubleArray(ArrayList<Double> arrayList) {
96
         double[] ret = new double[arrayList.size()];
97
         double[] ret = new double[arrayList.size()];
97
-        for (int i=0; i < ret.length; i++)
98
+        for (int i=0; i < ret.length; i++) {
98
             ret[i] = arrayList.get(i);
99
             ret[i] = arrayList.get(i);
100
+        }
99
         return ret;
101
         return ret;
100
     }
102
     }
101
 
103
 
102
     private static boolean[] toBooleanArray(ArrayList<Boolean> arrayList) {
104
     private static boolean[] toBooleanArray(ArrayList<Boolean> arrayList) {
103
         boolean[] ret = new boolean[arrayList.size()];
105
         boolean[] ret = new boolean[arrayList.size()];
104
-        for (int i=0; i < ret.length; i++)
106
+        for (int i=0; i < ret.length; i++) {
105
             ret[i] = arrayList.get(i);
107
             ret[i] = arrayList.get(i);
108
+        }
106
         return ret;
109
         return ret;
107
     }
110
     }
108
 
111
 
109
     private static String[] toStringArray(ArrayList<String> arrayList) {
112
     private static String[] toStringArray(ArrayList<String> arrayList) {
110
         String[] ret = new String[arrayList.size()];
113
         String[] ret = new String[arrayList.size()];
111
-        for (int i=0; i < ret.length; i++)
114
+        for (int i=0; i < ret.length; i++) {
112
             ret[i] = arrayList.get(i);
115
             ret[i] = arrayList.get(i);
116
+        }
113
         return ret;
117
         return ret;
114
     }
118
     }
115
 
119