mirror of
https://github.com/status-im/react-native.git
synced 2025-02-25 15:45:32 +00:00
Fallback for textAlign: justify
Summary:Fixes #5408 as per ide and vjeux suggestions here https://github.com/facebook/react-native/issues/529#issuecomment-107328799 Could've been probably done in a single `if` clause, but this is more explicit and leaves potential place for future implementation (if we ever decide to do so) Closes https://github.com/facebook/react-native/pull/7197 Differential Revision: D3217740 Pulled By: vjeux fb-gh-sync-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6 fbshipit-source-id: aa08a5c42e43c1abe17b72a424ee96146f2667f6
This commit is contained in:
parent
7102fd079a
commit
02578df4f7
@ -41,7 +41,8 @@ var TextStylePropTypes = Object.assign(Object.create(ViewStylePropTypes), {
|
||||
letterSpacing: ReactPropTypes.number,
|
||||
lineHeight: ReactPropTypes.number,
|
||||
/**
|
||||
* Specifies text alignment. The value 'justify' is only supported on iOS.
|
||||
* Specifies text alignment. The value 'justify' is only supported on iOS and
|
||||
* fallbacks to `left` on Android.
|
||||
*/
|
||||
textAlign: ReactPropTypes.oneOf(
|
||||
['auto' /*default*/, 'left', 'right', 'center', 'justify']
|
||||
|
@ -65,6 +65,9 @@ public class ReactTextViewManager extends BaseViewManager<ReactTextView, ReactTe
|
||||
view.setGravityHorizontal(Gravity.RIGHT);
|
||||
} else if ("center".equals(textAlign)) {
|
||||
view.setGravityHorizontal(Gravity.CENTER_HORIZONTAL);
|
||||
} else if ("justify".equals(textAlign)) {
|
||||
// Fallback gracefully for cross-platform compat instead of error
|
||||
view.setGravityHorizontal(Gravity.LEFT);
|
||||
} else {
|
||||
throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign);
|
||||
}
|
||||
|
@ -242,6 +242,9 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
view.setGravityHorizontal(Gravity.RIGHT);
|
||||
} else if ("center".equals(textAlign)) {
|
||||
view.setGravityHorizontal(Gravity.CENTER_HORIZONTAL);
|
||||
} else if ("justify".equals(textAlign)) {
|
||||
// Fallback gracefully for cross-platform compat instead of error
|
||||
view.setGravityHorizontal(Gravity.LEFT);
|
||||
} else {
|
||||
throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user