Bladeren bron

commented all old code to make the example run

Daniel Zlotin 8 jaren geleden
bovenliggende
commit
787f3b94ee
29 gewijzigde bestanden met toevoegingen van 1820 en 2038 verwijderingen
  1. 0
    8
      .babelrc
  2. 0
    23
      android/app/build.gradle
  3. 284
    305
      android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java
  4. 111
    121
      android/app/src/main/java/com/reactnativenavigation/activities/SingleScreenActivity.java
  5. 83
    95
      android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java
  6. 129
    147
      android/app/src/main/java/com/reactnativenavigation/adapters/ViewPagerAdapter.java
  7. 1
    1
      android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactEventEmitter.java
  8. 3
    0
      android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java
  9. 43
    49
      android/app/src/main/java/com/reactnativenavigation/controllers/ModalController.java
  10. 31
    5
      android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java
  11. 16
    20
      android/app/src/main/java/com/reactnativenavigation/core/objects/Drawer.java
  12. 62
    74
      android/app/src/main/java/com/reactnativenavigation/core/objects/_Button.java
  13. 120
    137
      android/app/src/main/java/com/reactnativenavigation/core/objects/_Screen.java
  14. 54
    65
      android/app/src/main/java/com/reactnativenavigation/layouts/BaseLayout.java
  15. 0
    8
      android/app/src/main/java/com/reactnativenavigation/layouts/Layout.java
  16. 10
    5
      android/app/src/main/java/com/reactnativenavigation/layouts/ScreenLayout.java
  17. 64
    81
      android/app/src/main/java/com/reactnativenavigation/modal/RnnModal.java
  18. 1
    1
      android/app/src/main/java/com/reactnativenavigation/react/JsDevImageLoader.java
  19. 34
    43
      android/app/src/main/java/com/reactnativenavigation/utils/StyleHelper.java
  20. 118
    132
      android/app/src/main/java/com/reactnativenavigation/views/RctView.java
  21. 23
    28
      android/app/src/main/java/com/reactnativenavigation/views/RnnReactRootView.java
  22. 60
    71
      android/app/src/main/java/com/reactnativenavigation/views/RnnTabLayout.java
  23. 357
    395
      android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java
  24. 161
    175
      android/app/src/main/java/com/reactnativenavigation/views/ScreenStack.java
  25. 1
    0
      android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java
  26. 12
    5
      android/app/src/main/java/com/reactnativenavigation/views/TitleBarButton.java
  27. 2
    2
      example-redux/android/app/src/main/java/com/exampleredux/MainActivity.java
  28. 0
    1
      example-redux/package.json
  29. 40
    41
      src/platformSpecific.android.js

+ 0
- 8
.babelrc Bestand weergeven

@@ -1,8 +0,0 @@
1
-{
2
-  "presets": [
3
-    "es2015",
4
-    "react",
5
-    "stage-0"
6
-  ],
7
-  "retainLines": true
8
-}

+ 0
- 23
android/app/build.gradle Bestand weergeven

@@ -1,23 +1,3 @@
1
-buildscript {
2
-    repositories {
3
-        jcenter()
4
-    }
5
-    dependencies {
6
-        classpath 'com.android.tools.build:gradle:2.1.2'
7
-    }
8
-}
9
-
10
-allprojects {
11
-    repositories {
12
-        mavenLocal()
13
-        jcenter()
14
-        maven {
15
-            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
16
-            url "$projectDir/../../node_modules/react-native/android"
17
-        }
18
-    }
19
-}
20
-
21 1
 apply plugin: 'com.android.library'
22 2
 
23 3
 android {
@@ -70,7 +50,4 @@ dependencies {
70 50
     compile "com.android.support:appcompat-v7:23.0.1"
71 51
     compile 'com.android.support:design:23.1.1'
72 52
     compile "com.facebook.react:react-native:+"  // From node_modules
73
-
74
-    testCompile 'junit:junit:4.12'
75
-    testCompile "org.robolectric:robolectric:3.1.1"
76 53
 }

+ 284
- 305
android/app/src/main/java/com/reactnativenavigation/activities/BottomTabActivity.java Bestand weergeven

@@ -1,308 +1,287 @@
1 1
 package com.reactnativenavigation.activities;
2 2
 
3
-import android.graphics.Color;
4
-import android.graphics.drawable.Drawable;
5
-import android.os.AsyncTask;
6
-import android.os.Bundle;
7
-import android.support.design.widget.CoordinatorLayout;
8
-
9
-import com.aurelhubert.ahbottomnavigation.AHBottomNavigation;
10
-import com.aurelhubert.ahbottomnavigation.AHBottomNavigationItem;
11
-import com.facebook.react.bridge.ReadableMap;
12
-import com.reactnativenavigation.R;
13
-import com.reactnativenavigation.core.objects.Drawer;
14
-import com.reactnativenavigation.core.objects._Screen;
15
-import com.reactnativenavigation.utils.StyleHelper;
16
-import com.reactnativenavigation.views.BottomNavigation;
17
-import com.reactnativenavigation.views.RnnToolBar;
18
-import com.reactnativenavigation.views.ScreenStack;
19
-
20
-import java.util.ArrayList;
21
-import java.util.HashMap;
22
-import java.util.Map;
23
-
24
-public class BottomTabActivity extends BaseReactActivity implements AHBottomNavigation.OnTabSelectedListener {
25
-    private static final String TAG = "BottomTabActivity";
26
-    public static final String DRAWER_PARAMS = "drawerParams";
27
-    public static final String EXTRA_SCREENS = "extraScreens";
28
-
29
-    private static final String TAB_STYLE_BUTTON_COLOR = "tabBarButtonColor";
30
-    private static final String TAB_STYLE_SELECTED_COLOR = "tabBarSelectedButtonColor";
31
-    private static final String TAB_STYLE_BAR_BG_COLOR = "tabBarBackgroundColor";
32
-    private static final String TAB_STYLE_INACTIVE_TITLES = "tabShowInactiveTitles";
33
-
34
-    private static int DEFAULT_TAB_BAR_BG_COLOR = 0xFFFFFFFF;
35
-    private static int DEFAULT_TAB_BUTTON_COLOR = Color.GRAY;
36
-    private static int DEFAULT_TAB_SELECTED_COLOR = 0xFF0000FF;
37
-    private static boolean DEFAULT_TAB_INACTIVE_TITLES = true;
38
-
39
-    private BottomNavigation mBottomNavigation;
40
-    private CoordinatorLayout mContentFrame;
41
-    private ArrayList<ScreenStack> mScreenStacks;
42
-    private int mCurrentStackPosition = -1;
43
-
44
-    @Override
45
-    protected void handleOnCreate() {
46
-        super.handleOnCreate();
47
-        reactInstanceManager = RctManager.getInstance().getReactInstanceManager();
48
-
49
-        setContentView(R.layout.bottom_tab_activity);
50
-        mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
51
-        mBottomNavigation = (BottomNavigation) findViewById(R.id.bottom_tab_bar);
52
-        mContentFrame = (CoordinatorLayout) findViewById(R.id.contentFrame);
53
-
54
-        final ArrayList<_Screen> screens = (ArrayList<_Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
55
-        final Drawer drawer = (Drawer) getIntent().getSerializableExtra(DRAWER_PARAMS);
56
-        mBottomNavigation.setForceTint(true);
57
-        setupDrawer(screens.get(0), drawer, R.id.drawerFrame, R.id.drawerLayout);
58
-        setupTabs(getIntent().getExtras());
59
-        setupPages(screens);
60
-
61
-        // Setup Toolbar after it's measured since icon height is dependent on Toolbar height
62
-        mContentFrame.post(new Runnable() {
63
-            @Override
64
-            public void run() {
65
-                setupToolbar(screens);
66
-            }
67
-        });
68
-    }
69
-
70
-    private void setupPages(ArrayList<_Screen> screens) {
71
-        new SetupTabsTask(this, toolbar, screens).execute();
72
-    }
73
-
74
-    private void setupToolbar(ArrayList<_Screen> screens) {
75
-        toolbar.setScreens(screens);
76
-        _Screen initialScreen = screens.get(0);
77
-        toolbar.update(initialScreen);
78
-        StyleHelper.updateStyles(toolbar, initialScreen);
79
-    }
80
-
81
-    @Override
82
-    protected void onResume() {
83
-        super.onResume();
84
-        if (mScreenStacks != null) {
85
-            StyleHelper.updateStyles(toolbar, getCurrentScreen());
86
-        }
87
-    }
88
-
89
-    private void setupTabs(Bundle style) {
90
-        mBottomNavigation.setForceTitlesDisplay(style.getBoolean(TAB_STYLE_INACTIVE_TITLES, DEFAULT_TAB_INACTIVE_TITLES));
91
-        mBottomNavigation.setForceTint(true);
92
-        mBottomNavigation.setDefaultBackgroundColor(getColor(style, TAB_STYLE_BAR_BG_COLOR, DEFAULT_TAB_BAR_BG_COLOR));
93
-        mBottomNavigation.setInactiveColor(getColor(style, TAB_STYLE_BUTTON_COLOR, DEFAULT_TAB_BUTTON_COLOR));
94
-        mBottomNavigation.setAccentColor(getColor(style, TAB_STYLE_SELECTED_COLOR, DEFAULT_TAB_SELECTED_COLOR));
95
-    }
96
-
97
-    private static int getColor(Bundle bundle, String key, int defaultColor) {
98
-        if (bundle.containsKey(key)) {
99
-            return Color.parseColor(bundle.getString(key));
100
-        } else {
101
-            return defaultColor;
102
-        }
103
-    }
104
-
105
-    @Override
106
-    public void push(_Screen screen) {
107
-        super.push(screen);
108
-        for (ScreenStack stack : mScreenStacks) {
109
-            if (stack.peek().navigatorId.equals(screen.navigatorId)) {
110
-                stack.push(screen);
111
-            }
112
-        }
113
-        StyleHelper.updateStyles(toolbar, getCurrentScreen());
114
-
115
-        if (shouldToggleTabs(screen)) {
116
-            mBottomNavigation.toggleTabs(screen.bottomTabsHidden, false);
117
-        }
118
-    }
119
-
120
-    @Override
121
-    public _Screen pop(String navigatorId) {
122
-        super.pop(navigatorId);
123
-        for (ScreenStack stack : mScreenStacks) {
124
-            if (stack.peek().navigatorId.equals(navigatorId)) {
125
-                _Screen popped = stack.pop();
126
-                _Screen currentScreen = getCurrentScreen();
127
-                StyleHelper.updateStyles(toolbar, currentScreen);
128
-
129
-                if (shouldToggleTabs(currentScreen)) {
130
-                    mBottomNavigation.toggleTabs(currentScreen.bottomTabsHidden, false);
131
-                }
132
-
133
-                return popped;
134
-            }
135
-        }
136
-        return null;
137
-    }
138
-
139
-    @Override
140
-    public _Screen popToRoot(String navigatorId) {
141
-        super.popToRoot(navigatorId);
142
-        for (ScreenStack stack : mScreenStacks) {
143
-            if (stack.peek().navigatorId.equals(navigatorId)) {
144
-                _Screen popped = stack.popToRoot();
145
-                _Screen currentScreen = getCurrentScreen();
146
-                StyleHelper.updateStyles(toolbar, currentScreen);
147
-
148
-                if (shouldToggleTabs(currentScreen)) {
149
-                    mBottomNavigation.toggleTabs(currentScreen.bottomTabsHidden, false);
150
-                }
151
-
152
-                return popped;
153
-            }
154
-        }
155
-        return null;
156
-    }
157
-
158
-    @Override
159
-    public _Screen getCurrentScreen() {
160
-        _Screen currentScreen = super.getCurrentScreen();
161
-        if (currentScreen != null) {
162
-            return currentScreen;
163
-        }
164
-
165
-        return mScreenStacks != null ? mScreenStacks.get(mCurrentStackPosition).peek() : null;
166
-    }
167
-
168
-    public _Screen resetTo(_Screen screen) {
169
-        super.resetTo(screen);
170
-        StyleHelper.updateStyles(toolbar, screen);
171
-        return mScreenStacks.get(mCurrentStackPosition).resetTo(screen);
172
-    }
173
-
174
-    @Override
175
-    protected String getCurrentNavigatorId() {
176
-        return mScreenStacks.get(mCurrentStackPosition).peek().navigatorId;
177
-    }
178
-
179
-    @Override
180
-    public int getScreenStackSize() {
181
-        return mScreenStacks.get(mCurrentStackPosition).getStackSize();
182
-    }
183
-
184
-    @Override
185
-    public void onTabSelected(int position, boolean wasSelected) {
186
-        if (wasSelected) {
187
-            return;
188
-        }
189
-
190
-        // Remove current ScreenStack
191
-        if (mCurrentStackPosition >= 0) {
192
-            mScreenStacks.get(mCurrentStackPosition).removeFromScreen(mContentFrame);
193
-        }
194
-
195
-        // Add new ScreenStack
196
-        mScreenStacks.get(position).addToScreen(mContentFrame);
197
-
198
-        mCurrentStackPosition = position;
199
-        StyleHelper.updateStyles(toolbar, getCurrentScreen());
200
-
201
-        // Hide or show back button if needed
202
-        if (getScreenStackSize() > 1) {
203
-            toolbar.setNavUpButton(getCurrentScreen());
204
-        } else {
205
-            toolbar.setNavUpButton();
206
-        }
207
-    }
208
-
209
-    public void setTabBadge(ReadableMap params) {
210
-        // Badge comes across as int, but if it's 0 clear the notification
211
-        int badgeCount = params.getInt(KEY_BADGE);
212
-        String badge = (badgeCount > 0) ? Integer.toString(badgeCount) : "";
213
-
214
-        // Tab index is optional, so default to current tab
215
-        int tabIndex = mBottomNavigation.getCurrentItem();
216
-        if (params.hasKey(KEY_TAB_INDEX)) {
217
-            tabIndex = params.getInt(KEY_TAB_INDEX);
218
-        }
219
-
220
-        mBottomNavigation.setNotification(badge, tabIndex);
221
-    }
222
-
223
-    public void switchToTab(ReadableMap params) {
224
-        Integer tabIndex;
225
-        if (params.hasKey(KEY_TAB_INDEX)) {
226
-            tabIndex = params.getInt(KEY_TAB_INDEX);
227
-        } else {
228
-            final String navigatorId = params.getString(KEY_NAVIGATOR_ID);
229
-            tabIndex = findNavigatorTabIndex(navigatorId);
230
-        }
231
-        mBottomNavigation.setCurrentItem(tabIndex);
232
-    }
233
-
234
-    public void toggleTabs(ReadableMap params) {
235
-        boolean hide = params.getBoolean(KEY_HIDDEN);
236
-        boolean animated = params.getBoolean(KEY_ANIMATED);
237
-        mBottomNavigation.toggleTabs(hide, animated);
238
-    }
239
-
240
-    private boolean shouldToggleTabs(_Screen newScreen) {
241
-        return mBottomNavigation.isShown() == newScreen.bottomTabsHidden;
242
-    }
243
-
244
-    public void onScrollChanged(int direction) {
245
-        mBottomNavigation.onScroll(direction);
246
-    }
247
-
248
-    private static class SetupTabsTask extends AsyncTask<Void, Void, Map<_Screen, Drawable>> {
249
-        private BottomTabActivity mActivity;
250
-        private RnnToolBar mToolBar;
251
-        private ArrayList<_Screen> mScreens;
252
-
253
-        public SetupTabsTask(BottomTabActivity context, RnnToolBar toolBar, ArrayList<_Screen> screens) {
254
-            mActivity = context;
255
-            mToolBar = toolBar;
256
-            mScreens = screens;
257
-        }
258
-
259
-        @Override
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) {
264
-                    icons.put(screen, screen.getIcon(this.mActivity));
265
-                }
266
-            }
267
-            return icons;
268
-        }
269
-
270
-        @Override
271
-        protected void onPostExecute(Map<_Screen, Drawable> icons) {
272
-            mActivity.setTabsWithIcons(mScreens, icons);
273
-            StyleHelper.updateStyles(mToolBar, mActivity.getCurrentScreen());
274
-        }
275
-    }
276
-
277
-    protected Integer findNavigatorTabIndex(String navigatorId) {
278
-        for (int i = 0; i < mScreenStacks.size(); i++) {
279
-            ScreenStack stack = mScreenStacks.get(i);
280
-            if (!stack.isEmpty() && stack.peek().navigatorId.equals(navigatorId)) {
281
-                return i;
282
-            }
283
-        }
284
-
285
-        return null;
286
-    }
287
-
288
-    private void setTabsWithIcons(ArrayList<_Screen> screens, Map<_Screen, Drawable> icons) {
289
-        mScreenStacks = new ArrayList<>();
290
-        for (int i = 0; i < screens.size(); i++) {
291
-            final _Screen screen = screens.get(i);
292
-            ScreenStack stack = new ScreenStack(this);
293
-            stack.push(screen);
294
-            mScreenStacks.add(stack);
295
-            AHBottomNavigationItem item = new AHBottomNavigationItem(screen.label, icons.get(screen), Color.GRAY);
296
-            mBottomNavigation.addItem(item);
297
-            mBottomNavigation.setOnTabSelectedListener(this);
298
-        }
299
-        this.onTabSelected(0, false);
300
-    }
301
-
302
-    @Override
303
-    protected void removeAllReactViews() {
304
-        for (ScreenStack screenStack : mScreenStacks) {
305
-            screenStack.removeAllReactViews();
306
-        }
307
-    }
3
+public class BottomTabActivity  {
4
+//    private static final String TAG = "BottomTabActivity";
5
+//    public static final String DRAWER_PARAMS = "drawerParams";
6
+//    public static final String EXTRA_SCREENS = "extraScreens";
7
+//
8
+//    private static final String TAB_STYLE_BUTTON_COLOR = "tabBarButtonColor";
9
+//    private static final String TAB_STYLE_SELECTED_COLOR = "tabBarSelectedButtonColor";
10
+//    private static final String TAB_STYLE_BAR_BG_COLOR = "tabBarBackgroundColor";
11
+//    private static final String TAB_STYLE_INACTIVE_TITLES = "tabShowInactiveTitles";
12
+//
13
+//    private static int DEFAULT_TAB_BAR_BG_COLOR = 0xFFFFFFFF;
14
+//    private static int DEFAULT_TAB_BUTTON_COLOR = Color.GRAY;
15
+//    private static int DEFAULT_TAB_SELECTED_COLOR = 0xFF0000FF;
16
+//    private static boolean DEFAULT_TAB_INACTIVE_TITLES = true;
17
+//
18
+//    private BottomNavigation mBottomNavigation;
19
+//    private CoordinatorLayout mContentFrame;
20
+//    private ArrayList<ScreenStack> mScreenStacks;
21
+//    private int mCurrentStackPosition = -1;
22
+//
23
+//    @Override
24
+//    protected void handleOnCreate() {
25
+//        super.handleOnCreate();
26
+//        reactInstanceManager = RctManager.getInstance().getReactInstanceManager();
27
+//
28
+//        setContentView(R.layout.bottom_tab_activity);
29
+//        mToolbar = (RnnToolBar) findViewById(R.id.toolbar);
30
+//        mBottomNavigation = (BottomNavigation) findViewById(R.id.bottom_tab_bar);
31
+//        mContentFrame = (CoordinatorLayout) findViewById(R.id.contentFrame);
32
+//
33
+//        final ArrayList<_Screen> screens = (ArrayList<_Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
34
+//        final Drawer drawer = (Drawer) getIntent().getSerializableExtra(DRAWER_PARAMS);
35
+//        mBottomNavigation.setForceTint(true);
36
+//        setupDrawer(screens.get(0), drawer, R.id.drawerFrame, R.id.drawerLayout);
37
+//        setupTabs(getIntent().getExtras());
38
+//        setupPages(screens);
39
+//
40
+//        // Setup Toolbar after it's measured since icon height is dependent on Toolbar height
41
+//        mContentFrame.post(new Runnable() {
42
+//            @Override
43
+//            public void run() {
44
+//                setupToolbar(screens);
45
+//            }
46
+//        });
47
+//    }
48
+//
49
+//    private void setupPages(ArrayList<_Screen> screens) {
50
+//        new SetupTabsTask(this, toolbar, screens).execute();
51
+//    }
52
+//
53
+//    private void setupToolbar(ArrayList<_Screen> screens) {
54
+//        toolbar.setScreens(screens);
55
+//        _Screen initialScreen = screens.get(0);
56
+//        toolbar.update(initialScreen);
57
+//        StyleHelper.updateStyles(toolbar, initialScreen);
58
+//    }
59
+//
60
+//    @Override
61
+//    protected void onResume() {
62
+//        super.onResume();
63
+//        if (mScreenStacks != null) {
64
+//            StyleHelper.updateStyles(toolbar, getCurrentScreen());
65
+//        }
66
+//    }
67
+//
68
+//    private void setupTabs(Bundle style) {
69
+//        mBottomNavigation.setForceTitlesDisplay(style.getBoolean(TAB_STYLE_INACTIVE_TITLES, DEFAULT_TAB_INACTIVE_TITLES));
70
+//        mBottomNavigation.setForceTint(true);
71
+//        mBottomNavigation.setDefaultBackgroundColor(getColor(style, TAB_STYLE_BAR_BG_COLOR, DEFAULT_TAB_BAR_BG_COLOR));
72
+//        mBottomNavigation.setInactiveColor(getColor(style, TAB_STYLE_BUTTON_COLOR, DEFAULT_TAB_BUTTON_COLOR));
73
+//        mBottomNavigation.setAccentColor(getColor(style, TAB_STYLE_SELECTED_COLOR, DEFAULT_TAB_SELECTED_COLOR));
74
+//    }
75
+//
76
+//    private static int getColor(Bundle bundle, String key, int defaultColor) {
77
+//        if (bundle.containsKey(key)) {
78
+//            return Color.parseColor(bundle.getString(key));
79
+//        } else {
80
+//            return defaultColor;
81
+//        }
82
+//    }
83
+//
84
+//    @Override
85
+//    public void push(_Screen screen) {
86
+//        super.push(screen);
87
+//        for (ScreenStack stack : mScreenStacks) {
88
+//            if (stack.peek().navigatorId.equals(screen.navigatorId)) {
89
+//                stack.push(screen);
90
+//            }
91
+//        }
92
+//        StyleHelper.updateStyles(toolbar, getCurrentScreen());
93
+//
94
+//        if (shouldToggleTabs(screen)) {
95
+//            mBottomNavigation.toggleTabs(screen.bottomTabsHidden, false);
96
+//        }
97
+//    }
98
+//
99
+//    @Override
100
+//    public _Screen pop(String navigatorId) {
101
+//        super.pop(navigatorId);
102
+//        for (ScreenStack stack : mScreenStacks) {
103
+//            if (stack.peek().navigatorId.equals(navigatorId)) {
104
+//                _Screen popped = stack.pop();
105
+//                _Screen currentScreen = getCurrentScreen();
106
+//                StyleHelper.updateStyles(toolbar, currentScreen);
107
+//
108
+//                if (shouldToggleTabs(currentScreen)) {
109
+//                    mBottomNavigation.toggleTabs(currentScreen.bottomTabsHidden, false);
110
+//                }
111
+//
112
+//                return popped;
113
+//            }
114
+//        }
115
+//        return null;
116
+//    }
117
+//
118
+//    @Override
119
+//    public _Screen popToRoot(String navigatorId) {
120
+//        super.popToRoot(navigatorId);
121
+//        for (ScreenStack stack : mScreenStacks) {
122
+//            if (stack.peek().navigatorId.equals(navigatorId)) {
123
+//                _Screen popped = stack.popToRoot();
124
+//                _Screen currentScreen = getCurrentScreen();
125
+//                StyleHelper.updateStyles(toolbar, currentScreen);
126
+//
127
+//                if (shouldToggleTabs(currentScreen)) {
128
+//                    mBottomNavigation.toggleTabs(currentScreen.bottomTabsHidden, false);
129
+//                }
130
+//
131
+//                return popped;
132
+//            }
133
+//        }
134
+//        return null;
135
+//    }
136
+//
137
+//    @Override
138
+//    public _Screen getCurrentScreen() {
139
+//        _Screen currentScreen = super.getCurrentScreen();
140
+//        if (currentScreen != null) {
141
+//            return currentScreen;
142
+//        }
143
+//
144
+//        return mScreenStacks != null ? mScreenStacks.get(mCurrentStackPosition).peek() : null;
145
+//    }
146
+//
147
+//    public _Screen resetTo(_Screen screen) {
148
+//        super.resetTo(screen);
149
+//        StyleHelper.updateStyles(toolbar, screen);
150
+//        return mScreenStacks.get(mCurrentStackPosition).resetTo(screen);
151
+//    }
152
+//
153
+//    @Override
154
+//    protected String getCurrentNavigatorId() {
155
+//        return mScreenStacks.get(mCurrentStackPosition).peek().navigatorId;
156
+//    }
157
+//
158
+//    @Override
159
+//    public int getScreenStackSize() {
160
+//        return mScreenStacks.get(mCurrentStackPosition).getStackSize();
161
+//    }
162
+//
163
+//    @Override
164
+//    public void onTabSelected(int position, boolean wasSelected) {
165
+//        if (wasSelected) {
166
+//            return;
167
+//        }
168
+//
169
+//        // Remove current ScreenStack
170
+//        if (mCurrentStackPosition >= 0) {
171
+//            mScreenStacks.get(mCurrentStackPosition).removeFromScreen(mContentFrame);
172
+//        }
173
+//
174
+//        // Add new ScreenStack
175
+//        mScreenStacks.get(position).addToScreen(mContentFrame);
176
+//
177
+//        mCurrentStackPosition = position;
178
+//        StyleHelper.updateStyles(toolbar, getCurrentScreen());
179
+//
180
+//        // Hide or show back button if needed
181
+//        if (getScreenStackSize() > 1) {
182
+//            toolbar.setNavUpButton(getCurrentScreen());
183
+//        } else {
184
+//            toolbar.setNavUpButton();
185
+//        }
186
+//    }
187
+//
188
+//    public void setTabBadge(ReadableMap params) {
189
+//        // Badge comes across as int, but if it's 0 clear the notification
190
+//        int badgeCount = params.getInt(KEY_BADGE);
191
+//        String badge = (badgeCount > 0) ? Integer.toString(badgeCount) : "";
192
+//
193
+//        // Tab index is optional, so default to current tab
194
+//        int tabIndex = mBottomNavigation.getCurrentItem();
195
+//        if (params.hasKey(KEY_TAB_INDEX)) {
196
+//            tabIndex = params.getInt(KEY_TAB_INDEX);
197
+//        }
198
+//
199
+//        mBottomNavigation.setNotification(badge, tabIndex);
200
+//    }
201
+//
202
+//    public void switchToTab(ReadableMap params) {
203
+//        Integer tabIndex;
204
+//        if (params.hasKey(KEY_TAB_INDEX)) {
205
+//            tabIndex = params.getInt(KEY_TAB_INDEX);
206
+//        } else {
207
+//            final String navigatorId = params.getString(KEY_NAVIGATOR_ID);
208
+//            tabIndex = findNavigatorTabIndex(navigatorId);
209
+//        }
210
+//        mBottomNavigation.setCurrentItem(tabIndex);
211
+//    }
212
+//
213
+//    public void toggleTabs(ReadableMap params) {
214
+//        boolean hide = params.getBoolean(KEY_HIDDEN);
215
+//        boolean animated = params.getBoolean(KEY_ANIMATED);
216
+//        mBottomNavigation.toggleTabs(hide, animated);
217
+//    }
218
+//
219
+//    private boolean shouldToggleTabs(_Screen newScreen) {
220
+//        return mBottomNavigation.isShown() == newScreen.bottomTabsHidden;
221
+//    }
222
+//
223
+//    public void onScrollChanged(int direction) {
224
+//        mBottomNavigation.onScroll(direction);
225
+//    }
226
+//
227
+//    private static class SetupTabsTask extends AsyncTask<Void, Void, Map<_Screen, Drawable>> {
228
+//        private BottomTabActivity mActivity;
229
+//        private RnnToolBar mToolBar;
230
+//        private ArrayList<_Screen> mScreens;
231
+//
232
+//        public SetupTabsTask(BottomTabActivity context, RnnToolBar toolBar, ArrayList<_Screen> screens) {
233
+//            mActivity = context;
234
+//            mToolBar = toolBar;
235
+//            mScreens = screens;
236
+//        }
237
+//
238
+//        @Override
239
+//        protected Map<_Screen, Drawable> doInBackground(Void... params) {
240
+//            Map<_Screen, Drawable> icons = new HashMap<>();
241
+//            for (_Screen screen : mScreens) {
242
+//                if (screen.icon != null) {
243
+//                    icons.put(screen, screen.getIcon(this.mActivity));
244
+//                }
245
+//            }
246
+//            return icons;
247
+//        }
248
+//
249
+//        @Override
250
+//        protected void onPostExecute(Map<_Screen, Drawable> icons) {
251
+//            mActivity.setTabsWithIcons(mScreens, icons);
252
+//            StyleHelper.updateStyles(mToolBar, mActivity.getCurrentScreen());
253
+//        }
254
+//    }
255
+//
256
+//    protected Integer findNavigatorTabIndex(String navigatorId) {
257
+//        for (int i = 0; i < mScreenStacks.size(); i++) {
258
+//            ScreenStack stack = mScreenStacks.get(i);
259
+//            if (!stack.isEmpty() && stack.peek().navigatorId.equals(navigatorId)) {
260
+//                return i;
261
+//            }
262
+//        }
263
+//
264
+//        return null;
265
+//    }
266
+//
267
+//    private void setTabsWithIcons(ArrayList<_Screen> screens, Map<_Screen, Drawable> icons) {
268
+//        mScreenStacks = new ArrayList<>();
269
+//        for (int i = 0; i < screens.size(); i++) {
270
+//            final _Screen screen = screens.get(i);
271
+//            ScreenStack stack = new ScreenStack(this);
272
+//            stack.push(screen);
273
+//            mScreenStacks.add(stack);
274
+//            AHBottomNavigationItem item = new AHBottomNavigationItem(screen.label, icons.get(screen), Color.GRAY);
275
+//            mBottomNavigation.addItem(item);
276
+//            mBottomNavigation.setOnTabSelectedListener(this);
277
+//        }
278
+//        this.onTabSelected(0, false);
279
+//    }
280
+//
281
+//    @Override
282
+//    protected void removeAllReactViews() {
283
+//        for (ScreenStack screenStack : mScreenStacks) {
284
+//            screenStack.removeAllReactViews();
285
+//        }
286
+//    }
308 287
 }

+ 111
- 121
android/app/src/main/java/com/reactnativenavigation/activities/SingleScreenActivity.java Bestand weergeven

@@ -1,124 +1,114 @@
1 1
 package com.reactnativenavigation.activities;
2 2
 
3
-import android.support.design.widget.CoordinatorLayout;
4
-
5
-import com.facebook.react.bridge.ReadableMap;
6
-import com.reactnativenavigation.R;
7
-import com.reactnativenavigation.core.objects.Drawer;
8
-import com.reactnativenavigation.core.objects._Screen;
9
-import com.reactnativenavigation.utils.StyleHelper;
10
-import com.reactnativenavigation.views.RnnToolBar;
11
-import com.reactnativenavigation.views.ScreenStack;
12
-
13
-public class SingleScreenActivity extends BaseReactActivity {
14
-
15
-    public static final String DRAWER_PARAMS = "drawerParams";
16
-    public static final String EXTRA_SCREEN = "extraScreen";
17
-
18
-    private ScreenStack mScreenStack;
19
-    private String mNavigatorId;
20
-
21
-    @Override
22
-    protected void handleOnCreate() {
23
-        super.handleOnCreate();
24
-        reactInstanceManager = RctManager.getInstance().getReactInstanceManager();
25
-
26
-        setContentView(R.layout.single_screen_activity);
27
-        toolbar = (RnnToolBar) findViewById(R.id.toolbar);
28
-
29
-        final _Screen screen = (_Screen) getIntent().getSerializableExtra(EXTRA_SCREEN);
30
-        final Drawer drawer = (Drawer) getIntent().getSerializableExtra(DRAWER_PARAMS);
31
-
32
-        mNavigatorId = screen.navigatorId;
33
-        setupToolbar(screen);
34
-        setupDrawer(screen, drawer, R.id.drawerFrame, R.id.drawerLayout);
35
-
36
-        mScreenStack = new ScreenStack(this);
37
-        CoordinatorLayout contentFrame = (CoordinatorLayout) findViewById(R.id.contentFrame);
38
-        assert contentFrame != null;
39
-        contentFrame.addView(mScreenStack);
40
-        mScreenStack.push(screen);
41
-
42
-        // Setup Toolbar after it's measured since icon height is dependent on Toolbar height
43
-        contentFrame.post(new Runnable() {
44
-            @Override
45
-            public void run() {
46
-                setupToolbar(screen);
47
-            }
48
-        });
49
-    }
50
-
51
-    protected void setupToolbar(_Screen screen) {
52
-        StyleHelper.updateStyles(toolbar, screen);
53
-    }
54
-
55
-    @Override
56
-    public void push(_Screen screen) {
57
-        super.push(screen);
58
-        mScreenStack.push(screen);
59
-        StyleHelper.updateStyles(toolbar, screen);
60
-    }
61
-
62
-    @Override
63
-    public _Screen pop(String navigatorId) {
64
-        super.pop(navigatorId);
65
-        _Screen popped = mScreenStack.pop();
66
-        StyleHelper.updateStyles(toolbar, getCurrentScreen());
67
-        return popped;
68
-    }
69
-
70
-    @Override
71
-    public _Screen popToRoot(String navigatorId) {
72
-        super.popToRoot(navigatorId);
73
-        _Screen screen = mScreenStack.popToRoot();
74
-        StyleHelper.updateStyles(toolbar, getCurrentScreen());
75
-        return screen;
76
-    }
77
-
78
-    @Override
79
-    public _Screen resetTo(_Screen screen) {
80
-        super.resetTo(screen);
81
-        _Screen popped = mScreenStack.resetTo(screen);
82
-        StyleHelper.updateStyles(toolbar, screen);
83
-        return popped;
84
-    }
85
-
86
-    @Override
87
-    public String getCurrentNavigatorId() {
88
-        return mNavigatorId;
89
-    }
90
-
91
-    @Override
92
-    public _Screen getCurrentScreen() {
93
-        _Screen currentScreen = super.getCurrentScreen();
94
-        if (currentScreen != null) {
95
-            return currentScreen;
96
-        }
97
-
98
-        return mScreenStack.peek();
99
-    }
100
-
101
-    @Override
102
-    public int getScreenStackSize() {
103
-        return mScreenStack.getStackSize();
104
-    }
105
-
106
-    @Override
107
-    protected void removeAllReactViews() {
108
-        mScreenStack.removeAllReactViews();
109
-    }
110
-
111
-    @Override
112
-    public void showFAB(ReadableMap params) {
113
-//        FloatingActionButton fab = new FloatingActionButton(this);
114
-//        fab.setImageDrawable(IconUtils.getIcon(this, params.getString("icon")));
115
-//        fab.setBackgroundColor(Color.parseColor(params.getString("backgroundColor")));
116
-//        fab.setImageResource(R.drawable.notification_background);
117
-//        CoordinatorLayout content = (CoordinatorLayout) findViewById(R.id.contentFrame);
118
-//        CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
119
-//        layoutParams.gravity = Gravity.BOTTOM | Gravity.END;
120
-//        int m = (int) ImageUtils.convertDpToPixel(16, this);
121
-//        layoutParams.setMargins(m, m, m, m);
122
-//        content.addView(fab, layoutParams);
123
-    }
3
+public class SingleScreenActivity {
4
+//
5
+//    public static final String DRAWER_PARAMS = "drawerParams";
6
+//    public static final String EXTRA_SCREEN = "extraScreen";
7
+//
8
+//    private ScreenStack mScreenStack;
9
+//    private String mNavigatorId;
10
+//
11
+//    @Override
12
+//    protected void handleOnCreate() {
13
+//        super.handleOnCreate();
14
+//        reactInstanceManager = RctManager.getInstance().getReactInstanceManager();
15
+//
16
+//        setContentView(R.layout.single_screen_activity);
17
+//        toolbar = (RnnToolBar) findViewById(R.id.toolbar);
18
+//
19
+//        final _Screen screen = (_Screen) getIntent().getSerializableExtra(EXTRA_SCREEN);
20
+//        final Drawer drawer = (Drawer) getIntent().getSerializableExtra(DRAWER_PARAMS);
21
+//
22
+//        mNavigatorId = screen.navigatorId;
23
+//        setupToolbar(screen);
24
+//        setupDrawer(screen, drawer, R.id.drawerFrame, R.id.drawerLayout);
25
+//
26
+//        mScreenStack = new ScreenStack(this);
27
+//        CoordinatorLayout contentFrame = (CoordinatorLayout) findViewById(R.id.contentFrame);
28
+//        assert contentFrame != null;
29
+//        contentFrame.addView(mScreenStack);
30
+//        mScreenStack.push(screen);
31
+//
32
+//        // Setup Toolbar after it's measured since icon height is dependent on Toolbar height
33
+//        contentFrame.post(new Runnable() {
34
+//            @Override
35
+//            public void run() {
36
+//                setupToolbar(screen);
37
+//            }
38
+//        });
39
+//    }
40
+//
41
+//    protected void setupToolbar(_Screen screen) {
42
+//        StyleHelper.updateStyles(toolbar, screen);
43
+//    }
44
+//
45
+//    @Override
46
+//    public void push(_Screen screen) {
47
+//        super.push(screen);
48
+//        mScreenStack.push(screen);
49
+//        StyleHelper.updateStyles(toolbar, screen);
50
+//    }
51
+//
52
+//    @Override
53
+//    public _Screen pop(String navigatorId) {
54
+//        super.pop(navigatorId);
55
+//        _Screen popped = mScreenStack.pop();
56
+//        StyleHelper.updateStyles(toolbar, getCurrentScreen());
57
+//        return popped;
58
+//    }
59
+//
60
+//    @Override
61
+//    public _Screen popToRoot(String navigatorId) {
62
+//        super.popToRoot(navigatorId);
63
+//        _Screen screen = mScreenStack.popToRoot();
64
+//        StyleHelper.updateStyles(toolbar, getCurrentScreen());
65
+//        return screen;
66
+//    }
67
+//
68
+//    @Override
69
+//    public _Screen resetTo(_Screen screen) {
70
+//        super.resetTo(screen);
71
+//        _Screen popped = mScreenStack.resetTo(screen);
72
+//        StyleHelper.updateStyles(toolbar, screen);
73
+//        return popped;
74
+//    }
75
+//
76
+//    @Override
77
+//    public String getCurrentNavigatorId() {
78
+//        return mNavigatorId;
79
+//    }
80
+//
81
+//    @Override
82
+//    public _Screen getCurrentScreen() {
83
+//        _Screen currentScreen = super.getCurrentScreen();
84
+//        if (currentScreen != null) {
85
+//            return currentScreen;
86
+//        }
87
+//
88
+//        return mScreenStack.peek();
89
+//    }
90
+//
91
+//    @Override
92
+//    public int getScreenStackSize() {
93
+//        return mScreenStack.getStackSize();
94
+//    }
95
+//
96
+//    @Override
97
+//    protected void removeAllReactViews() {
98
+//        mScreenStack.removeAllReactViews();
99
+//    }
100
+//
101
+//    @Override
102
+//    public void showFAB(ReadableMap params) {
103
+////        FloatingActionButton fab = new FloatingActionButton(this);
104
+////        fab.setImageDrawable(IconUtils.getIcon(this, params.getString("icon")));
105
+////        fab.setBackgroundColor(Color.parseColor(params.getString("backgroundColor")));
106
+////        fab.setImageResource(R.drawable.notification_background);
107
+////        CoordinatorLayout content = (CoordinatorLayout) findViewById(R.id.contentFrame);
108
+////        CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
109
+////        layoutParams.gravity = Gravity.BOTTOM | Gravity.END;
110
+////        int m = (int) ImageUtils.convertDpToPixel(16, this);
111
+////        layoutParams.setMargins(m, m, m, m);
112
+////        content.addView(fab, layoutParams);
113
+//    }
124 114
 }

+ 83
- 95
android/app/src/main/java/com/reactnativenavigation/activities/TabActivity.java Bestand weergeven

@@ -1,103 +1,91 @@
1 1
 package com.reactnativenavigation.activities;
2 2
 
3
-import android.support.v4.view.ViewPager;
4
-import android.view.Menu;
5
-
6
-import com.reactnativenavigation.R;
7
-import com.reactnativenavigation.adapters.ViewPagerAdapter;
8
-import com.reactnativenavigation.core.objects._Screen;
9
-import com.reactnativenavigation.utils.StyleHelper;
10
-import com.reactnativenavigation.views.RnnTabLayout;
11
-import com.reactnativenavigation.views.RnnToolBar;
12
-
13
-import java.util.ArrayList;
14
-
15 3
 /**
16 4
  * This class is currently not supported and will be removed in future release.
17 5
  * Created by guyc on 02/04/16.
18 6
  */
19 7
 @Deprecated
20
-public class TabActivity extends BaseReactActivity {
21
-    public static final String EXTRA_SCREENS = "extraScreens";
22
-
23
-    private RnnTabLayout mTabLayout;
24
-    private ViewPager mViewPager;
25
-    private ViewPagerAdapter mAdapter;
26
-
27
-    @Override
28
-    protected void handleOnCreate() {
29
-        super.handleOnCreate();
30
-        reactInstanceManager = RctManager.getInstance().getReactInstanceManager();
31
-
32
-        setContentView(R.layout.tab_activity);
33
-        toolbar = (RnnToolBar) findViewById(R.id.toolbar);
34
-        mTabLayout = (RnnTabLayout) findViewById(R.id.tabLayout);
35
-        mViewPager = (ViewPager) findViewById(R.id.viewPager);
36
-
37
-        ArrayList<_Screen> screens = (ArrayList<_Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
38
-
39
-        setupToolbar(screens);
40
-        setupViewPager(screens);
41
-    }
42
-
43
-    private void setupToolbar(ArrayList<_Screen> screens) {
44
-        _Screen initialScreen = screens.get(0);
45
-        toolbar.setScreens(screens);
46
-        toolbar.update(initialScreen);
47
-        setNavigationStyle(initialScreen);
48
-    }
49
-
50
-    public void setNavigationStyle(_Screen screen) {
51
-        mTabLayout.setStyle(screen);
52
-    }
53
-
54
-    private void setupViewPager(ArrayList<_Screen> screens) {
55
-        mAdapter = new ViewPagerAdapter(this, mViewPager, toolbar, screens);
56
-        mViewPager.setAdapter(mAdapter);
57
-        mTabLayout.setupWithViewPager(mViewPager);
58
-        mTabLayout.setOnTabSelectedListener(mAdapter);
59
-        mAdapter.notifyDataSetChanged();
60
-    }
61
-
62
-    @Override
63
-    public boolean onCreateOptionsMenu(Menu menu) {
64
-        boolean ret = super.onCreateOptionsMenu(menu);
65
-        toolbar.handleOnCreateOptionsMenuAsync();
66
-        return ret;
67
-    }
68
-
69
-    @Override
70
-    public void removeAllReactViews() {
71
-
72
-    }
73
-
74
-    @Override
75
-    public void push(_Screen screen) {
76
-        super.push(screen);
77
-        StyleHelper.updateStyles(toolbar, screen);
78
-        mAdapter.push(screen);
79
-    }
80
-
81
-    @Override
82
-    public _Screen pop(String navigatorId) {
83
-        super.pop(navigatorId);
84
-        _Screen popped = mAdapter.pop(navigatorId);
85
-        setNavigationStyle(getCurrentScreen());
86
-        return popped;
87
-    }
88
-
89
-    @Override
90
-    public _Screen getCurrentScreen() {
91
-        return mAdapter.peek(getCurrentNavigatorId());
92
-    }
93
-
94
-    @Override
95
-    protected String getCurrentNavigatorId() {
96
-        return mAdapter.getNavigatorId(mViewPager.getCurrentItem());
97
-    }
98
-
99
-    @Override
100
-    public int getScreenStackSize() {
101
-        return mAdapter.getStackSizeForNavigatorId(getCurrentNavigatorId());
102
-    }
8
+public class TabActivity {
9
+//    public static final String EXTRA_SCREENS = "extraScreens";
10
+//
11
+//    private RnnTabLayout mTabLayout;
12
+//    private ViewPager mViewPager;
13
+//    private ViewPagerAdapter mAdapter;
14
+//
15
+//    @Override
16
+//    protected void handleOnCreate() {
17
+//        super.handleOnCreate();
18
+//        reactInstanceManager = RctManager.getInstance().getReactInstanceManager();
19
+//
20
+//        setContentView(R.layout.tab_activity);
21
+//        toolbar = (RnnToolBar) findViewById(R.id.toolbar);
22
+//        mTabLayout = (RnnTabLayout) findViewById(R.id.tabLayout);
23
+//        mViewPager = (ViewPager) findViewById(R.id.viewPager);
24
+//
25
+//        ArrayList<_Screen> screens = (ArrayList<_Screen>) getIntent().getSerializableExtra(EXTRA_SCREENS);
26
+//
27
+//        setupToolbar(screens);
28
+//        setupViewPager(screens);
29
+//    }
30
+//
31
+//    private void setupToolbar(ArrayList<_Screen> screens) {
32
+//        _Screen initialScreen = screens.get(0);
33
+//        toolbar.setScreens(screens);
34
+//        toolbar.update(initialScreen);
35
+//        setNavigationStyle(initialScreen);
36
+//    }
37
+//
38
+//    public void setNavigationStyle(_Screen screen) {
39
+//        mTabLayout.setStyle(screen);
40
+//    }
41
+//
42
+//    private void setupViewPager(ArrayList<_Screen> screens) {
43
+//        mAdapter = new ViewPagerAdapter(this, mViewPager, toolbar, screens);
44
+//        mViewPager.setAdapter(mAdapter);
45
+//        mTabLayout.setupWithViewPager(mViewPager);
46
+//        mTabLayout.setOnTabSelectedListener(mAdapter);
47
+//        mAdapter.notifyDataSetChanged();
48
+//    }
49
+//
50
+//    @Override
51
+//    public boolean onCreateOptionsMenu(Menu menu) {
52
+//        boolean ret = super.onCreateOptionsMenu(menu);
53
+//        toolbar.handleOnCreateOptionsMenuAsync();
54
+//        return ret;
55
+//    }
56
+//
57
+//    @Override
58
+//    public void removeAllReactViews() {
59
+//
60
+//    }
61
+//
62
+//    @Override
63
+//    public void push(_Screen screen) {
64
+//        super.push(screen);
65
+//        StyleHelper.updateStyles(toolbar, screen);
66
+//        mAdapter.push(screen);
67
+//    }
68
+//
69
+//    @Override
70
+//    public _Screen pop(String navigatorId) {
71
+//        super.pop(navigatorId);
72
+//        _Screen popped = mAdapter.pop(navigatorId);
73
+//        setNavigationStyle(getCurrentScreen());
74
+//        return popped;
75
+//    }
76
+//
77
+//    @Override
78
+//    public _Screen getCurrentScreen() {
79
+//        return mAdapter.peek(getCurrentNavigatorId());
80
+//    }
81
+//
82
+//    @Override
83
+//    protected String getCurrentNavigatorId() {
84
+//        return mAdapter.getNavigatorId(mViewPager.getCurrentItem());
85
+//    }
86
+//
87
+//    @Override
88
+//    public int getScreenStackSize() {
89
+//        return mAdapter.getStackSizeForNavigatorId(getCurrentNavigatorId());
90
+//    }
103 91
 }

+ 129
- 147
android/app/src/main/java/com/reactnativenavigation/adapters/ViewPagerAdapter.java Bestand weergeven

@@ -1,153 +1,135 @@
1 1
 package com.reactnativenavigation.adapters;
2 2
 
3
-import android.support.design.widget.TabLayout;
4
-import android.support.v4.view.PagerAdapter;
5
-import android.support.v4.view.ViewPager;
6
-import android.view.View;
7
-import android.view.ViewGroup;
8
-
9
-import com.facebook.react.bridge.Arguments;
10
-import com.facebook.react.bridge.WritableMap;
11
-import com.reactnativenavigation.activities.BaseReactActivity;
12
-import com.reactnativenavigation.core.objects._Screen;
13
-import com.reactnativenavigation.utils.StyleHelper;
14
-import com.reactnativenavigation.views.RnnToolBar;
15
-import com.reactnativenavigation.views.ScreenStack;
16
-
17
-import java.util.ArrayList;
18
-import java.util.HashMap;
19
-import java.util.Map;
20
-
21 3
 /**
22 4
  * Created by guyc on 02/04/16.
23 5
  */
24
-public class ViewPagerAdapter extends PagerAdapter implements TabLayout.OnTabSelectedListener, ViewPager.OnPageChangeListener {
25
-
26
-    private static final String EVENT_ON_TAB_SELECTED = "OnTabSelected";
27
-
28
-    private ViewPager mViewPager;
29
-    private RnnToolBar mToolbar;
30
-    private final ArrayList<ScreenStack> mScreenStacks;
31
-    private final ArrayList<String> mNavigatorIds;
32
-    private final Map<String, ScreenStack> mStackByNavigatorId;
33
-    private int mCurrentPage = 0;
34
-
35
-    public ViewPagerAdapter(BaseReactActivity context, ViewPager viewPager, RnnToolBar toolbar,
36
-                            ArrayList<_Screen> screens) {
37
-        mViewPager = viewPager;
38
-        mToolbar = toolbar;
39
-        mScreenStacks = new ArrayList<>();
40
-        mNavigatorIds = new ArrayList<>();
41
-        mStackByNavigatorId = new HashMap<>();
42
-        for (_Screen screen : screens) {
43
-            ScreenStack stack = new ScreenStack(context);
44
-            stack.push(screen);
45
-            mScreenStacks.add(stack);
46
-            mNavigatorIds.add(screen.navigatorId);
47
-            mStackByNavigatorId.put(screen.navigatorId, stack);
48
-        }
49
-    }
50
-
51
-    public void push(_Screen screen) {
52
-        ScreenStack stack = mStackByNavigatorId.get(screen.navigatorId);
53
-        _Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
54
-        mToolbar.setupToolbarButtonsAsync(prevScreen, screen);
55
-        stack.push(screen);
56
-    }
57
-
58
-    public _Screen pop(String navigatorId) {
59
-        ScreenStack stack = mStackByNavigatorId.get(navigatorId);
60
-        _Screen oldScreen = stack != null ? stack.pop() : null;
61
-        _Screen newScreen = stack.peek();
62
-        mToolbar.setupToolbarButtonsAsync(oldScreen, newScreen);
63
-        return oldScreen;
64
-    }
65
-
66
-    public _Screen peek(String navigatorId) {
67
-        ScreenStack stack = mStackByNavigatorId.get(navigatorId);
68
-        return stack != null ? stack.peek() : null;
69
-    }
70
-
71
-    @Override
72
-    public Object instantiateItem(ViewGroup container, int position) {
73
-        ScreenStack view = mScreenStacks.get(position);
74
-        container.addView(view);
75
-        return view;
76
-    }
77
-
78
-    @Override
79
-    public void destroyItem(ViewGroup container, int position, Object view) {
80
-        container.removeView((View) view);
81
-    }
82
-
83
-    @Override
84
-    public int getCount() {
85
-        return mScreenStacks.size();
86
-    }
87
-
88
-    @Override
89
-    public boolean isViewFromObject(View view, Object object) {
90
-        return view == object;
91
-    }
92
-
93
-    @Override
94
-    public CharSequence getPageTitle(int position) {
95
-        return mScreenStacks.get(position).peek().label;
96
-    }
97
-
98
-    @Override
99
-    public void onTabSelected(TabLayout.Tab tab) {
100
-        // Set the viewPager's current item
101
-        int position = tab.getPosition();
102
-        mViewPager.setCurrentItem(position);
103
-
104
-        // Set screen buttons
105
-        _Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
106
-        _Screen newScreen = mScreenStacks.get(position).peek();
107
-        mToolbar.setupToolbarButtonsAsync(prevScreen, newScreen);
108
-
109
-        // Set title
110
-        mToolbar.setTitle(newScreen.title == null ? "" : newScreen.title);
111
-
112
-        // Set navigation color
113
-        StyleHelper.updateStyles(mToolbar, newScreen);
114
-
115
-        // Send tab selected event
116
-        WritableMap params = Arguments.createMap();
117
-        _Screen screen = mScreenStacks.get(position).peek();
118
-        RctManager.getInstance().sendEvent(EVENT_ON_TAB_SELECTED, screen, params);
119
-    }
120
-
121
-    @Override
122
-    public void onTabUnselected(TabLayout.Tab tab) {
123
-
124
-    }
125
-
126
-    @Override
127
-    public void onTabReselected(TabLayout.Tab tab) {
128
-
129
-    }
130
-
131
-    public String getNavigatorId(int position) {
132
-        return mNavigatorIds.get(position);
133
-    }
134
-
135
-    public int getStackSizeForNavigatorId(String activeNavigatorID) {
136
-        return mStackByNavigatorId.get(activeNavigatorID).getStackSize();
137
-    }
138
-
139
-    @Override
140
-    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
141
-
142
-    }
143
-
144
-    @Override
145
-    public void onPageSelected(int position) {
146
-        mCurrentPage = position;
147
-    }
148
-
149
-    @Override
150
-    public void onPageScrollStateChanged(int state) {
151
-
152
-    }
6
+public class ViewPagerAdapter {
7
+
8
+//    private static final String EVENT_ON_TAB_SELECTED = "OnTabSelected";
9
+//
10
+//    private ViewPager mViewPager;
11
+//    private RnnToolBar mToolbar;
12
+//    private final ArrayList<ScreenStack> mScreenStacks;
13
+//    private final ArrayList<String> mNavigatorIds;
14
+//    private final Map<String, ScreenStack> mStackByNavigatorId;
15
+//    private int mCurrentPage = 0;
16
+//
17
+//    public ViewPagerAdapter(BaseReactActivity context, ViewPager viewPager, RnnToolBar toolbar,
18
+//                            ArrayList<_Screen> screens) {
19
+//        mViewPager = viewPager;
20
+//        mToolbar = toolbar;
21
+//        mScreenStacks = new ArrayList<>();
22
+//        mNavigatorIds = new ArrayList<>();
23
+//        mStackByNavigatorId = new HashMap<>();
24
+//        for (_Screen screen : screens) {
25
+//            ScreenStack stack = new ScreenStack(context);
26
+//            stack.push(screen);
27
+//            mScreenStacks.add(stack);
28
+//            mNavigatorIds.add(screen.navigatorId);
29
+//            mStackByNavigatorId.put(screen.navigatorId, stack);
30
+//        }
31
+//    }
32
+//
33
+//    public void push(_Screen screen) {
34
+//        ScreenStack stack = mStackByNavigatorId.get(screen.navigatorId);
35
+//        _Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
36
+//        mToolbar.setupToolbarButtonsAsync(prevScreen, screen);
37
+//        stack.push(screen);
38
+//    }
39
+//
40
+//    public _Screen pop(String navigatorId) {
41
+//        ScreenStack stack = mStackByNavigatorId.get(navigatorId);
42
+//        _Screen oldScreen = stack != null ? stack.pop() : null;
43
+//        _Screen newScreen = stack.peek();
44
+//        mToolbar.setupToolbarButtonsAsync(oldScreen, newScreen);
45
+//        return oldScreen;
46
+//    }
47
+//
48
+//    public _Screen peek(String navigatorId) {
49
+//        ScreenStack stack = mStackByNavigatorId.get(navigatorId);
50
+//        return stack != null ? stack.peek() : null;
51
+//    }
52
+//
53
+//    @Override
54
+//    public Object instantiateItem(ViewGroup container, int position) {
55
+//        ScreenStack view = mScreenStacks.get(position);
56
+//        container.addView(view);
57
+//        return view;
58
+//    }
59
+//
60
+//    @Override
61
+//    public void destroyItem(ViewGroup container, int position, Object view) {
62
+//        container.removeView((View) view);
63
+//    }
64
+//
65
+//    @Override
66
+//    public int getCount() {
67
+//        return mScreenStacks.size();
68
+//    }
69
+//
70
+//    @Override
71
+//    public boolean isViewFromObject(View view, Object object) {
72
+//        return view == object;
73
+//    }
74
+//
75
+//    @Override
76
+//    public CharSequence getPageTitle(int position) {
77
+//        return mScreenStacks.get(position).peek().label;
78
+//    }
79
+//
80
+//    @Override
81
+//    public void onTabSelected(TabLayout.Tab tab) {
82
+//        // Set the viewPager's current item
83
+//        int position = tab.getPosition();
84
+//        mViewPager.setCurrentItem(position);
85
+//
86
+//        // Set screen buttons
87
+//        _Screen prevScreen = mScreenStacks.get(mCurrentPage).peek();
88
+//        _Screen newScreen = mScreenStacks.get(position).peek();
89
+//        mToolbar.setupToolbarButtonsAsync(prevScreen, newScreen);
90
+//
91
+//        // Set title
92
+//        mToolbar.setTitle(newScreen.title == null ? "" : newScreen.title);
93
+//
94
+//        // Set navigation color
95
+//        StyleHelper.updateStyles(mToolbar, newScreen);
96
+//
97
+//        // Send tab selected event
98
+//        WritableMap params = Arguments.createMap();
99
+//        _Screen screen = mScreenStacks.get(position).peek();
100
+//        RctManager.getInstance().sendEvent(EVENT_ON_TAB_SELECTED, screen, params);
101
+//    }
102
+//
103
+//    @Override
104
+//    public void onTabUnselected(TabLayout.Tab tab) {
105
+//
106
+//    }
107
+//
108
+//    @Override
109
+//    public void onTabReselected(TabLayout.Tab tab) {
110
+//
111
+//    }
112
+//
113
+//    public String getNavigatorId(int position) {
114
+//        return mNavigatorIds.get(position);
115
+//    }
116
+//
117
+//    public int getStackSizeForNavigatorId(String activeNavigatorID) {
118
+//        return mStackByNavigatorId.get(activeNavigatorID).getStackSize();
119
+//    }
120
+//
121
+//    @Override
122
+//    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
123
+//
124
+//    }
125
+//
126
+//    @Override
127
+//    public void onPageSelected(int position) {
128
+//        mCurrentPage = position;
129
+//    }
130
+//
131
+//    @Override
132
+//    public void onPageScrollStateChanged(int state) {
133
+//
134
+//    }
153 135
 }

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactEventEmitter.java Bestand weergeven

@@ -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
 }

+ 3
- 0
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java Bestand weergeven

@@ -1,5 +1,7 @@
1 1
 package com.reactnativenavigation.bridge;
2 2
 
3
+import android.util.Log;
4
+
3 5
 import com.facebook.react.bridge.ReactApplicationContext;
4 6
 import com.facebook.react.bridge.ReactContextBaseJavaModule;
5 7
 import com.facebook.react.bridge.ReactMethod;
@@ -29,6 +31,7 @@ public class NavigationReactModule extends ReactContextBaseJavaModule {
29 31
 
30 32
     @ReactMethod
31 33
     public void startApp(final ReadableMap params) {
34
+        Log.d(NAME, "startApp: " + params);
32 35
     }
33 36
 
34 37
     @ReactMethod

+ 43
- 49
android/app/src/main/java/com/reactnativenavigation/controllers/ModalController.java Bestand weergeven

@@ -1,54 +1,48 @@
1 1
 package com.reactnativenavigation.controllers;
2 2
 
3
-import android.support.annotation.Nullable;
4
-
5
-import com.reactnativenavigation.modal.RnnModal;
6
-
7
-import java.util.Stack;
8
-
9 3
 public class ModalController {
10 4
 
11
-    private final Stack<RnnModal> modals = new Stack<>();
12
-
13
-    public ModalController() {
14
-    }
15
-
16
-    public void add(RnnModal modal) {
17
-        modals.add(modal);
18
-    }
19
-
20
-    public boolean isModalDisplayed() {
21
-        return !modals.isEmpty();
22
-    }
23
-
24
-    @Nullable
25
-    public RnnModal get() {
26
-        return isModalDisplayed() ? modals.peek() : null;
27
-    }
28
-
29
-    public void remove() {
30
-        if (isModalDisplayed()) {
31
-            modals.pop();
32
-        }
33
-    }
34
-
35
-    public void dismissAllModals() {
36
-        while (isModalDisplayed()) {
37
-            dismissModal();
38
-        }
39
-    }
40
-
41
-    public void dismissModal() {
42
-        if (isModalDisplayed()) {
43
-            modals.pop().dismiss();
44
-        }
45
-    }
46
-
47
-    public void onDestroy() {
48
-
49
-    }
50
-
51
-    public boolean onBackPressed() {
52
-        return false;
53
-    }
5
+//    private final Stack<RnnModal> modals = new Stack<>();
6
+//
7
+//    public ModalController() {
8
+//    }
9
+//
10
+//    public void add(RnnModal modal) {
11
+//        modals.add(modal);
12
+//    }
13
+//
14
+//    public boolean isModalDisplayed() {
15
+//        return !modals.isEmpty();
16
+//    }
17
+//
18
+//    @Nullable
19
+//    public RnnModal get() {
20
+//        return isModalDisplayed() ? modals.peek() : null;
21
+//    }
22
+//
23
+//    public void remove() {
24
+//        if (isModalDisplayed()) {
25
+//            modals.pop();
26
+//        }
27
+//    }
28
+//
29
+//    public void dismissAllModals() {
30
+//        while (isModalDisplayed()) {
31
+//            dismissModal();
32
+//        }
33
+//    }
34
+//
35
+//    public void dismissModal() {
36
+//        if (isModalDisplayed()) {
37
+//            modals.pop().dismiss();
38
+//        }
39
+//    }
40
+//
41
+//    public void onDestroy() {
42
+//
43
+//    }
44
+//
45
+//    public boolean onBackPressed() {
46
+//        return false;
47
+//    }
54 48
 }

+ 31
- 5
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java Bestand weergeven

@@ -2,6 +2,7 @@ package com.reactnativenavigation.controllers;
2 2
 
3 3
 import android.app.Activity;
4 4
 import android.content.Intent;
5
+import android.graphics.Color;
5 6
 import android.os.Bundle;
6 7
 import android.support.v7.app.AppCompatActivity;
7 8
 import android.view.KeyEvent;
@@ -11,9 +12,11 @@ import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
11 12
 import com.facebook.react.shell.MainReactPackage;
12 13
 import com.reactnativenavigation.bridge.NavigationReactPackage;
13 14
 import com.reactnativenavigation.layouts.Layout;
15
+import com.reactnativenavigation.layouts.ScreenLayout;
14 16
 import com.reactnativenavigation.react.JsDevReloadHandler;
15 17
 import com.reactnativenavigation.react.NavigationReactInstance;
16 18
 import com.reactnativenavigation.react.RedboxPermission;
19
+import com.reactnativenavigation.views.TitleBarButton;
17 20
 
18 21
 import java.util.Arrays;
19 22
 import java.util.List;
@@ -30,7 +33,22 @@ public class NavigationActivity extends AppCompatActivity implements NavigationR
30 33
     private static Activity currentActivity;
31 34
     private NavigationReactInstance navigationReactInstance;
32 35
     private ModalController modalController;
33
-    private Layout layout;
36
+    private Layout layout = new Layout() {
37
+        @Override
38
+        public boolean onBackPressed() {
39
+            return false;
40
+        }
41
+
42
+        @Override
43
+        public void onDestroy() {
44
+
45
+        }
46
+
47
+        @Override
48
+        public void removeAllReactViews() {
49
+
50
+        }
51
+    };
34 52
 
35 53
     @Override
36 54
     protected void onCreate(Bundle savedInstanceState) {
@@ -39,6 +57,14 @@ public class NavigationActivity extends AppCompatActivity implements NavigationR
39 57
         navigationReactInstance = new NavigationReactInstance(this);
40 58
         navigationReactInstance.startReactContextOnceInBackgroundAndExecuteJS();
41 59
         RedboxPermission.permissionToShowRedboxIfNeeded(this);
60
+        createLayout();
61
+    }
62
+
63
+    private void createLayout() {
64
+        List<TitleBarButton.Params> btns = Arrays.asList(new TitleBarButton.Params("btn1", getResources().getDrawable(android.R.drawable.ic_media_play), Color.RED, TitleBarButton.Params.ShowAsAction.Always));
65
+        ScreenLayout.Params screenParams = new ScreenLayout.Params("v2.0", new Bundle(), btns);
66
+        ScreenLayout screenLayout = new ScreenLayout(this, navigationReactInstance.getReactInstanceManager(), screenParams);
67
+        setContentView(screenLayout);
42 68
     }
43 69
 
44 70
     @Override
@@ -57,7 +83,7 @@ public class NavigationActivity extends AppCompatActivity implements NavigationR
57 83
 
58 84
     @Override
59 85
     protected void onDestroy() {
60
-        modalController.onDestroy();
86
+//        modalController.onDestroy();
61 87
         layout.onDestroy();
62 88
         super.onDestroy();
63 89
         if (currentActivity == null || currentActivity.isFinishing()) {
@@ -90,9 +116,9 @@ public class NavigationActivity extends AppCompatActivity implements NavigationR
90 116
 
91 117
     @Override
92 118
     public void onBackPressed() {
93
-        if (modalController.onBackPressed()) {
94
-            return;
95
-        }
119
+//        if (modalController.onBackPressed()) {
120
+//            return;
121
+//        }
96 122
         if (layout.onBackPressed()) {
97 123
             return;
98 124
         }

+ 16
- 20
android/app/src/main/java/com/reactnativenavigation/core/objects/Drawer.java Bestand weergeven

@@ -1,23 +1,19 @@
1 1
 package com.reactnativenavigation.core.objects;
2 2
 
3
-import com.facebook.react.bridge.ReadableMap;
4
-
5
-import java.io.Serializable;
6
-
7
-public class Drawer extends JsonObject implements Serializable {
8
-    private static final long serialVersionUID = 982836768712398756L;
9
-
10
-    private static final String KEY_LEFT = "left";
11
-    private static final String KEY_RIGHT = "right";
12
-    private static final String KEY_DISABLE_OPEN_GESTURE = "disableOpenGesture";
13
-
14
-    public final _Screen left;
15
-    public final _Screen right;
16
-    public final boolean disableOpenGesture;
17
-
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;
21
-        disableOpenGesture = getBoolean(params, KEY_DISABLE_OPEN_GESTURE);
22
-    }
3
+public class Drawer  {
4
+//    private static final long serialVersionUID = 982836768712398756L;
5
+//
6
+//    private static final String KEY_LEFT = "left";
7
+//    private static final String KEY_RIGHT = "right";
8
+//    private static final String KEY_DISABLE_OPEN_GESTURE = "disableOpenGesture";
9
+//
10
+//    public final _Screen left;
11
+//    public final _Screen right;
12
+//    public final boolean disableOpenGesture;
13
+//
14
+//    public Drawer(ReadableMap params) {
15
+//        left = params.hasKey(KEY_LEFT) ? new _Screen(params.getMap(KEY_LEFT)) : null;
16
+//        right = params.hasKey(KEY_RIGHT) ? new _Screen(params.getMap(KEY_RIGHT)) : null;
17
+//        disableOpenGesture = getBoolean(params, KEY_DISABLE_OPEN_GESTURE);
18
+//    }
23 19
 }

+ 62
- 74
android/app/src/main/java/com/reactnativenavigation/core/objects/_Button.java Bestand weergeven

@@ -1,80 +1,68 @@
1 1
 package com.reactnativenavigation.core.objects;
2 2
 
3
-import android.content.Context;
4
-import android.graphics.drawable.Drawable;
5
-import android.view.MenuItem;
6
-
7
-import com.facebook.react.bridge.ReadableMap;
8
-import com.reactnativenavigation.react.ImageLoader;
9
-
10
-import java.io.Serializable;
11
-import java.util.HashMap;
12
-import java.util.Map;
13
-import java.util.concurrent.atomic.AtomicInteger;
14
-
15 3
 /**
16 4
  * Created by guyc on 08/04/16.
17 5
  */
18
-public class _Button extends JsonObject implements Serializable {
19
-    private static final long serialVersionUID = -570145217281069067L;
20
-
21
-    private static final String KEY_ID = "id";
22
-    private static final String KEY_TITLE = "title";
23
-    private static final String KEY_ICON = "icon";
24
-    private static final String KEY_DISABLED = "disabled";
25
-    private static final String KEY_SHOW_AS_ACTION = "showAsAction";
26
-
27
-    public String id;
28
-    public String title;
29
-    private String mIconSource;
30
-    public boolean disabled;
31
-    public String showAsAction;
32
-
33
-    private static final AtomicInteger sAtomicIdGenerator = new AtomicInteger();
34
-    private static final Map<String, Integer> sStringToNumericId = new HashMap<>();
35
-
36
-    public _Button(ReadableMap button) {
37
-        id = getString(button, KEY_ID);
38
-        title = getString(button, KEY_TITLE, "");
39
-        mIconSource = getString(button, KEY_ICON);
40
-        disabled = getBoolean(button, KEY_DISABLED);
41
-        showAsAction = getString(button, KEY_SHOW_AS_ACTION, "");
42
-    }
43
-
44
-    public boolean hasIcon() {
45
-        return mIconSource != null;
46
-    }
47
-
48
-    /**
49
-     * @param dimensions The requested icon dimensions
50
-     */
51
-    public Drawable getIcon(Context ctx, int dimensions) {
52
-       return ImageLoader.getIcon(ctx, mIconSource, dimensions);
53
-    }
54
-
55
-    public int getItemId() {
56
-        if (sStringToNumericId.containsKey(id)) {
57
-            return sStringToNumericId.get(id);
58
-        }
59
-
60
-        int itemId = sAtomicIdGenerator.addAndGet(1);
61
-        sStringToNumericId.put(id, itemId);
62
-        return itemId;
63
-    }
64
-
65
-    /**
66
-     * Each button has a string id, defined in JS, which is used to identify the button when
67
-     * handling events.
68
-     * @param item Toolbar button
69
-     * @return Returns the event id associated with the given menu item
70
-     */
71
-    public static String getButtonEventId(MenuItem item) {
72
-        for (Map.Entry<String, Integer> entry : sStringToNumericId.entrySet()) {
73
-            if (entry.getValue() == item.getItemId()) {
74
-                return entry.getKey();
75
-            }
76
-        }
77
-
78
-        return null;
79
-    }
6
+public class _Button  {
7
+//    private static final long serialVersionUID = -570145217281069067L;
8
+//
9
+//    private static final String KEY_ID = "id";
10
+//    private static final String KEY_TITLE = "title";
11
+//    private static final String KEY_ICON = "icon";
12
+//    private static final String KEY_DISABLED = "disabled";
13
+//    private static final String KEY_SHOW_AS_ACTION = "showAsAction";
14
+//
15
+//    public String id;
16
+//    public String title;
17
+//    private String mIconSource;
18
+//    public boolean disabled;
19
+//    public String showAsAction;
20
+//
21
+//    private static final AtomicInteger sAtomicIdGenerator = new AtomicInteger();
22
+//    private static final Map<String, Integer> sStringToNumericId = new HashMap<>();
23
+//
24
+//    public _Button(ReadableMap button) {
25
+//        id = getString(button, KEY_ID);
26
+//        title = getString(button, KEY_TITLE, "");
27
+//        mIconSource = getString(button, KEY_ICON);
28
+//        disabled = getBoolean(button, KEY_DISABLED);
29
+//        showAsAction = getString(button, KEY_SHOW_AS_ACTION, "");
30
+//    }
31
+//
32
+//    public boolean hasIcon() {
33
+//        return mIconSource != null;
34
+//    }
35
+//
36
+//    /**
37
+//     * @param dimensions The requested icon dimensions
38
+//     */
39
+//    public Drawable getIcon(Context ctx, int dimensions) {
40
+//       return ImageLoader.getIcon(ctx, mIconSource, dimensions);
41
+//    }
42
+//
43
+//    public int getItemId() {
44
+//        if (sStringToNumericId.containsKey(id)) {
45
+//            return sStringToNumericId.get(id);
46
+//        }
47
+//
48
+//        int itemId = sAtomicIdGenerator.addAndGet(1);
49
+//        sStringToNumericId.put(id, itemId);
50
+//        return itemId;
51
+//    }
52
+//
53
+//    /**
54
+//     * Each button has a string id, defined in JS, which is used to identify the button when
55
+//     * handling events.
56
+//     * @param item Toolbar button
57
+//     * @return Returns the event id associated with the given menu item
58
+//     */
59
+//    public static String getButtonEventId(MenuItem item) {
60
+//        for (Map.Entry<String, Integer> entry : sStringToNumericId.entrySet()) {
61
+//            if (entry.getValue() == item.getItemId()) {
62
+//                return entry.getKey();
63
+//            }
64
+//        }
65
+//
66
+//        return null;
67
+//    }
80 68
 }

+ 120
- 137
android/app/src/main/java/com/reactnativenavigation/core/objects/_Screen.java Bestand weergeven

@@ -1,143 +1,126 @@
1 1
 package com.reactnativenavigation.core.objects;
2 2
 
3
-import android.content.Context;
4
-import android.graphics.drawable.Drawable;
5
-import android.support.annotation.ColorInt;
6
-import android.support.annotation.NonNull;
7
-import android.support.annotation.Nullable;
8
-
9
-import com.facebook.react.bridge.ReadableArray;
10
-import com.facebook.react.bridge.ReadableMap;
11
-import com.facebook.react.bridge.ReadableNativeMap;
12
-import com.reactnativenavigation.react.ImageLoader;
13
-
14
-import java.io.Serializable;
15
-import java.util.ArrayList;
16
-import java.util.Collections;
17
-import java.util.HashMap;
18
-import java.util.List;
19
-
20 3
 /**
21 4
  * Created by guyc on 02/04/16.
22 5
  */
23
-public class _Screen extends JsonObject implements Serializable {
24
-    private static final long serialVersionUID = -1033475305421107791L;
25
-
26
-    private static final String KEY_TITLE = "title";
27
-    private static final String KEY_SCREEN = "screen";
28
-    private static final String KEY_LABEL = "label";
29
-    public static final String KEY_SCREEN_INSTANCE_ID = "screenInstanceID";
30
-    public static final String KEY_NAVIGATOR_ID = "navigatorID";
31
-    public static final String KEY_NAVIGATOR_EVENT_ID = "navigatorEventID";
32
-    private static final String KEY_ICON = "icon";
33
-    private static final String KEY_NAVIGATOR_BUTTONS = "navigatorButtons";
34
-    private static final String KEY_RIGHT_BUTTONS = "rightButtons";
35
-    private static final String KEY_TOOL_BAR_STYLE = "navigatorStyle";
36
-    private static final String KEY_STATUS_BAR_COLOR = "statusBarColor";
37
-    private static final String KEY_TOOL_BAR_COLOR = "navBarBackgroundColor";
38
-    private static final String KEY_TOOL_BAR_HIDDEN = "navBarHidden";
39
-    private static final String KEY_NAVIGATION_BAR_COLOR = "navigationBarColor";
40
-    private static final String KEY_NAV_BAR_BUTTON_COLOR = "navBarButtonColor";
41
-    private static final String KEY_NAV_BAR_TEXT_COLOR = "navBarTextColor";
42
-    private static final String KEY_BACK_BUTTON_HIDDEN = "backButtonHidden";
43
-    private static final String KEY_TAB_NORMAL_TEXT_COLOR = "tabNormalTextColor";
44
-    private static final String KEY_TAB_SELECTED_TEXT_COLOR = "tabSelectedTextColor";
45
-    private static final String KEY_TAB_INDICATOR_COLOR = "tabIndicatorColor";
46
-    private static final String KEY_BOTTOM_TABS_HIDDEN = "tabBarHidden";
47
-    private static final String KEY_BOTTOM_TABS_HIDDEN_ON_SCROLL = "bottomTabsHiddenOnScroll";
48
-    private static final String KEY_PROPS = "passProps";
49
-
50
-    public String title;
51
-    public final String label;
52
-    public final String screenId;
53
-    public final String screenInstanceId;
54
-    public final String navigatorId;
55
-    public final String navigatorEventId;
56
-    public final String icon;
57
-    public ArrayList<_Button> buttons;
58
-    public final boolean backButtonHidden;
59
-    public boolean bottomTabsHiddenOnScroll;
60
-    public HashMap<String, Object> passedProps = new HashMap<>();
61
-
62
-    // NavigationReactModule styling
63
-    @Nullable @ColorInt public Integer toolBarColor;
64
-    @Nullable public Boolean toolBarHidden;
65
-    @Nullable @ColorInt public Integer statusBarColor;
66
-    @Nullable @ColorInt public Integer navigationBarColor;
67
-    @Nullable @ColorInt public Integer navBarButtonColor;
68
-    @Nullable @ColorInt public Integer navBarTextColor;
69
-    @Nullable @ColorInt public Integer tabNormalTextColor;
70
-    @Nullable @ColorInt public Integer tabSelectedTextColor;
71
-    @Nullable @ColorInt public Integer tabIndicatorColor;
72
-    public Boolean bottomTabsHidden;
73
-
74
-    @NonNull
75
-    public List<_Button> getButtons() {
76
-        return buttons == null ? Collections.<_Button>emptyList() : buttons;
77
-    }
78
-
79
-    public _Screen(ReadableMap screen) {
80
-        title = getString(screen, KEY_TITLE);
81
-        label = getString(screen, KEY_LABEL);
82
-        screenId = getString(screen, KEY_SCREEN);
83
-        screenInstanceId = getString(screen, KEY_SCREEN_INSTANCE_ID);
84
-        navigatorId = getString(screen, KEY_NAVIGATOR_ID);
85
-        navigatorEventId = getString(screen, KEY_NAVIGATOR_EVENT_ID);
86
-        icon = getString(screen, KEY_ICON);
87
-        if(screen.hasKey(KEY_PROPS)) {
88
-            passedProps = ((ReadableNativeMap) screen.getMap(KEY_PROPS)).toHashMap();
89
-        }
90
-        buttons = getButtons(screen);
91
-        backButtonHidden = getBoolean(screen, KEY_BACK_BUTTON_HIDDEN);
92
-        setToolbarStyle(screen);
93
-    }
94
-
95
-    public void setTitle(ReadableMap params) {
96
-        this.title = getString(params, KEY_TITLE);
97
-    }
98
-
99
-    public void setButtons(ReadableMap params) {
100
-        this.buttons = getButtons(params);
101
-    }
102
-
103
-    private ArrayList<_Button> getButtons(ReadableMap screen) {
104
-        ArrayList<_Button> ret = new ArrayList<>();
105
-        if (hasButtons(screen)) {
106
-            ReadableArray rightButtons = getRightButtons(screen);
107
-            for (int i = 0; i < rightButtons.size(); i++) {
108
-                ret.add(new _Button(rightButtons.getMap(i)));
109
-            }
110
-        }
111
-        return ret;
112
-    }
113
-
114
-    private boolean hasButtons(ReadableMap screen) {
115
-        return screen.hasKey(KEY_RIGHT_BUTTONS) || screen.hasKey(KEY_NAVIGATOR_BUTTONS);
116
-    }
117
-
118
-    private ReadableArray getRightButtons(ReadableMap screen) {
119
-        return screen.hasKey(KEY_RIGHT_BUTTONS) ? screen.getArray(KEY_RIGHT_BUTTONS) :
120
-                screen.getMap(KEY_NAVIGATOR_BUTTONS).getArray(KEY_RIGHT_BUTTONS);
121
-    }
122
-
123
-    public Drawable getIcon(Context ctx) {
124
-        return ImageLoader.getIcon(ctx, icon);
125
-    }
126
-
127
-    public void setToolbarStyle(ReadableMap screen) {
128
-        ReadableMap style = getMap(screen, KEY_TOOL_BAR_STYLE);
129
-        if (style != null) {
130
-            toolBarColor = getColor(style, KEY_TOOL_BAR_COLOR);
131
-            toolBarHidden = getBoolean(style, KEY_TOOL_BAR_HIDDEN);
132
-            statusBarColor = getColor(style, KEY_STATUS_BAR_COLOR);
133
-            navigationBarColor = getColor(style, KEY_NAVIGATION_BAR_COLOR);
134
-            navBarButtonColor = getColor(style, KEY_NAV_BAR_BUTTON_COLOR);
135
-            navBarTextColor = getColor(style, KEY_NAV_BAR_TEXT_COLOR);
136
-            tabNormalTextColor = getColor(style, KEY_TAB_NORMAL_TEXT_COLOR);
137
-            tabSelectedTextColor = getColor(style, KEY_TAB_SELECTED_TEXT_COLOR);
138
-            tabIndicatorColor = getColor(style, KEY_TAB_INDICATOR_COLOR);
139
-            bottomTabsHidden = getBoolean(style, KEY_BOTTOM_TABS_HIDDEN);
140
-            bottomTabsHiddenOnScroll = getBoolean(style, KEY_BOTTOM_TABS_HIDDEN_ON_SCROLL);
141
-        }
142
-    }
6
+public class _Screen {
7
+//    private static final long serialVersionUID = -1033475305421107791L;
8
+//
9
+//    private static final String KEY_TITLE = "title";
10
+//    private static final String KEY_SCREEN = "screen";
11
+//    private static final String KEY_LABEL = "label";
12
+//    public static final String KEY_SCREEN_INSTANCE_ID = "screenInstanceID";
13
+//    public static final String KEY_NAVIGATOR_ID = "navigatorID";
14
+//    public static final String KEY_NAVIGATOR_EVENT_ID = "navigatorEventID";
15
+//    private static final String KEY_ICON = "icon";
16
+//    private static final String KEY_NAVIGATOR_BUTTONS = "navigatorButtons";
17
+//    private static final String KEY_RIGHT_BUTTONS = "rightButtons";
18
+//    private static final String KEY_TOOL_BAR_STYLE = "navigatorStyle";
19
+//    private static final String KEY_STATUS_BAR_COLOR = "statusBarColor";
20
+//    private static final String KEY_TOOL_BAR_COLOR = "navBarBackgroundColor";
21
+//    private static final String KEY_TOOL_BAR_HIDDEN = "navBarHidden";
22
+//    private static final String KEY_NAVIGATION_BAR_COLOR = "navigationBarColor";
23
+//    private static final String KEY_NAV_BAR_BUTTON_COLOR = "navBarButtonColor";
24
+//    private static final String KEY_NAV_BAR_TEXT_COLOR = "navBarTextColor";
25
+//    private static final String KEY_BACK_BUTTON_HIDDEN = "backButtonHidden";
26
+//    private static final String KEY_TAB_NORMAL_TEXT_COLOR = "tabNormalTextColor";
27
+//    private static final String KEY_TAB_SELECTED_TEXT_COLOR = "tabSelectedTextColor";
28
+//    private static final String KEY_TAB_INDICATOR_COLOR = "tabIndicatorColor";
29
+//    private static final String KEY_BOTTOM_TABS_HIDDEN = "tabBarHidden";
30
+//    private static final String KEY_BOTTOM_TABS_HIDDEN_ON_SCROLL = "bottomTabsHiddenOnScroll";
31
+//    private static final String KEY_PROPS = "passProps";
32
+//
33
+//    public String title;
34
+//    public final String label;
35
+//    public final String screenId;
36
+//    public final String screenInstanceId;
37
+//    public final String navigatorId;
38
+//    public final String navigatorEventId;
39
+//    public final String icon;
40
+//    public ArrayList<_Button> buttons;
41
+//    public final boolean backButtonHidden;
42
+//    public boolean bottomTabsHiddenOnScroll;
43
+//    public HashMap<String, Object> passedProps = new HashMap<>();
44
+//
45
+//    // NavigationReactModule styling
46
+//    @Nullable @ColorInt public Integer toolBarColor;
47
+//    @Nullable public Boolean toolBarHidden;
48
+//    @Nullable @ColorInt public Integer statusBarColor;
49
+//    @Nullable @ColorInt public Integer navigationBarColor;
50
+//    @Nullable @ColorInt public Integer navBarButtonColor;
51
+//    @Nullable @ColorInt public Integer navBarTextColor;
52
+//    @Nullable @ColorInt public Integer tabNormalTextColor;
53
+//    @Nullable @ColorInt public Integer tabSelectedTextColor;
54
+//    @Nullable @ColorInt public Integer tabIndicatorColor;
55
+//    public Boolean bottomTabsHidden;
56
+//
57
+//    @NonNull
58
+//    public List<_Button> getButtons() {
59
+//        return buttons == null ? Collections.<_Button>emptyList() : buttons;
60
+//    }
61
+//
62
+//    public _Screen(ReadableMap screen) {
63
+//        title = getString(screen, KEY_TITLE);
64
+//        label = getString(screen, KEY_LABEL);
65
+//        screenId = getString(screen, KEY_SCREEN);
66
+//        screenInstanceId = getString(screen, KEY_SCREEN_INSTANCE_ID);
67
+//        navigatorId = getString(screen, KEY_NAVIGATOR_ID);
68
+//        navigatorEventId = getString(screen, KEY_NAVIGATOR_EVENT_ID);
69
+//        icon = getString(screen, KEY_ICON);
70
+//        if(screen.hasKey(KEY_PROPS)) {
71
+//            passedProps = ((ReadableNativeMap) screen.getMap(KEY_PROPS)).toHashMap();
72
+//        }
73
+//        buttons = getButtons(screen);
74
+//        backButtonHidden = getBoolean(screen, KEY_BACK_BUTTON_HIDDEN);
75
+//        setToolbarStyle(screen);
76
+//    }
77
+//
78
+//    public void setTitle(ReadableMap params) {
79
+//        this.title = getString(params, KEY_TITLE);
80
+//    }
81
+//
82
+//    public void setButtons(ReadableMap params) {
83
+//        this.buttons = getButtons(params);
84
+//    }
85
+//
86
+//    private ArrayList<_Button> getButtons(ReadableMap screen) {
87
+//        ArrayList<_Button> ret = new ArrayList<>();
88
+//        if (hasButtons(screen)) {
89
+//            ReadableArray rightButtons = getRightButtons(screen);
90
+//            for (int i = 0; i < rightButtons.size(); i++) {
91
+//                ret.add(new _Button(rightButtons.getMap(i)));
92
+//            }
93
+//        }
94
+//        return ret;
95
+//    }
96
+//
97
+//    private boolean hasButtons(ReadableMap screen) {
98
+//        return screen.hasKey(KEY_RIGHT_BUTTONS) || screen.hasKey(KEY_NAVIGATOR_BUTTONS);
99
+//    }
100
+//
101
+//    private ReadableArray getRightButtons(ReadableMap screen) {
102
+//        return screen.hasKey(KEY_RIGHT_BUTTONS) ? screen.getArray(KEY_RIGHT_BUTTONS) :
103
+//                screen.getMap(KEY_NAVIGATOR_BUTTONS).getArray(KEY_RIGHT_BUTTONS);
104
+//    }
105
+//
106
+//    public Drawable getIcon(Context ctx) {
107
+//        return ImageLoader.getIcon(ctx, icon);
108
+//    }
109
+//
110
+//    public void setToolbarStyle(ReadableMap screen) {
111
+//        ReadableMap style = getMap(screen, KEY_TOOL_BAR_STYLE);
112
+//        if (style != null) {
113
+//            toolBarColor = getColor(style, KEY_TOOL_BAR_COLOR);
114
+//            toolBarHidden = getBoolean(style, KEY_TOOL_BAR_HIDDEN);
115
+//            statusBarColor = getColor(style, KEY_STATUS_BAR_COLOR);
116
+//            navigationBarColor = getColor(style, KEY_NAVIGATION_BAR_COLOR);
117
+//            navBarButtonColor = getColor(style, KEY_NAV_BAR_BUTTON_COLOR);
118
+//            navBarTextColor = getColor(style, KEY_NAV_BAR_TEXT_COLOR);
119
+//            tabNormalTextColor = getColor(style, KEY_TAB_NORMAL_TEXT_COLOR);
120
+//            tabSelectedTextColor = getColor(style, KEY_TAB_SELECTED_TEXT_COLOR);
121
+//            tabIndicatorColor = getColor(style, KEY_TAB_INDICATOR_COLOR);
122
+//            bottomTabsHidden = getBoolean(style, KEY_BOTTOM_TABS_HIDDEN);
123
+//            bottomTabsHiddenOnScroll = getBoolean(style, KEY_BOTTOM_TABS_HIDDEN_ON_SCROLL);
124
+//        }
125
+//    }
143 126
 }

+ 54
- 65
android/app/src/main/java/com/reactnativenavigation/layouts/BaseLayout.java Bestand weergeven

@@ -1,68 +1,57 @@
1 1
 package com.reactnativenavigation.layouts;
2 2
 
3
-import android.content.Context;
4
-import android.view.animation.Animation;
5
-import android.view.animation.AnimationUtils;
6
-import android.widget.FrameLayout;
7
-
8
-import com.reactnativenavigation.R;
9
-import com.reactnativenavigation.core.objects._Screen;
10
-import com.reactnativenavigation.views.RctView;
11
-import com.reactnativenavigation.views.RnnToolBar;
12
-import com.reactnativenavigation.views.ScreenStack;
13
-
14
-public abstract class BaseLayout extends FrameLayout implements Layout {
15
-
16
-    private OnScreenPoppedListener onScreenPoppedListener;
17
-
18
-    private RnnToolBar toolBar;
19
-    private ScreenStack screenStack;
20
-
21
-    public BaseLayout(Context context, _Screen initialScreen) {
22
-        super(context);
23
-        toolBar = (RnnToolBar) findViewById(R.id.toolbar);
24
-        screenStack = (ScreenStack) findViewById(R.id.screenStack);
25
-
26
-        toolBar.update(initialScreen);
27
-        addInitialScreen(initialScreen);
28
-    }
29
-
30
-    private void addInitialScreen(_Screen screen) {
31
-        screenStack.push(screen, new RctView.OnDisplayedListener() {
32
-            @Override
33
-            public void onDisplayed() {
34
-                Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.slide_up);
35
-                setAnimation(animation);
36
-                animate();
37
-            }
38
-        });
39
-    }
40
-
41
-    @Override
42
-    public void push(_Screen screen) {
43
-        screenStack.push(screen);
44
-    }
45
-
46
-    @Override
47
-    public _Screen pop() {
48
-        _Screen popped = screenStack.pop();
49
-        if (onScreenPoppedListener != null) {
50
-            onScreenPoppedListener.onScreenPopped(popped);
51
-        }
52
-        return popped;
53
-    }
54
-
55
-    @Override
56
-    public int getScreenCount() {
57
-        return screenStack.getStackSize();
58
-    }
59
-
60
-    @Override
61
-    public void removeAllReactViews() {
62
-        screenStack.removeAllReactViews();
63
-    }
64
-
65
-    public void setOnScreenPoppedListener(OnScreenPoppedListener onScreenPoppedListener) {
66
-        this.onScreenPoppedListener = onScreenPoppedListener;
67
-    }
3
+public abstract class BaseLayout {
4
+
5
+//    private OnScreenPoppedListener onScreenPoppedListener;
6
+//
7
+//    private RnnToolBar toolBar;
8
+//    private ScreenStack screenStack;
9
+//
10
+//    public BaseLayout(Context context, _Screen initialScreen) {
11
+//        super(context);
12
+//        toolBar = (RnnToolBar) findViewById(R.id.toolbar);
13
+//        screenStack = (ScreenStack) findViewById(R.id.screenStack);
14
+//
15
+//        toolBar.update(initialScreen);
16
+//        addInitialScreen(initialScreen);
17
+//    }
18
+//
19
+//    private void addInitialScreen(_Screen screen) {
20
+//        screenStack.push(screen, new RctView.OnDisplayedListener() {
21
+//            @Override
22
+//            public void onDisplayed() {
23
+//                Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.slide_up);
24
+//                setAnimation(animation);
25
+//                animate();
26
+//            }
27
+//        });
28
+//    }
29
+//
30
+//    @Override
31
+//    public void push(_Screen screen) {
32
+//        screenStack.push(screen);
33
+//    }
34
+//
35
+//    @Override
36
+//    public _Screen pop() {
37
+//        _Screen popped = screenStack.pop();
38
+//        if (onScreenPoppedListener != null) {
39
+//            onScreenPoppedListener.onScreenPopped(popped);
40
+//        }
41
+//        return popped;
42
+//    }
43
+//
44
+//    @Override
45
+//    public int getScreenCount() {
46
+//        return screenStack.getStackSize();
47
+//    }
48
+//
49
+//    @Override
50
+//    public void removeAllReactViews() {
51
+//        screenStack.removeAllReactViews();
52
+//    }
53
+//
54
+//    public void setOnScreenPoppedListener(OnScreenPoppedListener onScreenPoppedListener) {
55
+//        this.onScreenPoppedListener = onScreenPoppedListener;
56
+//    }
68 57
 }

+ 0
- 8
android/app/src/main/java/com/reactnativenavigation/layouts/Layout.java Bestand weergeven

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

+ 10
- 5
android/app/src/main/java/com/reactnativenavigation/layouts/ScreenLayout.java Bestand weergeven

@@ -18,15 +18,21 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
18 18
 public class ScreenLayout extends LinearLayout implements ScrollDirectionListener.OnScrollChanged {
19 19
 
20 20
     public static class Params {
21
-        String moduleName;
22
-        Bundle passProps;
23
-        List<TitleBarButton> buttons;
21
+        private final String moduleName;
22
+        private final Bundle passProps;
23
+        private final List<TitleBarButton.Params> buttons;
24
+
25
+        public Params(String moduleName, Bundle passProps, List<TitleBarButton.Params> buttons) {
26
+            this.moduleName = moduleName;
27
+            this.passProps = passProps;
28
+            this.buttons = buttons;
29
+        }
24 30
     }
25 31
 
26 32
     private final ReactInstanceManager reactInstanceManager;
27 33
     private final String moduleName;
28 34
     private final Bundle passProps;
29
-    private final List<TitleBarButton> buttons;
35
+    private final List<TitleBarButton.Params> buttons;
30 36
     private ContentView contentView;
31 37
     private TopBar topBar;
32 38
 
@@ -65,6 +71,5 @@ public class ScreenLayout extends LinearLayout implements ScrollDirectionListene
65 71
 
66 72
     @Override
67 73
     public void onScrollChanged(ScrollDirectionListener.Direction direction) {
68
-
69 74
     }
70 75
 }

+ 64
- 81
android/app/src/main/java/com/reactnativenavigation/modal/RnnModal.java Bestand weergeven

@@ -1,85 +1,68 @@
1 1
 package com.reactnativenavigation.modal;
2 2
 
3
-import android.annotation.SuppressLint;
4
-import android.app.Dialog;
5
-import android.content.Context;
6
-import android.content.DialogInterface;
7
-import android.support.annotation.Nullable;
8
-import android.view.View;
9
-import android.view.Window;
10
-
11
-import com.reactnativenavigation.R;
12
-import com.reactnativenavigation.activities.BaseReactActivity;
13
-import com.reactnativenavigation.controllers.ModalController;
14
-import com.reactnativenavigation.core.objects._Screen;
15
-import com.reactnativenavigation.layouts.Layout;
16
-import com.reactnativenavigation.layouts.OnScreenPoppedListener;
17
-import com.reactnativenavigation.utils.ContextProvider;
18
-import com.reactnativenavigation.utils.StyleHelper;
19
-
20
-public class RnnModal extends Dialog implements DialogInterface.OnDismissListener, OnScreenPoppedListener {
21
-
22
-    private Layout contentView;
23
-
24
-    public RnnModal(Context context, ModalController modalController, _Screen screen) {
25
-        super(context, R.style.Modal);
26
-        modalController.add(this);
27
-        init(context, screen);
28
-    }
29
-
30
-    @SuppressLint("InflateParams")
31
-    private void init(final Context context, _Screen screen) {
32
-        requestWindowFeature(Window.FEATURE_NO_TITLE);
33
-        contentView = null;
34
-        setContentView((View) contentView);
35
-
36
-//        // Set navigation colors
37
-//        if (SdkSupports.lollipop()) {
38
-//            Window window = getWindow();
39
-//            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
40
-//            StyleHelper.setWindowStyle(window, context.getApplicationContext(), screen);
3
+public class RnnModal {
4
+//
5
+//    private Layout contentView;
6
+//
7
+//    public RnnModal(Context context, ModalController modalController, _Screen screen) {
8
+//        super(context, R.style.Modal);
9
+//        modalController.add(this);
10
+//        init(context, screen);
11
+//    }
12
+//
13
+//    @SuppressLint("InflateParams")
14
+//    private void init(final Context context, _Screen screen) {
15
+//        requestWindowFeature(Window.FEATURE_NO_TITLE);
16
+//        contentView = null;
17
+//        setContentView((View) contentView);
18
+//
19
+////        // Set navigation colors
20
+////        if (SdkSupports.lollipop()) {
21
+////            Window window = getWindow();
22
+////            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
23
+////            StyleHelper.setWindowStyle(window, context.getApplicationContext(), screen);
24
+////        }
25
+//        setOnDismissListener(this);
26
+//    }
27
+//
28
+//    public void push(_Screen screen) {
29
+//        contentView.push(screen);
30
+//    }
31
+//
32
+//    public _Screen pop() {
33
+//        return contentView.pop();
34
+//    }
35
+//
36
+//    @Override
37
+//    public void onScreenPopped(_Screen popped) {
38
+//        if (contentView.getScreenCount() == 0) {
39
+//            dismiss();
41 40
 //        }
42
-        setOnDismissListener(this);
43
-    }
44
-
45
-    public void push(_Screen screen) {
46
-        contentView.push(screen);
47
-    }
48
-
49
-    public _Screen pop() {
50
-        return contentView.pop();
51
-    }
52
-
53
-    @Override
54
-    public void onScreenPopped(_Screen popped) {
55
-        if (contentView.getScreenCount() == 0) {
56
-            dismiss();
57
-        }
58
-    }
59
-
60
-    @Nullable
61
-    public _Screen getCurrentScreen() {
62
-        return mScreenStack.isEmpty() ? null : mScreenStack.peek();
63
-    }
64
-
65
-    @Override
66
-    public void onBackPressed() {
67
-        if (mScreenStack.getStackSize() == 1) {
68
-            super.onBackPressed();
69
-        } else {
70
-            pop();
71
-        }
72
-    }
73
-
74
-    @Override
75
-    public void onDismiss(DialogInterface dialog) {
76
-        mScreenStack.removeAllReactViews();
77
-        ModalController.getInstance().remove();
78
-        // After modal is dismissed, update Toolbar with screen from parent activity or previously displayed modal
79
-        BaseReactActivity context = ContextProvider.getActivityContext();
80
-        if (context != null) {
81
-            _Screen currentScreen = context.getCurrentScreen();
82
-            StyleHelper.updateStyles(mToolBar, currentScreen);
83
-        }
84
-    }
41
+//    }
42
+//
43
+//    @Nullable
44
+//    public _Screen getCurrentScreen() {
45
+//        return mScreenStack.isEmpty() ? null : mScreenStack.peek();
46
+//    }
47
+//
48
+//    @Override
49
+//    public void onBackPressed() {
50
+//        if (mScreenStack.getStackSize() == 1) {
51
+//            super.onBackPressed();
52
+//        } else {
53
+//            pop();
54
+//        }
55
+//    }
56
+//
57
+//    @Override
58
+//    public void onDismiss(DialogInterface dialog) {
59
+//        mScreenStack.removeAllReactViews();
60
+//        ModalController.getInstance().remove();
61
+//        // After modal is dismissed, update Toolbar with screen from parent activity or previously displayed modal
62
+//        BaseReactActivity context = ContextProvider.getActivityContext();
63
+//        if (context != null) {
64
+//            _Screen currentScreen = context.getCurrentScreen();
65
+//            StyleHelper.updateStyles(mToolBar, currentScreen);
66
+//        }
67
+//    }
85 68
 }

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/react/JsDevImageLoader.java Bestand weergeven

@@ -33,7 +33,7 @@ public class JsDevImageLoader {
33 33
     private static Drawable tryLoadIcon(String iconDevUri) throws IOException {
34 34
         URL url = new URL(iconDevUri);
35 35
         Bitmap bitmap = BitmapFactory.decodeStream(url.openStream());
36
-        final int dimensions = (int) ImageUtils.convertDpToPixel(48, NavigationApplication.instance);
36
+        final int dimensions = (int) ImageUtils.convertDpToPixel(48);
37 37
         // TODO: fix hard coded dimensions -add options to decodeStream
38 38
         bitmap = Bitmap.createScaledBitmap(bitmap, dimensions, dimensions, false);
39 39
         return new BitmapDrawable(NavigationApplication.instance.getResources(), bitmap);

+ 34
- 43
android/app/src/main/java/com/reactnativenavigation/utils/StyleHelper.java Bestand weergeven

@@ -1,50 +1,41 @@
1 1
 package com.reactnativenavigation.utils;
2 2
 
3
-import android.content.Context;
4
-import android.support.v4.content.ContextCompat;
5
-import android.util.Log;
6
-import android.view.Window;
7
-
8
-import com.reactnativenavigation.activities.BaseReactActivity;
9
-import com.reactnativenavigation.core.objects._Screen;
10
-import com.reactnativenavigation.views.RnnToolBar;
11
-
12 3
 /**
13 4
  * Created by guyc on 07/05/16.
14 5
  */
15 6
 public class StyleHelper {
16
-
17
-    public static void updateStyles(RnnToolBar toolBar, _Screen screen) {
18
-        try {
19
-            toolBar.updateAndSetButtons(screen);
20
-            setWindowStyle(screen);
21
-        } catch (Exception e) {
22
-            Log.w("RNNavigation", "Tried to update styles with no screen!");
23
-        }
24
-    }
25
-
26
-    private static void setWindowStyle(_Screen screen) {
27
-        BaseReactActivity context = ContextProvider.getActivityContext();
28
-        if (context != null) {
29
-            StyleHelper.setWindowStyle(context.getWindow(), context, screen);
30
-        }
31
-    }
32
-
33
-    public static void setWindowStyle(Window window, Context context, _Screen screen) {
34
-        if (SdkSupports.lollipop()) {
35
-            final int black = ContextCompat.getColor(context, android.R.color.black);
36
-            if (screen.statusBarColor != null) {
37
-                window.setStatusBarColor(screen.statusBarColor);
38
-            } else {
39
-                window.setStatusBarColor(black);
40
-            }
41
-
42
-            if (screen.navigationBarColor != null) {
43
-                window.setNavigationBarColor(screen.navigationBarColor);
44
-            } else {
45
-                window.setNavigationBarColor(black);
46
-            }
47
-        }
48
-
49
-    }
7
+//
8
+//    public static void updateStyles(RnnToolBar toolBar, _Screen screen) {
9
+//        try {
10
+//            toolBar.updateAndSetButtons(screen);
11
+//            setWindowStyle(screen);
12
+//        } catch (Exception e) {
13
+//            Log.w("RNNavigation", "Tried to update styles with no screen!");
14
+//        }
15
+//    }
16
+//
17
+//    private static void setWindowStyle(_Screen screen) {
18
+//        BaseReactActivity context = ContextProvider.getActivityContext();
19
+//        if (context != null) {
20
+//            StyleHelper.setWindowStyle(context.getWindow(), context, screen);
21
+//        }
22
+//    }
23
+//
24
+//    public static void setWindowStyle(Window window, Context context, _Screen screen) {
25
+//        if (SdkSupports.lollipop()) {
26
+//            final int black = ContextCompat.getColor(context, android.R.color.black);
27
+//            if (screen.statusBarColor != null) {
28
+//                window.setStatusBarColor(screen.statusBarColor);
29
+//            } else {
30
+//                window.setStatusBarColor(black);
31
+//            }
32
+//
33
+//            if (screen.navigationBarColor != null) {
34
+//                window.setNavigationBarColor(screen.navigationBarColor);
35
+//            } else {
36
+//                window.setNavigationBarColor(black);
37
+//            }
38
+//        }
39
+//
40
+//    }
50 41
 }

+ 118
- 132
android/app/src/main/java/com/reactnativenavigation/views/RctView.java Bestand weergeven

@@ -1,145 +1,131 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
-import android.os.Bundle;
4
-import android.view.View;
5
-import android.view.ViewGroup;
6
-import android.view.ViewTreeObserver;
7
-import android.widget.FrameLayout;
8
-import android.widget.ScrollView;
9
-
10
-import com.facebook.react.ReactInstanceManager;
11
-import com.facebook.react.ReactRootView;
12
-import com.reactnativenavigation.activities.BaseReactActivity;
13
-import com.reactnativenavigation.activities.BottomTabActivity;
14
-import com.reactnativenavigation.core.objects._Screen;
15
-import com.reactnativenavigation.utils.BridgeUtils;
16
-
17 3
 /**
18 4
  * Created by guyc on 10/03/16.
19 5
  */
20
-public class RctView extends FrameLayout {
21
-
22
-    private BottomTabActivity context;
23
-    private ReactRootView reactRootView;
24
-    private ScrollView scrollView;
25
-    private int lastScrollY = -1;
26
-    private final ViewTreeObserver.OnScrollChangedListener scrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() {
27
-        @Override
28
-        public void onScrollChanged() {
29
-            if (!scrollView.getViewTreeObserver().isAlive()) {
30
-                return;
31
-            }
32
-
33
-            final int scrollY = scrollView.getScrollY();
34
-            if (scrollY != lastScrollY && // Scroll position changed
35
-                scrollY > 0 && // Ignore top overscroll
36
-                scrollY < (scrollView.getChildAt(0).getHeight() - scrollView.getHeight())) { // Ignore bottom overscroll
37
-                int direction = scrollY > lastScrollY ?
38
-                        BottomNavigation.SCROLL_DIRECTION_DOWN :
39
-                        BottomNavigation.SCROLL_DIRECTION_UP;
40
-                lastScrollY = scrollY;
41
-                context.onScrollChanged(direction);
42
-            }
43
-        }
44
-    };
45
-    private boolean isScrollEventListenerRegistered = false;
46
-
47
-    private final View.OnAttachStateChangeListener stateChangeListener =
48
-            new View.OnAttachStateChangeListener() {
49
-                @Override
50
-                public void onViewAttachedToWindow(View v) {
51
-                    scrollView = getScrollView((ViewGroup) getParent());
52
-
53
-                    if (scrollView != null && !isScrollEventListenerRegistered) {
54
-                        addScrollListener();
55
-                    }
56
-                }
57
-
58
-                @Override
59
-                public void onViewDetachedFromWindow(final View detachedView) {
60
-                    removeScrollListener();
61
-
62
-                    post(new Runnable() {
63
-                        @Override
64
-                        public void run() {
65
-                            scrollView = getScrollView((ViewGroup) getParent());
66
-                            if (scrollView != null && !isScrollEventListenerRegistered) {
67
-                                isScrollEventListenerRegistered = true;
68
-                                addScrollListener();
69
-                            }
70
-                        }
71
-                    });
72
-                }
73
-            };
74
-
75
-    /**
76
-     * Interface used to run some code when the {@link ReactRootView} is visible.
77
-     */
78
-    public interface OnDisplayedListener {
79
-        /**
80
-         * This method will be invoked when the {@link ReactRootView} is visible.
81
-         */
82
-        void onDisplayed();
83
-    }
84
-
85
-    @SuppressWarnings("unchecked")
86
-    public RctView(BaseReactActivity ctx, ReactInstanceManager rctInstanceManager, final _Screen screen,
87
-                   final OnDisplayedListener onDisplayedListener) {
88
-        super(ctx);
89
-        setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
90
-
91
-        final OnDisplayedListener onDisplayedListenerInternal = screen.bottomTabsHiddenOnScroll ?
92
-            new OnDisplayedListener() {
93
-                @Override
94
-                public void onDisplayed() {
95
-                    if (onDisplayedListener != null) {
96
-                        onDisplayedListener.onDisplayed();
97
-                    }
98
-
99
-                    setupScrollViewWithBottomTabs();
100
-                }
101
-            } : onDisplayedListener;
102
-
103
-        reactRootView = new RnnReactRootView(ctx, onDisplayedListenerInternal);
104
-        reactRootView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
105
-        Bundle passProps = createPassProps(screen);
106
-        String componentName = screen.screenId;
107
-        reactRootView.startReactApplication(rctInstanceManager, componentName, passProps);
108
-
109
-        addView(reactRootView);
110
-    }
111
-
112
-    private Bundle createPassProps(_Screen screen) {
113
-        Bundle passProps = new Bundle();
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);
117
-        if (screen.passedProps != null) {
118
-            BridgeUtils.addMapToBundle(screen.passedProps, passProps);
119
-        }
120
-        return passProps;
121
-    }
122
-
123
-//    private void setupScrollViewWithBottomTabs() {
124
-//        scrollView = getScrollView((ViewGroup) getParent());
125
-//        if (scrollView != null) {
126
-//            context = (BottomTabActivity) getContext();
127
-//            attachStateChangeListener(scrollView);
128
-//            addScrollListener();
6
+public class RctView {
7
+//
8
+//    private BottomTabActivity context;
9
+//    private ReactRootView reactRootView;
10
+//    private ScrollView scrollView;
11
+//    private int lastScrollY = -1;
12
+//    private final ViewTreeObserver.OnScrollChangedListener scrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() {
13
+//        @Override
14
+//        public void onScrollChanged() {
15
+//            if (!scrollView.getViewTreeObserver().isAlive()) {
16
+//                return;
17
+//            }
18
+//
19
+//            final int scrollY = scrollView.getScrollY();
20
+//            if (scrollY != lastScrollY && // Scroll position changed
21
+//                scrollY > 0 && // Ignore top overscroll
22
+//                scrollY < (scrollView.getChildAt(0).getHeight() - scrollView.getHeight())) { // Ignore bottom overscroll
23
+//                int direction = scrollY > lastScrollY ?
24
+//                        BottomNavigation.SCROLL_DIRECTION_DOWN :
25
+//                        BottomNavigation.SCROLL_DIRECTION_UP;
26
+//                lastScrollY = scrollY;
27
+//                context.onScrollChanged(direction);
28
+//            }
129 29
 //        }
130
-//    }
131
-
132
-
133
-//    private void attachStateChangeListener(ScrollView scrollView) {
134
-//        scrollView.addOnAttachStateChangeListener(stateChangeListener);
30
+//    };
31
+//    private boolean isScrollEventListenerRegistered = false;
32
+//
33
+//    private final View.OnAttachStateChangeListener stateChangeListener =
34
+//            new View.OnAttachStateChangeListener() {
35
+//                @Override
36
+//                public void onViewAttachedToWindow(View v) {
37
+//                    scrollView = getScrollView((ViewGroup) getParent());
38
+//
39
+//                    if (scrollView != null && !isScrollEventListenerRegistered) {
40
+//                        addScrollListener();
41
+//                    }
42
+//                }
43
+//
44
+//                @Override
45
+//                public void onViewDetachedFromWindow(final View detachedView) {
46
+//                    removeScrollListener();
47
+//
48
+//                    post(new Runnable() {
49
+//                        @Override
50
+//                        public void run() {
51
+//                            scrollView = getScrollView((ViewGroup) getParent());
52
+//                            if (scrollView != null && !isScrollEventListenerRegistered) {
53
+//                                isScrollEventListenerRegistered = true;
54
+//                                addScrollListener();
55
+//                            }
56
+//                        }
57
+//                    });
58
+//                }
59
+//            };
60
+//
61
+//    /**
62
+//     * Interface used to run some code when the {@link ReactRootView} is visible.
63
+//     */
64
+//    public interface OnDisplayedListener {
65
+//        /**
66
+//         * This method will be invoked when the {@link ReactRootView} is visible.
67
+//         */
68
+//        void onDisplayed();
135 69
 //    }
136 70
 //
137
-//    private void addScrollListener() {
138
-//        scrollView.getViewTreeObserver().addOnScrollChangedListener(scrollChangedListener);
71
+//    @SuppressWarnings("unchecked")
72
+//    public RctView(BaseReactActivity ctx, ReactInstanceManager rctInstanceManager, final _Screen screen,
73
+//                   final OnDisplayedListener onDisplayedListener) {
74
+//        super(ctx);
75
+//        setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
76
+//
77
+//        final OnDisplayedListener onDisplayedListenerInternal = screen.bottomTabsHiddenOnScroll ?
78
+//            new OnDisplayedListener() {
79
+//                @Override
80
+//                public void onDisplayed() {
81
+//                    if (onDisplayedListener != null) {
82
+//                        onDisplayedListener.onDisplayed();
83
+//                    }
84
+//
85
+//                    setupScrollViewWithBottomTabs();
86
+//                }
87
+//            } : onDisplayedListener;
88
+//
89
+//        reactRootView = new RnnReactRootView(ctx, onDisplayedListenerInternal);
90
+//        reactRootView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
91
+//        Bundle passProps = createPassProps(screen);
92
+//        String componentName = screen.screenId;
93
+//        reactRootView.startReactApplication(rctInstanceManager, componentName, passProps);
94
+//
95
+//        addView(reactRootView);
139 96
 //    }
140 97
 //
141
-//    private void removeScrollListener() {
142
-//        scrollView.getViewTreeObserver().removeOnScrollChangedListener(scrollChangedListener);
98
+//    private Bundle createPassProps(_Screen screen) {
99
+//        Bundle passProps = new Bundle();
100
+//        passProps.putString(_Screen.KEY_SCREEN_INSTANCE_ID, screen.screenInstanceId);
101
+//        passProps.putString(_Screen.KEY_NAVIGATOR_ID, screen.navigatorId);
102
+//        passProps.putString(_Screen.KEY_NAVIGATOR_EVENT_ID, screen.navigatorEventId);
103
+//        if (screen.passedProps != null) {
104
+//            BridgeUtils.addMapToBundle(screen.passedProps, passProps);
105
+//        }
106
+//        return passProps;
143 107
 //    }
108
+//
109
+////    private void setupScrollViewWithBottomTabs() {
110
+////        scrollView = getScrollView((ViewGroup) getParent());
111
+////        if (scrollView != null) {
112
+////            context = (BottomTabActivity) getContext();
113
+////            attachStateChangeListener(scrollView);
114
+////            addScrollListener();
115
+////        }
116
+////    }
117
+//
118
+//
119
+////    private void attachStateChangeListener(ScrollView scrollView) {
120
+////        scrollView.addOnAttachStateChangeListener(stateChangeListener);
121
+////    }
122
+////
123
+////    private void addScrollListener() {
124
+////        scrollView.getViewTreeObserver().addOnScrollChangedListener(scrollChangedListener);
125
+////    }
126
+////
127
+////    private void removeScrollListener() {
128
+////        scrollView.getViewTreeObserver().removeOnScrollChangedListener(scrollChangedListener);
129
+////    }
144 130
 }
145 131
 

+ 23
- 28
android/app/src/main/java/com/reactnativenavigation/views/RnnReactRootView.java Bestand weergeven

@@ -1,34 +1,29 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
-import android.content.Context;
4
-import android.view.ViewTreeObserver;
5
-
6
-import com.facebook.react.ReactRootView;
7
-
8 3
 /**
9 4
  * Created by guyc on 11/07/16.
10 5
  */
11
-public class RnnReactRootView extends ReactRootView implements ViewTreeObserver.OnGlobalLayoutListener {
12
-    private final RctView.OnDisplayedListener mOnDisplayedListener;
13
-
14
-    public RnnReactRootView(Context context, RctView.OnDisplayedListener onDisplayedListener) {
15
-        super(context);
16
-        mOnDisplayedListener = onDisplayedListener;
17
-
18
-        if (onDisplayedListener != null) {
19
-            detectOnDisplay();
20
-        }
21
-    }
22
-
23
-    private void detectOnDisplay() {
24
-        getViewTreeObserver().addOnGlobalLayoutListener(this);
25
-    }
26
-
27
-    @Override
28
-    public void onGlobalLayout() {
29
-        if (getChildCount() >= 1) {
30
-            getViewTreeObserver().removeOnGlobalLayoutListener(this);
31
-            mOnDisplayedListener.onDisplayed();
32
-        }
33
-    }
6
+public class RnnReactRootView {
7
+//    private final RctView.OnDisplayedListener mOnDisplayedListener;
8
+//
9
+//    public RnnReactRootView(Context context, RctView.OnDisplayedListener onDisplayedListener) {
10
+//        super(context);
11
+//        mOnDisplayedListener = onDisplayedListener;
12
+//
13
+//        if (onDisplayedListener != null) {
14
+//            detectOnDisplay();
15
+//        }
16
+//    }
17
+//
18
+//    private void detectOnDisplay() {
19
+//        getViewTreeObserver().addOnGlobalLayoutListener(this);
20
+//    }
21
+//
22
+//    @Override
23
+//    public void onGlobalLayout() {
24
+//        if (getChildCount() >= 1) {
25
+//            getViewTreeObserver().removeOnGlobalLayoutListener(this);
26
+//            mOnDisplayedListener.onDisplayed();
27
+//        }
28
+//    }
34 29
 }

+ 60
- 71
android/app/src/main/java/com/reactnativenavigation/views/RnnTabLayout.java Bestand weergeven

@@ -1,77 +1,66 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
-import android.content.Context;
4
-import android.content.res.ColorStateList;
5
-import android.content.res.TypedArray;
6
-import android.graphics.drawable.Drawable;
7
-import android.support.design.widget.TabLayout;
8
-import android.util.AttributeSet;
9
-import android.util.TypedValue;
10
-
11
-import com.reactnativenavigation.R;
12
-import com.reactnativenavigation.core.objects._Screen;
13
-
14 3
 /**
15 4
  * Created by guyc on 07/05/16.
16 5
  */
17
-public class RnnTabLayout extends TabLayout {
18
-    private Drawable mBackground;
19
-    private ColorStateList mTabTextColors;
20
-    private int mSelectedTabIndicatorColor;
21
-
22
-    public RnnTabLayout(Context context) {
23
-        this(context, null);
24
-    }
25
-
26
-    public RnnTabLayout(Context context, AttributeSet attrs) {
27
-        this(context, attrs, 0);
28
-    }
29
-
30
-    public RnnTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
31
-        super(context, attrs, defStyleAttr);
32
-        init(context);
33
-    }
34
-
35
-    private void init(Context ctx) {
36
-        mBackground = getBackground();
37
-        mTabTextColors = getTabTextColors();
38
-
39
-        // Get default accent color which is used as the selected tab indicator color
40
-        TypedValue typedValue = new TypedValue();
41
-        TypedArray a = ctx.obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorAccent});
42
-        mSelectedTabIndicatorColor = a.getColor(0, 0);
43
-        a.recycle();
44
-    }
45
-
46
-    public void setStyle(_Screen screen) {
47
-        if (screen.toolBarColor != null) {
48
-            setBackgroundColor(screen.toolBarColor);
49
-        } else {
50
-            resetBackground();
51
-        }
52
-
53
-        if (screen.tabNormalTextColor != null && screen.tabSelectedTextColor != null) {
54
-            setTabTextColors(screen.tabNormalTextColor, screen.tabSelectedTextColor);
55
-        } else {
56
-            resetTextColors();
57
-        }
58
-
59
-        if (screen.tabIndicatorColor != null) {
60
-            setSelectedTabIndicatorColor(screen.tabIndicatorColor);
61
-        } else {
62
-            resetSelectedTabIndicatorColor();
63
-        }
64
-    }
65
-
66
-    public void resetBackground() {
67
-        setBackground(mBackground);
68
-    }
69
-
70
-    public void resetTextColors() {
71
-        setTabTextColors(mTabTextColors);
72
-    }
73
-
74
-    public void resetSelectedTabIndicatorColor() {
75
-        setSelectedTabIndicatorColor(mSelectedTabIndicatorColor);
76
-    }
6
+public class RnnTabLayout {
7
+//    private Drawable mBackground;
8
+//    private ColorStateList mTabTextColors;
9
+//    private int mSelectedTabIndicatorColor;
10
+//
11
+//    public RnnTabLayout(Context context) {
12
+//        this(context, null);
13
+//    }
14
+//
15
+//    public RnnTabLayout(Context context, AttributeSet attrs) {
16
+//        this(context, attrs, 0);
17
+//    }
18
+//
19
+//    public RnnTabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
20
+//        super(context, attrs, defStyleAttr);
21
+//        init(context);
22
+//    }
23
+//
24
+//    private void init(Context ctx) {
25
+//        mBackground = getBackground();
26
+//        mTabTextColors = getTabTextColors();
27
+//
28
+//        // Get default accent color which is used as the selected tab indicator color
29
+//        TypedValue typedValue = new TypedValue();
30
+//        TypedArray a = ctx.obtainStyledAttributes(typedValue.data, new int[]{R.attr.colorAccent});
31
+//        mSelectedTabIndicatorColor = a.getColor(0, 0);
32
+//        a.recycle();
33
+//    }
34
+//
35
+//    public void setStyle(_Screen screen) {
36
+//        if (screen.toolBarColor != null) {
37
+//            setBackgroundColor(screen.toolBarColor);
38
+//        } else {
39
+//            resetBackground();
40
+//        }
41
+//
42
+//        if (screen.tabNormalTextColor != null && screen.tabSelectedTextColor != null) {
43
+//            setTabTextColors(screen.tabNormalTextColor, screen.tabSelectedTextColor);
44
+//        } else {
45
+//            resetTextColors();
46
+//        }
47
+//
48
+//        if (screen.tabIndicatorColor != null) {
49
+//            setSelectedTabIndicatorColor(screen.tabIndicatorColor);
50
+//        } else {
51
+//            resetSelectedTabIndicatorColor();
52
+//        }
53
+//    }
54
+//
55
+//    public void resetBackground() {
56
+//        setBackground(mBackground);
57
+//    }
58
+//
59
+//    public void resetTextColors() {
60
+//        setTabTextColors(mTabTextColors);
61
+//    }
62
+//
63
+//    public void resetSelectedTabIndicatorColor() {
64
+//        setSelectedTabIndicatorColor(mSelectedTabIndicatorColor);
65
+//    }
77 66
 }

+ 357
- 395
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java Bestand weergeven

@@ -1,399 +1,361 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
-import android.app.Activity;
4
-import android.content.Context;
5
-import android.graphics.Color;
6
-import android.graphics.drawable.Drawable;
7
-import android.os.AsyncTask;
8
-import android.support.annotation.ColorInt;
9
-import android.support.annotation.NonNull;
10
-import android.support.annotation.UiThread;
11
-import android.support.v4.widget.DrawerLayout;
12
-import android.support.v7.app.ActionBar;
13
-import android.support.v7.app.ActionBarDrawerToggle;
14
-import android.support.v7.app.AppCompatActivity;
15
-import android.support.v7.graphics.drawable.DrawerArrowDrawable;
16
-import android.support.v7.widget.Toolbar;
17
-import android.view.Gravity;
18
-import android.view.Menu;
19
-import android.view.MenuItem;
20
-import android.view.View;
21
-import android.view.ViewTreeObserver;
22
-import android.widget.TextView;
23
-
24
-import com.reactnativenavigation.R;
25
-import com.reactnativenavigation.activities.BaseReactActivity;
26
-import com.reactnativenavigation.core.objects._Button;
27
-import com.reactnativenavigation.core.objects._Screen;
28
-import com.reactnativenavigation.utils.ContextProvider;
29
-import com.reactnativenavigation.react.ImageLoader;
30
-import com.reactnativenavigation.utils.ImageUtils;
31
-
32
-import java.lang.ref.WeakReference;
33
-import java.util.ArrayList;
34
-import java.util.HashMap;
35
-import java.util.List;
36
-import java.util.Map;
37
-
38
-/**
39
- * Created by guyc on 09/04/16.
40
- */
41
-public class RnnToolBar extends Toolbar {
42
-
43
-    private List<_Screen> mScreens;
44
-    private AsyncTask mDrawerIconTask;
45
-    private AsyncTask mSetupToolbarTask;
46
-    private Drawable mBackground;
47
-    private Drawable mDrawerIcon;
48
-    private DrawerLayout mDrawerLayout;
49
-    private ActionBarDrawerToggle mDrawerToggle;
50
-    private ArrayList<View> mMenuItems;
51
-
52
-    public RnnToolBar(Context context) {
53
-        super(context);
54
-        init();
55
-    }
56
-
57
-    private void init() {
58
-        mMenuItems = new ArrayList<>();
59
-        mBackground = getBackground();
60
-    }
61
-
62
-    public void setScreens(List<_Screen> screens) {
63
-        mScreens = screens;
64
-    }
65
-
66
-    public void handleOnCreateOptionsMenuAsync() {
67
-//        if (mScreens != null) {
68
-//            setupToolbarButtonsAsync(null, mScreens.get(0));
3
+public class RnnToolBar {
4
+
5
+//    private List<_Screen> mScreens;
6
+//    private AsyncTask mDrawerIconTask;
7
+//    private AsyncTask mSetupToolbarTask;
8
+//    private Drawable mBackground;
9
+//    private Drawable mDrawerIcon;
10
+//    private DrawerLayout mDrawerLayout;
11
+//    private ActionBarDrawerToggle mDrawerToggle;
12
+//    private ArrayList<View> mMenuItems;
13
+//
14
+//    public RnnToolBar(Context context) {
15
+//        super(context);
16
+//        init();
17
+//    }
18
+//
19
+//    private void init() {
20
+//        mMenuItems = new ArrayList<>();
21
+//        mBackground = getBackground();
22
+//    }
23
+//
24
+//    public void setScreens(List<_Screen> screens) {
25
+//        mScreens = screens;
26
+//    }
27
+//
28
+//    public void handleOnCreateOptionsMenuAsync() {
29
+////        if (mScreens != null) {
30
+////            setupToolbarButtonsAsync(null, mScreens.get(0));
31
+////        }
32
+//    }
33
+//
34
+//    public ActionBarDrawerToggle setupDrawer(DrawerLayout drawerLayout, _Screen drawerScreen, _Screen screen) {
35
+//        if (drawerLayout == null || drawerScreen == null) {
36
+//            return null;
69 37
 //        }
70
-    }
71
-
72
-    public ActionBarDrawerToggle setupDrawer(DrawerLayout drawerLayout, _Screen drawerScreen, _Screen screen) {
73
-        if (drawerLayout == null || drawerScreen == null) {
74
-            return null;
75
-        }
76
-
77
-        mDrawerLayout = drawerLayout;
78
-        mDrawerToggle = new ActionBarDrawerToggle(
79
-                ContextProvider.getActivityContext(),
80
-                mDrawerLayout,
81
-                this,
82
-                R.string.drawer_open,
83
-                R.string.drawer_close
84
-        );
85
-        mDrawerLayout.setDrawerListener(mDrawerToggle);
86
-        setupDrawerIconAsync(drawerScreen.icon, screen);
87
-
88
-        return mDrawerToggle;
89
-    }
90
-
91
-    public void setDrawerIcon(Drawable icon) {
92
-        mDrawerIcon = icon;
93
-    }
94
-
95
-    public void showDrawer(boolean animated) {
96
-        if (mDrawerLayout == null) {
97
-            return;
98
-        }
99
-
100
-        mDrawerLayout.openDrawer(Gravity.LEFT);
101
-    }
102
-
103
-    public void hideDrawer(boolean animated) {
104
-        if (mDrawerLayout == null) {
105
-            return;
106
-        }
107
-
108
-        mDrawerLayout.closeDrawer(Gravity.LEFT);
109
-    }
110
-
111
-    public void toggleDrawer(boolean animated) {
112
-        if (mDrawerLayout == null) {
113
-            return;
114
-        }
115
-
116
-        boolean visible = mDrawerLayout.isDrawerOpen(Gravity.LEFT);
117
-        if (visible) {
118
-            hideDrawer(animated);
119
-        } else {
120
-            showDrawer(animated);
121
-        }
122
-    }
123
-
124
-    public void setupDrawerIconAsync(String drawerIconSource, _Screen screen) {
125
-        if (mDrawerIconTask == null) {
126
-            mDrawerIconTask = new SetupDrawerIconTask(this, drawerIconSource, screen).execute();
127
-        }
128
-    }
129
-
130
-    public void setupToolbarButtonsAsync(_Screen newScreen) {
131
-        if (newScreen != null) {
132
-            this.setupToolbarButtonsAsync(null, newScreen);
133
-        }
134
-    }
135
-
136
-
137
-    public void setupToolbarButtonsAsync(_Screen oldScreen, _Screen newScreen) {
138
-        if (mSetupToolbarTask == null) {
139
-            mSetupToolbarTask = new SetupToolbarButtonsTask(this, oldScreen, newScreen).execute();
140
-        }
141
-    }
142
-
143
-    public void showToolbar(boolean animated) {
144
-        ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
145
-        if (actionBar != null) {
146
-            actionBar.setShowHideAnimationEnabled(animated);
147
-            // We hide the ToolBar's parent (AppBarLayout) since this animates the shadow added by AppBar as well
148
-            ((View) getParent()).setVisibility(VISIBLE);
149
-        }
150
-    }
151
-
152
-    public void hideToolbar(boolean animated) {
153
-        ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
154
-        if (actionBar != null) {
155
-            actionBar.setShowHideAnimationEnabled(animated);
156
-            // We hide the ToolBar's parent (AppBarLayout) since this animates the shadow added by AppBar as well
157
-            ((View) getParent()).setVisibility(GONE);
158
-        }
159
-    }
160
-
161
-    private void showToolbar() {
162
-        showToolbar(false);
163
-    }
164
-
165
-    private void hideToolbar() {
166
-        hideToolbar(false);
167
-    }
168
-
169
-    public void setNavUpButton() {
170
-        setNavUpButton(null);
171
-    }
172
-
173
-    @SuppressWarnings({"ConstantConditions"})
174
-    public void setNavUpButton(_Screen screen) {
175
-        BaseReactActivity context = ContextProvider.getActivityContext();
176
-        if (context == null) {
177
-            return;
178
-        }
179
-
180
-        ActionBar actionBar = context.getSupportActionBar();
181
-        if (actionBar == null) {
182
-            return;
183
-        }
184
-
185
-        boolean isBack = screen != null;
186
-        boolean hasDrawer = mDrawerToggle != null;
187
-
188
-        Drawable navIcon = null;
189
-        DrawerArrowDrawable navArrow = null;
190
-        if (hasDrawer && mDrawerIcon == null) {
191
-            navArrow = (DrawerArrowDrawable) this.getNavigationIcon();
192
-        } else {
193
-            if (isBack && !screen.backButtonHidden) {
194
-                navArrow = new DrawerArrowDrawable(context);
195
-            } else if (hasDrawer) {
196
-                navIcon = mDrawerIcon;
197
-            }
198
-        }
199
-
200
-        if (navArrow != null) {
201
-            navArrow.setProgress(isBack ? 1.0f : 0.0f);
202
-            if (screen != null && screen.navBarButtonColor != null) {
203
-                navArrow.setColor(screen.navBarButtonColor);
204
-            } else {
205
-                navArrow.setColor(Color.BLACK);
206
-            }
207
-            navIcon = navArrow;
208
-        }
209
-
210
-        actionBar.setHomeAsUpIndicator(navIcon);
211
-        actionBar.setDisplayHomeAsUpEnabled(navIcon != null);
212
-    }
213
-
214
-    /**
215
-     * Update the ToolBar from screen. This function sets any properties that are defined
216
-     * in the screen.
217
-     *
218
-     * @param screen The currently displayed screen
219
-     */
220
-    @UiThread
221
-    public void update(@NonNull _Screen screen) {
222
-        ((AppCompatActivity) getContext()).setSupportActionBar(this);
223
-        setTitle(screen.title);
224
-        setStyle(screen);
225
-    }
226
-
227
-    public void updateAndSetButtons(_Screen screen) {
228
-        update(screen);
229
-        setupToolbarButtonsAsync(screen);
230
-    }
231
-
232
-    private static class SetupDrawerIconTask extends AsyncTask<Void, Void, Drawable> {
233
-        private final WeakReference<RnnToolBar> mToolbarWR;
234
-        private final String mDrawerIconSource;
235
-        private final Integer mTintColor;
236
-
237
-        public SetupDrawerIconTask(RnnToolBar toolBar, String drawerIconSource, _Screen screen) {
238
-            mToolbarWR = new WeakReference<>(toolBar);
239
-            mDrawerIconSource = drawerIconSource;
240
-            mTintColor = screen.navBarButtonColor;
241
-        }
242
-
243
-        @Override
244
-        protected Drawable doInBackground(Void... params) {
245
-            Context context = ContextProvider.getActivityContext();
246
-            if (context == null || mDrawerIconSource == null) {
247
-                return null;
248
-            }
249
-
250
-            return ImageLoader.loadImage(mDrawerIconSource);
251
-        }
252
-
253
-        @Override
254
-        protected void onPostExecute(Drawable drawerIcon) {
255
-            RnnToolBar toolBar = mToolbarWR.get();
256
-            if (drawerIcon != null) {
257
-                if (mTintColor != null) {
258
-                    ImageUtils.tint(drawerIcon, mTintColor);
259
-                }
260
-                toolBar.setDrawerIcon(drawerIcon);
261
-            }
262
-
263
-            toolBar.setNavUpButton();
264
-            mToolbarWR.clear();
265
-        }
266
-    }
267
-
268
-    private static class SetupToolbarButtonsTask extends AsyncTask<Void, Void, Map<String, Drawable>> {
269
-        private final List<_Button> mOldButtons;
270
-        private final List<_Button> mNewButtons;
271
-        private final WeakReference<RnnToolBar> mToolbarWR;
272
-        @ColorInt
273
-        private final Integer mTintColor;
274
-        private final int mIconDimensions;
275
-
276
-        public SetupToolbarButtonsTask(RnnToolBar toolBar, _Screen oldScreen, _Screen newScreen) {
277
-            mToolbarWR = new WeakReference<>(toolBar);
278
-            mOldButtons = oldScreen == null ? null : oldScreen.getButtons();
279
-            mNewButtons = newScreen.getButtons();
280
-            mTintColor = newScreen.navBarButtonColor;
281
-            mIconDimensions = (int) ImageUtils.convertDpToPixel(48, toolBar.getContext());
282
-        }
283
-
284
-        @Override
285
-        protected Map<String, Drawable> doInBackground(Void... params) {
286
-            Context context = ContextProvider.getActivityContext();
287
-            if (context == null) {
288
-                return null;
289
-            }
290
-
291
-            Map<String, Drawable> icons = new HashMap<>();
292
-            for (_Button button : mNewButtons) {
293
-                if (button.hasIcon()) {
294
-                    icons.put(button.id, button.getIcon(context, mIconDimensions));
295
-                }
296
-            }
297
-            return icons;
298
-        }
299
-
300
-        @Override
301
-        protected void onPostExecute(Map<String, Drawable> icons) {
302
-            final Context context = ContextProvider.getActivityContext();
303
-            if (context == null) {
304
-                return;
305
-            }
306
-
307
-            Menu menu = ((BaseReactActivity) context).getMenu();
308
-            if (menu == null) {
309
-                RnnToolBar toolBar = mToolbarWR.get();
310
-                if (toolBar != null) {
311
-                    toolBar.mSetupToolbarTask = null;
312
-                }
313
-                mToolbarWR.clear();
314
-                return;
315
-            }
316
-
317
-            // Remove prev screen buttons
318
-            if (mOldButtons == null) {
319
-                menu.clear();
320
-            } else {
321
-                for (_Button btn : mOldButtons) {
322
-                    menu.removeItem(btn.getItemId());
323
-                }
324
-            }
325
-
326
-            // Add new screen buttons
327
-            final List<String> textButtons = new ArrayList<>();
328
-            final int size = mNewButtons.size();
329
-            for (int i = 0; i < size; i++) {
330
-                _Button button = mNewButtons.get(i);
331
-                MenuItem item = menu.add(Menu.NONE, button.getItemId(), size - i - 1, button.title);
332
-                item.setShowAsAction(getMenuItemShowAction(button.showAsAction));
333
-
334
-                // Set button icon
335
-                if (button.hasIcon()) {
336
-                    Drawable icon = icons.get(button.id);
337
-                    if (mTintColor != null) {
338
-                        ImageUtils.tint(icon, mTintColor);
339
-                    }
340
-                    item.setIcon(icon);
341
-                } else {
342
-                    textButtons.add(button.title);
343
-                }
344
-
345
-                // Disable button if needed
346
-                if (button.disabled) {
347
-                    item.setEnabled(false);
348
-                }
349
-            }
350
-
351
-            final RnnToolBar toolBar = mToolbarWR.get();
352
-            if (toolBar != null) {
353
-                // Tint overflow icon which appears when there's not enough space in Toolbar for icons
354
-                if (mTintColor != null) {
355
-                    ImageUtils.tint(toolBar.getOverflowIcon(), mTintColor);
356
-                }
357
-
358
-                // Tint text buttons
359
-                if (textButtons.size() > 0 && mTintColor != null) {
360
-                    final View decorView = ((Activity) context).getWindow().getDecorView();
361
-                    decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
362
-                        @Override
363
-                        public void onGlobalLayout() {
364
-                            decorView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
365
-
366
-                            // Find TextViews
367
-                            for (String text : textButtons) {
368
-                                decorView.findViewsWithText(toolBar.mMenuItems, text, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
369
-                            }
370
-
371
-                            // Set text color
372
-                            for (View button : toolBar.mMenuItems) {
373
-                                ((TextView) button).setTextColor(mTintColor);
374
-                            }
375
-
376
-                            toolBar.mMenuItems.clear();
377
-                        }
378
-                    });
379
-                }
380
-
381
-                toolBar.mSetupToolbarTask = null;
382
-                mToolbarWR.clear();
383
-            }
384
-        }
385
-
386
-        private int getMenuItemShowAction(String action) {
387
-            switch (action) {
388
-                case "never":
389
-                    return MenuItem.SHOW_AS_ACTION_NEVER;
390
-                case "always":
391
-                    return MenuItem.SHOW_AS_ACTION_ALWAYS;
392
-                case "withText":
393
-                    return MenuItem.SHOW_AS_ACTION_WITH_TEXT;
394
-                default:
395
-                    return MenuItem.SHOW_AS_ACTION_IF_ROOM;
396
-            }
397
-        }
398
-    }
38
+//
39
+//        mDrawerLayout = drawerLayout;
40
+//        mDrawerToggle = new ActionBarDrawerToggle(
41
+//                ContextProvider.getActivityContext(),
42
+//                mDrawerLayout,
43
+//                this,
44
+//                R.string.drawer_open,
45
+//                R.string.drawer_close
46
+//        );
47
+//        mDrawerLayout.setDrawerListener(mDrawerToggle);
48
+//        setupDrawerIconAsync(drawerScreen.icon, screen);
49
+//
50
+//        return mDrawerToggle;
51
+//    }
52
+//
53
+//    public void setDrawerIcon(Drawable icon) {
54
+//        mDrawerIcon = icon;
55
+//    }
56
+//
57
+//    public void showDrawer(boolean animated) {
58
+//        if (mDrawerLayout == null) {
59
+//            return;
60
+//        }
61
+//
62
+//        mDrawerLayout.openDrawer(Gravity.LEFT);
63
+//    }
64
+//
65
+//    public void hideDrawer(boolean animated) {
66
+//        if (mDrawerLayout == null) {
67
+//            return;
68
+//        }
69
+//
70
+//        mDrawerLayout.closeDrawer(Gravity.LEFT);
71
+//    }
72
+//
73
+//    public void toggleDrawer(boolean animated) {
74
+//        if (mDrawerLayout == null) {
75
+//            return;
76
+//        }
77
+//
78
+//        boolean visible = mDrawerLayout.isDrawerOpen(Gravity.LEFT);
79
+//        if (visible) {
80
+//            hideDrawer(animated);
81
+//        } else {
82
+//            showDrawer(animated);
83
+//        }
84
+//    }
85
+//
86
+//    public void setupDrawerIconAsync(String drawerIconSource, _Screen screen) {
87
+//        if (mDrawerIconTask == null) {
88
+//            mDrawerIconTask = new SetupDrawerIconTask(this, drawerIconSource, screen).execute();
89
+//        }
90
+//    }
91
+//
92
+//    public void setupToolbarButtonsAsync(_Screen newScreen) {
93
+//        if (newScreen != null) {
94
+//            this.setupToolbarButtonsAsync(null, newScreen);
95
+//        }
96
+//    }
97
+//
98
+//
99
+//    public void setupToolbarButtonsAsync(_Screen oldScreen, _Screen newScreen) {
100
+//        if (mSetupToolbarTask == null) {
101
+//            mSetupToolbarTask = new SetupToolbarButtonsTask(this, oldScreen, newScreen).execute();
102
+//        }
103
+//    }
104
+//
105
+//    public void showToolbar(boolean animated) {
106
+//        ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
107
+//        if (actionBar != null) {
108
+//            actionBar.setShowHideAnimationEnabled(animated);
109
+//            // We hide the ToolBar's parent (AppBarLayout) since this animates the shadow added by AppBar as well
110
+//            ((View) getParent()).setVisibility(VISIBLE);
111
+//        }
112
+//    }
113
+//
114
+//    public void hideToolbar(boolean animated) {
115
+//        ActionBar actionBar = ((AppCompatActivity) getContext()).getSupportActionBar();
116
+//        if (actionBar != null) {
117
+//            actionBar.setShowHideAnimationEnabled(animated);
118
+//            // We hide the ToolBar's parent (AppBarLayout) since this animates the shadow added by AppBar as well
119
+//            ((View) getParent()).setVisibility(GONE);
120
+//        }
121
+//    }
122
+//
123
+//    private void showToolbar() {
124
+//        showToolbar(false);
125
+//    }
126
+//
127
+//    private void hideToolbar() {
128
+//        hideToolbar(false);
129
+//    }
130
+//
131
+//    public void setNavUpButton() {
132
+//        setNavUpButton(null);
133
+//    }
134
+//
135
+//    @SuppressWarnings({"ConstantConditions"})
136
+//    public void setNavUpButton(_Screen screen) {
137
+//        BaseReactActivity context = ContextProvider.getActivityContext();
138
+//        if (context == null) {
139
+//            return;
140
+//        }
141
+//
142
+//        ActionBar actionBar = context.getSupportActionBar();
143
+//        if (actionBar == null) {
144
+//            return;
145
+//        }
146
+//
147
+//        boolean isBack = screen != null;
148
+//        boolean hasDrawer = mDrawerToggle != null;
149
+//
150
+//        Drawable navIcon = null;
151
+//        DrawerArrowDrawable navArrow = null;
152
+//        if (hasDrawer && mDrawerIcon == null) {
153
+//            navArrow = (DrawerArrowDrawable) this.getNavigationIcon();
154
+//        } else {
155
+//            if (isBack && !screen.backButtonHidden) {
156
+//                navArrow = new DrawerArrowDrawable(context);
157
+//            } else if (hasDrawer) {
158
+//                navIcon = mDrawerIcon;
159
+//            }
160
+//        }
161
+//
162
+//        if (navArrow != null) {
163
+//            navArrow.setProgress(isBack ? 1.0f : 0.0f);
164
+//            if (screen != null && screen.navBarButtonColor != null) {
165
+//                navArrow.setColor(screen.navBarButtonColor);
166
+//            } else {
167
+//                navArrow.setColor(Color.BLACK);
168
+//            }
169
+//            navIcon = navArrow;
170
+//        }
171
+//
172
+//        actionBar.setHomeAsUpIndicator(navIcon);
173
+//        actionBar.setDisplayHomeAsUpEnabled(navIcon != null);
174
+//    }
175
+//
176
+//    /**
177
+//     * Update the ToolBar from screen. This function sets any properties that are defined
178
+//     * in the screen.
179
+//     *
180
+//     * @param screen The currently displayed screen
181
+//     */
182
+//    @UiThread
183
+//    public void update(@NonNull _Screen screen) {
184
+//        ((AppCompatActivity) getContext()).setSupportActionBar(this);
185
+//        setTitle(screen.title);
186
+//        setStyle(screen);
187
+//    }
188
+//
189
+//    public void updateAndSetButtons(_Screen screen) {
190
+//        update(screen);
191
+//        setupToolbarButtonsAsync(screen);
192
+//    }
193
+//
194
+//    private static class SetupDrawerIconTask extends AsyncTask<Void, Void, Drawable> {
195
+//        private final WeakReference<RnnToolBar> mToolbarWR;
196
+//        private final String mDrawerIconSource;
197
+//        private final Integer mTintColor;
198
+//
199
+//        public SetupDrawerIconTask(RnnToolBar toolBar, String drawerIconSource, _Screen screen) {
200
+//            mToolbarWR = new WeakReference<>(toolBar);
201
+//            mDrawerIconSource = drawerIconSource;
202
+//            mTintColor = screen.navBarButtonColor;
203
+//        }
204
+//
205
+//        @Override
206
+//        protected Drawable doInBackground(Void... params) {
207
+//            Context context = ContextProvider.getActivityContext();
208
+//            if (context == null || mDrawerIconSource == null) {
209
+//                return null;
210
+//            }
211
+//
212
+//            return ImageLoader.loadImage(mDrawerIconSource);
213
+//        }
214
+//
215
+//        @Override
216
+//        protected void onPostExecute(Drawable drawerIcon) {
217
+//            RnnToolBar toolBar = mToolbarWR.get();
218
+//            if (drawerIcon != null) {
219
+//                if (mTintColor != null) {
220
+//                    ImageUtils.tint(drawerIcon, mTintColor);
221
+//                }
222
+//                toolBar.setDrawerIcon(drawerIcon);
223
+//            }
224
+//
225
+//            toolBar.setNavUpButton();
226
+//            mToolbarWR.clear();
227
+//        }
228
+//    }
229
+//
230
+//    private static class SetupToolbarButtonsTask extends AsyncTask<Void, Void, Map<String, Drawable>> {
231
+//        private final List<_Button> mOldButtons;
232
+//        private final List<_Button> mNewButtons;
233
+//        private final WeakReference<RnnToolBar> mToolbarWR;
234
+//        @ColorInt
235
+//        private final Integer mTintColor;
236
+//        private final int mIconDimensions;
237
+//
238
+//        public SetupToolbarButtonsTask(RnnToolBar toolBar, _Screen oldScreen, _Screen newScreen) {
239
+//            mToolbarWR = new WeakReference<>(toolBar);
240
+//            mOldButtons = oldScreen == null ? null : oldScreen.getButtons();
241
+//            mNewButtons = newScreen.getButtons();
242
+//            mTintColor = newScreen.navBarButtonColor;
243
+//            mIconDimensions = (int) ImageUtils.convertDpToPixel(48, toolBar.getContext());
244
+//        }
245
+//
246
+//        @Override
247
+//        protected Map<String, Drawable> doInBackground(Void... params) {
248
+//            Context context = ContextProvider.getActivityContext();
249
+//            if (context == null) {
250
+//                return null;
251
+//            }
252
+//
253
+//            Map<String, Drawable> icons = new HashMap<>();
254
+//            for (_Button button : mNewButtons) {
255
+//                if (button.hasIcon()) {
256
+//                    icons.put(button.id, button.getIcon(context, mIconDimensions));
257
+//                }
258
+//            }
259
+//            return icons;
260
+//        }
261
+//
262
+//        @Override
263
+//        protected void onPostExecute(Map<String, Drawable> icons) {
264
+//            final Context context = ContextProvider.getActivityContext();
265
+//            if (context == null) {
266
+//                return;
267
+//            }
268
+//
269
+//            Menu menu = ((BaseReactActivity) context).getMenu();
270
+//            if (menu == null) {
271
+//                RnnToolBar toolBar = mToolbarWR.get();
272
+//                if (toolBar != null) {
273
+//                    toolBar.mSetupToolbarTask = null;
274
+//                }
275
+//                mToolbarWR.clear();
276
+//                return;
277
+//            }
278
+//
279
+//            // Remove prev screen buttons
280
+//            if (mOldButtons == null) {
281
+//                menu.clear();
282
+//            } else {
283
+//                for (_Button btn : mOldButtons) {
284
+//                    menu.removeItem(btn.getItemId());
285
+//                }
286
+//            }
287
+//
288
+//            // Add new screen buttons
289
+//            final List<String> textButtons = new ArrayList<>();
290
+//            final int size = mNewButtons.size();
291
+//            for (int i = 0; i < size; i++) {
292
+//                _Button button = mNewButtons.get(i);
293
+//                MenuItem item = menu.add(Menu.NONE, button.getItemId(), size - i - 1, button.title);
294
+//                item.setShowAsAction(getMenuItemShowAction(button.showAsAction));
295
+//
296
+//                // Set button icon
297
+//                if (button.hasIcon()) {
298
+//                    Drawable icon = icons.get(button.id);
299
+//                    if (mTintColor != null) {
300
+//                        ImageUtils.tint(icon, mTintColor);
301
+//                    }
302
+//                    item.setIcon(icon);
303
+//                } else {
304
+//                    textButtons.add(button.title);
305
+//                }
306
+//
307
+//                // Disable button if needed
308
+//                if (button.disabled) {
309
+//                    item.setEnabled(false);
310
+//                }
311
+//            }
312
+//
313
+//            final RnnToolBar toolBar = mToolbarWR.get();
314
+//            if (toolBar != null) {
315
+//                // Tint overflow icon which appears when there's not enough space in Toolbar for icons
316
+//                if (mTintColor != null) {
317
+//                    ImageUtils.tint(toolBar.getOverflowIcon(), mTintColor);
318
+//                }
319
+//
320
+//                // Tint text buttons
321
+//                if (textButtons.size() > 0 && mTintColor != null) {
322
+//                    final View decorView = ((Activity) context).getWindow().getDecorView();
323
+//                    decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
324
+//                        @Override
325
+//                        public void onGlobalLayout() {
326
+//                            decorView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
327
+//
328
+//                            // Find TextViews
329
+//                            for (String text : textButtons) {
330
+//                                decorView.findViewsWithText(toolBar.mMenuItems, text, View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
331
+//                            }
332
+//
333
+//                            // Set text color
334
+//                            for (View button : toolBar.mMenuItems) {
335
+//                                ((TextView) button).setTextColor(mTintColor);
336
+//                            }
337
+//
338
+//                            toolBar.mMenuItems.clear();
339
+//                        }
340
+//                    });
341
+//                }
342
+//
343
+//                toolBar.mSetupToolbarTask = null;
344
+//                mToolbarWR.clear();
345
+//            }
346
+//        }
347
+//
348
+//        private int getMenuItemShowAction(String action) {
349
+//            switch (action) {
350
+//                case "never":
351
+//                    return MenuItem.SHOW_AS_ACTION_NEVER;
352
+//                case "always":
353
+//                    return MenuItem.SHOW_AS_ACTION_ALWAYS;
354
+//                case "withText":
355
+//                    return MenuItem.SHOW_AS_ACTION_WITH_TEXT;
356
+//                default:
357
+//                    return MenuItem.SHOW_AS_ACTION_IF_ROOM;
358
+//            }
359
+//        }
360
+//    }
399 361
 }

+ 161
- 175
android/app/src/main/java/com/reactnativenavigation/views/ScreenStack.java Bestand weergeven

@@ -1,178 +1,164 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
-import android.animation.LayoutTransition;
4
-import android.content.Context;
5
-import android.support.design.widget.CoordinatorLayout;
6
-import android.util.AttributeSet;
7
-import android.view.ViewGroup;
8
-
9
-import com.facebook.react.ReactInstanceManager;
10
-import com.reactnativenavigation.activities.BaseReactActivity;
11
-import com.reactnativenavigation.core.objects._Screen;
12
-
13
-import java.util.Stack;
14
-
15
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
16
-
17
-public class ScreenStack extends android.support.design.widget.CoordinatorLayout {
18
-
19
-    private static final int DISAPPEAR_ANIMATION_DELAY = 200;
20
-
21
-    private static class ScreenView {
22
-        _Screen screen;
23
-        RctView view;
24
-
25
-        public ScreenView(_Screen screen, RctView view) {
26
-            this.screen = screen;
27
-            this.view = view;
28
-        }
29
-    }
30
-
31
-    private final Stack<ScreenView> mStack = new Stack<>();
32
-    private final ReactInstanceManager mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();
33
-    private BaseReactActivity mReactActivity;
34
-
35
-    public ScreenStack(BaseReactActivity context) {
36
-        super(context);
37
-        init(context);
38
-    }
39
-
40
-    public ScreenStack(Context context, AttributeSet attrs) {
41
-        super(context, attrs);
42
-        init(context);
43
-    }
44
-
45
-    private void init(Context context) {
46
-        mReactActivity = (BaseReactActivity) context;
47
-        setLayoutTransition(new LayoutTransition());
48
-    }
49
-
50
-    public void push(_Screen screen) {
51
-        push(screen, null);
52
-    }
53
-
54
-    public void push(_Screen screen, RctView.OnDisplayedListener onDisplayed) {
55
-        RctView oldView = mStack.isEmpty() ? null : mStack.peek().view;
56
-        RctView view = new RctView(mReactActivity, mReactInstanceManager, screen, onDisplayed);
57
-        if (oldView != null) {
58
-            addView(view, MATCH_PARENT, MATCH_PARENT);
59
-
60
-            oldView.onTemporallyRemovedFromScreen();
61
-            getLayoutTransition().setStartDelay(LayoutTransition.DISAPPEARING, DISAPPEAR_ANIMATION_DELAY);
62
-            removeView(oldView);
63
-            getLayoutTransition().setStartDelay(LayoutTransition.DISAPPEARING, 0);
64
-        } else {
65
-            addView(view, MATCH_PARENT, MATCH_PARENT);
66
-        }
67
-        mStack.push(new ScreenView(screen, view));
68
-    }
69
-
70
-    public _Screen pop() {
71
-        if (mStack.isEmpty() || getStackSize() == 1) {
72
-            return null;
73
-        }
74
-
75
-        ScreenView popped = mStack.pop();
76
-
77
-        RctView newView = mStack.peek().view;
78
-        addView(newView);
79
-        newView.onReAddToScreen();
80
-
81
-        popped.view.onRemoveFromScreen();
82
-        removeView(popped.view);
83
-        return popped.screen;
84
-    }
85
-
86
-    public _Screen popToRoot() {
87
-        if (mStack.isEmpty() || getStackSize() <= 1) {
88
-            return null;
89
-        }
90
-
91
-        ScreenView oldScreenView = null;
92
-        while (getStackSize() > 1) {
93
-            ScreenView popped = mStack.pop();
94
-            popped.view.onRemoveFromScreen();
95
-            removeView(popped.view);
96
-            if (oldScreenView == null) {
97
-                oldScreenView = popped;
98
-            }
99
-        }
100
-
101
-        if (!mStack.isEmpty()) {
102
-            addView(mStack.peek().view, 0);
103
-        }
104
-
105
-        return oldScreenView != null ? oldScreenView.screen : null;
106
-    }
107
-
108
-    public _Screen resetTo(_Screen screen) {
109
-        return resetTo(screen, null);
110
-    }
111
-
112
-    public _Screen resetTo(_Screen screen, RctView.OnDisplayedListener onDisplayed) {
113
-        RctView view = new RctView(mReactActivity, mReactInstanceManager, screen, onDisplayed);
114
-        addView(view, MATCH_PARENT, MATCH_PARENT);
115
-
116
-        ScreenView oldScreenView = null;
117
-        if (!mStack.isEmpty()) {
118
-            while (getStackSize() > 0) {
119
-                ScreenView popped = mStack.pop();
120
-                popped.view.onRemoveFromScreen();
121
-                removeView(popped.view);
122
-                if (oldScreenView == null) {
123
-                    oldScreenView = popped;
124
-                }
125
-            }
126
-        }
127
-
128
-        // Add screen to stack after it's clear
129
-        mStack.push(new ScreenView(screen, view));
130
-
131
-        if (oldScreenView == null) {
132
-            return null;
133
-        }
134
-
135
-        return oldScreenView.screen;
136
-    }
137
-
138
-    public boolean isEmpty() {
139
-        return mStack.isEmpty();
140
-    }
141
-
142
-    public int getStackSize() {
143
-        return mStack.size();
144
-    }
145
-
146
-    public _Screen peek() {
147
-        return mStack.peek().screen;
148
-    }
149
-
150
-    /**
151
-     * Remove the ScreenStack from {@code parent} while preventing all child react views from getting unmounted
152
-     */
153
-    public void removeFromScreen(ViewGroup parent) {
154
-        mStack.peek().view.onTemporallyRemovedFromScreen();
155
-
156
-        parent.removeView(this);
157
-    }
158
-
159
-    /**
160
-     * Add ScreenStack to {@code parent}
161
-     */
162
-    public void addToScreen(ViewGroup parent) {
163
-        mStack.peek().view.onReAddToScreen();
164
-
165
-        parent.addView(this, new CoordinatorLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
166
-    }
167
-
168
-    public void removeAllReactViews() {
169
-        while (!mStack.empty()) {
170
-            RctView view = mStack.pop().view;
171
-            // Ensure view will be properly detached and unmounted
172
-            view.onRemoveFromScreen();
173
-            // Unmount the view
174
-            view.detachFromScreen();
175
-        }
176
-        removeAllViews();
177
-    }
3
+public class ScreenStack  {
4
+//
5
+//    private static final int DISAPPEAR_ANIMATION_DELAY = 200;
6
+//
7
+//    private static class ScreenView {
8
+//        _Screen screen;
9
+//        RctView view;
10
+//
11
+//        public ScreenView(_Screen screen, RctView view) {
12
+//            this.screen = screen;
13
+//            this.view = view;
14
+//        }
15
+//    }
16
+//
17
+//    private final Stack<ScreenView> mStack = new Stack<>();
18
+//    private final ReactInstanceManager mReactInstanceManager = RctManager.getInstance().getReactInstanceManager();
19
+//    private BaseReactActivity mReactActivity;
20
+//
21
+//    public ScreenStack(BaseReactActivity context) {
22
+//        super(context);
23
+//        init(context);
24
+//    }
25
+//
26
+//    public ScreenStack(Context context, AttributeSet attrs) {
27
+//        super(context, attrs);
28
+//        init(context);
29
+//    }
30
+//
31
+//    private void init(Context context) {
32
+//        mReactActivity = (BaseReactActivity) context;
33
+//        setLayoutTransition(new LayoutTransition());
34
+//    }
35
+//
36
+//    public void push(_Screen screen) {
37
+//        push(screen, null);
38
+//    }
39
+//
40
+//    public void push(_Screen screen, RctView.OnDisplayedListener onDisplayed) {
41
+//        RctView oldView = mStack.isEmpty() ? null : mStack.peek().view;
42
+//        RctView view = new RctView(mReactActivity, mReactInstanceManager, screen, onDisplayed);
43
+//        if (oldView != null) {
44
+//            addView(view, MATCH_PARENT, MATCH_PARENT);
45
+//
46
+//            oldView.onTemporallyRemovedFromScreen();
47
+//            getLayoutTransition().setStartDelay(LayoutTransition.DISAPPEARING, DISAPPEAR_ANIMATION_DELAY);
48
+//            removeView(oldView);
49
+//            getLayoutTransition().setStartDelay(LayoutTransition.DISAPPEARING, 0);
50
+//        } else {
51
+//            addView(view, MATCH_PARENT, MATCH_PARENT);
52
+//        }
53
+//        mStack.push(new ScreenView(screen, view));
54
+//    }
55
+//
56
+//    public _Screen pop() {
57
+//        if (mStack.isEmpty() || getStackSize() == 1) {
58
+//            return null;
59
+//        }
60
+//
61
+//        ScreenView popped = mStack.pop();
62
+//
63
+//        RctView newView = mStack.peek().view;
64
+//        addView(newView);
65
+//        newView.onReAddToScreen();
66
+//
67
+//        popped.view.onRemoveFromScreen();
68
+//        removeView(popped.view);
69
+//        return popped.screen;
70
+//    }
71
+//
72
+//    public _Screen popToRoot() {
73
+//        if (mStack.isEmpty() || getStackSize() <= 1) {
74
+//            return null;
75
+//        }
76
+//
77
+//        ScreenView oldScreenView = null;
78
+//        while (getStackSize() > 1) {
79
+//            ScreenView popped = mStack.pop();
80
+//            popped.view.onRemoveFromScreen();
81
+//            removeView(popped.view);
82
+//            if (oldScreenView == null) {
83
+//                oldScreenView = popped;
84
+//            }
85
+//        }
86
+//
87
+//        if (!mStack.isEmpty()) {
88
+//            addView(mStack.peek().view, 0);
89
+//        }
90
+//
91
+//        return oldScreenView != null ? oldScreenView.screen : null;
92
+//    }
93
+//
94
+//    public _Screen resetTo(_Screen screen) {
95
+//        return resetTo(screen, null);
96
+//    }
97
+//
98
+//    public _Screen resetTo(_Screen screen, RctView.OnDisplayedListener onDisplayed) {
99
+//        RctView view = new RctView(mReactActivity, mReactInstanceManager, screen, onDisplayed);
100
+//        addView(view, MATCH_PARENT, MATCH_PARENT);
101
+//
102
+//        ScreenView oldScreenView = null;
103
+//        if (!mStack.isEmpty()) {
104
+//            while (getStackSize() > 0) {
105
+//                ScreenView popped = mStack.pop();
106
+//                popped.view.onRemoveFromScreen();
107
+//                removeView(popped.view);
108
+//                if (oldScreenView == null) {
109
+//                    oldScreenView = popped;
110
+//                }
111
+//            }
112
+//        }
113
+//
114
+//        // Add screen to stack after it's clear
115
+//        mStack.push(new ScreenView(screen, view));
116
+//
117
+//        if (oldScreenView == null) {
118
+//            return null;
119
+//        }
120
+//
121
+//        return oldScreenView.screen;
122
+//    }
123
+//
124
+//    public boolean isEmpty() {
125
+//        return mStack.isEmpty();
126
+//    }
127
+//
128
+//    public int getStackSize() {
129
+//        return mStack.size();
130
+//    }
131
+//
132
+//    public _Screen peek() {
133
+//        return mStack.peek().screen;
134
+//    }
135
+//
136
+//    /**
137
+//     * Remove the ScreenStack from {@code parent} while preventing all child react views from getting unmounted
138
+//     */
139
+//    public void removeFromScreen(ViewGroup parent) {
140
+//        mStack.peek().view.onTemporallyRemovedFromScreen();
141
+//
142
+//        parent.removeView(this);
143
+//    }
144
+//
145
+//    /**
146
+//     * Add ScreenStack to {@code parent}
147
+//     */
148
+//    public void addToScreen(ViewGroup parent) {
149
+//        mStack.peek().view.onReAddToScreen();
150
+//
151
+//        parent.addView(this, new CoordinatorLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
152
+//    }
153
+//
154
+//    public void removeAllReactViews() {
155
+//        while (!mStack.empty()) {
156
+//            RctView view = mStack.pop().view;
157
+//            // Ensure view will be properly detached and unmounted
158
+//            view.onRemoveFromScreen();
159
+//            // Unmount the view
160
+//            view.detachFromScreen();
161
+//        }
162
+//        removeAllViews();
163
+//    }
178 164
 }

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java Bestand weergeven

@@ -36,6 +36,7 @@ public class TitleBar extends Toolbar {
36 36
     }
37 37
 
38 38
     public void setupMenuButton() {
39
+
39 40
     }
40 41
 
41 42
     private void createMenu() {

+ 12
- 5
android/app/src/main/java/com/reactnativenavigation/views/TitleBarButton.java Bestand weergeven

@@ -30,12 +30,19 @@ public class TitleBarButton {
30 30
         }
31 31
 
32 32
         // Todo: add id for click listener
33
-        String label;
34
-        Drawable icon;
33
+        private final String label;
34
+        private final Drawable icon;
35 35
         @ColorInt
36
-        int color;
37
-        ShowAsAction showAsAction;
38
-        boolean enabled = true;
36
+        private final int color;
37
+        private final ShowAsAction showAsAction;
38
+        private final boolean enabled = true;
39
+
40
+        public Params(String label, Drawable icon, int color, ShowAsAction showAsAction) {
41
+            this.label = label;
42
+            this.icon = icon;
43
+            this.color = color;
44
+            this.showAsAction = showAsAction;
45
+        }
39 46
     }
40 47
 
41 48
     private final Menu menu;

+ 2
- 2
example-redux/android/app/src/main/java/com/exampleredux/MainActivity.java Bestand weergeven

@@ -1,7 +1,7 @@
1 1
 package com.exampleredux;
2 2
 
3
-import com.reactnativenavigation.activities.RootActivity;
3
+import com.reactnativenavigation.controllers.NavigationActivity;
4 4
 
5
-public class MainActivity extends RootActivity {
5
+public class MainActivity extends NavigationActivity {
6 6
 
7 7
 }

+ 0
- 1
example-redux/package.json Bestand weergeven

@@ -11,7 +11,6 @@
11 11
   "dependencies": {
12 12
     "react-native": "0.25.1",
13 13
     "react": "0.14.5",
14
-    "fbjs": "^0.6.1",
15 14
     "react-redux": "^4.0.6",
16 15
     "redux": "^3.0.5",
17 16
     "redux-thunk": "^1.0.3",

+ 40
- 41
src/platformSpecific.android.js Bestand weergeven

@@ -1,11 +1,9 @@
1 1
 import React, {Component} from 'react';
2
-import {AppRegistry} from 'react-native';
2
+import {AppRegistry, NativeModules} from 'react-native';
3 3
 
4 4
 import Navigation from './Navigation';
5 5
 import utils from './utils';
6 6
 
7
-import {RctActivity} from 'react-native-navigation';
8
-
9 7
 const resolveAssetSource = require('react-native/Libraries/Image/resolveAssetSource');
10 8
 
11 9
 function startSingleScreenApp(params) {
@@ -20,7 +18,7 @@ function startSingleScreenApp(params) {
20 18
   addNavigationStyleParams(screen);
21 19
   screen.passProps = params.passProps;
22 20
   const drawer = setupDrawer(params.drawer);
23
-  RctActivity.startSingleScreenApp(screen, drawer);
21
+  //NativeModules.NavigationReactModule.startApp(screen, drawer);
24 22
 }
25 23
 
26 24
 function startTabBasedApp(params) {
@@ -38,7 +36,7 @@ function startTabBasedApp(params) {
38 36
   });
39 37
 
40 38
   const drawer = setupDrawer(params.drawer);
41
-  RctActivity.startTabBasedApp(params.tabs, params.tabsStyle, drawer);
39
+  //RctActivity.startTabBasedApp(params.tabs, params.tabsStyle, drawer);
42 40
 }
43 41
 
44 42
 function addTabIcon(tab) {
@@ -58,7 +56,7 @@ function navigatorPush(navigator, params) {
58 56
   addNavigatorParams(params, navigator);
59 57
   addNavigatorButtons(params);
60 58
   addNavigationStyleParams(params);
61
-  RctActivity.navigatorPush(params);
59
+  //RctActivity.navigatorPush(params);
62 60
 }
63 61
 
64 62
 function navigatorSetButtons(navigator, navigatorEventID, params) {
@@ -72,81 +70,81 @@ function navigatorSetButtons(navigator, navigatorEventID, params) {
72 70
       }
73 71
     });
74 72
   }
75
-  RctActivity.setNavigatorButtons(params);
73
+  //RctActivity.setNavigatorButtons(params);
76 74
 }
77 75
 
78 76
 function navigatorPop(navigator, params) {
79 77
   addNavigatorParams(params, navigator);
80
-  RctActivity.navigatorPop(params);
78
+  //RctActivity.navigatorPop(params);
81 79
 }
82 80
 
83 81
 function navigatorPopToRoot(navigator, params) {
84
-  RctActivity.navigatorPopToRoot({
85
-    navigatorID: navigator.navigatorID,
86
-    animated: !(params.animated === false)
87
-  });
82
+  //RctActivity.navigatorPopToRoot({
83
+  //  navigatorID: navigator.navigatorID,
84
+  //  animated: !(params.animated === false)
85
+  //});
88 86
 }
89 87
 
90 88
 function navigatorResetTo(navigator, params) {
91 89
   addNavigatorParams(params, navigator);
92 90
   addNavigatorButtons(params);
93 91
   addNavigationStyleParams(params);
94
-  RctActivity.navigatorResetTo(params);
92
+  //RctActivity.navigatorResetTo(params);
95 93
 }
96 94
 
97 95
 function navigatorSetTabBadge(navigator, params) {
98
-  RctActivity.setTabBadge({
99
-    tabIndex: params.tabIndex,
100
-    badge: params.badge
101
-  });
96
+  //RctActivity.setTabBadge({
97
+  //  tabIndex: params.tabIndex,
98
+  //  badge: params.badge
99
+  //});
102 100
 }
103 101
 
104 102
 function navigatorSetTitle(navigator, params) {
105
-  RctActivity.setNavigatorTitle(params);
103
+  //RctActivity.setNavigatorTitle(params);
106 104
 }
107 105
 
108 106
 function navigatorSwitchToTab(navigator, params) {
109
-  RctActivity.switchToTab({
110
-    navigatorID: navigator.navigatorID,
111
-    tabIndex: params.tabIndex
112
-  });
107
+  //RctActivity.switchToTab({
108
+  //  navigatorID: navigator.navigatorID,
109
+  //  tabIndex: params.tabIndex
110
+  //});
113 111
 }
114 112
 
115 113
 function navigatorToggleDrawer(navigator, params) {
116
-  RctActivity.toggleDrawer({
117
-    side: params.side,
118
-    animated: !(params.animated === false),
119
-    to: params.to || ''
120
-  });
114
+  //RctActivity.toggleDrawer({
115
+  //  side: params.side,
116
+  //  animated: !(params.animated === false),
117
+  //  to: params.to || ''
118
+  //});
121 119
 }
122 120
 
123 121
 function navigatorToggleNavBar(navigator, params) {
124
-  RctActivity.toggleNavigationBar({
125
-    hidden: params.to === 'hidden',
126
-    animated: !(params.animated === false)
127
-  });
122
+  //RctActivity.toggleNavigationBar({
123
+  //  hidden: params.to === 'hidden',
124
+  //  animated: !(params.animated === false)
125
+  //});
128 126
 }
129 127
 
130 128
 function navigatorToggleTabs(navigator, params) {
131
-  RctActivity.toggleNavigatorTabs({
132
-    hidden: params.to === 'hidden',
133
-    animated: !(params.animated === false)
134
-  });
129
+  //RctActivity.toggleNavigatorTabs({
130
+  //  hidden: params.to === 'hidden',
131
+  //  animated: !(params.animated === false)
132
+  //});
135 133
 }
136 134
 
137 135
 function showModal(params) {
138 136
   addNavigatorParams(params);
139 137
   addNavigatorButtons(params);
140 138
   addNavigationStyleParams(params);
141
-  RctActivity.showModal(params);
139
+  //RctActivity.showModal(params);
142 140
 }
143 141
 
144 142
 function dismissModal() {
145
-  RctActivity.dismissModal();
143
+  //RctActivity.dismissModal();
146 144
 }
147 145
 
148 146
 function dismissAllModals(params) {
149
-  RctActivity.dismissAllModals(params.animationType);
147
+  //RctActivity.dismissAllModals(params.animationType);
150 148
 }
151 149
 
152 150
 function addNavigatorParams(screen, navigator = null, idx = '') {
@@ -161,7 +159,7 @@ function addNavigatorButtons(screen) {
161 159
 
162 160
   // Get image uri from image id
163 161
   const rightButtons = screen.rightButtons ? screen.rightButtons : screen.navigatorButtons ?
164
-    screen.navigatorButtons.rightButtons : null;
162
+                                                                   screen.navigatorButtons.rightButtons : null;
165 163
   if (rightButtons) {
166 164
     rightButtons.forEach(function(button) {
167 165
       if (button.icon) {
@@ -192,14 +190,15 @@ function setupDrawer(drawerParams) {
192 190
   });
193 191
   if (drawer.disableOpenGesture === undefined) {
194 192
     drawer.disableOpenGesture = false;
195
-  };
193
+  }
194
+  ;
196 195
 
197 196
   return drawer;
198 197
 }
199 198
 
200 199
 function showFAB(params) {
201 200
   params.icon = resolveAssetSource(params.icon).uri;
202
-  RctActivity.showFAB(params);
201
+  //RctActivity.showFAB(params);
203 202
 }
204 203
 
205 204
 export default {