Front: First Pass on translations + remove unused setting tabs

This commit is contained in:
Arthur Jamet
2023-12-14 16:11:27 +01:00
committed by Clément Le Bihan
parent 00d097f643
commit d3994ff26e
13 changed files with 37 additions and 280 deletions
@@ -1,95 +0,0 @@
import React from 'react';
import { translate } from '../../i18n/i18n';
import ElementList from '../../components/GtkUI/ElementList';
import useUserSettings from '../../hooks/userSettings';
import { LoadingView } from '../../components/Loading';
import { Calendar1, MonitorMobbile, Send2, Warning2 } from 'iconsax-react-native';
const NotificationsSettings = () => {
const { settings, updateSettings } = useUserSettings();
if (!settings.data) {
return <LoadingView />;
}
return (
<ElementList
style={{ width: '100%' }}
elements={[
{
type: 'toggle',
icon: MonitorMobbile,
title: translate('SettingsNotificationsTabPushNotificationsSectionTitle'),
description: translate(
'SettingsNotificationsTabPushNotificationsSectionDescription'
),
data: {
value: settings.data.notifications.pushNotif,
onToggle: () => {
updateSettings({
notifications: {
pushNotif: !settings.data.notifications.pushNotif,
},
});
},
},
},
{
type: 'toggle',
icon: Send2,
title: translate('SettingsNotificationsTabEmailNotificationsSectionTitle'),
description: translate(
'SettingsNotificationsTabEmailNotificationsSectionDescription'
),
data: {
value: settings.data.notifications.emailNotif,
onToggle: () => {
updateSettings({
notifications: {
emailNotif: !settings.data.notifications.emailNotif,
},
});
},
},
},
{
type: 'toggle',
icon: Calendar1,
title: translate('SettingsNotificationsTabTrainingReminderSectionTitle'),
description: translate(
'SettingsNotificationsTabTrainingReminderSectionDescription'
),
data: {
value: settings.data.notifications.trainNotif,
onToggle: () => {
updateSettings({
notifications: {
trainNotif: !settings.data.notifications.trainNotif,
},
});
},
},
},
{
type: 'toggle',
icon: Warning2,
title: translate('SettingsNotificationsTabReleaseAlertSectionTitle'),
description: translate(
'SettingsNotificationsTabReleaseAlertSectionDescription'
),
data: {
value: settings.data.notifications.newSongNotif,
onToggle: () => {
updateSettings({
notifications: {
newSongNotif: !settings.data.notifications.newSongNotif,
},
});
},
},
},
]}
/>
);
};
export default NotificationsSettings;
+1 -54
View File
@@ -7,7 +7,7 @@ import { useSelector } from '../../state/Store';
import { updateSettings } from '../../state/SettingsSlice';
import ElementList from '../../components/GtkUI/ElementList';
import LocalSettings from '../../models/LocalSettings';
import { Brush2, Colorfilter, LanguageSquare, Rank, Sound } from 'iconsax-react-native';
import { Brush2, LanguageSquare, Rank } from 'iconsax-react-native';
const PreferencesSettings = () => {
const dispatch = useDispatch();
@@ -84,59 +84,6 @@ const PreferencesSettings = () => {
},
]}
/>
<ElementList
elements={[
{
icon: Colorfilter,
type: 'toggle',
title: translate('SettingsPreferencesTabColorblindModeSectionTitle'),
description: translate(
'SettingsPreferencesTabColorblindModeSectionDescription'
),
data: {
value: settings.colorBlind,
onToggle: () => {
dispatch(updateSettings({ colorBlind: !settings.colorBlind }));
},
},
},
]}
/>
<ElementList
elements={[
{
icon: Sound,
type: 'range',
title: translate('SettingsPreferencesTabMicVolumeSectionTitle'),
description: translate('SettingsPreferencesTabMicVolumeSectionDescription'),
data: {
value: settings.micVolume,
min: 0,
max: 1000,
step: 10,
onChange: (value) => {
dispatch(updateSettings({ micVolume: value }));
},
},
},
/*{
type: "dropdown",
title: translate("SettingsPreferencesDevice"),
data: {
value: settings.preferedInputName || "0",
defaultValue: "0",
onSelect: (itemValue: string) => {
dispatch(updateSettings({ preferedInputName: itemValue }));
},
options: [
{ label: "Mic_0", value: "0" },
{ label: "Mic_1", value: "1" },
{ label: "Mic_2", value: "2" },
],
},
},*/
]}
/>
</Column>
);
};
-69
View File
@@ -1,69 +0,0 @@
import API from '../../API';
import React from 'react';
import { LoadingView } from '../../components/Loading';
import ElementList from '../../components/GtkUI/ElementList';
import { translate } from '../../i18n/i18n';
import { useQuery } from '../../Queries';
import { Designtools, Magicpen, Star1 } from 'iconsax-react-native';
// Too painful to infer the settings-only, typed navigator. Gave up
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const PremiumSettings = () => {
const userQuery = useQuery(API.getUserInfo);
if (!userQuery.data || userQuery.isLoading) {
return <LoadingView />;
}
const user = userQuery.data;
return (
<ElementList
style={{ width: '100%' }}
elements={[
{
icon: Star1,
type: 'text',
title: translate('settingsPremiumTabPremiumAccountSectionTitle'),
description: translate('settingsPremiumTabPremiumAccountSectionDescription'),
data: {
text: translate(user.premium ? 'yes' : 'no'),
},
},
{
icon: Magicpen,
type: 'toggle',
title: translate('settingsPremiumTabPianoMagiqueSectionTitle'),
description: translate('settingsPremiumTabPianoMagiqueSectionDescription'),
helperText: translate('settingsPremiumTabPianoMagiqueSectionHelper'),
disabled: true,
data: {
value: false,
onToggle: () => {},
},
},
{
icon: Designtools,
type: 'dropdown',
title: translate('settingsPremiumTabThemePianoSectionTitle'),
description: translate('settingsPremiumTabThemePianoSectionDescription'),
disabled: true,
data: {
value: 'default',
onSelect: () => {},
options: [
{
label: 'Default',
value: 'default',
},
{
label: 'Catpuccino',
value: 'catpuccino',
},
],
},
},
]}
/>
);
};
export default PremiumSettings;
+1 -26
View File
@@ -1,7 +1,6 @@
import React from 'react';
import { Center, Text, useBreakpointValue, useTheme } from 'native-base';
import { Text, useBreakpointValue, useTheme } from 'native-base';
import ProfileSettings from './SettingsProfile';
import NotificationsSettings from './NotificationsSettings';
import PrivacySettings from './PrivacySettings';
import PreferencesSettings from './PreferencesSettings';
import { useWindowDimensions } from 'react-native';
@@ -15,50 +14,32 @@ import {
} from 'react-native-tab-view';
import {
HeartEdit,
Star1,
UserEdit,
Notification,
SecurityUser,
Music,
FolderCross,
} from 'iconsax-react-native';
import { Scene } from 'react-native-tab-view/lib/typescript/src/types';
import PremiumSettings from './SettingsPremium';
import { RouteProps } from '../../Navigation';
import ScaffoldCC from '../../components/UI/ScaffoldCC';
import { translate } from '../../i18n/i18n';
export const PianoSettings = () => {
return (
<Center style={{ flex: 1 }}>
<Text>Global settings for the virtual piano</Text>
</Center>
);
};
const renderScene = SceneMap({
profile: ProfileSettings,
premium: PremiumSettings,
preferences: PreferencesSettings,
notifications: NotificationsSettings,
privacy: PrivacySettings,
piano: PianoSettings,
});
const getTabData = (key: string) => {
switch (key) {
case 'profile':
return { index: 0, icon: UserEdit };
case 'premium':
return { index: 1, icon: Star1 };
case 'preferences':
return { index: 2, icon: HeartEdit };
case 'notifications':
return { index: 3, icon: Notification };
case 'privacy':
return { index: 4, icon: SecurityUser };
case 'piano':
return { index: 5, icon: Music };
default:
return { index: 6, icon: FolderCross };
}
@@ -71,11 +52,8 @@ const SettingsTab = (props: RouteProps<{}>) => {
const { colors } = useTheme();
const routes = [
{ key: 'profile', title: 'settingsTabProfile' },
{ key: 'premium', title: 'settingsTabPremium' },
{ key: 'preferences', title: 'settingsTabPreferences' },
{ key: 'notifications', title: 'settingsTabNotifications' },
{ key: 'privacy', title: 'settingsTabPrivacy' },
{ key: 'piano', title: 'settingsTabPiano' },
];
const screenSize = useBreakpointValue({ base: 'small', md: 'big' });
const isSmallScreen = screenSize === 'small';
@@ -113,11 +91,8 @@ const SettingsTab = (props: RouteProps<{}>) => {
{translate(
route.title as
| 'settingsTabProfile'
| 'settingsTabPremium'
| 'settingsTabPreferences'
| 'settingsTabNotifications'
| 'settingsTabPrivacy'
| 'settingsTabPiano'
)}
</Text>
)