From 13cadcf72636b65424d7eb0841b132ec6c981ffc Mon Sep 17 00:00:00 2001 From: keannu125 Date: Sun, 5 Mar 2023 21:14:16 +0800 Subject: [PATCH] Polished code and removed unused snippets --- .../ButtonAlignLeft/ButtonAlignLeft.tsx | 61 +++++++++---------- .../Buttons/ButtonCentered/ButtonCentered.tsx | 53 ++++++++-------- src/Routes/AddNote/AddNote.tsx | 16 ++--- src/Routes/Home/Home.tsx | 7 +-- src/Routes/Login/Login.tsx | 4 +- src/Routes/Register/Register.tsx | 4 +- src/Routes/UserInfo/UserInfo.tsx | 16 ++--- src/styles.tsx | 38 ++++++------ 8 files changed, 86 insertions(+), 113 deletions(-) diff --git a/src/Components/Buttons/ButtonAlignLeft/ButtonAlignLeft.tsx b/src/Components/Buttons/ButtonAlignLeft/ButtonAlignLeft.tsx index 6577cf7..013297d 100644 --- a/src/Components/Buttons/ButtonAlignLeft/ButtonAlignLeft.tsx +++ b/src/Components/Buttons/ButtonAlignLeft/ButtonAlignLeft.tsx @@ -1,7 +1,7 @@ -import * as React from "react"; -import { Text, View, Pressable, GestureResponderEvent } from "react-native"; -import { StyleSheet } from "react-native"; -import styles from "../../../styles"; +import * as React from 'react'; +import {Text, View, Pressable, GestureResponderEvent} from 'react-native'; +import {StyleSheet} from 'react-native'; +import styles from '../../../styles'; export interface props { children: React.ReactNode; @@ -12,67 +12,63 @@ export interface props { export default function ButtonAlignLeft(props: props) { switch (props.color) { - case "Red": + case 'Red': return ( + }}> {props.children} ); - case "Yellow": + case 'Yellow': return ( + }}> {props.children} ); - case "Green": + case 'Green': return ( + }}> {props.children} ); - case "Blue": + case 'Blue': return ( + }}> {props.children} ); @@ -81,11 +77,10 @@ export default function ButtonAlignLeft(props: props) { - + ...styles.button_generic, + ...{backgroundColor: '#bc231e'}, + }}> + Invalid button color specified diff --git a/src/Components/Buttons/ButtonCentered/ButtonCentered.tsx b/src/Components/Buttons/ButtonCentered/ButtonCentered.tsx index 031b99e..a240005 100644 --- a/src/Components/Buttons/ButtonCentered/ButtonCentered.tsx +++ b/src/Components/Buttons/ButtonCentered/ButtonCentered.tsx @@ -1,7 +1,7 @@ -import * as React from "react"; -import { Text, View, Pressable, GestureResponderEvent } from "react-native"; -import { StyleSheet } from "react-native"; -import styles from "../../../styles"; +import * as React from 'react'; +import {Text, View, Pressable, GestureResponderEvent} from 'react-native'; +import {StyleSheet} from 'react-native'; +import styles from '../../../styles'; export interface props { children: React.ReactNode; @@ -12,51 +12,47 @@ export interface props { export default function ButtonCentered(props: props) { switch (props.color) { - case "Red": + case 'Red': return ( + ...styles.button_generic, + ...{backgroundColor: '#bc231e', width: props.width}, + }}> {props.children} ); - case "Yellow": + case 'Yellow': return ( + ...styles.button_generic, + ...{backgroundColor: '#e2b465', width: props.width}, + }}> {props.children} ); - case "Green": + case 'Green': return ( + ...styles.button_generic, + ...{backgroundColor: '#0dbc6a', width: props.width}, + }}> {props.children} ); - case "Blue": + case 'Blue': return ( + ...styles.button_generic, + ...{backgroundColor: '#005997', width: props.width}, + }}> {props.children} ); @@ -65,11 +61,10 @@ export default function ButtonCentered(props: props) { - + ...styles.button_generic, + ...{backgroundColor: '#bc231e'}, + }}> + Invalid button color specified diff --git a/src/Routes/AddNote/AddNote.tsx b/src/Routes/AddNote/AddNote.tsx index d8e0350..5a3a3f2 100644 --- a/src/Routes/AddNote/AddNote.tsx +++ b/src/Routes/AddNote/AddNote.tsx @@ -1,16 +1,12 @@ -import * as React from "react"; -import { View, Text } from "react-native"; -import styles from "../../styles"; -import Background from "../../Components/Background/Background"; +import * as React from 'react'; +import {View, Text} from 'react-native'; +import styles from '../../styles'; +import Background from '../../Components/Background/Background'; -export interface props {} - -export default function AddNote(props: props) { +export default function AddNote() { return ( - - Add Note - + Add Note ); } diff --git a/src/Routes/Home/Home.tsx b/src/Routes/Home/Home.tsx index 92a8f8e..d7280d1 100644 --- a/src/Routes/Home/Home.tsx +++ b/src/Routes/Home/Home.tsx @@ -2,14 +2,9 @@ import * as React from 'react'; import {View, Text} from 'react-native'; import styles from '../../styles'; import Background from '../../Components/Background/Background'; -import {useNavigation} from '@react-navigation/native'; -import {RootDrawerParamList} from '../../Interfaces/Interfaces'; import AppIcon from '../../Components/Icons/AppIcon/AppIcon'; -export interface props {} - -export default function Home(props: props) { - const navigation = useNavigation(); +export default function Home() { return ( Login diff --git a/src/Routes/Register/Register.tsx b/src/Routes/Register/Register.tsx index 8af2a07..198b2a6 100644 --- a/src/Routes/Register/Register.tsx +++ b/src/Routes/Register/Register.tsx @@ -3,9 +3,7 @@ import {View, Text} from 'react-native'; import styles from '../../styles'; import Background from '../../Components/Background/Background'; -export interface props {} - -export default function Register(props: props) { +export default function Register() { return ( Register diff --git a/src/Routes/UserInfo/UserInfo.tsx b/src/Routes/UserInfo/UserInfo.tsx index 8b3f860..0570bcb 100644 --- a/src/Routes/UserInfo/UserInfo.tsx +++ b/src/Routes/UserInfo/UserInfo.tsx @@ -1,16 +1,12 @@ -import * as React from "react"; -import { View, Text } from "react-native"; -import styles from "../../styles"; -import Background from "../../Components/Background/Background"; +import * as React from 'react'; +import {View, Text} from 'react-native'; +import styles from '../../styles'; +import Background from '../../Components/Background/Background'; -export interface props {} - -export default function UserInfo(props: props) { +export default function UserInfo() { return ( - - UserInfo - + UserInfo ); } diff --git a/src/styles.tsx b/src/styles.tsx index e209dd4..4b2caff 100644 --- a/src/styles.tsx +++ b/src/styles.tsx @@ -1,34 +1,34 @@ -import { StyleSheet } from "react-native"; +import {StyleSheet} from 'react-native'; const styles = StyleSheet.create({ background: { - backgroundColor: "#002d4c", - height: "100%", - width: "100%", + backgroundColor: '#002d4c', + height: '100%', + width: '100%', }, text_white: { - color: "white", - fontWeight: "bold", - textAlign: "center", + color: 'white', + fontWeight: 'bold', + textAlign: 'center', }, - button_baseline: { - justifyContent: "center", - alignSelf: "center", - alignItems: "center", - display: "flex", - flexDirection: "row", + button_generic: { + justifyContent: 'center', + alignSelf: 'center', + alignItems: 'center', + display: 'flex', + flexDirection: 'row', margin: 8, padding: 8, borderRadius: 16, }, flex_row: { - display: "flex", - flexDirection: "row", - alignItems: "center", + display: 'flex', + flexDirection: 'row', + alignItems: 'center', }, flex_column: { - display: "flex", - flexDirection: "column", - alignItems: "center", + display: 'flex', + flexDirection: 'column', + alignItems: 'center', }, });