瀏覽代碼

Refactor towards StackLayout (#2506)

* Deleted getContentView method
* Delete Custom dialog code
* Delete topTab code
* sendOnNavigationButtonPressed was pulled to a dedicated interface
Guy Carmeli 6 年之前
父節點
當前提交
3a9e8d5368
No account linked to committer's email address

+ 0
- 5
lib/android/app/src/main/java/com/reactnativenavigation/anim/NavigationAnimator.java 查看文件

@@ -4,18 +4,13 @@ import android.animation.Animator;
4 4
 import android.animation.AnimatorListenerAdapter;
5 5
 import android.animation.AnimatorSet;
6 6
 import android.animation.ObjectAnimator;
7
-import android.animation.TimeInterpolator;
8 7
 import android.content.Context;
9 8
 import android.support.annotation.Nullable;
10
-import android.util.DisplayMetrics;
11 9
 import android.view.View;
12
-import android.view.ViewGroup;
13
-import android.view.WindowManager;
14 10
 import android.view.animation.AccelerateInterpolator;
15 11
 import android.view.animation.DecelerateInterpolator;
16 12
 
17 13
 import com.reactnativenavigation.utils.UiUtils;
18
-import com.reactnativenavigation.views.TopBar;
19 14
 
20 15
 @SuppressWarnings("ResourceType")
21 16
 public class NavigationAnimator {

+ 0
- 25
lib/android/app/src/main/java/com/reactnativenavigation/parse/LayoutFactory.java 查看文件

@@ -3,14 +3,12 @@ package com.reactnativenavigation.parse;
3 3
 import android.app.Activity;
4 4
 
5 5
 import com.facebook.react.ReactInstanceManager;
6
-import com.reactnativenavigation.react.ReactComponentViewCreator;
7 6
 import com.reactnativenavigation.utils.TypefaceLoader;
8 7
 import com.reactnativenavigation.viewcontrollers.BottomTabsController;
9 8
 import com.reactnativenavigation.viewcontrollers.ComponentViewController;
10 9
 import com.reactnativenavigation.viewcontrollers.SideMenuController;
11 10
 import com.reactnativenavigation.viewcontrollers.StackController;
12 11
 import com.reactnativenavigation.viewcontrollers.ViewController;
13
-import com.reactnativenavigation.viewcontrollers.overlay.DialogViewController;
14 12
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabController;
15 13
 import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsController;
16 14
 import com.reactnativenavigation.views.ComponentViewCreator;
@@ -49,12 +47,8 @@ public class LayoutFactory {
49 47
 				return createSideMenuLeft(node);
50 48
 			case SideMenuRight:
51 49
 				return createSideMenuRight(node);
52
-//			case CustomDialog:
53
-//				return createDialogComponent(node);
54 50
             case TopTabs:
55 51
                 return createTopTabs(node);
56
-//            case TopTab:
57
-//                return createTopTab(node);
58 52
 			default:
59 53
 				throw new IllegalArgumentException("Invalid node type: " + node.type);
60 54
 		}
@@ -123,13 +117,6 @@ public class LayoutFactory {
123 117
 		return tabsComponent;
124 118
 	}
125 119
 
126
-	private ViewController createDialogComponent(LayoutNode node) {
127
-		String id = node.id;
128
-		String name = node.data.optString("name");
129
-		ReactComponentViewCreator creator = new ReactComponentViewCreator(reactInstanceManager);
130
-		return new DialogViewController(activity, id, name, creator);
131
-	}
132
-
133 120
     private ViewController createTopTabs(LayoutNode node) {
134 121
         final List<TopTabController> tabs = new ArrayList<>();
135 122
         for (int i = 0; i < node.children.size(); i++) {
@@ -140,16 +127,4 @@ public class LayoutFactory {
140 127
         Options options = Options.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
141 128
         return new TopTabsController(activity, node.id, tabs, new TopTabsLayoutCreator(activity, tabs), options);
142 129
     }
143
-
144
-    private ViewController createTopTab(LayoutNode node) {
145
-        String id = node.id;
146
-        String name = node.data.optString("name");
147
-        Options options = Options.parse(typefaceManager, node.getNavigationOptions(), defaultOptions);
148
-        return new TopTabController(activity,
149
-                id,
150
-                name,
151
-                new ReactComponentViewCreator(reactInstanceManager),
152
-                options
153
-        );
154
-    }
155 130
 }

+ 2
- 13
lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java 查看文件

@@ -19,7 +19,6 @@ import com.reactnativenavigation.utils.TypefaceLoader;
19 19
 import com.reactnativenavigation.utils.UiThread;
20 20
 import com.reactnativenavigation.viewcontrollers.Navigator;
21 21
 import com.reactnativenavigation.viewcontrollers.ViewController;
22
-import com.reactnativenavigation.viewcontrollers.overlay.OverlayFactory;
23 22
 
24 23
 public class NavigationModule extends ReactContextBaseJavaModule {
25 24
 	private static final String NAME = "RNNBridgeModule";
@@ -102,18 +101,8 @@ public class NavigationModule extends ReactContextBaseJavaModule {
102 101
 
103 102
 	@ReactMethod
104 103
 	public void showOverlay(final String type, final ReadableMap data, final Promise promise) {
105
-		if (OverlayFactory.Overlay.create(type) == OverlayFactory.Overlay.CustomDialog) {
106
-			final LayoutNode layoutTree = LayoutNodeParser.parse(JSONParser.parse(data));
107
-			handle(() -> {
108
-                ViewController viewController = newLayoutFactory().create(layoutTree);
109
-                navigator().showOverlay(type, OverlayOptions.create(viewController), promise);
110
-            });
111
-		} else {
112
-			final OverlayOptions overlayOptions = OverlayOptions.parse(JSONParser.parse(data));
113
-			handle(() -> navigator().showOverlay(type, overlayOptions, promise));
114
-		}
115
-
116
-
104
+        final OverlayOptions overlayOptions = OverlayOptions.parse(JSONParser.parse(data));
105
+        handle(() -> navigator().showOverlay(type, overlayOptions, promise));
117 106
 	}
118 107
 
119 108
 	@ReactMethod

+ 7
- 16
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/StackController.java 查看文件

@@ -38,17 +38,13 @@ public class StackController extends ParentController {
38 38
 		View enteringView = child.getView();
39 39
 		getView().addView(enteringView);
40 40
 
41
-		//TODO animatePush only when needed
42 41
 		if (previousTop != null) {
43
-			animator.animatePush(enteringView, new NavigationAnimator.NavigationAnimationListener() {
44
-				@Override
45
-				public void onAnimationEnd() {
46
-					getView().removeView(previousTop.getView());
47
-					if (promise != null) {
48
-						promise.resolve(child.getId());
49
-					}
50
-				}
51
-			});
42
+			animator.animatePush(enteringView, () -> {
43
+                getView().removeView(previousTop.getView());
44
+                if (promise != null) {
45
+                    promise.resolve(child.getId());
46
+                }
47
+            });
52 48
 		} else if (promise != null) {
53 49
 			promise.resolve(child.getId());
54 50
 		}
@@ -80,12 +76,7 @@ public class StackController extends ParentController {
80 76
 		getView().addView(enteringView, getView().getChildCount() - 1);
81 77
 
82 78
 		if (animate) {
83
-			animator.animatePop(exitingView, new NavigationAnimator.NavigationAnimationListener() {
84
-				@Override
85
-				public void onAnimationEnd() {
86
-					finishPopping(exitingView, poppedTop, promise);
87
-				}
88
-			});
79
+			animator.animatePop(exitingView, () -> finishPopping(exitingView, poppedTop, promise));
89 80
 		} else {
90 81
 			finishPopping(exitingView, poppedTop, promise);
91 82
 		}

+ 0
- 36
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/overlay/CustomOverlay.java 查看文件

@@ -1,36 +0,0 @@
1
-package com.reactnativenavigation.viewcontrollers.overlay;
2
-
3
-
4
-import android.content.Context;
5
-
6
-import com.reactnativenavigation.parse.OverlayOptions;
7
-import com.reactnativenavigation.viewcontrollers.ComponentViewController;
8
-import com.reactnativenavigation.viewcontrollers.ViewController;
9
-import com.reactnativenavigation.views.CustomDialog;
10
-
11
-public class CustomOverlay implements OverlayInterface {
12
-
13
-	private CustomDialog dialog;
14
-
15
-	@Override
16
-	public CustomOverlay create(ViewController root, OverlayOptions options) {
17
-		//TODO; implement
18
-
19
-		ViewController viewController = options.getCustomView();
20
-		dialog = new CustomDialog(root.getActivity(), viewController.getView());
21
-
22
-		return this;
23
-	}
24
-
25
-	@Override
26
-	public void show() {
27
-		dialog.show();
28
-	}
29
-
30
-	@Override
31
-	public void dismiss() {
32
-		if (dialog != null) {
33
-			dialog.dismiss();
34
-		}
35
-	}
36
-}

+ 1
- 4
lib/android/app/src/main/java/com/reactnativenavigation/viewcontrollers/overlay/OverlayFactory.java 查看文件

@@ -1,8 +1,6 @@
1 1
 package com.reactnativenavigation.viewcontrollers.overlay;
2 2
 
3 3
 
4
-import android.content.Context;
5
-
6 4
 import com.reactnativenavigation.parse.OverlayOptions;
7 5
 import com.reactnativenavigation.viewcontrollers.ViewController;
8 6
 
@@ -10,8 +8,7 @@ public class OverlayFactory {
10 8
 
11 9
 	public enum Overlay {
12 10
 		AlertDialog("alert", new AlertOverlay()),
13
-		Snackbar("snackbar", new SnackbarOverlay()),
14
-		CustomDialog("custom", new CustomOverlay());
11
+		Snackbar("snackbar", new SnackbarOverlay());
15 12
 
16 13
 		private String name;
17 14
 		private OverlayInterface overlayInstance;

+ 0
- 6
lib/android/app/src/main/java/com/reactnativenavigation/views/Component.java 查看文件

@@ -1,18 +1,12 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
-import android.view.View;
4
-
5 3
 import com.reactnativenavigation.parse.Options;
6 4
 
7 5
 public interface Component {
8 6
     void applyOptions(Options options);
9 7
 
10
-    void sendOnNavigationButtonPressed(String id);
11
-
12 8
     TopBar getTopBar();
13 9
 
14
-    View getContentView();
15
-
16 10
     void drawBehindTopBar();
17 11
 
18 12
     void drawBelowTopBar();

+ 7
- 7
lib/android/app/src/main/java/com/reactnativenavigation/views/ComponentLayout.java 查看文件

@@ -13,7 +13,7 @@ import com.reactnativenavigation.viewcontrollers.ComponentViewController.*;
13 13
 import static android.view.ViewGroup.LayoutParams.*;
14 14
 
15 15
 @SuppressLint("ViewConstructor")
16
-public class ComponentLayout extends RelativeLayout implements ReactComponent {
16
+public class ComponentLayout extends RelativeLayout implements ReactComponent, TitleBarButton.OnClickListener {
17 17
 
18 18
     private TopBar topBar;
19 19
     private IReactView reactView;
@@ -22,7 +22,7 @@ public class ComponentLayout extends RelativeLayout implements ReactComponent {
22 22
 	public ComponentLayout(Context context, IReactView reactView, EventDispatcher eventDispatcher) {
23 23
 		super(context);
24 24
 		this.reactView = reactView;
25
-		this.topBar = new TopBar(context, this, eventDispatcher);
25
+		this.topBar = new TopBar(context, reactView.asView(), this, eventDispatcher);
26 26
         optionsPresenter = new OptionsPresenter(this);
27 27
         initViews();
28 28
     }
@@ -74,11 +74,6 @@ public class ComponentLayout extends RelativeLayout implements ReactComponent {
74 74
         return topBar;
75 75
     }
76 76
 
77
-    @Override
78
-    public View getContentView() {
79
-        return reactView.asView();
80
-    }
81
-
82 77
     @Override
83 78
     public void drawBehindTopBar() {
84 79
         RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) reactView.asView().getLayoutParams();
@@ -92,4 +87,9 @@ public class ComponentLayout extends RelativeLayout implements ReactComponent {
92 87
         layoutParams.addRule(BELOW, topBar.getId());
93 88
         reactView.asView().setLayoutParams(layoutParams);
94 89
     }
90
+
91
+    @Override
92
+    public void onPress(String buttonId) {
93
+        reactView.sendOnNavigationButtonPressed(buttonId);
94
+    }
95 95
 }

+ 0
- 29
lib/android/app/src/main/java/com/reactnativenavigation/views/CustomDialog.java 查看文件

@@ -1,29 +0,0 @@
1
-package com.reactnativenavigation.views;
2
-
3
-import android.app.Dialog;
4
-import android.content.Context;
5
-import android.support.annotation.NonNull;
6
-import android.util.Log;
7
-import android.view.View;
8
-import android.view.ViewGroup;
9
-import android.view.ViewTreeObserver;
10
-import android.view.WindowManager;
11
-
12
-import com.facebook.react.ReactRootView;
13
-
14
-
15
-public class CustomDialog extends Dialog {
16
-
17
-	private View component;
18
-
19
-	public CustomDialog(@NonNull Context context, @NonNull View component) {
20
-		super(context);
21
-
22
-		this.component = component;
23
-		init();
24
-	}
25
-
26
-	private void init() {
27
-		addContentView(component, new WindowManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
28
-	}
29
-}

+ 9
- 5
lib/android/app/src/main/java/com/reactnativenavigation/views/TitleBarButton.java 查看文件

@@ -22,13 +22,17 @@ import com.reactnativenavigation.utils.UiUtils;
22 22
 import java.util.ArrayList;
23 23
 
24 24
 public class TitleBarButton implements MenuItem.OnMenuItemClickListener {
25
+    public interface OnClickListener {
26
+        void onPress(String buttonId);
27
+    }
28
+
25 29
 	private Toolbar toolbar;
26 30
 	private final Button button;
27
-	private Component component;
28 31
 	private Drawable icon;
32
+    private OnClickListener onPressListener;
29 33
 
30
-	TitleBarButton(Component component, Toolbar toolbar, Button button) {
31
-		this.component = component;
34
+    TitleBarButton(Toolbar toolbar, Button button, OnClickListener onPressListener) {
35
+        this.onPressListener = onPressListener;
32 36
 		this.toolbar = toolbar;
33 37
 		this.button = button;
34 38
 	}
@@ -118,12 +122,12 @@ public class TitleBarButton implements MenuItem.OnMenuItemClickListener {
118 122
 	}
119 123
 
120 124
 	private void setNavigationClickListener() {
121
-		toolbar.setNavigationOnClickListener(view -> component.sendOnNavigationButtonPressed(button.id));
125
+		toolbar.setNavigationOnClickListener(view -> onPressListener.onPress(button.id));
122 126
 	}
123 127
 
124 128
 	@Override
125 129
 	public boolean onMenuItemClick(MenuItem menuItem) {
126
-		this.component.sendOnNavigationButtonPressed(button.id);
130
+		onPressListener.onPress(button.id);
127 131
 		return true;
128 132
 	}
129 133
 

+ 24
- 20
lib/android/app/src/main/java/com/reactnativenavigation/views/TopBar.java 查看文件

@@ -1,40 +1,44 @@
1 1
 package com.reactnativenavigation.views;
2 2
 
3
-import android.annotation.*;
4
-import android.content.*;
5
-import android.graphics.*;
6
-import android.support.annotation.*;
7
-import android.support.design.widget.*;
3
+import android.annotation.SuppressLint;
4
+import android.content.Context;
5
+import android.graphics.Typeface;
6
+import android.support.annotation.ColorInt;
7
+import android.support.annotation.Nullable;
8
+import android.support.design.widget.AppBarLayout;
8 9
 import android.support.v7.widget.Toolbar;
9
-import android.util.*;
10
-import android.view.*;
11
-import android.widget.*;
12
-
13
-import com.facebook.react.uimanager.events.*;
14
-import com.reactnativenavigation.anim.*;
10
+import android.util.Log;
11
+import android.view.Menu;
12
+import android.view.View;
13
+import android.view.ViewGroup;
14
+import android.widget.TextView;
15
+
16
+import com.facebook.react.uimanager.events.EventDispatcher;
17
+import com.reactnativenavigation.anim.TopBarAnimator;
18
+import com.reactnativenavigation.anim.TopBarCollapseBehavior;
15 19
 import com.reactnativenavigation.parse.Button;
16 20
 import com.reactnativenavigation.parse.Color;
17
-import com.reactnativenavigation.parse.*;
18 21
 import com.reactnativenavigation.parse.Number;
19
-import com.reactnativenavigation.viewcontrollers.toptabs.*;
22
+import com.reactnativenavigation.parse.Options;
23
+import com.reactnativenavigation.viewcontrollers.toptabs.TopTabsViewPager;
20 24
 
21
-import java.util.*;
25
+import java.util.ArrayList;
22 26
 
23 27
 @SuppressLint("ViewConstructor")
24 28
 public class TopBar extends AppBarLayout {
25 29
     private final Toolbar titleBar;
30
+    private TitleBarButton.OnClickListener onClickListener;
26 31
     private final TopBarCollapseBehavior collapsingBehavior;
27 32
     private final TopBarAnimator animator;
28
-    private Component component;
29 33
     private TopTabs topTabs;
30 34
 
31
-    public TopBar(final Context context, Component component, EventDispatcher eventDispatcher) {
35
+    public TopBar(final Context context, View contentView, TitleBarButton.OnClickListener onClickListener, EventDispatcher eventDispatcher) {
32 36
         super(context);
37
+        this.onClickListener = onClickListener;
33 38
         collapsingBehavior = new TopBarCollapseBehavior(eventDispatcher, this);
34
-        this.component = component;
35 39
         titleBar = new Toolbar(context);
36 40
         topTabs = new TopTabs(getContext());
37
-        this.animator = new TopBarAnimator(this, component != null ? component.getContentView() : null);
41
+        this.animator = new TopBarAnimator(this, contentView);
38 42
         addView(titleBar);
39 43
     }
40 44
 
@@ -119,7 +123,7 @@ public class TopBar extends AppBarLayout {
119 123
     }
120 124
 
121 125
     private void setLeftButton(final Button button) {
122
-        TitleBarButton leftBarButton = new TitleBarButton(component, this.titleBar, button);
126
+        TitleBarButton leftBarButton = new TitleBarButton(this.titleBar, button, onClickListener);
123 127
         leftBarButton.applyNavigationIcon(getContext());
124 128
     }
125 129
 
@@ -133,7 +137,7 @@ public class TopBar extends AppBarLayout {
133 137
 
134 138
         for (int i = 0; i < rightButtons.size(); i++) {
135 139
             Button button = rightButtons.get(i);
136
-            TitleBarButton titleBarButton = new TitleBarButton(component, this.titleBar, button);
140
+            TitleBarButton titleBarButton = new TitleBarButton(this.titleBar, button, onClickListener);
137 141
             titleBarButton.addToMenu(getContext(), menu);
138 142
         }
139 143
     }

+ 8
- 13
lib/android/app/src/main/java/com/reactnativenavigation/views/TopTabsLayout.java 查看文件

@@ -15,7 +15,7 @@ import com.reactnativenavigation.viewcontrollers.toptabs.*;
15 15
 import java.util.*;
16 16
 
17 17
 @SuppressLint("ViewConstructor")
18
-public class TopTabsLayout extends RelativeLayout implements Component {
18
+public class TopTabsLayout extends RelativeLayout implements Component, TitleBarButton.OnClickListener {
19 19
 
20 20
     private TopBar topBar;
21 21
     private List<TopTabController> tabs;
@@ -25,9 +25,9 @@ public class TopTabsLayout extends RelativeLayout implements Component {
25 25
     public TopTabsLayout(Context context, List<TopTabController> tabs, TopTabsAdapter adapter) {
26 26
         super(context);
27 27
         this.tabs = tabs;
28
-        topBar = new TopBar(context, this, null);
29
-        topBar.setId(View.generateViewId());
30 28
         viewPager = new TopTabsViewPager(context, tabs, adapter);
29
+        topBar = new TopBar(context, viewPager, this, null);
30
+        topBar.setId(View.generateViewId());
31 31
         optionsPresenter = new OptionsPresenter(this);
32 32
         initViews();
33 33
     }
@@ -45,21 +45,11 @@ public class TopTabsLayout extends RelativeLayout implements Component {
45 45
         optionsPresenter.applyOptions(options);
46 46
     }
47 47
 
48
-    @Override
49
-    public void sendOnNavigationButtonPressed(String id) {
50
-        viewPager.sendOnNavigationButtonPressed(id);
51
-    }
52
-
53 48
     @Override
54 49
     public TopBar getTopBar() {
55 50
         return topBar;
56 51
     }
57 52
 
58
-    @Override
59
-    public View getContentView() {
60
-        return viewPager;
61
-    }
62
-
63 53
     @Override
64 54
     public void drawBehindTopBar() {
65 55
 
@@ -87,4 +77,9 @@ public class TopTabsLayout extends RelativeLayout implements Component {
87 77
     public int getCurrentItem() {
88 78
         return viewPager.getCurrentItem();
89 79
     }
80
+
81
+    @Override
82
+    public void onPress(String buttonId) {
83
+        viewPager.sendOnNavigationButtonPressed(buttonId);
84
+    }
90 85
 }

+ 7
- 7
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentLayout.java 查看文件

@@ -8,7 +8,7 @@ import com.reactnativenavigation.parse.*;
8 8
 import com.reactnativenavigation.presentation.*;
9 9
 import com.reactnativenavigation.views.*;
10 10
 
11
-public class TestComponentLayout extends RelativeLayout implements ReactComponent {
11
+public class TestComponentLayout extends RelativeLayout implements ReactComponent, TitleBarButton.OnClickListener {
12 12
 
13 13
     private final TopBar topBar;
14 14
     private final View contentView;
@@ -16,8 +16,8 @@ public class TestComponentLayout extends RelativeLayout implements ReactComponen
16 16
 
17 17
     public TestComponentLayout(final Context context) {
18 18
         super(context);
19
-        topBar = new TopBar(context, this, null);
20 19
         contentView = new View(context);
20
+        topBar = new TopBar(context, contentView, this, null);
21 21
         addView(topBar);
22 22
         addView(contentView);
23 23
         optionsPresenter = new OptionsPresenter(this);
@@ -27,11 +27,6 @@ public class TestComponentLayout extends RelativeLayout implements ReactComponen
27 27
         return topBar;
28 28
     }
29 29
 
30
-    @Override
31
-    public View getContentView() {
32
-        return contentView;
33
-    }
34
-
35 30
     @Override
36 31
     public void drawBehindTopBar() {
37 32
         RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
@@ -77,4 +72,9 @@ public class TestComponentLayout extends RelativeLayout implements ReactComponen
77 72
     public void sendOnNavigationButtonPressed(String id) {
78 73
 
79 74
     }
75
+
76
+    @Override
77
+    public void onPress(String buttonId) {
78
+
79
+    }
80 80
 }

+ 6
- 6
lib/android/app/src/test/java/com/reactnativenavigation/mocks/TestComponentView.java 查看文件

@@ -6,13 +6,13 @@ import android.view.*;
6 6
 import com.reactnativenavigation.parse.*;
7 7
 import com.reactnativenavigation.views.*;
8 8
 
9
-public class TestComponentView extends View implements ReactComponent {
9
+public class TestComponentView extends View implements ReactComponent, TitleBarButton.OnClickListener {
10 10
 
11 11
     private TopBar topBar;
12 12
 
13 13
     public TestComponentView(final Context context) {
14 14
         super(context);
15
-        topBar = new TopBar(context, this, null);
15
+        topBar = new TopBar(context, this, this, null);
16 16
 
17 17
     }
18 18
 
@@ -54,17 +54,17 @@ public class TestComponentView extends View implements ReactComponent {
54 54
     }
55 55
 
56 56
     @Override
57
-    public View getContentView() {
58
-        return null;
57
+    public void drawBehindTopBar() {
58
+
59 59
     }
60 60
 
61 61
     @Override
62
-    public void drawBehindTopBar() {
62
+    public void drawBelowTopBar() {
63 63
 
64 64
     }
65 65
 
66 66
     @Override
67
-    public void drawBelowTopBar() {
67
+    public void onPress(String buttonId) {
68 68
 
69 69
     }
70 70
 }

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/views/TopBarTest.java 查看文件

@@ -9,7 +9,7 @@ import static org.assertj.core.api.Java6Assertions.*;
9 9
 public class TopBarTest extends BaseTest {
10 10
     @Test
11 11
     public void title() throws Exception {
12
-        TopBar topBar = new TopBar(newActivity(), null, null);
12
+        TopBar topBar = new TopBar(newActivity(), null, buttonId -> {}, null);
13 13
         assertThat(topBar.getTitle()).isEmpty();
14 14
 
15 15
         topBar.setTitle("new title");