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} + + + + + +