| 
				
			 | 
			
			
				@@ -3,7 +3,11 @@ package com.reactnativenavigation.views; 
			 | 
		
	
		
			
			| 
				3
			 | 
			
				3
			 | 
			
			
				 import android.content.Context; 
			 | 
		
	
		
			
			| 
				4
			 | 
			
				4
			 | 
			
			
				 import android.graphics.Color; 
			 | 
		
	
		
			
			| 
				5
			 | 
			
				5
			 | 
			
			
				 import android.os.Build; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				6
			 | 
			
			
				+import android.os.Bundle; 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				7
			 | 
			
			
				 import android.support.design.widget.AppBarLayout; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				8
			 | 
			
			
				+import android.support.v7.app.ActionBar; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				9
			 | 
			
			
				+import android.text.TextUtils; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				10
			 | 
			
			
				+import android.view.Gravity; 
			 | 
		
	
		
			
			| 
				7
			 | 
			
				11
			 | 
			
			
				 import android.view.ViewGroup; 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				12
			 | 
			
			
				 import android.widget.FrameLayout; 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				13
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -11,9 +15,11 @@ import com.facebook.react.bridge.Callback; 
			 | 
		
	
		
			
			| 
				11
			 | 
			
				15
			 | 
			
			
				 import com.reactnativenavigation.animation.VisibilityAnimator; 
			 | 
		
	
		
			
			| 
				12
			 | 
			
				16
			 | 
			
			
				 import com.reactnativenavigation.params.BaseScreenParams; 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				17
			 | 
			
			
				 import com.reactnativenavigation.params.ContextualMenuParams; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				18
			 | 
			
			
				+import com.reactnativenavigation.params.NavigationParams; 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				19
			 | 
			
			
				 import com.reactnativenavigation.params.StyleParams; 
			 | 
		
	
		
			
			| 
				15
			 | 
			
				20
			 | 
			
			
				 import com.reactnativenavigation.params.TitleBarButtonParams; 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				21
			 | 
			
			
				 import com.reactnativenavigation.params.TitleBarLeftButtonParams; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				22
			 | 
			
			
				+import com.reactnativenavigation.screens.Screen; 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				23
			 | 
			
			
				 import com.reactnativenavigation.utils.ViewUtils; 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				24
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				19
			 | 
			
				25
			 | 
			
			
				 import java.util.List; 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -81,6 +87,34 @@ public class TopBar extends AppBarLayout { 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				87
			 | 
			
			
				         titleBar.setSubtitle(subtitle); 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				88
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				89
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				+    public void setReactView(String topBarReactView, String alignment) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+        if (!TextUtils.isEmpty(topBarReactView)) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				92
			 | 
			
			
				+            final ContentView view = new ContentView(getContext(), topBarReactView, new NavigationParams(Bundle.EMPTY)); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				+            if ("fill".equals(alignment)) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+                addReactViewFill(view); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				+            } else { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				+                addCenteredReactView(view); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				+            } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				99
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+    private void addReactViewFill(ContentView view) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+        view.setLayoutParams(new LayoutParams(MATCH_PARENT, ViewUtils.getToolBarHeight())); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+        titleBar.addView(view); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				+    private void addCenteredReactView(final ContentView view) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				+        titleBar.addView(view, new LayoutParams(WRAP_CONTENT, ViewUtils.getToolBarHeight())); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				+        view.setOnDisplayListener(new Screen.OnDisplayListener() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				+            @Override 
			 | 
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				+            public void onDisplay() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				111
			 | 
			
			
				+                view.getLayoutParams().width = (int) (float) view.getChildAt(0).getMeasuredWidth(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				112
			 | 
			
			
				+                ((ActionBar.LayoutParams) view.getLayoutParams()).gravity = Gravity.CENTER; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				113
			 | 
			
			
				+                view.requestLayout(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				+            } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				115
			 | 
			
			
				+        }); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				116
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				118
			 | 
			
			
				     public void setButtonColor(StyleParams styleParams) { 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				119
			 | 
			
			
				         titleBar.setButtonColor(styleParams.titleBarButtonColor); 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				120
			 | 
			
			
				     } 
			 |