Browse Source

Add bottomTabs.preferLargeIcons option (#5658)

This option is used to force large icons to be displayed when only three icons, without titles, are present on the screen.
Guy Carmeli 5 years ago
parent
commit
fd93167dbe
No account linked to committer's email address

+ 1
- 1
lib/android/app/build.gradle View File

@@ -97,7 +97,7 @@ dependencies {
97 97
     implementation 'androidx.annotation:annotation:1.1.0'
98 98
     implementation 'com.google.android.material:material:1.1.0-alpha08'
99 99
 
100
-    implementation 'com.github.wix-playground:ahbottomnavigation:3.0.5'
100
+    implementation 'com.github.wix-playground:ahbottomnavigation:3.0.8'
101 101
     implementation 'com.github.wix-playground:reflow-animator:1.0.4'
102 102
     implementation 'com.github.clans:fab:1.6.4'
103 103
 

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

@@ -30,6 +30,7 @@ public class BottomTabsOptions {
30 30
 		options.currentTabIndex = NumberParser.parse(json,"currentTabIndex");
31 31
 		options.visible = BoolParser.parse(json,"visible");
32 32
         options.drawBehind = BoolParser.parse(json, "drawBehind");
33
+        options.preferLargeIcons = BoolParser.parse(json, "preferLargeIcons");
33 34
 		options.animate = BoolParser.parse(json,"animate");
34 35
         options.elevation = FractionParser.parse(json, "elevation");
35 36
         options.testId = TextParser.parse(json, "testID");
@@ -43,6 +44,7 @@ public class BottomTabsOptions {
43 44
 	public Bool visible = new NullBool();
44 45
     public Bool drawBehind = new NullBool();
45 46
 	public Bool animate = new NullBool();
47
+    public Bool preferLargeIcons = new NullBool();
46 48
 	public Number currentTabIndex = new NullNumber();
47 49
 	public Fraction elevation = new NullFraction();
48 50
 	public Text currentTabId = new NullText();
@@ -56,6 +58,7 @@ public class BottomTabsOptions {
56 58
 		if (other.visible.hasValue()) visible = other.visible;
57 59
         if (other.drawBehind.hasValue()) drawBehind = other.drawBehind;
58 60
 		if (other.animate.hasValue()) animate = other.animate;
61
+        if (other.preferLargeIcons.hasValue()) preferLargeIcons = other.preferLargeIcons;
59 62
         if (other.elevation.hasValue()) elevation = other.elevation;
60 63
         if (other.backgroundColor.hasValue()) backgroundColor = other.backgroundColor;
61 64
         if (other.testId.hasValue()) testId = other.testId;
@@ -69,6 +72,7 @@ public class BottomTabsOptions {
69 72
         if (!visible.hasValue()) visible = defaultOptions.visible;
70 73
         if (!drawBehind.hasValue()) drawBehind = defaultOptions.drawBehind;
71 74
         if (!animate.hasValue()) animate = defaultOptions.animate;
75
+        if (!preferLargeIcons.hasValue()) preferLargeIcons = defaultOptions.preferLargeIcons;
72 76
         if (!elevation.hasValue()) elevation = defaultOptions.elevation;
73 77
         if (!backgroundColor.hasValue()) backgroundColor = defaultOptions.backgroundColor;
74 78
         if (!titleDisplayMode.hasValue()) titleDisplayMode = defaultOptions.titleDisplayMode;

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

@@ -68,6 +68,7 @@ public class BottomTabsPresenter {
68 68
         AnimationsOptions animations = options.animations;
69 69
 
70 70
         if (options.layout.direction.hasValue()) bottomTabs.setLayoutDirection(options.layout.direction);
71
+        if (bottomTabsOptions.preferLargeIcons.hasValue()) bottomTabs.setPreferLargeIcons(bottomTabsOptions.preferLargeIcons.get());
71 72
         if (bottomTabsOptions.titleDisplayMode.hasValue()) {
72 73
             bottomTabs.setTitleState(bottomTabsOptions.titleDisplayMode.toState());
73 74
         }
@@ -114,6 +115,7 @@ public class BottomTabsPresenter {
114 115
         AnimationsOptions animationsOptions = options.animations;
115 116
 
116 117
         bottomTabs.setLayoutDirection(options.layout.direction);
118
+        bottomTabs.setPreferLargeIcons(options.bottomTabsOptions.preferLargeIcons.get(false));
117 119
         bottomTabs.setTitleState(bottomTabsOptions.titleDisplayMode.get(TitleState.SHOW_WHEN_ACTIVE));
118 120
         bottomTabs.setBackgroundColor(bottomTabsOptions.backgroundColor.get(Color.WHITE));
119 121
         if (bottomTabsOptions.currentTabIndex.hasValue()) {

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

@@ -480,6 +480,12 @@ export interface OptionsBottomTabs {
480 480
    * Enable animations when toggling visibility
481 481
    */
482 482
   animate?: boolean;
483
+  /**
484
+   * Use large icons when possible, even when three tabs without titles are displayed
485
+   * #### (android specific)
486
+   * @default false
487
+   */
488
+  preferLargeIcons?: boolean;
483 489
   /**
484 490
    * Switch to another screen within the bottom tabs via index (starting from 0)
485 491
    */