Browse Source

Add Android support for rootBackgroundImageName (#3051)

Yee Wong 6 years ago
parent
commit
7f220e7dff

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

@@ -101,6 +101,10 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
101 101
         if (hasBackgroundColor()) {
102 102
             layout.asView().setBackgroundColor(AppStyle.appStyle.screenBackgroundColor.getColor());
103 103
         }
104
+        String rootBackgroundImageName = activityParams.screenParams.styleParams.rootBackgroundImageName;
105
+        if (rootBackgroundImageName != null) {
106
+            layout.asView().setBackgroundResource(this.getResources().getIdentifier(rootBackgroundImageName, "drawable", this.getPackageName()));
107
+        }
104 108
         setContentView(layout.asView());
105 109
     }
106 110
 

+ 1
- 0
android/app/src/main/java/com/reactnativenavigation/params/StyleParams.java View File

@@ -137,6 +137,7 @@ public class StyleParams {
137 137
     public int topTabsHeight;
138 138
 
139 139
     public Color screenBackgroundColor;
140
+    public String rootBackgroundImageName;
140 141
 
141 142
     public boolean drawScreenAboveBottomTabs;
142 143
 

+ 2
- 2
docs/styling-the-navigator.md View File

@@ -73,6 +73,7 @@ this.props.navigator.setStyle({
73 73
   screenBackgroundColor: 'white', // Default screen color, visible before the actual react view is rendered
74 74
   orientation: 'portrait' // Sets a specific orientation to a modal and all screens pushed to it. Default: 'auto'. Supported values: 'auto', 'landscape', 'portrait'
75 75
   disabledButtonColor: '#ff0000' // chnaged the navigation bar button text color when disabled.
76
+  rootBackgroundImageName: 'iOS: <name of image in Images.xcassets>. Android: <name of drawable>', // Static while you transition between screens. Works best with screenBackgroundColor: 'transparent'
76 77
   
77 78
   // iOS only
78 79
   statusBarTextColorSchemeSingleScreen: 'light', // same as statusBarTextColorScheme but does NOT remember across pushes
@@ -82,8 +83,7 @@ this.props.navigator.setStyle({
82 83
   disabledBackGesture: false, // default: false. Disable the back gesture (swipe gesture) in order to pop the top screen. 
83 84
   disabledSimultaneousGesture: true, // default: true. Disable simultaneous gesture recognition.
84 85
   screenBackgroundImageName: '<name of image in Images.xcassets>', // Optional. default screen background image.
85
-  rootBackgroundImageName: '<name of image in Images.xcassets>', // Static while you transition between screens. Works best with screenBackgroundColor: 'transparent'
86
-
86
+  
87 87
   navBarButtonFontSize: 20, // Change font size nav bar buttons (eg. the back button) (remembered across pushes)
88 88
   navBarButtonFontWeight: '500', // Change font weight nav bar buttons (eg. the back button) (remembered across pushes)
89 89
 

+ 1
- 0
src/deprecated/platformSpecificDeprecated.android.js View File

@@ -215,6 +215,7 @@ function convertStyleParams(originalStyleObject) {
215 215
     topTabsScrollable: originalStyleObject.topTabsScrollable,
216 216
     topTabsHeight: originalStyleObject.topTabsHeight,
217 217
     screenBackgroundColor: processColor(originalStyleObject.screenBackgroundColor),
218
+    rootBackgroundImageName: originalStyleObject.rootBackgroundImageName,
218 219
 
219 220
     drawScreenAboveBottomTabs: !originalStyleObject.drawUnderTabBar,
220 221