Quellcode durchsuchen

titlebarbuttons

Daniel Zlotin vor 8 Jahren
Ursprung
Commit
18b36b0899

+ 1
- 1
android/app/src/main/java/com/reactnativenavigation/activities/BaseReactActivity.java Datei anzeigen

@@ -119,7 +119,7 @@ public abstract class BaseReactActivity extends AppCompatActivity implements Def
119 119
 //        if (item.getItemId() == android.R.id.home) {
120 120
 //            onBackPressed();
121 121
 //        } else {
122
-//            String eventId = Button.getButtonEventId(item);
122
+//            String eventId = TitleBarButton.getButtonEventId(item);
123 123
 //            assert eventId != null;
124 124
 //
125 125
 //            WritableMap params = Arguments.createMap();

+ 3
- 3
android/app/src/main/java/com/reactnativenavigation/layouts/ScreenLayout.java Datei anzeigen

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

+ 9
- 7
android/app/src/main/java/com/reactnativenavigation/views/RnnToolBar.java Datei anzeigen

@@ -76,11 +76,11 @@ public class RnnToolBar extends Toolbar {
76 76
 
77 77
         mDrawerLayout = drawerLayout;
78 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 85
         mDrawerLayout.setDrawerListener(mDrawerToggle);
86 86
         setupDrawerIconAsync(drawerScreen.icon, screen);
@@ -214,6 +214,7 @@ public class RnnToolBar extends Toolbar {
214 214
     /**
215 215
      * Update the ToolBar from screen. This function sets any properties that are defined
216 216
      * in the screen.
217
+     *
217 218
      * @param screen The currently displayed screen
218 219
      */
219 220
     @UiThread
@@ -268,7 +269,8 @@ public class RnnToolBar extends Toolbar {
268 269
         private final List<_Button> mOldButtons;
269 270
         private final List<_Button> mNewButtons;
270 271
         private final WeakReference<RnnToolBar> mToolbarWR;
271
-        @ColorInt private final Integer mTintColor;
272
+        @ColorInt
273
+        private final Integer mTintColor;
272 274
         private final int mIconDimensions;
273 275
 
274 276
         public SetupToolbarButtonsTask(RnnToolBar toolBar, _Screen oldScreen, _Screen newScreen) {
@@ -313,7 +315,7 @@ public class RnnToolBar extends Toolbar {
313 315
             }
314 316
 
315 317
             // Remove prev screen buttons
316
-            if(mOldButtons == null) {
318
+            if (mOldButtons == null) {
317 319
                 menu.clear();
318 320
             } else {
319 321
                 for (_Button btn : mOldButtons) {

+ 13
- 12
android/app/src/main/java/com/reactnativenavigation/views/TitleBar.java Datei anzeigen

@@ -9,7 +9,6 @@ import android.view.MenuInflater;
9 9
 
10 10
 import com.reactnativenavigation.R;
11 11
 import com.reactnativenavigation.animation.HideOnScrollAnimator;
12
-import com.reactnativenavigation.core.Button;
13 12
 
14 13
 import java.util.List;
15 14
 
@@ -23,7 +22,20 @@ public class TitleBar extends Toolbar {
23 22
     public TitleBar(Context context) {
24 23
         super(context);
25 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 41
     private void createMenu() {
@@ -35,17 +47,6 @@ public class TitleBar extends Toolbar {
35 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 50
     public void setHideOnScroll(boolean hideOnScroll) {
50 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 Datei anzeigen

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

+ 7
- 0
android/app/src/main/java/com/reactnativenavigation/views/TitleBarMenuButton.java Datei anzeigen

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