moved functionnal NotificationView into it's dedicated file
This commit is contained in:
@@ -1,36 +1,68 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { View } from 'react-native';
|
import { View } from "react-native";
|
||||||
import { Center, Button, Text, Switch, Heading } from "native-base";
|
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}) => {
|
const NotificationsView = ({ navigation }) => {
|
||||||
return (
|
const dispatch = useDispatch();
|
||||||
<Center style={{ flex: 1, justifyContent: 'center' }}>
|
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>
|
export default NotificationsView;
|
||||||
<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;
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { FontAwesome, MaterialCommunityIcons, FontAwesome5 } from '@expo/vector-
|
|||||||
import ChangePasswordForm from '../../components/forms/changePasswordForm';
|
import ChangePasswordForm from '../../components/forms/changePasswordForm';
|
||||||
import ChangeEmailForm from '../../components/forms/changeEmailForm';
|
import ChangeEmailForm from '../../components/forms/changeEmailForm';
|
||||||
import ProfileSettings from './SettingsProfileView';
|
import ProfileSettings from './SettingsProfileView';
|
||||||
|
import NotificationsView from './NotificationView';
|
||||||
|
|
||||||
import API, { APIError } from '../../API';
|
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}) => {
|
export const PrivacyView = ({navigation}) => {
|
||||||
return (
|
return (
|
||||||
<Center style={{ flex: 1}}>
|
<Center style={{ flex: 1}}>
|
||||||
|
|||||||
Reference in New Issue
Block a user