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
         if (hasBackgroundColor()) {
101
         if (hasBackgroundColor()) {
102
             layout.asView().setBackgroundColor(AppStyle.appStyle.screenBackgroundColor.getColor());
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
         setContentView(layout.asView());
108
         setContentView(layout.asView());
105
     }
109
     }
106
 
110
 

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

137
     public int topTabsHeight;
137
     public int topTabsHeight;
138
 
138
 
139
     public Color screenBackgroundColor;
139
     public Color screenBackgroundColor;
140
+    public String rootBackgroundImageName;
140
 
141
 
141
     public boolean drawScreenAboveBottomTabs;
142
     public boolean drawScreenAboveBottomTabs;
142
 
143
 

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

73
   screenBackgroundColor: 'white', // Default screen color, visible before the actual react view is rendered
73
   screenBackgroundColor: 'white', // Default screen color, visible before the actual react view is rendered
74
   orientation: 'portrait' // Sets a specific orientation to a modal and all screens pushed to it. Default: 'auto'. Supported values: 'auto', 'landscape', 'portrait'
74
   orientation: 'portrait' // Sets a specific orientation to a modal and all screens pushed to it. Default: 'auto'. Supported values: 'auto', 'landscape', 'portrait'
75
   disabledButtonColor: '#ff0000' // chnaged the navigation bar button text color when disabled.
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
   // iOS only
78
   // iOS only
78
   statusBarTextColorSchemeSingleScreen: 'light', // same as statusBarTextColorScheme but does NOT remember across pushes
79
   statusBarTextColorSchemeSingleScreen: 'light', // same as statusBarTextColorScheme but does NOT remember across pushes
82
   disabledBackGesture: false, // default: false. Disable the back gesture (swipe gesture) in order to pop the top screen. 
83
   disabledBackGesture: false, // default: false. Disable the back gesture (swipe gesture) in order to pop the top screen. 
83
   disabledSimultaneousGesture: true, // default: true. Disable simultaneous gesture recognition.
84
   disabledSimultaneousGesture: true, // default: true. Disable simultaneous gesture recognition.
84
   screenBackgroundImageName: '<name of image in Images.xcassets>', // Optional. default screen background image.
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
   navBarButtonFontSize: 20, // Change font size nav bar buttons (eg. the back button) (remembered across pushes)
87
   navBarButtonFontSize: 20, // Change font size nav bar buttons (eg. the back button) (remembered across pushes)
88
   navBarButtonFontWeight: '500', // Change font weight nav bar buttons (eg. the back button) (remembered across pushes)
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
     topTabsScrollable: originalStyleObject.topTabsScrollable,
215
     topTabsScrollable: originalStyleObject.topTabsScrollable,
216
     topTabsHeight: originalStyleObject.topTabsHeight,
216
     topTabsHeight: originalStyleObject.topTabsHeight,
217
     screenBackgroundColor: processColor(originalStyleObject.screenBackgroundColor),
217
     screenBackgroundColor: processColor(originalStyleObject.screenBackgroundColor),
218
+    rootBackgroundImageName: originalStyleObject.rootBackgroundImageName,
218
 
219
 
219
     drawScreenAboveBottomTabs: !originalStyleObject.drawUnderTabBar,
220
     drawScreenAboveBottomTabs: !originalStyleObject.drawUnderTabBar,
220
 
221