From 630a21c5b6fc86623ed98a41bcef3307575e61ab Mon Sep 17 00:00:00 2001 From: Mauritz Lemgen Date: Mon, 22 Apr 2024 18:57:20 +0200 Subject: [PATCH] Update calculator assets and styles --- calculator/App.js | 209 +++++++++++++++++++----- calculator/app.json | 14 +- calculator/assets/adaptive-icon.png | Bin 17547 -> 0 bytes calculator/assets/delete-left-solid.png | Bin 34421 -> 0 bytes calculator/assets/delete-left-solid.svg | 1 - calculator/assets/logo.png | Bin 0 -> 6164 bytes calculator/components/Button.js | 139 ++++++++++------ 7 files changed, 271 insertions(+), 92 deletions(-) delete mode 100644 calculator/assets/adaptive-icon.png delete mode 100644 calculator/assets/delete-left-solid.png delete mode 100644 calculator/assets/delete-left-solid.svg create mode 100644 calculator/assets/logo.png diff --git a/calculator/App.js b/calculator/App.js index 8a778e0..65b95ec 100644 --- a/calculator/App.js +++ b/calculator/App.js @@ -1,51 +1,151 @@ -import { StatusBar } from 'expo-status-bar'; -import * as React from 'react'; -import { Pressable, StyleSheet, Text, View, Vibration } from 'react-native'; -import Button from './components/Button'; -import { ScrollView } from 'react-native'; +import * as React from "react"; +import { StyleSheet, Text, View } from "react-native"; +import Button from "./components/Button"; +import { ScrollView } from "react-native"; +/** + * Main component of the calculator app. + * @returns {JSX.Element} The rendered component. + */ export default function App() { const [display, setDisplay] = React.useState("0"); const [last, setLast] = React.useState(""); - + const equalsHandler = () => { + try { + setLast(display); + setDisplay(eval(display.replace("%", " * 0.01"))); + } catch { + setDisplay(display); + } + }; return ( - - {last} - {display} - - + + {last} + + + {display} + + + + + +