Skip to content

Commit

Permalink
feat: Right-to-Left layout support
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoà Phan authored and Hoà Phan committed Mar 5, 2023
1 parent 7f97b25 commit 51ae80b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
1 change: 0 additions & 1 deletion example/src/dropdown/DropdownWithConfirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
textItem: {
flex: 1,
fontSize: 16,
},
placeholderStyle: {
Expand Down
8 changes: 5 additions & 3 deletions src/components/Dropdown/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StyleSheet } from 'react-native';
import { I18nManager, StyleSheet } from 'react-native';

export const styles = StyleSheet.create({
mainWrap: {
Expand Down Expand Up @@ -28,24 +28,26 @@ export const styles = StyleSheet.create({
justifyContent: 'flex-end',
},
dropdown: {
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
justifyContent: 'space-between',
alignItems: 'center',
height: 35,
},
title: {
marginVertical: 5,
fontSize: 16,
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
},
item: {
padding: 17,
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
textItem: {
flex: 1,
fontSize: 16,
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
},
icon: {
width: 20,
Expand Down
16 changes: 10 additions & 6 deletions src/components/MultiSelect/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StyleSheet } from 'react-native';
import { I18nManager, StyleSheet } from 'react-native';

export const styles = StyleSheet.create({
mainWrap: {
Expand Down Expand Up @@ -28,33 +28,35 @@ export const styles = StyleSheet.create({
justifyContent: 'flex-end',
},
dropdown: {
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
justifyContent: 'space-between',
alignItems: 'center',
height: 35,
},
dropdownInside: {
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
justifyContent: 'space-between',
alignItems: 'center',
minHeight: 35,
},
title: {
marginVertical: 5,
fontSize: 16,
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
},
wrapItem: {
marginBottom: 0.5,
},
item: {
padding: 17,
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
textItem: {
flex: 1,
fontSize: 16,
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
},
icon: {
width: 20,
Expand All @@ -69,7 +71,7 @@ export const styles = StyleSheet.create({
height: 45,
},
rowSelectedItem: {
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
flexWrap: 'wrap',
},
selectedItem: {
Expand All @@ -81,15 +83,17 @@ export const styles = StyleSheet.create({
paddingHorizontal: 8,
marginVertical: 6,
marginRight: 8,
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
},
selectedTextItem: {
marginLeft: 5,
color: 'gray',
fontSize: 16,
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
},
selectedTextLeftItem: {
fontSize: 12,
color: 'gray',
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
},
});
5 changes: 3 additions & 2 deletions src/components/SelectCountry/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StyleSheet } from 'react-native';
import { I18nManager, StyleSheet } from 'react-native';

export const styles = StyleSheet.create({
dropdown: {
Expand All @@ -10,7 +10,7 @@ export const styles = StyleSheet.create({
width: 60,
},
item: {
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
padding: 6,
alignItems: 'center',
},
Expand All @@ -23,5 +23,6 @@ export const styles = StyleSheet.create({
selectedTextStyle: {
flex: 1,
fontSize: 12,
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
},
});
7 changes: 4 additions & 3 deletions src/components/TextInput/styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StyleSheet } from 'react-native';
import { I18nManager, StyleSheet } from 'react-native';

export const styles = StyleSheet.create({
container: {
Expand All @@ -8,20 +8,21 @@ export const styles = StyleSheet.create({
justifyContent: 'center',
},
textInput: {
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
alignItems: 'center',
flex: 1,
},
input: {
fontSize: 16,
flex: 1,
textAlign: I18nManager.isRTL ? 'right' : 'left',
},
label: {
marginBottom: 4,
fontSize: 16,
},
row: {
flexDirection: 'row',
flexDirection: I18nManager.isRTL ? 'row-reverse' : 'row',
},
icon: {
width: 20,
Expand Down

0 comments on commit 51ae80b

Please sign in to comment.