Skip to content

Commit f0596db

Browse files
MarkPollmannTrancever
authored andcommitted
feat: add rtl support to ProgressBar (#1523)
1 parent c3c8c5f commit f0596db

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/components/ProgressBar.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ViewStyle,
88
StyleProp,
99
LayoutChangeEvent,
10+
I18nManager,
1011
} from 'react-native';
1112
import setColor from 'color';
1213
import { withTheme } from '../core/theming';
@@ -44,6 +45,7 @@ type State = {
4445

4546
const INDETERMINATE_DURATION = 2000;
4647
const INDETERMINATE_MAX_WIDTH = 0.6;
48+
const { isRTL } = I18nManager;
4749

4850
/**
4951
* Progress bar is an indicator used to present progress of some activity in the app.
@@ -187,14 +189,17 @@ class ProgressBar extends React.Component<Props, State> {
187189
? {
188190
inputRange: [0, 0.5, 1],
189191
outputRange: [
190-
-0.5 * width,
191-
-0.5 * INDETERMINATE_MAX_WIDTH * width,
192-
0.7 * width,
192+
(isRTL ? 1 : -1) * 0.5 * width,
193+
(isRTL ? 1 : -1) *
194+
0.5 *
195+
INDETERMINATE_MAX_WIDTH *
196+
width,
197+
(isRTL ? -1 : 1) * 0.7 * width,
193198
],
194199
}
195200
: {
196201
inputRange: [0, 1],
197-
outputRange: [-0.5 * width, 0],
202+
outputRange: [(isRTL ? 1 : -1) * 0.5 * width, 0],
198203
}
199204
),
200205
},

0 commit comments

Comments
 (0)