From a775d44be1ae7061e8169035542b3cc1dd507cdb Mon Sep 17 00:00:00 2001 From: ShivaniVora Date: Sun, 13 Oct 2024 01:09:41 -0500 Subject: [PATCH] Updated settings screen --- package.json | 11 +- src/screens/Settings/SettingsScreen.jsx | 183 ++++++++++++++---------- src/screens/Settings/TimePicker.jsx | 74 ++++++++-- src/styles/settings.js | 47 +++++- 4 files changed, 222 insertions(+), 93 deletions(-) diff --git a/package.json b/package.json index 4bbe6f53..add655d4 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "dependencies": { "@babel/preset-env": "^7.22.14", "@expo/cli": "^0.10.11", + "@fontsource/poppins": "^5.1.0", "@react-native-async-storage/async-storage": "1.23.1", "@react-native-community/datetimepicker": "8.0.1", "@react-native-community/slider": "4.5.2", @@ -34,18 +35,18 @@ "axios": "^1.5.0", "bcrypt": "^5.1.1", "dotenv": "^16.3.1", - "expo": "^51.0.32", + "expo": "^51.0.37", "expo-auth-session": "~5.5.2", "expo-av": "~14.0.7", "expo-build-properties": "~0.12.5", "expo-constants": "~16.0.2", "expo-crypto": "~13.0.2", - "expo-dev-client": "~4.0.25", - "expo-notifications": "~0.28.16", + "expo-dev-client": "~4.0.28", + "expo-notifications": "~0.28.18", "expo-random": "~14.0.1", - "expo-splash-screen": "~0.27.5", + "expo-splash-screen": "~0.27.6", "expo-status-bar": "~1.12.1", - "expo-updates": "~0.25.24", + "expo-updates": "~0.25.27", "expo-web-browser": "~13.0.3", "firebase": "^10.4.0", "jwt-decode": "^3.1.2", diff --git a/src/screens/Settings/SettingsScreen.jsx b/src/screens/Settings/SettingsScreen.jsx index ebad5233..3dd4412f 100644 --- a/src/screens/Settings/SettingsScreen.jsx +++ b/src/screens/Settings/SettingsScreen.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { View, Switch, TouchableOpacity, Linking } from "react-native"; // import { Notifications } from "expo"; import * as Notifications from "expo-notifications"; @@ -10,6 +10,9 @@ import { useFocusEffect } from "@react-navigation/native"; import Text from "../../components/Text"; import defaultSettings from "../../components/DefaultSettings"; import SettingsStyle from "../../styles/settings"; +import { Slider } from "react-native-elements"; +import '@fontsource/poppins'; +import TimePicker from "./TimePicker"; const termsURL = "https://gtbitsofgood.github.io/brain-exercise/terms/"; const privacyURL = "https://gtbitsofgood.github.io/brain-exercise/privacy/"; @@ -43,12 +46,16 @@ const { text, section, subtext, - animationRow, timeButton, icon, rowInfo, - firstSection, touchableRow, + buttonText, + thumbStyle, + trackStyle, + slider, + minSize, + maxSize, } = SettingsStyle; // Settings Navigation @@ -58,6 +65,47 @@ function SettingsScreen({ navigation }) { const [animationToggleOn, setAnimationToggleOn] = useState( settings.animationOn, ); + const [fontSize, setFontSize] = useState(settings.fontSize); + const [timePickerOpen, setTimePickerOpen] = useState(false); + const [soundEffectsToggleOn, setSoundEffectsToggleOn] = useState( + settings.soundEffectsOn || defaultSettings.soundEffectsOn, + ); + const [voiceOverToggleOn, setVoiceOverToggleOn] = useState( + settings.voiceOverOn || defaultSettings.voiceOverOn, + ); + + const setSoundEffectsToggleOnWrapper = async () => { + setSoundEffectsToggleOn(!soundEffectsToggleOn); + settings.soundEffectsOn = !soundEffectsToggleOn; + const jsonSettings = JSON.stringify(settings); + //console.log(settings.soundEffectsOn) + await AsyncStorage.setItem("SETTINGS", jsonSettings); + } + + const setVoiceOverToggleOnWrapper = async () => { + setVoiceOverToggleOn(!voiceOverToggleOn); + settings.voiceOveron = !voiceOverToggleOn; + const jsonSettings = JSON.stringify(settings); + //console.log(settings.soundEffectsOn) + await AsyncStorage.setItem("SETTINGS", jsonSettings); + } + + const setAnimationOnWrapper = async () => { + setAnimationToggleOn(!animationToggleOn); + settings.animationOn = !animationToggleOn; + const jsonSettings = JSON.stringify(settings); + //console.log(settings.soundEffectsOn) + await AsyncStorage.setItem("SETTINGS", jsonSettings); + } + + useEffect(() => { + updateFontSize(); + }, [fontSize]); + + const updateFontSize = async () => { + settings.fontSize = fontSize; + await storeSettings(settings); + } useFocusEffect( React.useCallback(() => { @@ -108,17 +156,14 @@ function SettingsScreen({ navigation }) { return ( - + - Notifications - - - Daily Reminders + Daily Reminders (Mon-Fri) {toggleOn && ( - Reminder Time + Daily Reminder Time