Skip to content
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

#203 RTL is not handled in inji app #255

Merged
merged 3 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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