Bläddra i källkod

Rename alignment to componentAlignment

Guy Carmeli 7 år sedan
förälder
incheckning
0d614911c5

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/parse/TitleOptions.java Visa fil

31
         options.fontSize = FractionParser.parse(json, "fontSize");
31
         options.fontSize = FractionParser.parse(json, "fontSize");
32
         options.fontFamily = typefaceManager.getTypeFace(json.optString("fontFamily", ""));
32
         options.fontFamily = typefaceManager.getTypeFace(json.optString("fontFamily", ""));
33
         options.component = TextParser.parse(json, "component");
33
         options.component = TextParser.parse(json, "component");
34
-        options.alignment = Alignment.fromString(TextParser.parse(json, "alignment").get(""));
34
+        options.componentAlignment = Alignment.fromString(TextParser.parse(json, "componentAlignment").get(""));
35
 
35
 
36
         validate(options);
36
         validate(options);
37
 
37
 
43
     public Fraction fontSize = new NullFraction();
43
     public Fraction fontSize = new NullFraction();
44
     @Nullable public Typeface fontFamily;
44
     @Nullable public Typeface fontFamily;
45
     public Text component = new NullText();
45
     public Text component = new NullText();
46
-    public Alignment alignment = Alignment.Default;
46
+    public Alignment componentAlignment = Alignment.Default;
47
 
47
 
48
     void mergeWith(final TitleOptions other) {
48
     void mergeWith(final TitleOptions other) {
49
         if (other.text.hasValue()) text = other.text;
49
         if (other.text.hasValue()) text = other.text;
51
         if (other.fontSize.hasValue()) fontSize = other.fontSize;
51
         if (other.fontSize.hasValue()) fontSize = other.fontSize;
52
         if (other.fontFamily != null) fontFamily = other.fontFamily;
52
         if (other.fontFamily != null) fontFamily = other.fontFamily;
53
         if (other.component.hasValue()) component = other.component;
53
         if (other.component.hasValue()) component = other.component;
54
-        if (other.alignment != Alignment.Default) alignment = other.alignment;
54
+        if (other.componentAlignment != Alignment.Default) componentAlignment = other.componentAlignment;
55
         validate(this);
55
         validate(this);
56
     }
56
     }
57
 
57
 
61
         if (!fontSize.hasValue()) fontSize = defaultOptions.fontSize;
61
         if (!fontSize.hasValue()) fontSize = defaultOptions.fontSize;
62
         if (fontFamily == null) fontFamily = defaultOptions.fontFamily;
62
         if (fontFamily == null) fontFamily = defaultOptions.fontFamily;
63
         if (!component.hasValue()) component = defaultOptions.component;
63
         if (!component.hasValue()) component = defaultOptions.component;
64
-        if (alignment == Alignment.Default) alignment = defaultOptions.alignment;
64
+        if (componentAlignment == Alignment.Default) componentAlignment = defaultOptions.componentAlignment;
65
         validate(this);
65
         validate(this);
66
     }
66
     }
67
 
67
 

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java Visa fil

47
 
47
 
48
     private void applyTopBarOptions(TopBarOptions options, AnimationsOptions animationOptions, Component component) {
48
     private void applyTopBarOptions(TopBarOptions options, AnimationsOptions animationOptions, Component component) {
49
         topBar.setTitle(options.title.text.get(""));
49
         topBar.setTitle(options.title.text.get(""));
50
-        if (options.title.component.hasValue()) topBar.setTitleComponent(options.title.component.get(), options.title.alignment);
50
+        if (options.title.component.hasValue()) topBar.setTitleComponent(options.title.component.get(), options.title.componentAlignment);
51
         topBar.setTitleFontSize(options.title.fontSize.get(defaultTitleFontSize));
51
         topBar.setTitleFontSize(options.title.fontSize.get(defaultTitleFontSize));
52
         topBar.setTitleTextColor(options.title.color.get(DEFAULT_TITLE_COLOR));
52
         topBar.setTitleTextColor(options.title.color.get(DEFAULT_TITLE_COLOR));
53
         topBar.setTitleTypeface(options.title.fontFamily);
53
         topBar.setTitleTypeface(options.title.fontFamily);
136
 
136
 
137
     private void mergeTopBarOptions(TopBarOptions options, AnimationsOptions animationsOptions, Component component) {
137
     private void mergeTopBarOptions(TopBarOptions options, AnimationsOptions animationsOptions, Component component) {
138
         if (options.title.text.hasValue()) topBar.setTitle(options.title.text.get());
138
         if (options.title.text.hasValue()) topBar.setTitle(options.title.text.get());
139
-        if (options.title.component.hasValue()) topBar.setTitleComponent(options.title.component.get(), options.title.alignment);
139
+        if (options.title.component.hasValue()) topBar.setTitleComponent(options.title.component.get(), options.title.componentAlignment);
140
         if (options.title.color.hasValue()) topBar.setTitleTextColor(options.title.color.get());
140
         if (options.title.color.hasValue()) topBar.setTitleTextColor(options.title.color.get());
141
         if (options.title.fontSize.hasValue()) topBar.setTitleFontSize(options.title.fontSize.get());
141
         if (options.title.fontSize.hasValue()) topBar.setTitleFontSize(options.title.fontSize.get());
142
         if (options.title.fontFamily != null) topBar.setTitleTypeface(options.title.fontFamily);
142
         if (options.title.fontFamily != null) topBar.setTitleTypeface(options.title.fontFamily);

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/parse/OptionsTest.java Visa fil

100
         assertThat(result.fabOptions.hideOnScroll.get()).isEqualTo(FAB_HIDE_ON_SCROLL);
100
         assertThat(result.fabOptions.hideOnScroll.get()).isEqualTo(FAB_HIDE_ON_SCROLL);
101
         assertThat(result.fabOptions.alignVertically.get()).isEqualTo(FAB_ALIGN_VERTICALLY);
101
         assertThat(result.fabOptions.alignVertically.get()).isEqualTo(FAB_ALIGN_VERTICALLY);
102
         assertThat(result.fabOptions.alignHorizontally.get()).isEqualTo(FAB_ALIGN_HORIZONTALLY);
102
         assertThat(result.fabOptions.alignHorizontally.get()).isEqualTo(FAB_ALIGN_HORIZONTALLY);
103
-        assertThat(result.topBarOptions.title.alignment).isEqualTo(Alignment.Center);
103
+        assertThat(result.topBarOptions.title.componentAlignment).isEqualTo(Alignment.Center);
104
     }
104
     }
105
 
105
 
106
     @NonNull
106
     @NonNull
134
                 .put("color", TOP_BAR_TEXT_COLOR)
134
                 .put("color", TOP_BAR_TEXT_COLOR)
135
                 .put("fontSize", TOP_BAR_FONT_SIZE)
135
                 .put("fontSize", TOP_BAR_FONT_SIZE)
136
                 .put("fontFamily", TOP_BAR_FONT_FAMILY)
136
                 .put("fontFamily", TOP_BAR_FONT_FAMILY)
137
-                .put("alignment", TITLE_ALIGNMENT);
137
+                .put("componentAlignment", TITLE_ALIGNMENT);
138
     }
138
     }
139
 
139
 
140
     private JSONObject createSubtitle() throws JSONException {
140
     private JSONObject createSubtitle() throws JSONException {

+ 1
- 1
playground/src/screens/OptionsScreen.js Visa fil

262
       topBar: {
262
       topBar: {
263
         title: {
263
         title: {
264
           component: 'navigation.playground.CustomTopBar',
264
           component: 'navigation.playground.CustomTopBar',
265
-          alignment: 'center'
265
+          componentAlignment: 'center'
266
         }
266
         }
267
       }
267
       }
268
     });
268
     });