-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rtl support with dynamic right & left properties #70
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
// @flow | ||
import React, { Component } from 'react'; | ||
|
||
import { View, Animated } from 'react-native'; | ||
import { View, Animated, I18nManager } from 'react-native'; | ||
import styles from './style'; | ||
|
||
import type { valueXY } from '../types'; | ||
|
||
|
||
const rtl = I18nManager.isRTL; | ||
const start = rtl ? 'right' : 'left'; | ||
const end = rtl ? 'left' : 'right'; | ||
|
||
type Props = { | ||
size: valueXY, | ||
position: valueXY, | ||
|
@@ -78,23 +83,23 @@ class ViewMask extends Component<Props, State> { | |
style={[ | ||
styles.overlayRectangle, | ||
{ | ||
right: leftOverlayRight, | ||
[end]: leftOverlayRight, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change of syntax, again? How do the brackets help? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RichardLitt |
||
}]} | ||
/> | ||
<Animated.View | ||
style={[ | ||
styles.overlayRectangle, | ||
{ | ||
left: rightOverlayLeft, | ||
[start]: rightOverlayLeft, | ||
}]} | ||
/> | ||
<Animated.View | ||
style={[ | ||
styles.overlayRectangle, | ||
{ | ||
top: bottomOverlayTopBoundary, | ||
left: verticalOverlayLeftBoundary, | ||
right: verticalOverlayRightBoundary, | ||
[start]: verticalOverlayLeftBoundary, | ||
[end]: verticalOverlayRightBoundary, | ||
}, | ||
]} | ||
/> | ||
|
@@ -103,8 +108,8 @@ class ViewMask extends Component<Props, State> { | |
styles.overlayRectangle, | ||
{ | ||
bottom: topOverlayBottomBoundary, | ||
left: verticalOverlayLeftBoundary, | ||
right: verticalOverlayRightBoundary, | ||
[start]: verticalOverlayLeftBoundary, | ||
[end]: verticalOverlayRightBoundary, | ||
}, | ||
]} | ||
/> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you changed the syntax, instead of using
tooltip.end
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bracket notation is for computed keys.
tooltip.end = 1;
results in{ end: 1 }
whereasconst end = 'left'; tooltip[end] = 1
gives{ left: 1 }
, unless I misunderstood your question.