Browse Source

Fix title component in RN 0.51

Guy Carmeli 6 years ago
parent
commit
ba86c2615e

+ 3
- 6
lib/android/app/src/main/java/com/reactnativenavigation/views/titlebar/TitleBar.java View File

@@ -24,7 +24,6 @@ import java.util.ArrayList;
24 24
 import java.util.List;
25 25
 
26 26
 import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
27
-import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
28 27
 
29 28
 @SuppressLint("ViewConstructor")
30 29
 public class TitleBar extends Toolbar {
@@ -166,12 +165,10 @@ public class TitleBar extends Toolbar {
166 165
     }
167 166
 
168 167
     public Toolbar.LayoutParams getComponentLayoutParams(TitleOptions.Alignment alignment) {
169
-        if (alignment == TitleOptions.Alignment.Fill) {
170
-            return new LayoutParams(MATCH_PARENT, getHeight());
171
-        } else {
172
-            LayoutParams lp = new LayoutParams(WRAP_CONTENT, getHeight());
168
+        LayoutParams lp = new LayoutParams(MATCH_PARENT, getHeight());
169
+        if (alignment == TitleOptions.Alignment.Center) {
173 170
             lp.gravity = Gravity.CENTER;
174
-            return lp;
175 171
         }
172
+        return lp;
176 173
     }
177 174
 }

+ 1
- 5
lib/android/app/src/main/java/com/reactnativenavigation/views/topbar/TopBar.java View File

@@ -69,11 +69,7 @@ public class TopBar extends AppBarLayout implements ScrollEventListener.ScrollAw
69 69
     }
70 70
 
71 71
     protected TitleBar createTitleBar(Context context, ReactViewCreator buttonCreator, TitleBarReactViewCreator reactViewCreator, TopBarButtonController.OnClickListener onClickListener) {
72
-        return new TitleBar(context,
73
-                buttonCreator,
74
-                reactViewCreator,
75
-                onClickListener
76
-        );
72
+        return new TitleBar(context, buttonCreator, reactViewCreator, onClickListener);
77 73
     }
78 74
 
79 75
     public void setTitle(String title) {