Browse Source

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

Set topBar title height property
David 6 years ago
parent
commit
09c8c37e64

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

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

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

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