Guy Carmeli преди 8 години
родител
ревизия
2de5049a83
променени са 22 файла, в които са добавени 280 реда и са изтрити 265 реда
  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 Целия файл

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

+ 12
- 12
android/app/src/main/java/com/reactnativenavigation/activities/SingleScreenActivity.java Целия файл

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

+ 10
- 10
android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java Целия файл

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

+ 12
- 12
android/app/src/main/java/com/reactnativenavigation/adapters/ViewPagerAdapter.java Целия файл

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

2
 
2
 
3
 import com.facebook.react.bridge.WritableMap;
3
 import com.facebook.react.bridge.WritableMap;
4
 import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter;
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
 public class NavigationReactEventEmitter {
7
 public class NavigationReactEventEmitter {
8
 
8
 
17
 
17
 
18
         params.putString(KEY_EVENT_TYPE, EVENT_TYPE);
18
         params.putString(KEY_EVENT_TYPE, EVENT_TYPE);
19
         params.putString(KEY_EVENT_ID, eventName);
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
         eventEmitter.emit(navigatorEventId, params);
21
         eventEmitter.emit(navigatorEventId, params);
22
     }
22
     }
23
 }
23
 }

+ 113
- 0
android/app/src/main/java/com/reactnativenavigation/core/Button.java Целия файл

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 Целия файл

11
     private static final String KEY_RIGHT = "right";
11
     private static final String KEY_RIGHT = "right";
12
     private static final String KEY_DISABLE_OPEN_GESTURE = "disableOpenGesture";
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
     public final boolean disableOpenGesture;
16
     public final boolean disableOpenGesture;
17
 
17
 
18
     public Drawer(ReadableMap params) {
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
         disableOpenGesture = getBoolean(params, KEY_DISABLE_OPEN_GESTURE);
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 Целия файл

15
 /**
15
 /**
16
  * Created by guyc on 08/04/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
     private static final long serialVersionUID = -570145217281069067L;
19
     private static final long serialVersionUID = -570145217281069067L;
20
 
20
 
21
     private static final String KEY_ID = "id";
21
     private static final String KEY_ID = "id";
33
     private static final AtomicInteger sAtomicIdGenerator = new AtomicInteger();
33
     private static final AtomicInteger sAtomicIdGenerator = new AtomicInteger();
34
     private static final Map<String, Integer> sStringToNumericId = new HashMap<>();
34
     private static final Map<String, Integer> sStringToNumericId = new HashMap<>();
35
 
35
 
36
-    public Button(ReadableMap button) {
36
+    public _Button(ReadableMap button) {
37
         id = getString(button, KEY_ID);
37
         id = getString(button, KEY_ID);
38
         title = getString(button, KEY_TITLE, "");
38
         title = getString(button, KEY_TITLE, "");
39
         mIconSource = getString(button, KEY_ICON);
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 Целия файл

20
 /**
20
 /**
21
  * Created by guyc on 02/04/16.
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
     private static final long serialVersionUID = -1033475305421107791L;
24
     private static final long serialVersionUID = -1033475305421107791L;
25
 
25
 
26
     private static final String KEY_TITLE = "title";
26
     private static final String KEY_TITLE = "title";
54
     public final String navigatorId;
54
     public final String navigatorId;
55
     public final String navigatorEventId;
55
     public final String navigatorEventId;
56
     public final String icon;
56
     public final String icon;
57
-    public ArrayList<Button> buttons;
57
+    public ArrayList<_Button> buttons;
58
     public final boolean backButtonHidden;
58
     public final boolean backButtonHidden;
59
     public boolean bottomTabsHiddenOnScroll;
59
     public boolean bottomTabsHiddenOnScroll;
60
     public HashMap<String, Object> passedProps = new HashMap<>();
60
     public HashMap<String, Object> passedProps = new HashMap<>();
72
     public Boolean bottomTabsHidden;
72
     public Boolean bottomTabsHidden;
73
 
73
 
74
     @NonNull
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
         title = getString(screen, KEY_TITLE);
80
         title = getString(screen, KEY_TITLE);
81
         label = getString(screen, KEY_LABEL);
81
         label = getString(screen, KEY_LABEL);
82
         screenId = getString(screen, KEY_SCREEN);
82
         screenId = getString(screen, KEY_SCREEN);
100
         this.buttons = getButtons(params);
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
         if (hasButtons(screen)) {
105
         if (hasButtons(screen)) {
106
             ReadableArray rightButtons = getRightButtons(screen);
106
             ReadableArray rightButtons = getRightButtons(screen);
107
             for (int i = 0; i < rightButtons.size(); i++) {
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
         return ret;
111
         return ret;

+ 6
- 6
android/app/src/main/java/com/reactnativenavigation/layouts/BaseLayout.java Целия файл

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

+ 3
- 3
android/app/src/main/java/com/reactnativenavigation/layouts/Layout.java Целия файл

1
 package com.reactnativenavigation.layouts;
1
 package com.reactnativenavigation.layouts;
2
 
2
 
3
-import com.reactnativenavigation.core.objects.Screen;
3
+import com.reactnativenavigation.core.objects._Screen;
4
 
4
 
5
 public interface Layout {
5
 public interface Layout {
6
     boolean onBackPressed();
6
     boolean onBackPressed();
9
 
9
 
10
     void removeAllReactViews();
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
     int getScreenCount();
16
     int getScreenCount();
17
 }
17
 }

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/layouts/OnScreenPoppedListener.java Целия файл

1
 package com.reactnativenavigation.layouts;
1
 package com.reactnativenavigation.layouts;
2
 
2
 
3
-import com.reactnativenavigation.core.objects.Screen;
3
+import com.reactnativenavigation.core.objects._Screen;
4
 
4
 
5
 public interface OnScreenPoppedListener {
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 Целия файл

5
 import android.widget.LinearLayout;
5
 import android.widget.LinearLayout;
6
 
6
 
7
 import com.facebook.react.ReactInstanceManager;
7
 import com.facebook.react.ReactInstanceManager;
8
+import com.reactnativenavigation.core.Button;
8
 import com.reactnativenavigation.views.ContentView;
9
 import com.reactnativenavigation.views.ContentView;
9
 import com.reactnativenavigation.views.ScrollDirectionListener;
10
 import com.reactnativenavigation.views.ScrollDirectionListener;
11
+import com.reactnativenavigation.views.TitleBar;
12
+
13
+import java.util.List;
10
 
14
 
11
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
15
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
12
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
16
 import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
13
 
17
 
14
 public class ScreenLayout extends LinearLayout implements ScrollDirectionListener.OnScrollChanged {
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
     private final ReactInstanceManager reactInstanceManager;
26
     private final ReactInstanceManager reactInstanceManager;
17
     private final String moduleName;
27
     private final String moduleName;
18
     private final Bundle passProps;
28
     private final Bundle passProps;
29
+    private final List<Button> buttons;
19
     private ContentView contentView;
30
     private ContentView contentView;
20
     private TopBar topBar;
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
         super(context);
34
         super(context);
24
         this.reactInstanceManager = reactInstanceManager;
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
         setOrientation(VERTICAL);
39
         setOrientation(VERTICAL);
28
 
40
 
29
         createViews();
41
         createViews();
31
 
43
 
32
     private void createViews() {
44
     private void createViews() {
33
         addTopBar();
45
         addTopBar();
46
+        addTitleBarAndSetButtons();
34
         addContentView();
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
     private void addTopBar() {
56
     private void addTopBar() {
38
         topBar = new TopBar(getContext());
57
         topBar = new TopBar(getContext());
39
         addView(topBar, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
58
         addView(topBar, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT));

+ 8
- 10
android/app/src/main/java/com/reactnativenavigation/modal/RnnModal.java Целия файл

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

+ 4
- 13
android/app/src/main/java/com/reactnativenavigation/utils/ImageUtils.java Целия файл

1
 package com.reactnativenavigation.utils;
1
 package com.reactnativenavigation.utils;
2
 
2
 
3
-import android.content.Context;
4
 import android.graphics.PorterDuff;
3
 import android.graphics.PorterDuff;
5
 import android.graphics.PorterDuffColorFilter;
4
 import android.graphics.PorterDuffColorFilter;
6
 import android.graphics.drawable.Drawable;
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
 public class ImageUtils {
9
 public class ImageUtils {
12
 
10
 
13
     public static void tint(Drawable drawable, int tint) {
11
     public static void tint(Drawable drawable, int tint) {
14
         drawable.setColorFilter(new PorterDuffColorFilter(tint, PorterDuff.Mode.SRC_IN));
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
         return dp * scale + 0.5f;
17
         return dp * scale + 0.5f;
27
     }
18
     }
28
 }
19
 }

+ 4
- 4
android/app/src/main/java/com/reactnativenavigation/utils/StyleHelper.java Целия файл

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

+ 0
- 104
android/app/src/main/java/com/reactnativenavigation/views/Button.java Целия файл

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 Целия файл

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

+ 2
- 2
android/app/src/main/java/com/reactnativenavigation/views/RnnTabLayout.java Целия файл

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

+ 18
- 19
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java Целия файл

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

+ 10
- 10
android/app/src/main/java/com/reactnativenavigation/views/ScreenStack.java Целия файл

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

+ 7
- 7
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java Целия файл

1
 package com.reactnativenavigation.views;
1
 package com.reactnativenavigation.views;
2
 
2
 
3
 import android.app.Activity;
3
 import android.app.Activity;
4
+import android.content.Context;
4
 import android.support.v7.widget.ActionMenuView;
5
 import android.support.v7.widget.ActionMenuView;
5
 import android.support.v7.widget.Toolbar;
6
 import android.support.v7.widget.Toolbar;
6
 import android.view.Menu;
7
 import android.view.Menu;
7
 import android.view.MenuInflater;
8
 import android.view.MenuInflater;
8
 
9
 
9
 import com.reactnativenavigation.R;
10
 import com.reactnativenavigation.R;
11
+import com.reactnativenavigation.core.Button;
10
 
12
 
11
 import java.util.List;
13
 import java.util.List;
12
 
14
 
15
     private Menu menu;
17
     private Menu menu;
16
     private ActionMenuView actionMenuView;
18
     private ActionMenuView actionMenuView;
17
 
19
 
18
-
19
-
20
-    public TitleBar(Activity context) {
20
+    public TitleBar(Context context) {
21
         super(context);
21
         super(context);
22
         createMenu();
22
         createMenu();
23
     }
23
     }
31
         // TODO: Maybe setSupportActionBar
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
         Activity context = (Activity) getContext();
37
         Activity context = (Activity) getContext();
39
         for (int i = 0; i < buttons.size(); i++) {
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
             final int index = buttons.size() - i - 1;
41
             final int index = buttons.size() - i - 1;
42
             button.addToMenu(context, menu, index);
42
             button.addToMenu(context, menu, index);
43
         }
43
         }