Browse Source

Add BottomTabs elevation configuration (#3980)

Raul Migdonio Rodriguez Te 6 years ago
parent
commit
f684c1ddd2

+ 1
- 0
docs/docs/styling.md View File

237
     }
237
     }
238
   },
238
   },
239
   bottomTabs: {
239
   bottomTabs: {
240
+    elevation: 8, // BottomTabs elevation in dp
240
     titleDisplayMode: 'alwaysShow' | 'showWhenActive' | 'alwaysHide' // Sets the title state for each tab.
241
     titleDisplayMode: 'alwaysShow' | 'showWhenActive' | 'alwaysHide' // Sets the title state for each tab.
241
   },
242
   },
242
   bottomTab: {
243
   bottomTab: {

+ 7
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/BottomTabsOptions.java View File

2
 
2
 
3
 import com.reactnativenavigation.parse.params.Bool;
3
 import com.reactnativenavigation.parse.params.Bool;
4
 import com.reactnativenavigation.parse.params.Colour;
4
 import com.reactnativenavigation.parse.params.Colour;
5
+import com.reactnativenavigation.parse.params.Fraction;
5
 import com.reactnativenavigation.parse.params.NullBool;
6
 import com.reactnativenavigation.parse.params.NullBool;
6
 import com.reactnativenavigation.parse.params.NullColor;
7
 import com.reactnativenavigation.parse.params.NullColor;
8
+import com.reactnativenavigation.parse.params.NullFraction;
7
 import com.reactnativenavigation.parse.params.NullNumber;
9
 import com.reactnativenavigation.parse.params.NullNumber;
8
 import com.reactnativenavigation.parse.params.NullText;
10
 import com.reactnativenavigation.parse.params.NullText;
9
 import com.reactnativenavigation.parse.params.Number;
11
 import com.reactnativenavigation.parse.params.Number;
11
 import com.reactnativenavigation.parse.params.TitleDisplayMode;
13
 import com.reactnativenavigation.parse.params.TitleDisplayMode;
12
 import com.reactnativenavigation.parse.parsers.BoolParser;
14
 import com.reactnativenavigation.parse.parsers.BoolParser;
13
 import com.reactnativenavigation.parse.parsers.ColorParser;
15
 import com.reactnativenavigation.parse.parsers.ColorParser;
16
+import com.reactnativenavigation.parse.parsers.FractionParser;
14
 import com.reactnativenavigation.parse.parsers.NumberParser;
17
 import com.reactnativenavigation.parse.parsers.NumberParser;
15
 import com.reactnativenavigation.parse.parsers.TextParser;
18
 import com.reactnativenavigation.parse.parsers.TextParser;
16
 
19
 
28
 		options.visible = BoolParser.parse(json,"visible");
31
 		options.visible = BoolParser.parse(json,"visible");
29
         options.drawBehind = BoolParser.parse(json, "drawBehind");
32
         options.drawBehind = BoolParser.parse(json, "drawBehind");
30
 		options.animate = BoolParser.parse(json,"animate");
33
 		options.animate = BoolParser.parse(json,"animate");
34
+        options.elevation = FractionParser.parse(json, "elevation");
31
         options.testId = TextParser.parse(json, "testID");
35
         options.testId = TextParser.parse(json, "testID");
32
         options.titleDisplayMode = TitleDisplayMode.fromString(json.optString("titleDisplayMode"));
36
         options.titleDisplayMode = TitleDisplayMode.fromString(json.optString("titleDisplayMode"));
33
 
37
 
39
     public Bool drawBehind = new NullBool();
43
     public Bool drawBehind = new NullBool();
40
 	public Bool animate = new NullBool();
44
 	public Bool animate = new NullBool();
41
 	public Number currentTabIndex = new NullNumber();
45
 	public Number currentTabIndex = new NullNumber();
46
+	public Fraction elevation = new NullFraction();
42
 	public Text currentTabId = new NullText();
47
 	public Text currentTabId = new NullText();
43
     public Text testId = new NullText();
48
     public Text testId = new NullText();
44
     public TitleDisplayMode titleDisplayMode = TitleDisplayMode.UNDEFINED;
49
     public TitleDisplayMode titleDisplayMode = TitleDisplayMode.UNDEFINED;
49
 		if (other.visible.hasValue()) visible = other.visible;
54
 		if (other.visible.hasValue()) visible = other.visible;
50
         if (other.drawBehind.hasValue()) drawBehind = other.drawBehind;
55
         if (other.drawBehind.hasValue()) drawBehind = other.drawBehind;
51
 		if (other.animate.hasValue()) animate = other.animate;
56
 		if (other.animate.hasValue()) animate = other.animate;
57
+        if (other.elevation.hasValue()) elevation = other.elevation;
52
         if (other.backgroundColor.hasValue()) backgroundColor = other.backgroundColor;
58
         if (other.backgroundColor.hasValue()) backgroundColor = other.backgroundColor;
53
         if (other.testId.hasValue()) testId = other.testId;
59
         if (other.testId.hasValue()) testId = other.testId;
54
         if (other.titleDisplayMode.hasValue()) titleDisplayMode = other.titleDisplayMode;
60
         if (other.titleDisplayMode.hasValue()) titleDisplayMode = other.titleDisplayMode;
60
         if (!visible.hasValue()) visible = defaultOptions.visible;
66
         if (!visible.hasValue()) visible = defaultOptions.visible;
61
         if (!drawBehind.hasValue()) drawBehind = defaultOptions.drawBehind;
67
         if (!drawBehind.hasValue()) drawBehind = defaultOptions.drawBehind;
62
         if (!animate.hasValue()) animate = defaultOptions.animate;
68
         if (!animate.hasValue()) animate = defaultOptions.animate;
69
+        if (!elevation.hasValue()) elevation = defaultOptions.elevation;
63
         if (!backgroundColor.hasValue()) backgroundColor = defaultOptions.backgroundColor;
70
         if (!backgroundColor.hasValue()) backgroundColor = defaultOptions.backgroundColor;
64
         if (!titleDisplayMode.hasValue()) titleDisplayMode = defaultOptions.titleDisplayMode;
71
         if (!titleDisplayMode.hasValue()) titleDisplayMode = defaultOptions.titleDisplayMode;
65
     }
72
     }

+ 3
- 0
lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabsOptionsPresenter.java View File

158
                 bottomTabs.hideBottomNavigation(false);
158
                 bottomTabs.hideBottomNavigation(false);
159
             }
159
             }
160
         }
160
         }
161
+        if (options.elevation.hasValue()) {
162
+            bottomTabs.setUseElevation(true, options.elevation.get().floatValue());
163
+        }
161
     }
164
     }
162
 }
165
 }

+ 5
- 0
lib/src/interfaces/Options.ts View File

411
    * #### (Android specific)
411
    * #### (Android specific)
412
    */
412
    */
413
   titleDisplayMode?: 'alwaysShow' | 'showWhenActive' | 'alwaysHide';
413
   titleDisplayMode?: 'alwaysShow' | 'showWhenActive' | 'alwaysHide';
414
+  /**
415
+   * Set the elevation of the Bottom Tabs in dp
416
+   * #### (Android specific)
417
+   */
418
+  elevation?: AndroidDensityNumber;
414
 }
419
 }
415
 
420
 
416
 export interface OptionsBottomTab {
421
 export interface OptionsBottomTab {