added privacy settings in the settings store and linked to the settings ui
This commit is contained in:
@@ -9,7 +9,10 @@ export type SettingsState = {
|
||||
preferedLevel: 'easy' | 'medium' | 'hard',
|
||||
colorBlind: boolean,
|
||||
micLevel: number,
|
||||
preferedInputName?: string
|
||||
preferedInputName?: string,
|
||||
dataCollection: boolean,
|
||||
customAds: boolean,
|
||||
recommandations: boolean,
|
||||
}
|
||||
|
||||
export const settingsSlice = createSlice({
|
||||
@@ -23,7 +26,10 @@ export const settingsSlice = createSlice({
|
||||
preferedLevel: 'easy',
|
||||
colorBlind: false,
|
||||
micLevel: 50,
|
||||
colorScheme: "system"
|
||||
colorScheme: "system",
|
||||
dataCollection: true,
|
||||
customAds: true,
|
||||
recommandations: true,
|
||||
},
|
||||
},
|
||||
reducers: {
|
||||
|
||||
@@ -36,6 +36,7 @@ const handleSignup = async (username: string, password: string, email: string, a
|
||||
const AuthenticationView = () => {
|
||||
const navigation = useNavigation();
|
||||
const dispatch = useDispatch();
|
||||
console.log(navigation.getState());
|
||||
const params = navigation.getState().routes.find((route) => {
|
||||
// this is not ideal way to check if we are on login page
|
||||
return route.name === "Login";
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import React from "react";
|
||||
import { View } from "react-native";
|
||||
import { Center, Button, Text, Switch, Heading } from "native-base";
|
||||
import { Center, Heading } from "native-base";
|
||||
import { translate } from "../../i18n/i18n";
|
||||
import ElementList from "../../components/GtkUI/ElementList";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { RootState, useSelector } from "../../state/Store";
|
||||
import { SettingsState, updateSettings } from "../../state/SettingsSlice";
|
||||
|
||||
const PrivacyView = () => {
|
||||
const dispatch = useDispatch();
|
||||
const settings: SettingsState = useSelector(
|
||||
(state: RootState) => state.settings.settings as SettingsState
|
||||
);
|
||||
|
||||
const PrivacyView = ({ navigation }) => {
|
||||
const [dataCollection, setDataCollection] = React.useState(false);
|
||||
const [customAds, setCustomAds] = React.useState(false);
|
||||
const [recommendations, setRecommendations] = React.useState(false);
|
||||
return (
|
||||
<Center style={{ flex: 1 }}>
|
||||
<Heading style={{ textAlign: "center" }}>{translate("privBtn")}</Heading>
|
||||
@@ -23,24 +27,31 @@ const PrivacyView = ({ navigation }) => {
|
||||
type: "toggle",
|
||||
title: translate("dataCollection"),
|
||||
data: {
|
||||
value: dataCollection,
|
||||
onToggle: () => setDataCollection(!dataCollection),
|
||||
value: settings.dataCollection,
|
||||
onToggle: () =>
|
||||
dispatch(
|
||||
updateSettings({ dataCollection: !settings.dataCollection })
|
||||
),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
title: translate("customAds"),
|
||||
data: {
|
||||
value: customAds,
|
||||
onToggle: () => setCustomAds(!customAds),
|
||||
value: settings.customAds,
|
||||
onToggle: () =>
|
||||
dispatch(updateSettings({ customAds: !settings.customAds })),
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "toggle",
|
||||
title: translate("recommendations"),
|
||||
data: {
|
||||
value: recommendations,
|
||||
onToggle: () => setRecommendations(!recommendations),
|
||||
value: settings.recommandations,
|
||||
onToggle: () =>
|
||||
dispatch(
|
||||
updateSettings({ recommandations: !settings.recommandations })
|
||||
),
|
||||
},
|
||||
},
|
||||
]}
|
||||
|
||||
Reference in New Issue
Block a user