moved functionnal NotificationView into it's dedicated file

This commit is contained in:
Clément Le Bihan
2023-04-10 22:43:28 +02:00
parent 0cd8846e2c
commit d9ede44d7d
2 changed files with 65 additions and 69 deletions

View File

@@ -1,36 +1,68 @@
import React from "react";
import { View } from 'react-native';
import { View } from "react-native";
import { Center, Button, Text, Switch, Heading } from "native-base";
import { translate } from "../../i18n/i18n";
import { translate, Translate } from "../../i18n/i18n";
import { useDispatch } from "react-redux";
import { RootState, useSelector } from "../../state/Store";
import { useLanguage } from "../../state/LanguageSlice";
import { SettingsState, updateSettings } from '../../state/SettingsSlice';
const NotificationsView = ({navigation}) => {
return (
<Center style={{ flex: 1, justifyContent: 'center' }}>
const NotificationsView = ({ navigation }) => {
const dispatch = useDispatch();
const settings: SettingsState = useSelector(
(state: RootState) => state.settings
);
return (
<Center style={{ flex: 1, justifyContent: "center" }}>
<Heading style={{ textAlign: "center" }}>
<Translate translationKey="notifBtn" />
</Heading>
<View style={{ margin: 20 }}>
<Text style={{ textAlign: "center" }}>Push notifications</Text>
<Switch
value={settings.enablePushNotifications}
style={{ alignSelf: "center", margin: 10 }}
colorScheme="primary"
onValueChange={(value) => {
dispatch(updateSettings({ enablePushNotifications: value }));
}}
/>
</View>
<View style={{ margin: 20 }}>
<Text style={{ textAlign: "center" }}>Email notifications</Text>
<Switch
value={settings.enableMailNotifications}
style={{ alignSelf: "center", margin: 10 }}
colorScheme="primary"
onValueChange={(value) => {
dispatch(updateSettings({ enableMailNotifications: value }));
}}
/>
</View>
<View style={{ margin: 20 }}>
<Text style={{ textAlign: "center" }}>Training reminder</Text>
<Switch
value={settings.enableLessongsReminders}
style={{ alignSelf: "center", margin: 10 }}
colorScheme="primary"
onValueChange={(value) => {
dispatch(updateSettings({ enableLessongsReminders: value }));
}}
/>
</View>
<View style={{ margin: 20 }}>
<Text style={{ textAlign: "center" }}>New songs</Text>
<Switch
value={settings.enableReleaseAlerts}
style={{ alignSelf: "center", margin: 10 }}
colorScheme="primary"
onValueChange={(value) => {
dispatch(updateSettings({ enableReleaseAlerts: value }));
}}
/>
</View>
</Center>
);
};
<Heading style={{ textAlign: "center" }}>{ translate('notifBtn')}</Heading>
<Button variant='outline' style={{ margin: 10}} onPress={() => navigation.navigate('Settings')} >{ translate('backBtn') }</Button>
<View style={{margin: 20}} >
<Text style={{ textAlign: "center" }}>Push notifications</Text>
<Switch style={{ alignSelf: 'center', margin: 10 }} colorScheme="primary"/>
</View>
<View style={{margin: 20}}>
<Text style={{ textAlign: "center" }}>Email notifications</Text>
<Switch style={{ alignSelf: 'center', margin: 10 }} colorScheme="primary"/>
</View>
<View style={{margin: 20}}>
<Text style={{ textAlign: "center" }}>Training reminder</Text>
<Switch style={{ alignSelf: 'center', margin: 10 }} colorScheme="primary"/>
</View>
<View style={{margin: 20}}>
<Text style={{ textAlign: "center" }}>New songs</Text>
<Switch style={{ alignSelf: 'center', margin: 10 }} colorScheme="primary"/>
</View>
</Center>
)
}
export default NotificationsView;
export default NotificationsView;

View File

@@ -14,6 +14,7 @@ import { FontAwesome, MaterialCommunityIcons, FontAwesome5 } from '@expo/vector-
import ChangePasswordForm from '../../components/forms/changePasswordForm';
import ChangeEmailForm from '../../components/forms/changeEmailForm';
import ProfileSettings from './SettingsProfileView';
import NotificationsView from './NotificationView';
import API, { APIError } from '../../API';
@@ -158,43 +159,6 @@ export const PreferencesView = ({navigation}) => {
)
}
const NotificationsView = ({navigation}) => {
const dispatch = useDispatch();
const settings: SettingsState = useSelector((state: RootState) => state.settings);
return (
<Center style={{ flex: 1, justifyContent: 'center' }}>
<Heading style={{ textAlign: "center" }}>
<Translate translationKey='notifBtn'/>
</Heading>
<View style={{margin: 20}} >
<Text style={{ textAlign: "center" }}>Push notifications</Text>
<Switch value={settings.enablePushNotifications} style={{ alignSelf: 'center', margin: 10 }} colorScheme="primary"
onValueChange={(value) => { dispatch(updateSettings({ enablePushNotifications: value })) }}
/>
</View>
<View style={{margin: 20}}>
<Text style={{ textAlign: "center" }}>Email notifications</Text>
<Switch value={settings.enableMailNotifications} style={{ alignSelf: 'center', margin: 10 }} colorScheme="primary"
onValueChange={(value) => { dispatch(updateSettings({ enableMailNotifications: value })) }}
/>
</View>
<View style={{margin: 20}}>
<Text style={{ textAlign: "center" }}>Training reminder</Text>
<Switch value={settings.enableLessongsReminders} style={{ alignSelf: 'center', margin: 10 }} colorScheme="primary"
onValueChange={(value) => { dispatch(updateSettings({ enableLessongsReminders: value })) }}
/>
</View>
<View style={{margin: 20}}>
<Text style={{ textAlign: "center" }}>New songs</Text>
<Switch value={settings.enableReleaseAlerts} style={{ alignSelf: 'center', margin: 10 }} colorScheme="primary"
onValueChange={(value) => { dispatch(updateSettings({ enableReleaseAlerts: value })) }}
/>
</View>
</Center>
)
}
export const PrivacyView = ({navigation}) => {
return (
<Center style={{ flex: 1}}>