Przeglądaj źródła

Fix title height not being set on Android (#4587)

Set topBar title height property
David 6 lat temu
rodzic
commit
09c8c37e64

+ 2
- 0
lib/android/app/src/main/java/com/reactnativenavigation/parse/TitleOptions.java Wyświetl plik

@@ -13,6 +13,7 @@ import com.reactnativenavigation.parse.params.Number;
13 13
 import com.reactnativenavigation.parse.params.Text;
14 14
 import com.reactnativenavigation.parse.parsers.ColorParser;
15 15
 import com.reactnativenavigation.parse.parsers.FractionParser;
16
+import com.reactnativenavigation.parse.parsers.NumberParser;
16 17
 import com.reactnativenavigation.parse.parsers.TextParser;
17 18
 import com.reactnativenavigation.utils.TypefaceLoader;
18 19
 
@@ -30,6 +31,7 @@ public class TitleOptions {
30 31
         options.fontSize = FractionParser.parse(json, "fontSize");
31 32
         options.fontFamily = typefaceManager.getTypeFace(json.optString("fontFamily", ""));
32 33
         options.alignment = Alignment.fromString(TextParser.parse(json, "alignment").get(""));
34
+        options.height = NumberParser.parse(json, "height");
33 35
 
34 36
         return options;
35 37
     }

+ 3
- 0
lib/android/app/src/test/java/com/reactnativenavigation/parse/OptionsTest.java Wyświetl plik

@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
25 25
 public class OptionsTest extends BaseTest {
26 26
 
27 27
     private static final String TITLE = "the title";
28
+    private static final Number TITLE_HEIGHT = new Number(100);
28 29
     private static final String FAB_ID = "FAB";
29 30
     private static final String FAB_ALIGN_HORIZONTALLY = "right";
30 31
     private static final String FAB_ALIGN_VERTICALLY = "bottom";
@@ -83,6 +84,7 @@ public class OptionsTest extends BaseTest {
83 84
     private void assertResult(Options result) {
84 85
         assertThat(result.topBar.title.text.get()).isEqualTo(TITLE);
85 86
         assertThat(result.topBar.background.color.get()).isEqualTo(TOP_BAR_BACKGROUND_COLOR);
87
+        assertThat(result.topBar.title.height.get()).isEqualTo(TITLE_HEIGHT.get());
86 88
         assertThat(result.topBar.title.color.get()).isEqualTo(TOP_BAR_TEXT_COLOR);
87 89
         assertThat(result.topBar.title.fontSize.get()).isEqualTo(TOP_BAR_FONT_SIZE);
88 90
         assertThat(result.topBar.title.fontFamily).isEqualTo(TOP_BAR_TYPEFACE);
@@ -134,6 +136,7 @@ public class OptionsTest extends BaseTest {
134 136
     private JSONObject createTitle() throws JSONException {
135 137
         return new JSONObject()
136 138
                 .put("text", "the title")
139
+                .put("height", TITLE_HEIGHT.get())
137 140
                 .put("color", TOP_BAR_TEXT_COLOR)
138 141
                 .put("fontSize", TOP_BAR_FONT_SIZE)
139 142
                 .put("fontFamily", TOP_BAR_FONT_FAMILY);