Skip to content

Commit

Permalink
Merge pull request #255 from idpass/203/rtl-support
Browse files Browse the repository at this point in the history
#203 RTL is not handled in inji app
  • Loading branch information
pmigueld authored Nov 7, 2022
2 parents a5dc4e8 + 7d03c45 commit 81ba102
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 224 deletions.
24 changes: 20 additions & 4 deletions components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
import React from 'react';
import { SUPPORTED_LANGUAGES } from '../i18n';
import { View } from 'react-native';
import { I18nManager, View } from 'react-native';
import { Picker } from './ui/Picker';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useTranslation } from 'react-i18next';
import i18next from 'i18next';
import RNRestart from 'react-native-restart';

export const LanguageSelector: React.FC<LanguageSelectorProps> = (props) => {
const { i18n } = useTranslation();
const languages = Object.entries(SUPPORTED_LANGUAGES).map(
([value, label]) => ({ label, value })
);

const changeLanguage = async (value: string) => {
await i18n.changeLanguage(value);
await AsyncStorage.setItem('language', i18n.language);
const changeLanguage = async (language: string) => {
if (language !== i18n.language) {
await i18n.changeLanguage(language).then(async () => {
await AsyncStorage.setItem('language', i18n.language);
const isRTL = i18next.dir(language) === 'rtl' ? true : false;
if (isRTL !== I18nManager.isRTL) {
try {
I18nManager.forceRTL(isRTL);
setTimeout(() => {
RNRestart.Restart();
}, 150);
} catch (e) {
console.log('error', e);
}
}
});
}
};

return (
Expand Down
11 changes: 6 additions & 5 deletions components/VcDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,31 @@ export const VcDetails: React.FC<VcDetailsProps> = (props) => {
<Column>
<Row pY={16} pX={8} align="space-between">
<Column fill elevation={1} pY={12} pX={16} margin="0 8">
<Text size="smaller" color={Colors.Grey}>
<Text size="smaller" color={Colors.Grey} align="left">
{t('generatedOn')}
</Text>
<Text weight="bold" size="smaller">
<Text weight="bold" size="smaller" align="left">
{new Date(props.vc?.generatedOn).toLocaleDateString()}
</Text>
</Column>
<Column fill elevation={1} pY={12} pX={16} margin="0 8">
<Text
size="smaller"
align="left"
color={Colors.Grey}
style={{ textTransform: 'uppercase' }}>
{props.vc?.idType}
</Text>
<Text weight="bold" size="smaller">
<Text weight="bold" size="smaller" align="left">
{props.vc?.id}
</Text>
</Column>
<Column fill elevation={1} pY={12} pX={16} margin="0 8">
<Text size="smaller" color={Colors.Grey}>
<Text size="smaller" align="left" color={Colors.Grey}>
{t('status')}
</Text>
<Row>
<Text weight="bold" size="smaller">
<Text weight="bold" size="smaller" align="left">
{t('valid')}
</Text>
{props.vc?.isVerified && <VerifiedIcon />}
Expand Down
5 changes: 3 additions & 2 deletions components/VcItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useContext, useRef } from 'react';
import { useInterpret, useSelector } from '@xstate/react';
import { Pressable, StyleSheet } from 'react-native';
import { I18nManager, Pressable, StyleSheet } from 'react-native';
import { CheckBox, Icon } from 'react-native-elements';
import { ActorRefFrom } from 'xstate';
import {
Expand All @@ -21,6 +21,7 @@ const styles = StyleSheet.create({
title: {
color: Colors.Black,
backgroundColor: 'transparent',
textAlign: 'left',
},
loadingTitle: {
color: 'transparent',
Expand Down Expand Up @@ -65,7 +66,7 @@ export const VcItem: React.FC<VcItemProps> = (props) => {
onPress={() => props.onPress(service)}
/>
) : (
<Icon name="chevron-right" />
<Icon name={I18nManager.isRTL ? 'chevron-left' : 'chevron-right'} />
);

return (
Expand Down
1 change: 1 addition & 0 deletions components/ui/TextItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const TextItem: React.FC<TextItemProps> = (props) => {
style={{
borderBottomColor: Colors.Grey6,
borderBottomWidth: props.divider ? 1 : 0,
alignItems: 'flex-start',
}}>
{props.label && (
<Text size="smaller" color={Colors.Grey} weight="semibold">
Expand Down
Loading

0 comments on commit 81ba102

Please sign in to comment.