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
     implementation 'androidx.annotation:annotation:1.1.0'
97
     implementation 'androidx.annotation:annotation:1.1.0'
98
     implementation 'com.google.android.material:material:1.1.0-alpha08'
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
     implementation 'com.github.wix-playground:reflow-animator:1.0.4'
101
     implementation 'com.github.wix-playground:reflow-animator:1.0.4'
102
     implementation 'com.github.clans:fab:1.6.4'
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
 		options.currentTabIndex = NumberParser.parse(json,"currentTabIndex");
30
 		options.currentTabIndex = NumberParser.parse(json,"currentTabIndex");
31
 		options.visible = BoolParser.parse(json,"visible");
31
 		options.visible = BoolParser.parse(json,"visible");
32
         options.drawBehind = BoolParser.parse(json, "drawBehind");
32
         options.drawBehind = BoolParser.parse(json, "drawBehind");
33
+        options.preferLargeIcons = BoolParser.parse(json, "preferLargeIcons");
33
 		options.animate = BoolParser.parse(json,"animate");
34
 		options.animate = BoolParser.parse(json,"animate");
34
         options.elevation = FractionParser.parse(json, "elevation");
35
         options.elevation = FractionParser.parse(json, "elevation");
35
         options.testId = TextParser.parse(json, "testID");
36
         options.testId = TextParser.parse(json, "testID");
43
 	public Bool visible = new NullBool();
44
 	public Bool visible = new NullBool();
44
     public Bool drawBehind = new NullBool();
45
     public Bool drawBehind = new NullBool();
45
 	public Bool animate = new NullBool();
46
 	public Bool animate = new NullBool();
47
+    public Bool preferLargeIcons = new NullBool();
46
 	public Number currentTabIndex = new NullNumber();
48
 	public Number currentTabIndex = new NullNumber();
47
 	public Fraction elevation = new NullFraction();
49
 	public Fraction elevation = new NullFraction();
48
 	public Text currentTabId = new NullText();
50
 	public Text currentTabId = new NullText();
56
 		if (other.visible.hasValue()) visible = other.visible;
58
 		if (other.visible.hasValue()) visible = other.visible;
57
         if (other.drawBehind.hasValue()) drawBehind = other.drawBehind;
59
         if (other.drawBehind.hasValue()) drawBehind = other.drawBehind;
58
 		if (other.animate.hasValue()) animate = other.animate;
60
 		if (other.animate.hasValue()) animate = other.animate;
61
+        if (other.preferLargeIcons.hasValue()) preferLargeIcons = other.preferLargeIcons;
59
         if (other.elevation.hasValue()) elevation = other.elevation;
62
         if (other.elevation.hasValue()) elevation = other.elevation;
60
         if (other.backgroundColor.hasValue()) backgroundColor = other.backgroundColor;
63
         if (other.backgroundColor.hasValue()) backgroundColor = other.backgroundColor;
61
         if (other.testId.hasValue()) testId = other.testId;
64
         if (other.testId.hasValue()) testId = other.testId;
69
         if (!visible.hasValue()) visible = defaultOptions.visible;
72
         if (!visible.hasValue()) visible = defaultOptions.visible;
70
         if (!drawBehind.hasValue()) drawBehind = defaultOptions.drawBehind;
73
         if (!drawBehind.hasValue()) drawBehind = defaultOptions.drawBehind;
71
         if (!animate.hasValue()) animate = defaultOptions.animate;
74
         if (!animate.hasValue()) animate = defaultOptions.animate;
75
+        if (!preferLargeIcons.hasValue()) preferLargeIcons = defaultOptions.preferLargeIcons;
72
         if (!elevation.hasValue()) elevation = defaultOptions.elevation;
76
         if (!elevation.hasValue()) elevation = defaultOptions.elevation;
73
         if (!backgroundColor.hasValue()) backgroundColor = defaultOptions.backgroundColor;
77
         if (!backgroundColor.hasValue()) backgroundColor = defaultOptions.backgroundColor;
74
         if (!titleDisplayMode.hasValue()) titleDisplayMode = defaultOptions.titleDisplayMode;
78
         if (!titleDisplayMode.hasValue()) titleDisplayMode = defaultOptions.titleDisplayMode;

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

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

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

480
    * Enable animations when toggling visibility
480
    * Enable animations when toggling visibility
481
    */
481
    */
482
   animate?: boolean;
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
    * Switch to another screen within the bottom tabs via index (starting from 0)
490
    * Switch to another screen within the bottom tabs via index (starting from 0)
485
    */
491
    */