Browse Source

titlebarbuttons

Daniel Zlotin 8 years ago
parent
commit
18b36b0899

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/activities/BaseReactActivity.java View File

119
 //        if (item.getItemId() == android.R.id.home) {
119
 //        if (item.getItemId() == android.R.id.home) {
120
 //            onBackPressed();
120
 //            onBackPressed();
121
 //        } else {
121
 //        } else {
122
-//            String eventId = Button.getButtonEventId(item);
122
+//            String eventId = TitleBarButton.getButtonEventId(item);
123
 //            assert eventId != null;
123
 //            assert eventId != null;
124
 //
124
 //
125
 //            WritableMap params = Arguments.createMap();
125
 //            WritableMap params = Arguments.createMap();

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

5
 import android.widget.LinearLayout;
5
 import android.widget.LinearLayout;
6
 
6
 
7
 import com.facebook.react.ReactInstanceManager;
7
 import com.facebook.react.ReactInstanceManager;
8
-import com.reactnativenavigation.core.Button;
8
+import com.reactnativenavigation.views.TitleBarButton;
9
 import com.reactnativenavigation.views.ContentView;
9
 import com.reactnativenavigation.views.ContentView;
10
 import com.reactnativenavigation.views.ScrollDirectionListener;
10
 import com.reactnativenavigation.views.ScrollDirectionListener;
11
 import com.reactnativenavigation.views.TitleBar;
11
 import com.reactnativenavigation.views.TitleBar;
20
     public static class Params {
20
     public static class Params {
21
         String moduleName;
21
         String moduleName;
22
         Bundle passProps;
22
         Bundle passProps;
23
-        List<Button> buttons;
23
+        List<TitleBarButton> buttons;
24
     }
24
     }
25
 
25
 
26
     private final ReactInstanceManager reactInstanceManager;
26
     private final ReactInstanceManager reactInstanceManager;
27
     private final String moduleName;
27
     private final String moduleName;
28
     private final Bundle passProps;
28
     private final Bundle passProps;
29
-    private final List<Button> buttons;
29
+    private final List<TitleBarButton> buttons;
30
     private ContentView contentView;
30
     private ContentView contentView;
31
     private TopBar topBar;
31
     private TopBar topBar;
32
 
32
 

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

76
 
76
 
77
         mDrawerLayout = drawerLayout;
77
         mDrawerLayout = drawerLayout;
78
         mDrawerToggle = new ActionBarDrawerToggle(
78
         mDrawerToggle = new ActionBarDrawerToggle(
79
-            ContextProvider.getActivityContext(),
80
-            mDrawerLayout,
81
-            this,
82
-            R.string.drawer_open,
83
-            R.string.drawer_close
79
+                ContextProvider.getActivityContext(),
80
+                mDrawerLayout,
81
+                this,
82
+                R.string.drawer_open,
83
+                R.string.drawer_close
84
         );
84
         );
85
         mDrawerLayout.setDrawerListener(mDrawerToggle);
85
         mDrawerLayout.setDrawerListener(mDrawerToggle);
86
         setupDrawerIconAsync(drawerScreen.icon, screen);
86
         setupDrawerIconAsync(drawerScreen.icon, screen);
214
     /**
214
     /**
215
      * Update the ToolBar from screen. This function sets any properties that are defined
215
      * Update the ToolBar from screen. This function sets any properties that are defined
216
      * in the screen.
216
      * in the screen.
217
+     *
217
      * @param screen The currently displayed screen
218
      * @param screen The currently displayed screen
218
      */
219
      */
219
     @UiThread
220
     @UiThread
268
         private final List<_Button> mOldButtons;
269
         private final List<_Button> mOldButtons;
269
         private final List<_Button> mNewButtons;
270
         private final List<_Button> mNewButtons;
270
         private final WeakReference<RnnToolBar> mToolbarWR;
271
         private final WeakReference<RnnToolBar> mToolbarWR;
271
-        @ColorInt private final Integer mTintColor;
272
+        @ColorInt
273
+        private final Integer mTintColor;
272
         private final int mIconDimensions;
274
         private final int mIconDimensions;
273
 
275
 
274
         public SetupToolbarButtonsTask(RnnToolBar toolBar, _Screen oldScreen, _Screen newScreen) {
276
         public SetupToolbarButtonsTask(RnnToolBar toolBar, _Screen oldScreen, _Screen newScreen) {
313
             }
315
             }
314
 
316
 
315
             // Remove prev screen buttons
317
             // Remove prev screen buttons
316
-            if(mOldButtons == null) {
318
+            if (mOldButtons == null) {
317
                 menu.clear();
319
                 menu.clear();
318
             } else {
320
             } else {
319
                 for (_Button btn : mOldButtons) {
321
                 for (_Button btn : mOldButtons) {

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

9
 
9
 
10
 import com.reactnativenavigation.R;
10
 import com.reactnativenavigation.R;
11
 import com.reactnativenavigation.animation.HideOnScrollAnimator;
11
 import com.reactnativenavigation.animation.HideOnScrollAnimator;
12
-import com.reactnativenavigation.core.Button;
13
 
12
 
14
 import java.util.List;
13
 import java.util.List;
15
 
14
 
23
     public TitleBar(Context context) {
22
     public TitleBar(Context context) {
24
         super(context);
23
         super(context);
25
         createMenu();
24
         createMenu();
25
+    }
26
+
27
+    public void setButtons(List<TitleBarButton.Params> buttons) {
28
+        menu.clear();
29
+
30
+        for (int i = 0; i < buttons.size(); i++) {
31
+            final TitleBarButton button = new TitleBarButton(menu, actionMenuView, buttons.get(i));
32
+            // Add button in reverse order because in iOS index 0 starts at right
33
+            final int index = buttons.size() - i - 1;
34
+            button.addToMenu(index);
35
+        }
36
+    }
26
 
37
 
38
+    public void setupMenuButton() {
27
     }
39
     }
28
 
40
 
29
     private void createMenu() {
41
     private void createMenu() {
35
         // TODO: Maybe setSupportActionBar
47
         // TODO: Maybe setSupportActionBar
36
     }
48
     }
37
 
49
 
38
-    public void setButtons(List<Button.Params> buttons) {
39
-        menu.clear();
40
-
41
-        for (int i = 0; i < buttons.size(); i++) {
42
-            final Button button = new Button(menu, actionMenuView, buttons.get(i));
43
-            // Add button in reverse order because in iOS index 0 starts at right
44
-            final int index = buttons.size() - i - 1;
45
-            button.addToMenu(index);
46
-        }
47
-    }
48
-
49
     public void setHideOnScroll(boolean hideOnScroll) {
50
     public void setHideOnScroll(boolean hideOnScroll) {
50
         this.hideOnScroll = hideOnScroll;
51
         this.hideOnScroll = hideOnScroll;
51
     }
52
     }

android/app/src/main/java/com/reactnativenavigation/core/Button.java → android/app/src/main/java/com/reactnativenavigation/views/TitleBarButton.java View File

1
-package com.reactnativenavigation.core;
1
+package com.reactnativenavigation.views;
2
 
2
 
3
 import android.graphics.drawable.Drawable;
3
 import android.graphics.drawable.Drawable;
4
 import android.support.annotation.ColorInt;
4
 import android.support.annotation.ColorInt;
14
 
14
 
15
 import java.util.ArrayList;
15
 import java.util.ArrayList;
16
 
16
 
17
-public class Button {
17
+public class TitleBarButton {
18
     public static class Params {
18
     public static class Params {
19
         public enum ShowAsAction {
19
         public enum ShowAsAction {
20
             IfRoom(MenuItem.SHOW_AS_ACTION_IF_ROOM),
20
             IfRoom(MenuItem.SHOW_AS_ACTION_IF_ROOM),
42
     private final ActionMenuView parent;
42
     private final ActionMenuView parent;
43
     private Params buttonParams;
43
     private Params buttonParams;
44
 
44
 
45
-    public Button(Menu menu, ActionMenuView parent, Params buttonParams) {
45
+    public TitleBarButton(Menu menu, ActionMenuView parent, Params buttonParams) {
46
         this.menu = menu;
46
         this.menu = menu;
47
         this.parent = parent;
47
         this.parent = parent;
48
         this.buttonParams = buttonParams;
48
         this.buttonParams = buttonParams;

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

1
+package com.reactnativenavigation.views;
2
+
3
+public class TitleBarMenuButton {
4
+
5
+    public TitleBarMenuButton() {
6
+    }
7
+}