From 642046653051450b098afe02c0e9017555a4a540 Mon Sep 17 00:00:00 2001 From: RazerMoon <33849459+RazerMoon@users.noreply.github.com> Date: Fri, 26 Feb 2021 19:55:48 +0000 Subject: [PATCH] Beta --- package.json | 1 + src/components/About/DependencyList.tsx | 24 +-- src/components/DarkModeSwitch.tsx | 2 - .../Dependencies/LicensesListItem.tsx | 4 - src/components/Home/SubjectCard.tsx | 13 ++ src/components/Home/TotalPoints.tsx | 9 +- src/screens/About.tsx | 2 - src/screens/Home.tsx | 25 ++- src/screens/Settings.tsx | 10 +- src/screens/dev/Home.tsx | 158 ------------------ src/themes/BrandTheme.ts | 12 ++ src/ui/StyledComponents/Text.tsx | 27 --- src/ui/StyledComponents/TextInput.tsx | 29 ---- 13 files changed, 56 insertions(+), 260 deletions(-) delete mode 100644 src/screens/dev/Home.tsx delete mode 100644 src/ui/StyledComponents/Text.tsx delete mode 100644 src/ui/StyledComponents/TextInput.tsx diff --git a/package.json b/package.json index f2de4c1..9d778c8 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "expo": "~40.0.0", "expo-app-loading": "^1.0.1", "expo-font": "~8.4.0", + "expo-linear-gradient": "~8.4.0", "expo-web-browser": "~8.6.0", "nanoid": "^3.1.20", "react": "16.13.1", diff --git a/src/components/About/DependencyList.tsx b/src/components/About/DependencyList.tsx index b5bcb5a..01a1857 100644 --- a/src/components/About/DependencyList.tsx +++ b/src/components/About/DependencyList.tsx @@ -8,12 +8,8 @@ const DependencyList = ({ navigation, }: Pick): JSX.Element => { return ( - - + + )} onPress={() => openBrowserAsync("https://expo.io/")} - accessibilityComponentType="" - accessibilityTraits="" /> - + )} onPress={() => openBrowserAsync("https://reactnative.dev/")} - accessibilityComponentType="" - accessibilityTraits="" /> - + )} onPress={() => openBrowserAsync("https://reactnativepaper.com/")} - accessibilityComponentType="" - accessibilityTraits="" /> - + )} onPress={() => navigation.navigate("Dependencies")} - accessibilityComponentType="" - accessibilityTraits="" /> - + ); }; diff --git a/src/components/DarkModeSwitch.tsx b/src/components/DarkModeSwitch.tsx index ccb0206..da88f41 100644 --- a/src/components/DarkModeSwitch.tsx +++ b/src/components/DarkModeSwitch.tsx @@ -31,8 +31,6 @@ const DarkModeSwitch = (props: Props): JSX.Element => { return !prev; }) } - accessibilityComponentType="" - accessibilityTraits="" /> ); }; diff --git a/src/components/Dependencies/LicensesListItem.tsx b/src/components/Dependencies/LicensesListItem.tsx index a782460..ed41750 100644 --- a/src/components/Dependencies/LicensesListItem.tsx +++ b/src/components/Dependencies/LicensesListItem.tsx @@ -48,12 +48,8 @@ const LicensesListItem = ({ description={`${version} • ${licenses} • ${username}`} style={{ margin: 5, ...style }} onPress={() => onPress(repository)} - accessibilityComponentType="" - accessibilityTraits="" left={(props) => ( { const setSubject = (val: Subject) => { setScores((prev) => { const newScores = prev.scores; + + if ( + val === "Link Modules" && + newScores[index].subject !== "Link Modules" + ) { + setGrade("M"); + } else if ( + val !== "Link Modules" && + newScores[index].subject === "Link Modules" + ) { + setGrade("H3"); + } + newScores[index].subject = val; newScores[index].points = gradeToPoints(newScores[index].grade, val); return { ...prev, scores: [...newScores] }; diff --git a/src/components/Home/TotalPoints.tsx b/src/components/Home/TotalPoints.tsx index 95e9fc1..bf2adcc 100644 --- a/src/components/Home/TotalPoints.tsx +++ b/src/components/Home/TotalPoints.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useEffect, useState } from "react"; +import React, { useContext, useEffect } from "react"; import { View } from "react-native"; import { Text } from "react-native-paper"; import ScoresContext from "../../contexts/ScoresContext"; @@ -19,11 +19,12 @@ const TotalPoints = (): JSX.Element => { style={{ flexDirection: "row", justifyContent: "space-evenly", - width: "90%", + alignItems: "center", + width: "80%", }} > - Total - {totalPoints} + Total + {totalPoints} ); }; diff --git a/src/screens/About.tsx b/src/screens/About.tsx index e808b78..b90918d 100644 --- a/src/screens/About.tsx +++ b/src/screens/About.tsx @@ -46,8 +46,6 @@ export default function About({ navigation }: Props): JSX.Element { elevation: 5, }} - accessibilityComponentType="" - accessibilityTraits="" /> Hi, I'm Peter! diff --git a/src/screens/Home.tsx b/src/screens/Home.tsx index cf44bc4..9300125 100644 --- a/src/screens/Home.tsx +++ b/src/screens/Home.tsx @@ -1,10 +1,11 @@ import React, { useContext } from "react"; import { ScrollView, View } from "react-native"; -import { IconButton } from "react-native-paper"; +import { IconButton, useTheme } from "react-native-paper"; import SubjectCard from "../components/Home/SubjectCard"; import TotalPoints from "../components/Home/TotalPoints"; import ScoresContext from "../contexts/ScoresContext"; +import { CustomTheme } from "../themes/BrandTheme"; import { HomeProps as Props } from "../utils/StackTypes"; export default function Home({ navigation }: Props): JSX.Element { @@ -12,6 +13,8 @@ export default function Home({ navigation }: Props): JSX.Element { data: { scores }, } = useContext(ScoresContext); + const { colors } = useTheme() as CustomTheme; + React.useLayoutEffect(() => { navigation.setOptions({ headerRight: () => ( @@ -27,24 +30,32 @@ export default function Home({ navigation }: Props): JSX.Element { {scores.map(({ id }, index) => { - return ( - - ); /* This won't work if multiple of the same subject is used as key */ + return ; })} - + diff --git a/src/screens/Settings.tsx b/src/screens/Settings.tsx index 1caecfc..05b99a1 100644 --- a/src/screens/Settings.tsx +++ b/src/screens/Settings.tsx @@ -16,8 +16,6 @@ export default function Settings({ navigation }: Props): JSX.Element { navigation.navigate("About")} - accessibilityComponentType="" - accessibilityTraits="" /> ), }); @@ -25,15 +23,9 @@ export default function Settings({ navigation }: Props): JSX.Element { return ( - + ( )} diff --git a/src/screens/dev/Home.tsx b/src/screens/dev/Home.tsx deleted file mode 100644 index 71895b1..0000000 --- a/src/screens/dev/Home.tsx +++ /dev/null @@ -1,158 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { View, SafeAreaView, Button, Alert } from "react-native"; -import AsyncStorage from "@react-native-async-storage/async-storage"; -import Text from "../../ui/StyledComponents/Text"; -import TextInput from "../../ui/StyledComponents/TextInput"; - -const Home = (): JSX.Element => { - const [keys, setKeys] = useState(); - const [keyId, setKeyId] = useState("@ug_name"); - const [keyVal, setKeyVal] = useState("Peter"); - const [retKeyId, setRetKeyId] = useState("@ug_name"); - - const getAllKeys = async () => { - try { - const value = (await AsyncStorage.getAllKeys()).filter((word) => - word.startsWith("@ug_") - ); - if (value !== null) { - // value previously stored - setKeys(value); - } - } catch (e) { - // error reading value - } - }; - - useEffect(() => { - getAllKeys(); - }, []); - - const storeData = async (key: string, value: string) => { - try { - await AsyncStorage.setItem(key, value); - Alert.alert("data stored"); - getAllKeys(); - } catch (e) { - // saving error - } - }; - - const getData = async (key: string) => { - try { - const value = await AsyncStorage.getItem(key); - if (value !== null) { - // value previously stored - Alert.alert(value); - } else { - Alert.alert("no value stored!"); - } - } catch (e) { - // error reading value - } - }; - - const removeAll = async () => { - try { - if (keys) { - AsyncStorage.multiRemove(keys); - } - getAllKeys(); - } catch (e) { - // something - } - }; - - return ( - - - - {keys && ( - <> - {keys.map((val) => { - return {val.slice(4)}; - })} - - )} - - - - - setKeyId(`@ug_${value && value.length > 0 ? value : "name"}`) - } - /> - - - - setKeyVal(`${value && value.length > 0 ? value : "Peter"}`) - } - /> - - - - - -