A fully functional iOS-style calculator built with React Native and Expo. This calculator replicates the classic iOS calculator design with a clean, minimalist interface and smooth touch interactions.
- ✅ Basic Operations: Addition, subtraction, multiplication, division
- ✅ Special Functions:
- Clear (C)
- Toggle positive/negative (±)
- Percentage (%)
- Decimal point (.)
- ✅ iOS-Style Design: Black background with gray and orange buttons
- ✅ Responsive Layout: Adapts to different screen sizes
- ✅ Touch Feedback: Buttons respond with visual feedback when pressed
- ✅ Real-time Display: Shows current calculation result
The app features the iconic iOS calculator design:
- Black background for the main container
- Dark gray buttons for numbers (0-9)
- Light gray buttons for functions (C, ±, %)
- Orange buttons for operations (+, -, ×, ÷, =)
- Large display at the top showing results
- Circular buttons with proper spacing
- Node.js (v18 or newer)
- npm or yarn
- Expo Go app on your iPhone (download from App Store)
- Windows, Mac, or Linux computer
-
Clone or download this repository
cd CalculatorApp -
Install dependencies
npm install
-
Start the development server
npx expo start
For school/restricted WiFi networks:
npx expo start --tunnel
-
Run on your device
- Open Expo Go on your iPhone
- Scan the QR code from your terminal
- The app will load on your device!
- Install Expo Go from the App Store
- Make sure your phone and computer are on the same WiFi network
- Scan the QR code from the terminal
- The calculator will load instantly
- Start the dev server:
npx expo start - Press
wto open in your web browser - Test the calculator directly in Chrome/Edge
- Enter numbers: Tap any number button (0-9)
- Perform operations:
- Tap +, -, ×, or ÷ to select an operation
- Enter the second number
- Tap = to see the result
- Clear: Tap C to reset the calculator
- Toggle sign: Tap ± to make numbers positive/negative
- Percentage: Tap % to convert to percentage
- Decimal: Tap . to add decimal points
CalculatorApp/
├── App.js # Main calculator component
├── package.json # Project dependencies
├── app.json # Expo configuration
└── node_modules/ # Installed packages
- React Native - Framework for building native apps
- Expo - Platform for universal React applications
- JavaScript - Programming language
- React Hooks - State management (useState)
The calculator uses React's useState hook to manage:
- display: Current number shown on screen
- previousValue: First number in the calculation
- operation: Selected operation (+, -, ×, ÷)
- resetDisplay: Flag to know when to start a new number
- User enters first number → stored in
display - User taps operation →
displaymoves topreviousValue - User enters second number → stored in
display - User taps = → calculation performed → result shown
handleNumberPress: Adds digits to the displayhandleOperationPress: Stores operation and first numbercalculate: Performs the actual math operationhandleEquals: Executes calculation and shows resulthandleClear: Resets everything to initial state
Want to customize the calculator? Here are some easy modifications:
In App.js, modify the StyleSheet:
// Background color
backgroundColor: '#000', // Change to any color
// Number buttons
backgroundColor: '#333', // Dark gray
// Function buttons (C, ±, %)
backgroundColor: '#a5a5a5', // Light gray
// Operation buttons (+, -, ×, ÷, =)
backgroundColor: '#ff9500', // Orange// Display text size
fontSize: 70, // Make it bigger or smaller
// Button text size
fontSize: 30, // Adjust button numbersAdd a square root function:
const handleSquareRoot = () => {
setDisplay(String(Math.sqrt(parseFloat(display))));
};Then add a button:
<Button text="√" onPress={handleSquareRoot} style={styles.functionButton} />- Solution: Use tunnel mode:
npx expo start --tunnel - Make sure both devices are on the same WiFi
- School/public WiFi may block connections
- Try pressing
rin terminal to reload - Check that Expo Go is up to date
- Manually type the URL shown in terminal into Expo Go
- Check terminal for error messages
- Make sure all dependencies are installed:
npm install - Verify
App.jscode is correct
- Most warnings are harmless and won't affect functionality
- The app will still work on your phone
- Add scientific calculator mode
- Add calculation history
- Support landscape orientation
- Add keyboard input support
- Add themes (light/dark mode)
- Add memory functions (M+, M-, MR, MC)
- Add haptic feedback
- Add sound effects
Want to improve this calculator? Feel free to:
- Fork the project
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available for educational purposes.
Built as a learning project for iOS app development using React Native.
- Design inspired by Apple's iOS Calculator
- Built with React Native and Expo
- Thanks to the React Native community for excellent documentation
Having issues? Here are some resources:
Made with ❤️ using React Native + Expo
Note: This is an educational project and not affiliated with Apple Inc.
