Guy Carmeli 8 years ago
parent
commit
2de5049a83
22 changed files with 280 additions and 265 deletions
  1. 25
    25
      android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java
  2. 12
    12
      android/app/src/main/java/com/reactnativenavigation/activities/SingleScreenActivity.java
  3. 10
    10
      android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java
  4. 12
    12
      android/app/src/main/java/com/reactnativenavigation/adapters/ViewPagerAdapter.java
  5. 2
    2
      android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactEventEmitter.java
  6. 113
    0
      android/app/src/main/java/com/reactnativenavigation/core/Button.java
  7. 4
    4
      android/app/src/main/java/com/reactnativenavigation/core/objects/Drawer.java
  8. 2
    2
      android/app/src/main/java/com/reactnativenavigation/core/objects/_Button.java
  9. 8
    8
      android/app/src/main/java/com/reactnativenavigation/core/objects/_Screen.java
  10. 6
    6
      android/app/src/main/java/com/reactnativenavigation/layouts/BaseLayout.java
  11. 3
    3
      android/app/src/main/java/com/reactnativenavigation/layouts/Layout.java
  12. 2
    2
      android/app/src/main/java/com/reactnativenavigation/layouts/OnScreenPoppedListener.java
  13. 22
    3
      android/app/src/main/java/com/reactnativenavigation/layouts/ScreenLayout.java
  14. 8
    10
      android/app/src/main/java/com/reactnativenavigation/modal/RnnModal.java
  15. 4
    13
      android/app/src/main/java/com/reactnativenavigation/utils/ImageUtils.java
  16. 4
    4
      android/app/src/main/java/com/reactnativenavigation/utils/StyleHelper.java
  17. 0
    104
      android/app/src/main/java/com/reactnativenavigation/views/Button.java
  18. 6
    7
      android/app/src/main/java/com/reactnativenavigation/views/RctView.java
  19. 2
    2
      android/app/src/main/java/com/reactnativenavigation/views/RnnTabLayout.java
  20. 18
    19
      android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java
  21. 10
    10
      android/app/src/main/java/com/reactnativenavigation/views/ScreenStack.java
  22. 7
    7
      android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java

+ 25
- 25
android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java View File

@@ -11,7 +11,7 @@ import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
11 11
 import com.facebook.react.bridge.ReadableMap;
12 12
 import com.reactnativenavigation.R;
13 13
 import com.reactnativenavigation.core.objects.Drawer;
14
-import com.reactnativenavigation.core.objects.Screen;
14
+import com.reactnativenavigation.core.objects._Screen;
15 15
 import com.reactnativenavigation.utils.StyleHelper;
16 16
 import com.reactnativenavigation.views.BottomNavigation;
17 17
 import com.reactnativenavigation.views.RnnToolBar;
@@ -51,7 +51,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
51 51
         mBottomNavigation = (BottomNavigation) findViewById(R.id.bottom_tab_bar);
52 52
         mContentFrame = (CoordinatorLayout) findViewById(R.id.contentFrame);
53 53
 
54
-        final ArrayList<Screen> screens = (ArrayList<Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
54
+        final ArrayList<_Screen> screens = (ArrayList<_Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
55 55
         final Drawer drawer = (Drawer) getIntent().getSerializableExtra(DRAWER_PARAMS);
56 56
         mBottomNavigation.setForceTint(true);
57 57
         setupDrawer(screens.get(0), drawer, R.id.drawerFrame, R.id.drawerLayout);
@@ -67,13 +67,13 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
67 67
         });
68 68
     }
69 69
 
70
-    private void setupPages(ArrayList<Screen> screens) {
70
+    private void setupPages(ArrayList<_Screen> screens) {
71 71
         new SetupTabsTask(this, toolbar, screens).execute();
72 72
     }
73 73
 
74
-    private void setupToolbar(ArrayList<Screen> screens) {
74
+    private void setupToolbar(ArrayList<_Screen> screens) {
75 75
         toolbar.setScreens(screens);
76
-        Screen initialScreen = screens.get(0);
76
+        _Screen initialScreen = screens.get(0);
77 77
         toolbar.update(initialScreen);
78 78
         StyleHelper.updateStyles(toolbar, initialScreen);
79 79
     }
@@ -103,7 +103,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
103 103
     }
104 104
 
105 105
     @Override
106
-    public void push(Screen screen) {
106
+    public void push(_Screen screen) {
107 107
         super.push(screen);
108 108
         for (ScreenStack stack : mScreenStacks) {
109 109
             if (stack.peek().navigatorId.equals(screen.navigatorId)) {
@@ -118,12 +118,12 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
118 118
     }
119 119
 
120 120
     @Override
121
-    public Screen pop(String navigatorId) {
121
+    public _Screen pop(String navigatorId) {
122 122
         super.pop(navigatorId);
123 123
         for (ScreenStack stack : mScreenStacks) {
124 124
             if (stack.peek().navigatorId.equals(navigatorId)) {
125
-                Screen popped = stack.pop();
126
-                Screen currentScreen = getCurrentScreen();
125
+                _Screen popped = stack.pop();
126
+                _Screen currentScreen = getCurrentScreen();
127 127
                 StyleHelper.updateStyles(toolbar, currentScreen);
128 128
 
129 129
                 if (shouldToggleTabs(currentScreen)) {
@@ -137,12 +137,12 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
137 137
     }
138 138
 
139 139
     @Override
140
-    public Screen popToRoot(String navigatorId) {
140
+    public _Screen popToRoot(String navigatorId) {
141 141
         super.popToRoot(navigatorId);
142 142
         for (ScreenStack stack : mScreenStacks) {
143 143
             if (stack.peek().navigatorId.equals(navigatorId)) {
144
-                Screen popped = stack.popToRoot();
145
-                Screen currentScreen = getCurrentScreen();
144
+                _Screen popped = stack.popToRoot();
145
+                _Screen currentScreen = getCurrentScreen();
146 146
                 StyleHelper.updateStyles(toolbar, currentScreen);
147 147
 
148 148
                 if (shouldToggleTabs(currentScreen)) {
@@ -156,8 +156,8 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
156 156
     }
157 157
 
158 158
     @Override
159
-    public Screen getCurrentScreen() {
160
-        Screen currentScreen = super.getCurrentScreen();
159
+    public _Screen getCurrentScreen() {
160
+        _Screen currentScreen = super.getCurrentScreen();
161 161
         if (currentScreen != null) {
162 162
             return currentScreen;
163 163
         }
@@ -165,7 +165,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
165 165
         return mScreenStacks != null ? mScreenStacks.get(mCurrentStackPosition).peek() : null;
166 166
     }
167 167
 
168
-    public Screen resetTo(Screen screen) {
168
+    public _Screen resetTo(_Screen screen) {
169 169
         super.resetTo(screen);
170 170
         StyleHelper.updateStyles(toolbar, screen);
171 171
         return mScreenStacks.get(mCurrentStackPosition).resetTo(screen);
@@ -237,7 +237,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
237 237
         mBottomNavigation.toggleTabs(hide, animated);
238 238
     }
239 239
 
240
-    private boolean shouldToggleTabs(Screen newScreen) {
240
+    private boolean shouldToggleTabs(_Screen newScreen) {
241 241
         return mBottomNavigation.isShown() == newScreen.bottomTabsHidden;
242 242
     }
243 243
 
@@ -245,21 +245,21 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
245 245
         mBottomNavigation.onScroll(direction);
246 246
     }
247 247
 
248
-    private static class SetupTabsTask extends AsyncTask<Void, Void, Map<Screen, Drawable>> {
248
+    private static class SetupTabsTask extends AsyncTask<Void, Void, Map<_Screen, Drawable>> {
249 249
         private BottomTabActivity mActivity;
250 250
         private RnnToolBar mToolBar;
251
-        private ArrayList<Screen> mScreens;
251
+        private ArrayList<_Screen> mScreens;
252 252
 
253
-        public SetupTabsTask(BottomTabActivity context, RnnToolBar toolBar, ArrayList<Screen> screens) {
253
+        public SetupTabsTask(BottomTabActivity context, RnnToolBar toolBar, ArrayList<_Screen> screens) {
254 254
             mActivity = context;
255 255
             mToolBar = toolBar;
256 256
             mScreens = screens;
257 257
         }
258 258
 
259 259
         @Override
260
-        protected Map<Screen, Drawable> doInBackground(Void... params) {
261
-            Map<Screen, Drawable> icons = new HashMap<>();
262
-            for (Screen screen : mScreens) {
260
+        protected Map<_Screen, Drawable> doInBackground(Void... params) {
261
+            Map<_Screen, Drawable> icons = new HashMap<>();
262
+            for (_Screen screen : mScreens) {
263 263
                 if (screen.icon != null) {
264 264
                     icons.put(screen, screen.getIcon(this.mActivity));
265 265
                 }
@@ -268,7 +268,7 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
268 268
         }
269 269
 
270 270
         @Override
271
-        protected void onPostExecute(Map<Screen, Drawable> icons) {
271
+        protected void onPostExecute(Map<_Screen, Drawable> icons) {
272 272
             mActivity.setTabsWithIcons(mScreens, icons);
273 273
             StyleHelper.updateStyles(mToolBar, mActivity.getCurrentScreen());
274 274
         }
@@ -285,10 +285,10 @@ public class BottomTabActivity extends BaseReactActivity implements AHBottomNavi
285 285
         return null;
286 286
     }
287 287
 
288
-    private void setTabsWithIcons(ArrayList<Screen> screens, Map<Screen, Drawable> icons) {
288
+    private void setTabsWithIcons(ArrayList<_Screen> screens, Map<_Screen, Drawable> icons) {
289 289
         mScreenStacks = new ArrayList<>();
290 290
         for (int i = 0; i < screens.size(); i++) {
291
-            final Screen screen = screens.get(i);
291
+            final _Screen screen = screens.get(i);
292 292
             ScreenStack stack = new ScreenStack(this);
293 293
             stack.push(screen);
294 294
             mScreenStacks.add(stack);

+ 12
- 12
android/app/src/main/java/com/reactnativenavigation/activities/SingleScreenActivity.java View File

@@ -5,7 +5,7 @@ import android.support.design.widget.CoordinatorLayout;
5 5
 import com.facebook.react.bridge.ReadableMap;
6 6
 import com.reactnativenavigation.R;
7 7
 import com.reactnativenavigation.core.objects.Drawer;
8
-import com.reactnativenavigation.core.objects.Screen;
8
+import com.reactnativenavigation.core.objects._Screen;
9 9
 import com.reactnativenavigation.utils.StyleHelper;
10 10
 import com.reactnativenavigation.views.RnnToolBar;
11 11
 import com.reactnativenavigation.views.ScreenStack;
@@ -26,7 +26,7 @@ public class SingleScreenActivity extends BaseReactActivity {
26 26
         setContentView(R.layout.single_screen_activity);
27 27
         toolbar = (RnnToolBar) findViewById(R.id.toolbar);
28 28
 
29
-        final Screen screen = (Screen) getIntent().getSerializableExtra(EXTRA_SCREEN);
29
+        final _Screen screen = (_Screen) getIntent().getSerializableExtra(EXTRA_SCREEN);
30 30
         final Drawer drawer = (Drawer) getIntent().getSerializableExtra(DRAWER_PARAMS);
31 31
 
32 32
         mNavigatorId = screen.navigatorId;
@@ -48,37 +48,37 @@ public class SingleScreenActivity extends BaseReactActivity {
48 48
         });
49 49
     }
50 50
 
51
-    protected void setupToolbar(Screen screen) {
51
+    protected void setupToolbar(_Screen screen) {
52 52
         StyleHelper.updateStyles(toolbar, screen);
53 53
     }
54 54
 
55 55
     @Override
56
-    public void push(Screen screen) {
56
+    public void push(_Screen screen) {
57 57
         super.push(screen);
58 58
         mScreenStack.push(screen);
59 59
         StyleHelper.updateStyles(toolbar, screen);
60 60
     }
61 61
 
62 62
     @Override
63
-    public Screen pop(String navigatorId) {
63
+    public _Screen pop(String navigatorId) {
64 64
         super.pop(navigatorId);
65
-        Screen popped = mScreenStack.pop();
65
+        _Screen popped = mScreenStack.pop();
66 66
         StyleHelper.updateStyles(toolbar, getCurrentScreen());
67 67
         return popped;
68 68
     }
69 69
 
70 70
     @Override
71
-    public Screen popToRoot(String navigatorId) {
71
+    public _Screen popToRoot(String navigatorId) {
72 72
         super.popToRoot(navigatorId);
73
-        Screen screen = mScreenStack.popToRoot();
73
+        _Screen screen = mScreenStack.popToRoot();
74 74
         StyleHelper.updateStyles(toolbar, getCurrentScreen());
75 75
         return screen;
76 76
     }
77 77
 
78 78
     @Override
79
-    public Screen resetTo(Screen screen) {
79
+    public _Screen resetTo(_Screen screen) {
80 80
         super.resetTo(screen);
81
-        Screen popped = mScreenStack.resetTo(screen);
81
+        _Screen popped = mScreenStack.resetTo(screen);
82 82
         StyleHelper.updateStyles(toolbar, screen);
83 83
         return popped;
84 84
     }
@@ -89,8 +89,8 @@ public class SingleScreenActivity extends BaseReactActivity {
89 89
     }
90 90
 
91 91
     @Override
92
-    public Screen getCurrentScreen() {
93
-        Screen currentScreen = super.getCurrentScreen();
92
+    public _Screen getCurrentScreen() {
93
+        _Screen currentScreen = super.getCurrentScreen();
94 94
         if (currentScreen != null) {
95 95
             return currentScreen;
96 96
         }

+ 10
- 10
android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java View File

@@ -5,7 +5,7 @@ import android.view.Menu;
5 5
 
6 6
 import com.reactnativenavigation.R;
7 7
 import com.reactnativenavigation.adapters.ViewPagerAdapter;
8
-import com.reactnativenavigation.core.objects.Screen;
8
+import com.reactnativenavigation.core.objects._Screen;
9 9
 import com.reactnativenavigation.utils.StyleHelper;
10 10
 import com.reactnativenavigation.views.RnnTabLayout;
11 11
 import com.reactnativenavigation.views.RnnToolBar;
@@ -34,24 +34,24 @@ public class TabActivity extends BaseReactActivity {
34 34
         mTabLayout = (RnnTabLayout) findViewById(R.id.tabLayout);
35 35
         mViewPager = (ViewPager) findViewById(R.id.viewPager);
36 36
 
37
-        ArrayList<Screen> screens = (ArrayList<Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
37
+        ArrayList<_Screen> screens = (ArrayList<_Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
38 38
 
39 39
         setupToolbar(screens);
40 40
         setupViewPager(screens);
41 41
     }
42 42
 
43
-    private void setupToolbar(ArrayList<Screen> screens) {
44
-        Screen initialScreen = screens.get(0);
43
+    private void setupToolbar(ArrayList<_Screen> screens) {
44
+        _Screen initialScreen = screens.get(0);
45 45
         toolbar.setScreens(screens);
46 46
         toolbar.update(initialScreen);
47 47
         setNavigationStyle(initialScreen);
48 48
     }
49 49
 
50
-    public void setNavigationStyle(Screen screen) {
50
+    public void setNavigationStyle(_Screen screen) {
51 51
         mTabLayout.setStyle(screen);
52 52
     }
53 53
 
54
-    private void setupViewPager(ArrayList<Screen> screens) {
54
+    private void setupViewPager(ArrayList<_Screen> screens) {
55 55
         mAdapter = new ViewPagerAdapter(this, mViewPager, toolbar, screens);
56 56
         mViewPager.setAdapter(mAdapter);
57 57
         mTabLayout.setupWithViewPager(mViewPager);
@@ -72,22 +72,22 @@ public class TabActivity extends BaseReactActivity {
72 72
     }
73 73
 
74 74
     @Override
75
-    public void push(Screen screen) {
75
+    public void push(_Screen screen) {
76 76
         super.push(screen);
77 77
         StyleHelper.updateStyles(toolbar, screen);
78 78
         mAdapter.push(screen);
79 79
     }
80 80
 
81 81
     @Override
82
-    public Screen pop(String navigatorId) {
82
+    public _Screen pop(String navigatorId) {
83 83
         super.pop(navigatorId);
84
-        Screen popped = mAdapter.pop(navigatorId);
84
+        _Screen popped = mAdapter.pop(navigatorId);
85 85
         setNavigationStyle(getCurrentScreen());
86 86
         return popped;
87 87
     }
88 88
 
89 89
     @Override
90
-    public Screen getCurrentScreen() {
90
+    public _Screen getCurrentScreen() {
91 91
         return mAdapter.peek(getCurrentNavigatorId());
92 92
     }
93 93
 

+ 12
- 12
android/app/src/main/java/com/reactnativenavigation/adapters/ViewPagerAdapter.java View File

@@ -9,7 +9,7 @@ import android.view.ViewGroup;
9 9
 import com.facebook.react.bridge.Arguments;
10 10
 import com.facebook.react.bridge.WritableMap;
11 11
 import com.reactnativenavigation.activities.BaseReactActivity;
12
-import com.reactnativenavigation.core.objects.Screen;
12
+import com.reactnativenavigation.core.objects._Screen;
13 13
 import com.reactnativenavigation.utils.StyleHelper;
14 14
 import com.reactnativenavigation.views.RnnToolBar;
15 15
 import com.reactnativenavigation.views.ScreenStack;
@@ -33,13 +33,13 @@ public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSel
33 33
     private int mCurrentPage = 0;
34 34
 
35 35
     public ViewPagerAdapter(BaseReactActivity context, ViewPager viewPager, RnnToolBar toolbar,
36
-                            ArrayList<Screen> screens) {
36
+                            ArrayList<_Screen> screens) {
37 37
         mViewPager = viewPager;
38 38
         mToolbar = toolbar;
39 39
         mScreenStacks = new ArrayList<>();
40 40
         mNavigatorIds = new ArrayList<>();
41 41
         mStackByNavigatorId = new HashMap<>();
42
-        for (Screen screen : screens) {
42
+        for (_Screen screen : screens) {
43 43
             ScreenStack stack = new ScreenStack(context);
44 44
             stack.push(screen);
45 45
             mScreenStacks.add(stack);
@@ -48,22 +48,22 @@ public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSel
48 48
         }
49 49
     }
50 50
 
51
-    public void push(Screen screen) {
51
+    public void push(_Screen screen) {
52 52
         ScreenStack stack = mStackByNavigatorId.get(screen.navigatorId);
53
-        Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
53
+        _Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
54 54
         mToolbar.setupToolbarButtonsAsync(prevScreen, screen);
55 55
         stack.push(screen);
56 56
     }
57 57
 
58
-    public Screen pop(String navigatorId) {
58
+    public _Screen pop(String navigatorId) {
59 59
         ScreenStack stack = mStackByNavigatorId.get(navigatorId);
60
-        Screen oldScreen =  stack != null ? stack.pop() : null;
61
-        Screen newScreen = stack.peek();
60
+        _Screen oldScreen = stack != null ? stack.pop() : null;
61
+        _Screen newScreen = stack.peek();
62 62
         mToolbar.setupToolbarButtonsAsync(oldScreen, newScreen);
63 63
         return oldScreen;
64 64
     }
65 65
 
66
-    public Screen peek(String navigatorId) {
66
+    public _Screen peek(String navigatorId) {
67 67
         ScreenStack stack = mStackByNavigatorId.get(navigatorId);
68 68
         return stack != null ? stack.peek() : null;
69 69
     }
@@ -102,8 +102,8 @@ public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSel
102 102
         mViewPager.setCurrentItem(position);
103 103
 
104 104
         // Set screen buttons
105
-        Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
106
-        Screen newScreen = mScreenStacks.get(position).peek();
105
+        _Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
106
+        _Screen newScreen = mScreenStacks.get(position).peek();
107 107
         mToolbar.setupToolbarButtonsAsync(prevScreen, newScreen);
108 108
 
109 109
         // Set title
@@ -114,7 +114,7 @@ public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSel
114 114
 
115 115
         // Send tab selected event
116 116
         WritableMap params = Arguments.createMap();
117
-        Screen screen = mScreenStacks.get(position).peek();
117
+        _Screen screen = mScreenStacks.get(position).peek();
118 118
         RctManager.getInstance().sendEvent(EVENT_ON_TAB_SELECTED, screen, params);
119 119
     }
120 120
 

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactEventEmitter.java View File

@@ -2,7 +2,7 @@ package com.reactnativenavigation.bridge;
2 2
 
3 3
 import com.facebook.react.bridge.WritableMap;
4 4
 import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
5
-import com.reactnativenavigation.core.objects.Screen;
5
+import com.reactnativenavigation.core.objects._Screen;
6 6
 
7 7
 public class NavigationReactEventEmitter {
8 8
 
@@ -17,7 +17,7 @@ public class NavigationReactEventEmitter {
17 17
 
18 18
         params.putString(KEY_EVENT_TYPE, EVENT_TYPE);
19 19
         params.putString(KEY_EVENT_ID, eventName);
20
-        params.putString(Screen.KEY_NAVIGATOR_EVENT_ID, navigatorEventId);
20
+        params.putString(_Screen.KEY_NAVIGATOR_EVENT_ID, navigatorEventId);
21 21
         eventEmitter.emit(navigatorEventId, params);
22 22
     }
23 23
 }

+ 113
- 0
android/app/src/main/java/com/reactnativenavigation/core/Button.java View File

@@ -0,0 +1,113 @@
1
+package com.reactnativenavigation.core;
2
+
3
+import android.app.Activity;
4
+import android.graphics.drawable.Drawable;
5
+import android.support.annotation.ColorInt;
6
+import android.support.annotation.NonNull;
7
+import android.support.v7.widget.ActionMenuView;
8
+import android.view.Menu;
9
+import android.view.MenuItem;
10
+import android.view.View;
11
+import android.widget.TextView;
12
+
13
+import com.reactnativenavigation.utils.ImageUtils;
14
+import com.reactnativenavigation.utils.ViewUtils;
15
+
16
+import java.util.ArrayList;
17
+
18
+public class Button {
19
+    public static class Params {
20
+        public enum ShowAsAction {
21
+            IfRoom(MenuItem.SHOW_AS_ACTION_IF_ROOM),
22
+            Always(MenuItem.SHOW_AS_ACTION_ALWAYS),
23
+            Never(MenuItem.SHOW_AS_ACTION_NEVER),
24
+            WithText(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
25
+
26
+            int action;
27
+            ShowAsAction(int action) {
28
+                this.action = action;
29
+            }
30
+        }
31
+
32
+        // Todo: add id for click listener
33
+        String label;
34
+        Drawable icon;
35
+        @ColorInt
36
+        int color;
37
+        ShowAsAction showAsAction;
38
+    }
39
+
40
+    private final Activity activity;
41
+    private final Menu menu;
42
+    private final ActionMenuView parent;
43
+    private Params buttonParams;
44
+
45
+    public Button(Activity activity, Menu menu, ActionMenuView parent, Params buttonParams) {
46
+        this.activity = activity;
47
+        this.menu = menu;
48
+        this.parent = parent;
49
+        this.buttonParams = buttonParams;
50
+    }
51
+
52
+    public MenuItem addToMenu(int index) {
53
+        MenuItem item = menu.add(Menu.NONE, Menu.NONE, index, buttonParams.label);
54
+        item.setShowAsAction(buttonParams.showAsAction.action);
55
+        setIcon(item);
56
+        setColor();
57
+        return item;
58
+    }
59
+
60
+    private void setIcon(MenuItem item) {
61
+        if (hasIcon()) {
62
+            item.setIcon(buttonParams.icon);
63
+        }
64
+    }
65
+
66
+    private void setColor() {
67
+        if (!hasColor()) {
68
+            return;
69
+        }
70
+
71
+        if (hasIcon()) {
72
+            setIconColor();
73
+        } else {
74
+            setTextColor();
75
+        }
76
+    }
77
+
78
+    private void setIconColor() {
79
+        ImageUtils.tint(buttonParams.icon, buttonParams.color);
80
+    }
81
+
82
+    private void setTextColor() {
83
+        ViewUtils.runOnPreDraw(parent, new Runnable() {
84
+            @Override
85
+            public void run() {
86
+                ArrayList<View> outViews = findActualTextViewInMenuByLabel();
87
+                setTextColorInternal(outViews);
88
+            }
89
+        });
90
+    }
91
+
92
+    @NonNull
93
+    private ArrayList<View> findActualTextViewInMenuByLabel() {
94
+        ArrayList<View> outViews = new ArrayList<>();
95
+        parent.findViewsWithText(outViews, buttonParams.label, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
96
+        return outViews;
97
+    }
98
+
99
+    private void setTextColorInternal(ArrayList<View> outViews) {
100
+        for (View button : outViews) {
101
+            ((TextView) button).setTextColor(buttonParams.color);
102
+        }
103
+    }
104
+
105
+    private boolean hasIcon() {
106
+        return buttonParams.icon != null;
107
+    }
108
+
109
+    private boolean hasColor() {
110
+        return buttonParams.color > 0;
111
+    }
112
+
113
+}

+ 4
- 4
android/app/src/main/java/com/reactnativenavigation/core/objects/Drawer.java View File

@@ -11,13 +11,13 @@ public class Drawer extends JsonObject implements Serializable {
11 11
     private static final String KEY_RIGHT = "right";
12 12
     private static final String KEY_DISABLE_OPEN_GESTURE = "disableOpenGesture";
13 13
 
14
-    public final Screen left;
15
-    public final Screen right;
14
+    public final _Screen left;
15
+    public final _Screen right;
16 16
     public final boolean disableOpenGesture;
17 17
 
18 18
     public Drawer(ReadableMap params) {
19
-        left = params.hasKey(KEY_LEFT) ? new Screen(params.getMap(KEY_LEFT)) : null;
20
-        right = params.hasKey(KEY_RIGHT) ? new Screen(params.getMap(KEY_RIGHT)) : null;
19
+        left = params.hasKey(KEY_LEFT) ? new _Screen(params.getMap(KEY_LEFT)) : null;
20
+        right = params.hasKey(KEY_RIGHT) ? new _Screen(params.getMap(KEY_RIGHT)) : null;
21 21
         disableOpenGesture = getBoolean(params, KEY_DISABLE_OPEN_GESTURE);
22 22
     }
23 23
 }

android/app/src/main/java/com/reactnativenavigation/core/objects/Button.java → android/app/src/main/java/com/reactnativenavigation/core/objects/_Button.java View File

@@ -15,7 +15,7 @@ import java.util.concurrent.atomic.AtomicInteger;
15 15
 /**
16 16
  * Created by guyc on 08/04/16.
17 17
  */
18
-public class Button extends JsonObject implements Serializable {
18
+public class _Button extends JsonObject implements Serializable {
19 19
     private static final long serialVersionUID = -570145217281069067L;
20 20
 
21 21
     private static final String KEY_ID = "id";
@@ -33,7 +33,7 @@ public class Button extends JsonObject implements Serializable {
33 33
     private static final AtomicInteger sAtomicIdGenerator = new AtomicInteger();
34 34
     private static final Map<String, Integer> sStringToNumericId = new HashMap<>();
35 35
 
36
-    public Button(ReadableMap button) {
36
+    public _Button(ReadableMap button) {
37 37
         id = getString(button, KEY_ID);
38 38
         title = getString(button, KEY_TITLE, "");
39 39
         mIconSource = getString(button, KEY_ICON);

android/app/src/main/java/com/reactnativenavigation/core/objects/Screen.java → android/app/src/main/java/com/reactnativenavigation/core/objects/_Screen.java View File

@@ -20,7 +20,7 @@ import java.util.List;
20 20
 /**
21 21
  * Created by guyc on 02/04/16.
22 22
  */
23
-public class Screen extends JsonObject implements Serializable {
23
+public class _Screen extends JsonObject implements Serializable {
24 24
     private static final long serialVersionUID = -1033475305421107791L;
25 25
 
26 26
     private static final String KEY_TITLE = "title";
@@ -54,7 +54,7 @@ public class Screen extends JsonObject implements Serializable {
54 54
     public final String navigatorId;
55 55
     public final String navigatorEventId;
56 56
     public final String icon;
57
-    public ArrayList<Button> buttons;
57
+    public ArrayList<_Button> buttons;
58 58
     public final boolean backButtonHidden;
59 59
     public boolean bottomTabsHiddenOnScroll;
60 60
     public HashMap<String, Object> passedProps = new HashMap<>();
@@ -72,11 +72,11 @@ public class Screen extends JsonObject implements Serializable {
72 72
     public Boolean bottomTabsHidden;
73 73
 
74 74
     @NonNull
75
-    public List<Button> getButtons() {
76
-        return buttons == null ? Collections.<Button>emptyList() : buttons;
75
+    public List<_Button> getButtons() {
76
+        return buttons == null ? Collections.<_Button>emptyList() : buttons;
77 77
     }
78 78
 
79
-    public Screen(ReadableMap screen) {
79
+    public _Screen(ReadableMap screen) {
80 80
         title = getString(screen, KEY_TITLE);
81 81
         label = getString(screen, KEY_LABEL);
82 82
         screenId = getString(screen, KEY_SCREEN);
@@ -100,12 +100,12 @@ public class Screen extends JsonObject implements Serializable {
100 100
         this.buttons = getButtons(params);
101 101
     }
102 102
 
103
-    private ArrayList<Button> getButtons(ReadableMap screen) {
104
-        ArrayList<Button> ret = new ArrayList<>();
103
+    private ArrayList<_Button> getButtons(ReadableMap screen) {
104
+        ArrayList<_Button> ret = new ArrayList<>();
105 105
         if (hasButtons(screen)) {
106 106
             ReadableArray rightButtons = getRightButtons(screen);
107 107
             for (int i = 0; i < rightButtons.size(); i++) {
108
-                ret.add(new Button(rightButtons.getMap(i)));
108
+                ret.add(new _Button(rightButtons.getMap(i)));
109 109
             }
110 110
         }
111 111
         return ret;

+ 6
- 6
android/app/src/main/java/com/reactnativenavigation/layouts/BaseLayout.java View File

@@ -6,7 +6,7 @@ import android.view.animation.AnimationUtils;
6 6
 import android.widget.FrameLayout;
7 7
 
8 8
 import com.reactnativenavigation.R;
9
-import com.reactnativenavigation.core.objects.Screen;
9
+import com.reactnativenavigation.core.objects._Screen;
10 10
 import com.reactnativenavigation.views.RctView;
11 11
 import com.reactnativenavigation.views.RnnToolBar;
12 12
 import com.reactnativenavigation.views.ScreenStack;
@@ -18,7 +18,7 @@ public abstract class BaseLayout extends FrameLayout implements Layout {
18 18
     private RnnToolBar toolBar;
19 19
     private ScreenStack screenStack;
20 20
 
21
-    public BaseLayout(Context context, Screen initialScreen) {
21
+    public BaseLayout(Context context, _Screen initialScreen) {
22 22
         super(context);
23 23
         toolBar = (RnnToolBar) findViewById(R.id.toolbar);
24 24
         screenStack = (ScreenStack) findViewById(R.id.screenStack);
@@ -27,7 +27,7 @@ public abstract class BaseLayout extends FrameLayout implements Layout {
27 27
         addInitialScreen(initialScreen);
28 28
     }
29 29
 
30
-    private void addInitialScreen(Screen screen) {
30
+    private void addInitialScreen(_Screen screen) {
31 31
         screenStack.push(screen, new RctView.OnDisplayedListener() {
32 32
             @Override
33 33
             public void onDisplayed() {
@@ -39,13 +39,13 @@ public abstract class BaseLayout extends FrameLayout implements Layout {
39 39
     }
40 40
 
41 41
     @Override
42
-    public void push(Screen screen) {
42
+    public void push(_Screen screen) {
43 43
         screenStack.push(screen);
44 44
     }
45 45
 
46 46
     @Override
47
-    public Screen pop() {
48
-        Screen popped = screenStack.pop();
47
+    public _Screen pop() {
48
+        _Screen popped = screenStack.pop();
49 49
         if (onScreenPoppedListener != null) {
50 50
             onScreenPoppedListener.onScreenPopped(popped);
51 51
         }

+ 3
- 3
android/app/src/main/java/com/reactnativenavigation/layouts/Layout.java View File

@@ -1,6 +1,6 @@
1 1
 package com.reactnativenavigation.layouts;
2 2
 
3
-import com.reactnativenavigation.core.objects.Screen;
3
+import com.reactnativenavigation.core.objects._Screen;
4 4
 
5 5
 public interface Layout {
6 6
     boolean onBackPressed();
@@ -9,9 +9,9 @@ public interface Layout {
9 9
 
10 10
     void removeAllReactViews();
11 11
 
12
-    void push(Screen screen);
12
+    void push(_Screen screen);
13 13
 
14
-    Screen pop();
14
+    _Screen pop();
15 15
 
16 16
     int getScreenCount();
17 17
 }

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/layouts/OnScreenPoppedListener.java View File

@@ -1,8 +1,8 @@
1 1
 package com.reactnativenavigation.layouts;
2 2
 
3
-import com.reactnativenavigation.core.objects.Screen;
3
+import com.reactnativenavigation.core.objects._Screen;
4 4
 
5 5
 public interface OnScreenPoppedListener {
6 6
 
7
-    void onScreenPopped(Screen popped);
7
+    void onScreenPopped(_Screen popped);
8 8
 }

+ 22
- 3
android/app/src/main/java/com/reactnativenavigation/layouts/ScreenLayout.java View File

@@ -5,25 +5,37 @@ import android.os.Bundle;
5 5
 import android.widget.LinearLayout;
6 6
 
7 7
 import com.facebook.react.ReactInstanceManager;
8
+import com.reactnativenavigation.core.Button;
8 9
 import com.reactnativenavigation.views.ContentView;
9 10
 import com.reactnativenavigation.views.ScrollDirectionListener;
11
+import com.reactnativenavigation.views.TitleBar;
12
+
13
+import java.util.List;
10 14
 
11 15
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
12 16
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
13 17
 
14 18
 public class ScreenLayout extends LinearLayout implements ScrollDirectionListener.OnScrollChanged {
15 19
 
20
+    public static class Params {
21
+        String moduleName;
22
+        Bundle passProps;
23
+        List<Button> buttons;
24
+    }
25
+
16 26
     private final ReactInstanceManager reactInstanceManager;
17 27
     private final String moduleName;
18 28
     private final Bundle passProps;
29
+    private final List<Button> buttons;
19 30
     private ContentView contentView;
20 31
     private TopBar topBar;
21 32
 
22
-    public ScreenLayout(Context context, ReactInstanceManager reactInstanceManager, String moduleName, Bundle passProps) {
33
+    public ScreenLayout(Context context, ReactInstanceManager reactInstanceManager, Params screenParams) {
23 34
         super(context);
24 35
         this.reactInstanceManager = reactInstanceManager;
25
-        this.moduleName = moduleName;
26
-        this.passProps = passProps;
36
+        moduleName = screenParams.moduleName;
37
+        passProps = screenParams.passProps;
38
+        buttons = screenParams.buttons;
27 39
         setOrientation(VERTICAL);
28 40
 
29 41
         createViews();
@@ -31,9 +43,16 @@ public class ScreenLayout extends LinearLayout implements ScrollDirectionListene
31 43
 
32 44
     private void createViews() {
33 45
         addTopBar();
46
+        addTitleBarAndSetButtons();
34 47
         addContentView();
35 48
     }
36 49
 
50
+    private void addTitleBarAndSetButtons() {
51
+        TitleBar titleBar = new TitleBar(getContext());
52
+        titleBar.setButtons(buttons);
53
+        topBar.addView(titleBar);
54
+    }
55
+
37 56
     private void addTopBar() {
38 57
         topBar = new TopBar(getContext());
39 58
         addView(topBar, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT));

+ 8
- 10
android/app/src/main/java/com/reactnativenavigation/modal/RnnModal.java View File

@@ -7,30 +7,28 @@ import android.content.DialogInterface;
7 7
 import android.support.annotation.Nullable;
8 8
 import android.view.View;
9 9
 import android.view.Window;
10
-import android.view.WindowManager;
11 10
 
12 11
 import com.reactnativenavigation.R;
13 12
 import com.reactnativenavigation.activities.BaseReactActivity;
14 13
 import com.reactnativenavigation.controllers.ModalController;
15
-import com.reactnativenavigation.core.objects.Screen;
14
+import com.reactnativenavigation.core.objects._Screen;
16 15
 import com.reactnativenavigation.layouts.Layout;
17 16
 import com.reactnativenavigation.layouts.OnScreenPoppedListener;
18 17
 import com.reactnativenavigation.utils.ContextProvider;
19
-import com.reactnativenavigation.utils.SdkSupports;
20 18
 import com.reactnativenavigation.utils.StyleHelper;
21 19
 
22 20
 public class RnnModal extends Dialog implements DialogInterface.OnDismissListener, OnScreenPoppedListener {
23 21
 
24 22
     private Layout contentView;
25 23
 
26
-    public RnnModal(Context context, ModalController modalController, Screen screen) {
24
+    public RnnModal(Context context, ModalController modalController, _Screen screen) {
27 25
         super(context, R.style.Modal);
28 26
         modalController.add(this);
29 27
         init(context, screen);
30 28
     }
31 29
 
32 30
     @SuppressLint("InflateParams")
33
-    private void init(final Context context, Screen screen) {
31
+    private void init(final Context context, _Screen screen) {
34 32
         requestWindowFeature(Window.FEATURE_NO_TITLE);
35 33
         contentView = null;
36 34
         setContentView((View) contentView);
@@ -44,23 +42,23 @@ public class RnnModal extends Dialog implements DialogInterface.OnDismissListene
44 42
         setOnDismissListener(this);
45 43
     }
46 44
 
47
-    public void push(Screen screen) {
45
+    public void push(_Screen screen) {
48 46
         contentView.push(screen);
49 47
     }
50 48
 
51
-    public Screen pop() {
49
+    public _Screen pop() {
52 50
         return contentView.pop();
53 51
     }
54 52
 
55 53
     @Override
56
-    public void onScreenPopped(Screen popped) {
54
+    public void onScreenPopped(_Screen popped) {
57 55
         if (contentView.getScreenCount() == 0) {
58 56
             dismiss();
59 57
         }
60 58
     }
61 59
 
62 60
     @Nullable
63
-    public Screen getCurrentScreen() {
61
+    public _Screen getCurrentScreen() {
64 62
         return mScreenStack.isEmpty() ? null : mScreenStack.peek();
65 63
     }
66 64
 
@@ -80,7 +78,7 @@ public class RnnModal extends Dialog implements DialogInterface.OnDismissListene
80 78
         // After modal is dismissed, update Toolbar with screen from parent activity or previously displayed modal
81 79
         BaseReactActivity context = ContextProvider.getActivityContext();
82 80
         if (context != null) {
83
-            Screen currentScreen = context.getCurrentScreen();
81
+            _Screen currentScreen = context.getCurrentScreen();
84 82
             StyleHelper.updateStyles(mToolBar, currentScreen);
85 83
         }
86 84
     }

+ 4
- 13
android/app/src/main/java/com/reactnativenavigation/utils/ImageUtils.java View File

@@ -1,28 +1,19 @@
1 1
 package com.reactnativenavigation.utils;
2 2
 
3
-import android.content.Context;
4 3
 import android.graphics.PorterDuff;
5 4
 import android.graphics.PorterDuffColorFilter;
6 5
 import android.graphics.drawable.Drawable;
7 6
 
8
-/**
9
- * Created by guyc on 23/04/16.
10
- */
7
+import com.reactnativenavigation.NavigationApplication;
8
+
11 9
 public class ImageUtils {
12 10
 
13 11
     public static void tint(Drawable drawable, int tint) {
14 12
         drawable.setColorFilter(new PorterDuffColorFilter(tint, PorterDuff.Mode.SRC_IN));
15 13
     }
16 14
 
17
-    /**
18
-     * This method converts dp unit to equivalent pixels, depending on device density.
19
-     *
20
-     * @param dp      A value in dp (density independent pixels) unit. Which we need to convert into pixels
21
-     * @param context Context to get resources and device specific display metrics
22
-     * @return A float value to represent px equivalent to dp depending on device density
23
-     */
24
-    public static float convertDpToPixel(float dp, Context context) {
25
-        float scale = context.getResources().getDisplayMetrics().density;
15
+    public static float convertDpToPixel(float dp) {
16
+        float scale = NavigationApplication.instance.getResources().getDisplayMetrics().density;
26 17
         return dp * scale + 0.5f;
27 18
     }
28 19
 }

+ 4
- 4
android/app/src/main/java/com/reactnativenavigation/utils/StyleHelper.java View File

@@ -6,7 +6,7 @@ import android.util.Log;
6 6
 import android.view.Window;
7 7
 
8 8
 import com.reactnativenavigation.activities.BaseReactActivity;
9
-import com.reactnativenavigation.core.objects.Screen;
9
+import com.reactnativenavigation.core.objects._Screen;
10 10
 import com.reactnativenavigation.views.RnnToolBar;
11 11
 
12 12
 /**
@@ -14,7 +14,7 @@ import com.reactnativenavigation.views.RnnToolBar;
14 14
  */
15 15
 public class StyleHelper {
16 16
 
17
-    public static void updateStyles(RnnToolBar toolBar, Screen screen) {
17
+    public static void updateStyles(RnnToolBar toolBar, _Screen screen) {
18 18
         try {
19 19
             toolBar.updateAndSetButtons(screen);
20 20
             setWindowStyle(screen);
@@ -23,14 +23,14 @@ public class StyleHelper {
23 23
         }
24 24
     }
25 25
 
26
-    private static void setWindowStyle(Screen screen) {
26
+    private static void setWindowStyle(_Screen screen) {
27 27
         BaseReactActivity context = ContextProvider.getActivityContext();
28 28
         if (context != null) {
29 29
             StyleHelper.setWindowStyle(context.getWindow(), context, screen);
30 30
         }
31 31
     }
32 32
 
33
-    public static void setWindowStyle(Window window, Context context, Screen screen) {
33
+    public static void setWindowStyle(Window window, Context context, _Screen screen) {
34 34
         if (SdkSupports.lollipop()) {
35 35
             final int black = ContextCompat.getColor(context, android.R.color.black);
36 36
             if (screen.statusBarColor != null) {

+ 0
- 104
android/app/src/main/java/com/reactnativenavigation/views/Button.java View File

@@ -1,104 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.app.Activity;
4
-import android.graphics.drawable.Drawable;
5
-import android.support.annotation.ColorInt;
6
-import android.support.annotation.NonNull;
7
-import android.view.Menu;
8
-import android.view.MenuItem;
9
-import android.view.View;
10
-import android.view.ViewTreeObserver;
11
-import android.widget.TextView;
12
-
13
-import com.reactnativenavigation.utils.ImageUtils;
14
-
15
-import java.util.ArrayList;
16
-
17
-public class Button {
18
-    public enum ShowAsAction {
19
-        IfRoom(MenuItem.SHOW_AS_ACTION_IF_ROOM),
20
-        Always(MenuItem.SHOW_AS_ACTION_ALWAYS),
21
-        Never(MenuItem.SHOW_AS_ACTION_NEVER),
22
-        WithText(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
23
-
24
-        int action;
25
-        ShowAsAction(int action) {
26
-            this.action = action;
27
-        }
28
-    }
29
-
30
-    String label;
31
-    Drawable icon;
32
-    @ColorInt
33
-    int color;
34
-    ShowAsAction showAsAction;
35
-
36
-    public MenuItem addToMenu(Activity context, Menu menu, int index) {
37
-        MenuItem item = menu.add(Menu.NONE, Menu.NONE, index, label);
38
-        setShowAsAction(item);
39
-        setIcon(item);
40
-        setColor(context, item);
41
-        return item;
42
-    }
43
-
44
-    private void setShowAsAction(MenuItem item) {
45
-        item.setShowAsAction(showAsAction.action);
46
-    }
47
-
48
-    private void setIcon(MenuItem item) {
49
-        if (icon != null) {
50
-            item.setIcon(icon);
51
-        }
52
-    }
53
-
54
-    private void setColor(Activity context, MenuItem item) {
55
-        if (!hasColor()) {
56
-            return;
57
-        }
58
-
59
-        if (hasIcon()) {
60
-            setIconColor();
61
-        } else {
62
-            setTextColor(context);
63
-        }
64
-    }
65
-
66
-    private void setTextColor(Activity context) {
67
-        final View decorView = context.getWindow().getDecorView();
68
-        decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
69
-            @Override
70
-            public void onGlobalLayout() {
71
-                decorView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
72
-
73
-                ArrayList<View> outViews = findButtonTextView();
74
-                setTextColorInternal(outViews);
75
-            }
76
-
77
-            @NonNull
78
-            private ArrayList<View> findButtonTextView() {
79
-                ArrayList<View> outViews = new ArrayList<>();
80
-                decorView.findViewsWithText(outViews, label, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
81
-                return outViews;
82
-            }
83
-
84
-            private void setTextColorInternal(ArrayList<View> outViews) {
85
-                for (View button : outViews) {
86
-                    ((TextView) button).setTextColor(color);
87
-                }
88
-            }
89
-        });
90
-    }
91
-
92
-    private void setIconColor() {
93
-        ImageUtils.tint(icon, color);
94
-    }
95
-
96
-    private boolean hasIcon() {
97
-        return icon != null;
98
-    }
99
-
100
-    private boolean hasColor() {
101
-        return color > 0;
102
-    }
103
-
104
-}

+ 6
- 7
android/app/src/main/java/com/reactnativenavigation/views/RctView.java View File

@@ -11,9 +11,8 @@ import com.facebook.react.ReactInstanceManager;
11 11
 import com.facebook.react.ReactRootView;
12 12
 import com.reactnativenavigation.activities.BaseReactActivity;
13 13
 import com.reactnativenavigation.activities.BottomTabActivity;
14
-import com.reactnativenavigation.core.objects.Screen;
14
+import com.reactnativenavigation.core.objects._Screen;
15 15
 import com.reactnativenavigation.utils.BridgeUtils;
16
-import com.reactnativenavigation.utils.ReflectionUtils;
17 16
 
18 17
 /**
19 18
  * Created by guyc on 10/03/16.
@@ -84,7 +83,7 @@ public class RctView extends FrameLayout {
84 83
     }
85 84
 
86 85
     @SuppressWarnings("unchecked")
87
-    public RctView(BaseReactActivity ctx, ReactInstanceManager rctInstanceManager, final Screen screen,
86
+    public RctView(BaseReactActivity ctx, ReactInstanceManager rctInstanceManager, final _Screen screen,
88 87
                    final OnDisplayedListener onDisplayedListener) {
89 88
         super(ctx);
90 89
         setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
@@ -110,11 +109,11 @@ public class RctView extends FrameLayout {
110 109
         addView(reactRootView);
111 110
     }
112 111
 
113
-    private Bundle createPassProps(Screen screen) {
112
+    private Bundle createPassProps(_Screen screen) {
114 113
         Bundle passProps = new Bundle();
115
-        passProps.putString(Screen.KEY_SCREEN_INSTANCE_ID, screen.screenInstanceId);
116
-        passProps.putString(Screen.KEY_NAVIGATOR_ID, screen.navigatorId);
117
-        passProps.putString(Screen.KEY_NAVIGATOR_EVENT_ID, screen.navigatorEventId);
114
+        passProps.putString(_Screen.KEY_SCREEN_INSTANCE_ID, screen.screenInstanceId);
115
+        passProps.putString(_Screen.KEY_NAVIGATOR_ID, screen.navigatorId);
116
+        passProps.putString(_Screen.KEY_NAVIGATOR_EVENT_ID, screen.navigatorEventId);
118 117
         if (screen.passedProps != null) {
119 118
             BridgeUtils.addMapToBundle(screen.passedProps, passProps);
120 119
         }

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/views/RnnTabLayout.java View File

@@ -9,7 +9,7 @@ import android.util.AttributeSet;
9 9
 import android.util.TypedValue;
10 10
 
11 11
 import com.reactnativenavigation.R;
12
-import com.reactnativenavigation.core.objects.Screen;
12
+import com.reactnativenavigation.core.objects._Screen;
13 13
 
14 14
 /**
15 15
  * Created by guyc on 07/05/16.
@@ -43,7 +43,7 @@ public class RnnTabLayout extends TabLayout {
43 43
         a.recycle();
44 44
     }
45 45
 
46
-    public void setStyle(Screen screen) {
46
+    public void setStyle(_Screen screen) {
47 47
         if (screen.toolBarColor != null) {
48 48
             setBackgroundColor(screen.toolBarColor);
49 49
         } else {

+ 18
- 19
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java View File

@@ -14,7 +14,6 @@ import android.support.v7.app.ActionBarDrawerToggle;
14 14
 import android.support.v7.app.AppCompatActivity;
15 15
 import android.support.v7.graphics.drawable.DrawerArrowDrawable;
16 16
 import android.support.v7.widget.Toolbar;
17
-import android.util.AttributeSet;
18 17
 import android.view.Gravity;
19 18
 import android.view.Menu;
20 19
 import android.view.MenuItem;
@@ -24,8 +23,8 @@ import android.widget.TextView;
24 23
 
25 24
 import com.reactnativenavigation.R;
26 25
 import com.reactnativenavigation.activities.BaseReactActivity;
27
-import com.reactnativenavigation.core.objects.Button;
28
-import com.reactnativenavigation.core.objects.Screen;
26
+import com.reactnativenavigation.core.objects._Button;
27
+import com.reactnativenavigation.core.objects._Screen;
29 28
 import com.reactnativenavigation.utils.ContextProvider;
30 29
 import com.reactnativenavigation.react.ImageLoader;
31 30
 import com.reactnativenavigation.utils.ImageUtils;
@@ -41,7 +40,7 @@ import java.util.Map;
41 40
  */
42 41
 public class RnnToolBar extends Toolbar {
43 42
 
44
-    private List<Screen> mScreens;
43
+    private List<_Screen> mScreens;
45 44
     private AsyncTask mDrawerIconTask;
46 45
     private AsyncTask mSetupToolbarTask;
47 46
     private Drawable mBackground;
@@ -60,7 +59,7 @@ public class RnnToolBar extends Toolbar {
60 59
         mBackground = getBackground();
61 60
     }
62 61
 
63
-    public void setScreens(List<Screen> screens) {
62
+    public void setScreens(List<_Screen> screens) {
64 63
         mScreens = screens;
65 64
     }
66 65
 
@@ -70,7 +69,7 @@ public class RnnToolBar extends Toolbar {
70 69
 //        }
71 70
     }
72 71
 
73
-    public ActionBarDrawerToggle setupDrawer(DrawerLayout drawerLayout, Screen drawerScreen, Screen screen) {
72
+    public ActionBarDrawerToggle setupDrawer(DrawerLayout drawerLayout, _Screen drawerScreen, _Screen screen) {
74 73
         if (drawerLayout == null || drawerScreen == null) {
75 74
             return null;
76 75
         }
@@ -122,20 +121,20 @@ public class RnnToolBar extends Toolbar {
122 121
         }
123 122
     }
124 123
 
125
-    public void setupDrawerIconAsync(String drawerIconSource, Screen screen) {
124
+    public void setupDrawerIconAsync(String drawerIconSource, _Screen screen) {
126 125
         if (mDrawerIconTask == null) {
127 126
             mDrawerIconTask = new SetupDrawerIconTask(this, drawerIconSource, screen).execute();
128 127
         }
129 128
     }
130 129
 
131
-    public void setupToolbarButtonsAsync(Screen newScreen) {
130
+    public void setupToolbarButtonsAsync(_Screen newScreen) {
132 131
         if (newScreen != null) {
133 132
             this.setupToolbarButtonsAsync(null, newScreen);
134 133
         }
135 134
     }
136 135
 
137 136
 
138
-    public void setupToolbarButtonsAsync(Screen oldScreen, Screen newScreen) {
137
+    public void setupToolbarButtonsAsync(_Screen oldScreen, _Screen newScreen) {
139 138
         if (mSetupToolbarTask == null) {
140 139
             mSetupToolbarTask = new SetupToolbarButtonsTask(this, oldScreen, newScreen).execute();
141 140
         }
@@ -172,7 +171,7 @@ public class RnnToolBar extends Toolbar {
172 171
     }
173 172
 
174 173
     @SuppressWarnings({"ConstantConditions"})
175
-    public void setNavUpButton(Screen screen) {
174
+    public void setNavUpButton(_Screen screen) {
176 175
         BaseReactActivity context = ContextProvider.getActivityContext();
177 176
         if (context == null) {
178 177
             return;
@@ -218,13 +217,13 @@ public class RnnToolBar extends Toolbar {
218 217
      * @param screen The currently displayed screen
219 218
      */
220 219
     @UiThread
221
-    public void update(@NonNull Screen screen) {
220
+    public void update(@NonNull _Screen screen) {
222 221
         ((AppCompatActivity) getContext()).setSupportActionBar(this);
223 222
         setTitle(screen.title);
224 223
         setStyle(screen);
225 224
     }
226 225
 
227
-    public void updateAndSetButtons(Screen screen) {
226
+    public void updateAndSetButtons(_Screen screen) {
228 227
         update(screen);
229 228
         setupToolbarButtonsAsync(screen);
230 229
     }
@@ -234,7 +233,7 @@ public class RnnToolBar extends Toolbar {
234 233
         private final String mDrawerIconSource;
235 234
         private final Integer mTintColor;
236 235
 
237
-        public SetupDrawerIconTask(RnnToolBar toolBar, String drawerIconSource, Screen screen) {
236
+        public SetupDrawerIconTask(RnnToolBar toolBar, String drawerIconSource, _Screen screen) {
238 237
             mToolbarWR = new WeakReference<>(toolBar);
239 238
             mDrawerIconSource = drawerIconSource;
240 239
             mTintColor = screen.navBarButtonColor;
@@ -266,13 +265,13 @@ public class RnnToolBar extends Toolbar {
266 265
     }
267 266
 
268 267
     private static class SetupToolbarButtonsTask extends AsyncTask<Void, Void, Map<String, Drawable>> {
269
-        private final List<Button> mOldButtons;
270
-        private final List<Button> mNewButtons;
268
+        private final List<_Button> mOldButtons;
269
+        private final List<_Button> mNewButtons;
271 270
         private final WeakReference<RnnToolBar> mToolbarWR;
272 271
         @ColorInt private final Integer mTintColor;
273 272
         private final int mIconDimensions;
274 273
 
275
-        public SetupToolbarButtonsTask(RnnToolBar toolBar, Screen oldScreen, Screen newScreen) {
274
+        public SetupToolbarButtonsTask(RnnToolBar toolBar, _Screen oldScreen, _Screen newScreen) {
276 275
             mToolbarWR = new WeakReference<>(toolBar);
277 276
             mOldButtons = oldScreen == null ? null : oldScreen.getButtons();
278 277
             mNewButtons = newScreen.getButtons();
@@ -288,7 +287,7 @@ public class RnnToolBar extends Toolbar {
288 287
             }
289 288
 
290 289
             Map<String, Drawable> icons = new HashMap<>();
291
-            for (Button button : mNewButtons) {
290
+            for (_Button button : mNewButtons) {
292 291
                 if (button.hasIcon()) {
293 292
                     icons.put(button.id, button.getIcon(context, mIconDimensions));
294 293
                 }
@@ -317,7 +316,7 @@ public class RnnToolBar extends Toolbar {
317 316
             if(mOldButtons == null) {
318 317
                 menu.clear();
319 318
             } else {
320
-                for (Button btn : mOldButtons) {
319
+                for (_Button btn : mOldButtons) {
321 320
                     menu.removeItem(btn.getItemId());
322 321
                 }
323 322
             }
@@ -326,7 +325,7 @@ public class RnnToolBar extends Toolbar {
326 325
             final List<String> textButtons = new ArrayList<>();
327 326
             final int size = mNewButtons.size();
328 327
             for (int i = 0; i < size; i++) {
329
-                Button button = mNewButtons.get(i);
328
+                _Button button = mNewButtons.get(i);
330 329
                 MenuItem item = menu.add(Menu.NONE, button.getItemId(), size - i - 1, button.title);
331 330
                 item.setShowAsAction(getMenuItemShowAction(button.showAsAction));
332 331
 

+ 10
- 10
android/app/src/main/java/com/reactnativenavigation/views/ScreenStack.java View File

@@ -8,7 +8,7 @@ import android.view.ViewGroup;
8 8
 
9 9
 import com.facebook.react.ReactInstanceManager;
10 10
 import com.reactnativenavigation.activities.BaseReactActivity;
11
-import com.reactnativenavigation.core.objects.Screen;
11
+import com.reactnativenavigation.core.objects._Screen;
12 12
 
13 13
 import java.util.Stack;
14 14
 
@@ -19,10 +19,10 @@ public class ScreenStack extends android.support.design.widget.CoordinatorLayout
19 19
     private static final int DISAPPEAR_ANIMATION_DELAY = 200;
20 20
 
21 21
     private static class ScreenView {
22
-        Screen screen;
22
+        _Screen screen;
23 23
         RctView view;
24 24
 
25
-        public ScreenView(Screen screen, RctView view) {
25
+        public ScreenView(_Screen screen, RctView view) {
26 26
             this.screen = screen;
27 27
             this.view = view;
28 28
         }
@@ -47,11 +47,11 @@ public class ScreenStack extends android.support.design.widget.CoordinatorLayout
47 47
         setLayoutTransition(new LayoutTransition());
48 48
     }
49 49
 
50
-    public void push(Screen screen) {
50
+    public void push(_Screen screen) {
51 51
         push(screen, null);
52 52
     }
53 53
 
54
-    public void push(Screen screen, RctView.OnDisplayedListener onDisplayed) {
54
+    public void push(_Screen screen, RctView.OnDisplayedListener onDisplayed) {
55 55
         RctView oldView = mStack.isEmpty() ? null : mStack.peek().view;
56 56
         RctView view = new RctView(mReactActivity, mReactInstanceManager, screen, onDisplayed);
57 57
         if (oldView != null) {
@@ -67,7 +67,7 @@ public class ScreenStack extends android.support.design.widget.CoordinatorLayout
67 67
         mStack.push(new ScreenView(screen, view));
68 68
     }
69 69
 
70
-    public Screen pop() {
70
+    public _Screen pop() {
71 71
         if (mStack.isEmpty() || getStackSize() == 1) {
72 72
             return null;
73 73
         }
@@ -83,7 +83,7 @@ public class ScreenStack extends android.support.design.widget.CoordinatorLayout
83 83
         return popped.screen;
84 84
     }
85 85
 
86
-    public Screen popToRoot() {
86
+    public _Screen popToRoot() {
87 87
         if (mStack.isEmpty() || getStackSize() <= 1) {
88 88
             return null;
89 89
         }
@@ -105,11 +105,11 @@ public class ScreenStack extends android.support.design.widget.CoordinatorLayout
105 105
         return oldScreenView != null ? oldScreenView.screen : null;
106 106
     }
107 107
 
108
-    public Screen resetTo(Screen screen) {
108
+    public _Screen resetTo(_Screen screen) {
109 109
         return resetTo(screen, null);
110 110
     }
111 111
 
112
-    public Screen resetTo(Screen screen, RctView.OnDisplayedListener onDisplayed) {
112
+    public _Screen resetTo(_Screen screen, RctView.OnDisplayedListener onDisplayed) {
113 113
         RctView view = new RctView(mReactActivity, mReactInstanceManager, screen, onDisplayed);
114 114
         addView(view, MATCH_PARENT, MATCH_PARENT);
115 115
 
@@ -143,7 +143,7 @@ public class ScreenStack extends android.support.design.widget.CoordinatorLayout
143 143
         return mStack.size();
144 144
     }
145 145
 
146
-    public Screen peek() {
146
+    public _Screen peek() {
147 147
         return mStack.peek().screen;
148 148
     }
149 149
 

+ 7
- 7
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java View File

@@ -1,12 +1,14 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3 3
 import android.app.Activity;
4
+import android.content.Context;
4 5
 import android.support.v7.widget.ActionMenuView;
5 6
 import android.support.v7.widget.Toolbar;
6 7
 import android.view.Menu;
7 8
 import android.view.MenuInflater;
8 9
 
9 10
 import com.reactnativenavigation.R;
11
+import com.reactnativenavigation.core.Button;
10 12
 
11 13
 import java.util.List;
12 14
 
@@ -15,9 +17,7 @@ public class TitleBar extends Toolbar {
15 17
     private Menu menu;
16 18
     private ActionMenuView actionMenuView;
17 19
 
18
-
19
-
20
-    public TitleBar(Activity context) {
20
+    public TitleBar(Context context) {
21 21
         super(context);
22 22
         createMenu();
23 23
     }
@@ -31,13 +31,13 @@ public class TitleBar extends Toolbar {
31 31
         // TODO: Maybe setSupportActionBar
32 32
     }
33 33
 
34
-    public void setButtons(List<Button> buttons) {
35
-        removeView(actionMenuView);
36
-        createMenu();
34
+    public void setButtons(List<Button.Params> buttons) {
35
+        menu.clear();
37 36
 
38 37
         Activity context = (Activity) getContext();
39 38
         for (int i = 0; i < buttons.size(); i++) {
40
-            final Button button = buttons.get(i);
39
+            final Button button = new Button(context, buttons.get(i));
40
+            // Add button in reverse order because in iOS, index 0 starts at right
41 41
             final int index = buttons.size() - i - 1;
42 42
             button.addToMenu(context, menu, index);
43 43
         }