瀏覽代碼

Rename alignment to componentAlignment

Guy Carmeli 6 年之前
父節點
當前提交
0d614911c5

+ 4
- 4
lib/android/app/src/main/java/com/reactnativenavigation/parse/TitleOptions.java 查看文件

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

+ 2
- 2
lib/android/app/src/main/java/com/reactnativenavigation/presentation/OptionsPresenter.java 查看文件

@@ -47,7 +47,7 @@ public class OptionsPresenter {
47 47
 
48 48
     private void applyTopBarOptions(TopBarOptions options, AnimationsOptions animationOptions, Component component) {
49 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 51
         topBar.setTitleFontSize(options.title.fontSize.get(defaultTitleFontSize));
52 52
         topBar.setTitleTextColor(options.title.color.get(DEFAULT_TITLE_COLOR));
53 53
         topBar.setTitleTypeface(options.title.fontFamily);
@@ -136,7 +136,7 @@ public class OptionsPresenter {
136 136
 
137 137
     private void mergeTopBarOptions(TopBarOptions options, AnimationsOptions animationsOptions, Component component) {
138 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 140
         if (options.title.color.hasValue()) topBar.setTitleTextColor(options.title.color.get());
141 141
         if (options.title.fontSize.hasValue()) topBar.setTitleFontSize(options.title.fontSize.get());
142 142
         if (options.title.fontFamily != null) topBar.setTitleTypeface(options.title.fontFamily);

+ 2
- 2
lib/android/app/src/test/java/com/reactnativenavigation/parse/OptionsTest.java 查看文件

@@ -100,7 +100,7 @@ public class OptionsTest extends BaseTest {
100 100
         assertThat(result.fabOptions.hideOnScroll.get()).isEqualTo(FAB_HIDE_ON_SCROLL);
101 101
         assertThat(result.fabOptions.alignVertically.get()).isEqualTo(FAB_ALIGN_VERTICALLY);
102 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 106
     @NonNull
@@ -134,7 +134,7 @@ public class OptionsTest extends BaseTest {
134 134
                 .put("color", TOP_BAR_TEXT_COLOR)
135 135
                 .put("fontSize", TOP_BAR_FONT_SIZE)
136 136
                 .put("fontFamily", TOP_BAR_FONT_FAMILY)
137
-                .put("alignment", TITLE_ALIGNMENT);
137
+                .put("componentAlignment", TITLE_ALIGNMENT);
138 138
     }
139 139
 
140 140
     private JSONObject createSubtitle() throws JSONException {

+ 1
- 1
playground/src/screens/OptionsScreen.js 查看文件

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