Browse Source

Rename topBar.hidden to topBar.visible

Guy Carmeli 6 years ago
parent
commit
11c1dec05b

+ 6
- 6
lib/android/app/src/main/java/com/reactnativenavigation/parse/TopBarOptions.java View File

@@ -24,7 +24,7 @@ public class TopBarOptions implements DEFAULT_VALUES {
24 24
         options.textColor = ColorParser.parse(json, "textColor");
25 25
         options.textFontSize = FractionParser.parse(json, "textFontSize");
26 26
         options.textFontFamily = typefaceManager.getTypeFace(json.optString("textFontFamily", ""));
27
-        options.hidden = BoolParser.parse(json, "hidden");
27
+        options.visible = BoolParser.parse(json, "visible");
28 28
         options.animateHide = BoolParser.parse(json,"animateHide");
29 29
         options.hideOnScroll = BoolParser.parse(json,"hideOnScroll");
30 30
         options.drawBehind = BoolParser.parse(json,"drawBehind");
@@ -41,7 +41,7 @@ public class TopBarOptions implements DEFAULT_VALUES {
41 41
     public Color textColor = new NullColor();
42 42
     public Fraction textFontSize = new NullFraction();
43 43
     @Nullable public Typeface textFontFamily;
44
-    public Bool hidden = new NullBool();
44
+    public Bool visible = new NullBool();
45 45
     public Bool animateHide = new NullBool();
46 46
     public Bool hideOnScroll = new NullBool();
47 47
     public Bool drawBehind = new NullBool();
@@ -59,8 +59,8 @@ public class TopBarOptions implements DEFAULT_VALUES {
59 59
             textFontSize = other.textFontSize;
60 60
         if (other.textFontFamily != null)
61 61
             textFontFamily = other.textFontFamily;
62
-        if (other.hidden.hasValue()) {
63
-            hidden = other.hidden;
62
+        if (other.visible.hasValue()) {
63
+            visible = other.visible;
64 64
         }
65 65
         if (other.animateHide.hasValue()) {
66 66
             animateHide = other.animateHide;
@@ -88,8 +88,8 @@ public class TopBarOptions implements DEFAULT_VALUES {
88 88
             textFontSize = defaultOptions.textFontSize;
89 89
         if (textFontFamily == null)
90 90
             textFontFamily = defaultOptions.textFontFamily;
91
-        if (!hidden.hasValue())
92
-            hidden = defaultOptions.hidden;
91
+        if (!visible.hasValue())
92
+            visible = defaultOptions.visible;
93 93
         if (!animateHide.hasValue())
94 94
             animateHide = defaultOptions.animateHide;
95 95
         if (!hideOnScroll.hasValue())

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

@@ -34,10 +34,10 @@ public class OptionsPresenter {
34 34
         if (options.testId.hasValue()) topBar.setTestId(options.testId.get());
35 35
 
36 36
         topBar.setTitleTypeface(options.textFontFamily);
37
-        if (options.hidden.isTrue()) {
37
+        if (options.visible.isFalse()) {
38 38
             topBar.hide(options.animateHide);
39 39
         }
40
-        if (options.hidden.isFalseOrUndefined()) {
40
+        if (options.visible.isTrueOrUndefined()) {
41 41
             topBar.show(options.animateHide);
42 42
         }
43 43
         if (options.drawBehind.isTrue()) {

+ 11
- 12
lib/android/app/src/test/java/com/reactnativenavigation/parse/OptionsTest.java View File

@@ -22,7 +22,7 @@ public class OptionsTest extends BaseTest {
22 22
     private static final int TOP_BAR_FONT_SIZE = 18;
23 23
     private static final String TOP_BAR_FONT_FAMILY = "HelveticaNeue-CondensedBold";
24 24
     private static final Typeface TOP_BAR_TYPEFACE = Typeface.create("HelveticaNeue-CondensedBold", Typeface.BOLD);
25
-    private static final Bool TOP_BAR_HIDDEN = new Bool(true);
25
+    private static final Bool TOP_BAR_VISIBLE = new Bool(true);
26 26
     private static final Bool TOP_BAR_DRAW_BEHIND = new Bool(true);
27 27
     private static final Bool TOP_BAR_HIDE_ON_SCROLL = new Bool(true);
28 28
     private static final Bool BOTTOM_TABS_ANIMATE_HIDE = new Bool(true);
@@ -46,7 +46,7 @@ public class OptionsTest extends BaseTest {
46 46
     @Test
47 47
     public void parsesJson() throws Exception {
48 48
         JSONObject json = new JSONObject()
49
-                .put("topBar", createTopBar(TOP_BAR_HIDDEN.get()))
49
+                .put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
50 50
                 .put("bottomTabs", createBottomTabs());
51 51
         Options result = Options.parse(mockLoader, json);
52 52
         assertResult(result);
@@ -58,7 +58,7 @@ public class OptionsTest extends BaseTest {
58 58
         assertThat(result.topBarOptions.textColor.get()).isEqualTo(TOP_BAR_TEXT_COLOR);
59 59
         assertThat(result.topBarOptions.textFontSize.get()).isEqualTo(TOP_BAR_FONT_SIZE);
60 60
         assertThat(result.topBarOptions.textFontFamily).isEqualTo(TOP_BAR_TYPEFACE);
61
-        assertThat(result.topBarOptions.hidden.get()).isEqualTo(TOP_BAR_HIDDEN.get());
61
+        assertThat(result.topBarOptions.visible.get()).isEqualTo(TOP_BAR_VISIBLE.get());
62 62
         assertThat(result.topBarOptions.drawBehind.get()).isEqualTo(TOP_BAR_DRAW_BEHIND.get());
63 63
         assertThat(result.topBarOptions.hideOnScroll.get()).isEqualTo(TOP_BAR_HIDE_ON_SCROLL.get());
64 64
         assertThat(result.bottomTabsOptions.animateHide.get()).isEqualTo(BOTTOM_TABS_ANIMATE_HIDE.get());
@@ -77,14 +77,14 @@ public class OptionsTest extends BaseTest {
77 77
     }
78 78
 
79 79
     @NonNull
80
-    private JSONObject createTopBar(boolean hidden) throws JSONException {
80
+    private JSONObject createTopBar(boolean visible) throws JSONException {
81 81
         return new JSONObject()
82 82
                 .put("title", "the title")
83 83
                 .put("backgroundColor", TOP_BAR_BACKGROUND_COLOR)
84 84
                 .put("textColor", TOP_BAR_TEXT_COLOR)
85 85
                 .put("textFontSize", TOP_BAR_FONT_SIZE)
86 86
                 .put("textFontFamily", TOP_BAR_FONT_FAMILY)
87
-                .put("hidden", hidden)
87
+                .put("visible", visible)
88 88
                 .put("drawBehind", TOP_BAR_DRAW_BEHIND.get())
89 89
                 .put("hideOnScroll", TOP_BAR_HIDE_ON_SCROLL.get());
90 90
     }
@@ -97,7 +97,7 @@ public class OptionsTest extends BaseTest {
97 97
                 .put("textColor", TOP_BAR_TEXT_COLOR)
98 98
                 .put("textFontSize", TOP_BAR_FONT_SIZE)
99 99
                 .put("textFontFamily", TOP_BAR_FONT_FAMILY)
100
-                .put("visible", TOP_BAR_HIDDEN);
100
+                .put("visible", TOP_BAR_VISIBLE);
101 101
     }
102 102
 
103 103
     @NonNull
@@ -117,22 +117,21 @@ public class OptionsTest extends BaseTest {
117 117
         Options options1 = Options.parse(mockLoader, json1);
118 118
         options1.topBarOptions.title = new Text("some title");
119 119
 
120
-
121 120
         JSONObject json2 = new JSONObject();
122 121
         json2.put("topBar", createTopBar(false));
123 122
         Options options2 = Options.parse(mockLoader, json2);
124 123
         options2.topBarOptions.title = new NullText();
125 124
 
126 125
         Options merged = options1.mergeWith(options2);
127
-        assertThat(options1.topBarOptions.hidden.get()).isTrue();
128
-        assertThat(merged.topBarOptions.hidden.get()).isFalse();
126
+        assertThat(options1.topBarOptions.visible.get()).isTrue();
127
+        assertThat(merged.topBarOptions.visible.get()).isFalse();
129 128
         assertThat(merged.topBarOptions.title.get()).isEqualTo("some title");
130 129
     }
131 130
 
132 131
     @Test
133 132
     public void mergeDefaultOptions() throws Exception {
134 133
         JSONObject json = new JSONObject();
135
-        json.put("topBar", createTopBar(TOP_BAR_HIDDEN.get()));
134
+        json.put("topBar", createTopBar(TOP_BAR_VISIBLE.get()));
136 135
         json.put("bottomTabs", createBottomTabs());
137 136
         Options defaultOptions = Options.parse(mockLoader, json);
138 137
         Options options = new Options();
@@ -148,7 +147,7 @@ public class OptionsTest extends BaseTest {
148 147
         Options defaultOptions = Options.parse(mockLoader, defaultJson);
149 148
 
150 149
         JSONObject json = new JSONObject()
151
-                .put("topBar", createTopBar(TOP_BAR_HIDDEN.get()))
150
+                .put("topBar", createTopBar(TOP_BAR_VISIBLE.get()))
152 151
                 .put("bottomTabs", createBottomTabs());
153 152
         Options options = Options.parse(mockLoader, json);
154 153
         options.withDefaultOptions(defaultOptions);
@@ -164,7 +163,7 @@ public class OptionsTest extends BaseTest {
164 163
     @Test
165 164
     public void topBar_defaultOptions() throws Exception {
166 165
         Options uut = new Options();
167
-        assertThat(uut.topBarOptions.hidden.isFalseOrUndefined()).isTrue();
166
+        assertThat(uut.topBarOptions.visible.isFalseOrUndefined()).isTrue();
168 167
         assertThat(uut.topBarOptions.animateHide.isTrueOrUndefined()).isTrue();
169 168
     }
170 169
 }

+ 1
- 1
lib/android/app/src/test/java/com/reactnativenavigation/viewcontrollers/OptionsApplyingTest.java View File

@@ -146,7 +146,7 @@ public class OptionsApplyingTest extends BaseTest {
146 146
         assertThat(stackController.getTopBar().getVisibility()).isNotEqualTo(View.GONE);
147 147
 
148 148
         Options opts = new Options();
149
-        opts.topBarOptions.hidden = new Bool(true);
149
+        opts.topBarOptions.visible = new Bool(false);
150 150
         uut.mergeOptions(opts);
151 151
 
152 152
         assertThat(stackController.getTopBar().getVisibility()).isEqualTo(View.GONE);