Skip to content

Commit 1b918b2

Browse files
Merge pull request #102 from OpenDTU-App/96-add-a-note-about-the-weblate-project-inside-the-app
2 parents f56e483 + a487870 commit 1b918b2

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

src/components/modals/ChangeLanguageModal.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import { useCallback, useState } from 'react';
33
import { useTranslation } from 'react-i18next';
44
import { Box } from 'react-native-flex-layout';
55
import type { ModalProps } from 'react-native-paper';
6-
import { Button, Portal, RadioButton, Text } from 'react-native-paper';
6+
import {
7+
Button,
8+
Portal,
9+
RadioButton,
10+
Text,
11+
useTheme,
12+
} from 'react-native-paper';
13+
14+
import { Linking } from 'react-native';
715

816
import { setLanguage } from '@/slices/settings';
917

@@ -13,6 +21,7 @@ import useAppLanguage from '@/hooks/useAppLanguage';
1321

1422
import { rootLogging } from '@/utils/log';
1523

24+
import { colors, weblateUrl } from '@/constants';
1625
import { useAppDispatch } from '@/store';
1726
import type { SupportedLanguage } from '@/translations';
1827
import { supportedLanguages } from '@/translations';
@@ -23,6 +32,7 @@ const ChangeLanguageModal: FC<Omit<ModalProps, 'children'>> = props => {
2332
const { onDismiss } = props;
2433
const dispatch = useAppDispatch();
2534
const { t } = useTranslation();
35+
const theme = useTheme();
2636

2737
const language = useAppLanguage();
2838

@@ -39,11 +49,20 @@ const ChangeLanguageModal: FC<Omit<ModalProps, 'children'>> = props => {
3949
onDismiss?.();
4050
}, [dispatch, onDismiss, selectedLanguage]);
4151

52+
const handleOpenWeblate = useCallback(async () => {
53+
if (await Linking.canOpenURL(weblateUrl)) {
54+
await Linking.openURL(weblateUrl);
55+
} else {
56+
// TODO: Better error handling (issue #101)
57+
log.error('Cannot open Weblate URL');
58+
}
59+
}, []);
60+
4261
return (
4362
<Portal>
4463
<BaseModal {...props}>
45-
<Box p={16}>
46-
<Box mb={8}>
64+
<Box p={8}>
65+
<Box m={8}>
4766
<Text variant="bodyLarge">{t('settings.changeTheLanguage')}</Text>
4867
</Box>
4968
<RadioButton.Group
@@ -60,6 +79,24 @@ const ChangeLanguageModal: FC<Omit<ModalProps, 'children'>> = props => {
6079
/>
6180
))}
6281
</RadioButton.Group>
82+
<Box
83+
mt={16}
84+
style={{
85+
gap: 8,
86+
backgroundColor: theme.colors.elevation.level1,
87+
padding: 8,
88+
borderRadius: theme.roundness * 4,
89+
}}
90+
>
91+
<Text variant="bodyMedium">{t('settings.weblateInfo')}</Text>
92+
<Button
93+
buttonColor={colors.weblate}
94+
textColor={colors.onWeblate}
95+
onPress={handleOpenWeblate}
96+
>
97+
{t('settings.openWeblate')}
98+
</Button>
99+
</Box>
63100
<Box
64101
mt={16}
65102
style={{

src/constants/index.ts renamed to src/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export const colors = {
1414
warningSurface: '#fff9c4',
1515
onWarningSurface: '#7a471d',
1616
},
17+
weblate: '#124b47',
18+
onWeblate: '#fff',
1719
};
1820

1921
export const spacing = 8;
@@ -23,3 +25,6 @@ export const defaultUser = 'admin';
2325
export const minimumOpenDtuFirmwareVersion = 'v23.11.16';
2426

2527
export const maximumTestedOpenDtuFirmwareVersion = 'v24.4.12';
28+
29+
export const weblateUrl =
30+
'https://weblate.commanderred.xyz/engage/opendtu-react-native/';

src/translations/translation-files

0 commit comments

Comments
 (0)