help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
swift-ios-calculator
RSK World
swift-ios-calculator
Swift iOS Calculator v1.0 - AI Math Solver + 3D Graphing + Apple Watch Integration + iOS Widgets + Siri Shortcuts + Currency Converter + Scientific Calculator + Matrix Operations + Platform Integration + Modern iOS Development
swift-ios-calculator
  • Assets.xcassets
  • Base.lproj
  • swift-ios-calculator.xcodeproj
  • AIMathSolverViewController.swift26.6 KB
  • AppDelegate.swift1.7 KB
  • CalculatorHistoryViewController.swift6.5 KB
  • CalculatorLogic.swift4.4 KB
  • CalculatorSettingsViewController.swift5.6 KB
  • CalculatorTheme.swift8.3 KB
  • CalculatorUtils.swift6.9 KB
  • CalculatorViewController.swift3.4 KB
  • CalculatorWidget.swift14.3 KB
  • CalculatorWidgetInfo.plist846 B
  • ChemistryCalculatorViewController.swift26.9 KB
  • CurrencyConverterViewController.swift13.3 KB
  • CustomFormulaBuilderViewController.swift22.1 KB
  • EngineeringCalculatorViewController.swift25.7 KB
  • EquationSolverViewController.swift22.8 KB
  • FinancialCalculatorViewController.swift27.5 KB
  • GeometryCalculatorViewController.swift29.7 KB
  • Graphing3DViewController.swift20.8 KB
  • GraphingCalculatorViewController.swift14.7 KB
  • Info.plist3.2 KB
  • LICENSE1.1 KB
  • MainTabBarController.swift22.3 KB
  • MatrixCalculatorViewController.swift26.6 KB
  • PRIVACY_POLICY.md1.6 KB
  • PhysicsCalculatorService.swift8.2 KB
  • ProgrammerCalculatorViewController.swift11 KB
  • README.md8.7 KB
  • RELEASE_NOTES.md6.5 KB
  • SceneDelegate.swift2.8 KB
  • ScientificCalculatorViewController.swift6.2 KB
  • SiriShortcutsManager.swift23.5 KB
  • Swift iOS Calculator.entitlements1.1 KB
  • UnitConverterViewController.swift14 KB
  • WatchCalculatorViewController.swift15.3 KB
  • index.html47.5 KB
README.mdMainTabBarController.swiftScientificCalculatorViewController.swift
README.md
Raw Download

README.md

# Swift iOS Calculator

A comprehensive, professional-grade calculator application for iOS featuring advanced mathematical capabilities, AI-powered problem solving, and modern platform integration.

## šŸ“± Features

### Core Calculators
- **Basic Calculator** - Standard arithmetic operations with memory functions
- **Scientific Calculator** - Advanced mathematical functions and constants
- **Programmer Calculator** - Binary, hexadecimal, octal, and decimal conversions
- **Unit Converter** - Convert between 50+ units across 7 categories
- **Currency Converter** - Real-time currency exchange rates for 20+ currencies
- **Graphing Calculator** - 2D function plotting with zoom and pan
- **3D Graphing Calculator** - Multivariable surface visualization with SceneKit

### Advanced Mathematics
- **AI Math Solver** - Step-by-step solutions for algebra, calculus, and more
- **Matrix Calculator** - Complete linear algebra operations
- **Equation Solver** - Algebraic and differential equation solving
- **Statistics Calculator** - Data analysis and statistical computations

### Specialized Calculators
- **Financial Calculator** - Investment, retirement, and loan calculations
- **Geometry Calculator** - 2D and 3D shape calculations
- **Physics Calculator** - Mechanics, optics, and thermodynamics
- **Chemistry Calculator** - Molar mass, reactions, and stoichiometry
- **Engineering Calculator** - Circuit analysis and material calculations

### Platform Integration
- **iOS Widgets** - Home screen quick access widgets
- **Apple Watch App** - Companion calculator for Apple Watch
- **Siri Shortcuts** - Voice commands and deep linking
- **Camera Scanning** - Scan math problems with your camera
- **Voice Input** - Enter equations using voice commands

### User Experience
- **5 Beautiful Themes** - Light, Dark, Blue, Green, and Sunset themes
- **Calculation History** - Track and reuse previous calculations
- **Haptic Feedback** - Tactile feedback for better user experience
- **Animations** - Smooth transitions and micro-interactions
- **Accessibility** - Full VoiceOver and accessibility support

## šŸš€ Installation

1. Clone the repository
2. Open `Swift iOS Calculator.xcodeproj` in Xcode
3. Select your target device or simulator
4. Build and run the project

## šŸ“‹ Requirements

- iOS 14.0+
- Xcode 12.0+
- Swift 5.0+

## šŸ—ļø Project Structure

```
Swift iOS Calculator/
ā”œā”€ā”€ AppDelegate.swift # App lifecycle management
ā”œā”€ā”€ SceneDelegate.swift # Scene management
ā”œā”€ā”€ MainTabBarController.swift # Main navigation
ā”œā”€ā”€ Core Calculators/
│ ā”œā”€ā”€ CalculatorViewController.swift
│ ā”œā”€ā”€ ScientificCalculatorViewController.swift
│ ā”œā”€ā”€ ProgrammerCalculatorViewController.swift
│ └── GraphingCalculatorViewController.swift
ā”œā”€ā”€ Advanced Mathematics/
│ ā”œā”€ā”€ AIMathSolverViewController.swift
│ ā”œā”€ā”€ Graphing3DViewController.swift
│ ā”œā”€ā”€ MatrixCalculatorViewController.swift
│ └── EquationSolverViewController.swift
ā”œā”€ā”€ Converters/
│ ā”œā”€ā”€ UnitConverterViewController.swift
│ └── CurrencyConverterViewController.swift
ā”œā”€ā”€ Specialized/
│ ā”œā”€ā”€ FinancialCalculatorViewController.swift
│ ā”œā”€ā”€ GeometryCalculatorViewController.swift
│ ā”œā”€ā”€ PhysicsCalculatorViewController.swift
│ ā”œā”€ā”€ ChemistryCalculatorViewController.swift
│ └── EngineeringCalculatorViewController.swift
ā”œā”€ā”€ Platform Integration/
│ ā”œā”€ā”€ CalculatorWidget.swift
│ ā”œā”€ā”€ WatchCalculatorViewController.swift
│ └── SiriShortcutsManager.swift
ā”œā”€ā”€ Utilities/
│ ā”œā”€ā”€ CalculatorLogic.swift
│ ā”œā”€ā”€ CalculatorTheme.swift
│ ā”œā”€ā”€ CalculatorSettingsViewController.swift
│ ā”œā”€ā”€ CalculatorHistoryViewController.swift
│ └── CalculatorUtils.swift
ā”œā”€ā”€ Resources/
│ ā”œā”€ā”€ Assets.xcassets/
│ ā”œā”€ā”€ Base.lproj/ (Storyboards)
│ └── Info.plist
└── Swift iOS Calculator.xcodeproj/
```

## šŸŽØ Themes

The app includes 5 beautiful themes:
- **Light** - Clean, bright interface
- **Dark** - Easy on the eyes in low light
- **Blue** - Professional blue color scheme
- **Green** - Nature-inspired green theme
- **Sunset** - Warm orange and red tones

## 🧮 Calculator Types

### Basic Calculator
- Addition, subtraction, multiplication, division
- Memory functions (M+, M-, MR, MC)
- Percentage calculations
- Square root and power functions

### Scientific Calculator
- Trigonometric functions (sin, cos, tan, asin, acos, atan)
- Logarithmic functions (log, ln, exp)
- Power and root functions
- Mathematical constants (Ļ€, e)
- Angle unit conversions (degrees/radians)

### Programmer Calculator
- Number base conversions (binary, octal, decimal, hexadecimal)
- Bitwise operations (AND, OR, XOR, NOT)
- Shift operations (<<, >>)
- 8, 16, 32, and 64-bit support
- Signed and unsigned integer support

### Unit Converter
Categories include:
- **Length**: Meter, Kilometer, Mile, Yard, Foot, Inch
- **Weight**: Kilogram, Gram, Pound, Ounce, Ton
- **Temperature**: Celsius, Fahrenheit, Kelvin, Rankine
- **Volume**: Liter, Gallon, Quart, Pint, Cup
- **Area**: Square Meter, Square Foot, Hectare, Acre
- **Speed**: m/s, km/h, mph, knot
- **Time**: Second, Minute, Hour, Day, Week, Month, Year

### Currency Converter
- 20+ major world currencies
- Real-time exchange rate updates
- Favorite currency pairs
- Historical rate tracking

### Graphing Calculator
- Multiple function plotting
- Zoom and pan functionality
- Grid and axis display
- Function color coding
- Export capabilities

### 3D Graphing Calculator
- Multivariable surface plotting
- Interactive 3D rotation
- Multiple color schemes
- Adjustable resolution
- Preset mathematical functions

### AI Math Solver
Categories include:
- **Algebra**: Equation solving, factoring, simplification
- **Calculus**: Derivatives, integrals, limits
- **Trigonometry**: Identities, equations, proofs
- **Geometry**: Area, volume, perimeter calculations
- **Statistics**: Mean, median, mode, standard deviation
- **Physics**: Formulas and problem solving

Features:
- Step-by-step solutions
- Camera problem scanning
- Voice input support
- Problem history
- Difficulty levels

### Matrix Calculator
- Matrix operations (addition, subtraction, multiplication)
- Scalar multiplication
- Transpose, determinant, inverse
- Rank calculation
- Eigenvalue computation
- Support for 2Ɨ2, 3Ɨ3, 4Ɨ4 matrices

## šŸ”§ Technical Features

### Architecture
- **MVC Pattern** - Clean separation of concerns
- **Modular Design** - Easy to extend and maintain
- **Protocol-Oriented** - Leverages Swift protocols
- **Memory Management** - Efficient resource usage

### Platform Integration
- **iOS 14 Widgets** - Home screen quick access
- **Apple Watch** - Native watchOS app
- **Siri Shortcuts** - Voice command integration
- **Deep Linking** - URL scheme support
- **Background Updates** - Currency rate updates

### User Experience
- **Theme System** - Dynamic theme switching
- **Haptic Feedback** - Tactile responses
- **Animations** - Smooth transitions
- **Accessibility** - VoiceOver support
- **Localization Ready** - Multi-language support

## šŸ“Š Data Storage

- **UserDefaults** - Settings and preferences
- **Core Data** - Calculation history (optional)
- **Keychain** - Secure data storage
- **iCloud Sync** - Cross-device synchronization

## šŸ”’ Privacy & Security

- **Local Processing** - All calculations done locally
- **No Data Collection** - No user data sent to servers
- **Secure Storage** - Sensitive data encrypted
- **Permissions** - Minimal app permissions required

## šŸ¤ Contributing

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request

## šŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

## šŸ‘„ Team

- **Developer**: Molla Samser (Founder, RSK World)
- **Designer & Tester**: Rima Khatun

## šŸ“ž Contact

- **Email**: info@rskworld.com
- **Phone**: +91 93305 39277
- **Website**: https://rskworld.in
- **Address**: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India - 713147

## šŸ—“ļø Version History

### Version 1.0.0 (January 2026)
- Initial release with all core calculator types
- AI-powered math solver
- 3D graphing capabilities
- Matrix calculator
- Platform integration (widgets, watch, Siri)
- 5 beautiful themes
- Comprehensive documentation

---

**Made with ā¤ļø by RSK World**

*Ā© 2026 RSK World. All rights reserved.*
MainTabBarController.swift
Raw Download
Find: Go to:
//
//  MainTabBarController.swift
//  Swift iOS Calculator
//
//  Created by RSK World on 23/01/2026.
//  Copyright Ā© 2026 RSK World. All rights reserved.
//
//  Developer: Molla Samser (Founder, RSK World)
//  Designer & Tester: Rima Khatun
//  Contact: info@rskworld.com, +91 93305 39277
//  Website: https://rskworld.in
//  Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India - 713147
//

import UIKit

class MainTabBarController: UITabBarController {
    
    // MARK: - Lifecycle
    override func viewDidLoad() {
        super.viewDidLoad()
        setupTabBar()
        setupViewControllers()
    }
    
    // MARK: - Setup
    private func setupTabBar() {
        tabBar.backgroundColor = CalculatorTheme.shared.backgroundColor
        tabBar.barTintColor = CalculatorTheme.shared.backgroundColor
        tabBar.tintColor = CalculatorTheme.shared.accentColor
        tabBar.unselectedItemTintColor = CalculatorTheme.shared.textColor.withAlphaComponent(0.6)
        
        // Custom appearance
        if #available(iOS 15.0, *) {
            let appearance = UITabBarAppearance()
            appearance.configureWithOpaqueBackground()
            appearance.backgroundColor = CalculatorTheme.shared.backgroundColor
            appearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: CalculatorTheme.shared.accentColor]
            appearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: CalculatorTheme.shared.textColor.withAlphaComponent(0.6)]
            
            tabBar.standardAppearance = appearance
            tabBar.scrollEdgeAppearance = appearance
        }
    }
    
    private func setupViewControllers() {
        var viewControllers: [UIViewController] = []
        
        // Basic Calculator
        let basicCalculator = createBasicCalculator()
        viewControllers.append(basicCalculator)
        
        // Scientific Calculator
        let scientificCalculator = createScientificCalculator()
        viewControllers.append(scientificCalculator)
        
        // Programmer Calculator
        let programmerCalculator = createProgrammerCalculator()
        viewControllers.append(programmerCalculator)
        
        // Unit Converter
        let unitConverter = createUnitConverter()
        viewControllers.append(unitConverter)
        
        // Currency Converter
        let currencyConverter = createCurrencyConverter()
        viewControllers.append(currencyConverter)
        
        // Graphing Calculator
        let graphingCalculator = createGraphingCalculator()
        viewControllers.append(graphingCalculator)
        
        // More (Settings, History, etc.)
        let more = createMoreSection()
        viewControllers.append(more)
        
        self.viewControllers = viewControllers
    }
    
    private func createBasicCalculator() -> UINavigationController {
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let calculatorVC = storyboard.instantiateViewController(withIdentifier: "CalculatorViewController") as! CalculatorViewController
        
        let navController = UINavigationController(rootViewController: calculatorVC)
        navController.tabBarItem = UITabBarItem(
            title: "Basic",
            image: UIImage(systemName: "calculator"),
            selectedImage: UIImage(systemName: "calculator.fill")
        )
        
        return navController
    }
    
    private func createScientificCalculator() -> UINavigationController {
        let storyboard = UIStoryboard(name: "Scientific", bundle: nil)
        let scientificVC = storyboard.instantiateViewController(withIdentifier: "ScientificCalculatorViewController") as! ScientificCalculatorViewController
        
        let navController = UINavigationController(rootViewController: scientificVC)
        navController.tabBarItem = UITabBarItem(
            title: "Scientific",
            image: UIImage(systemName: "function"),
            selectedImage: UIImage(systemName: "function.fill")
        )
        
        return navController
    }
    
    private func createProgrammerCalculator() -> UINavigationController {
        let storyboard = UIStoryboard(name: "ProgrammerCalculator", bundle: nil)
        let programmerVC = storyboard.instantiateViewController(withIdentifier: "ProgrammerCalculatorViewController") as! ProgrammerCalculatorViewController
        
        let navController = UINavigationController(rootViewController: programmerVC)
        navController.tabBarItem = UITabBarItem(
            title: "Programmer",
            image: UIImage(systemName: "cpu"),
            selectedImage: UIImage(systemName: "cpu.fill")
        )
        
        return navController
    }
    
    private func createUnitConverter() -> UINavigationController {
        let storyboard = UIStoryboard(name: "UnitConverter", bundle: nil)
        let unitConverterVC = storyboard.instantiateViewController(withIdentifier: "UnitConverterViewController") as! UnitConverterViewController
        
        let navController = UINavigationController(rootViewController: unitConverterVC)
        navController.tabBarItem = UITabBarItem(
            title: "Units",
            image: UIImage(systemName: "ruler"),
            selectedImage: UIImage(systemName: "ruler.fill")
        )
        
        return navController
    }
    
    private func createCurrencyConverter() -> UINavigationController {
        let storyboard = UIStoryboard(name: "CurrencyConverter", bundle: nil)
        let currencyVC = storyboard.instantiateViewController(withIdentifier: "CurrencyConverterViewController") as! CurrencyConverterViewController
        
        let navController = UINavigationController(rootViewController: currencyVC)
        navController.tabBarItem = UITabBarItem(
            title: "Currency",
            image: UIImage(systemName: "dollarsign.circle"),
            selectedImage: UIImage(systemName: "dollarsign.circle.fill")
        )
        
        return navController
    }
    
    private func createGraphingCalculator() -> UINavigationController {
        let storyboard = UIStoryboard(name: "GraphingCalculator", bundle: nil)
        let graphingVC = storyboard.instantiateViewController(withIdentifier: "GraphingCalculatorViewController") as! GraphingCalculatorViewController
        
        let navController = UINavigationController(rootViewController: graphingVC)
        navController.tabBarItem = UITabBarItem(
            title: "Graphing",
            image: UIImage(systemName: "chart.xyaxis.line"),
            selectedImage: UIImage(systemName: "chart.xyaxis.line.fill")
        )
        
        return navController
    }
    
    private func createMoreSection() -> UINavigationController {
        let moreVC = MoreViewController()
        
        let navController = UINavigationController(rootViewController: moreVC)
        navController.tabBarItem = UITabBarItem(
            title: "More",
            image: UIImage(systemName: "ellipsis.circle"),
            selectedImage: UIImage(systemName: "ellipsis.circle.fill")
        )
        
        return navController
    }
}

// MARK: - More View Controller
class MoreViewController: UITableViewController {
    
    private let menuItems = [
        ("History", "clock.arrow.circlepath", "View calculation history"),
        ("Settings", "gearshape", "Customize calculator settings"),
        ("Themes", "paintbrush", "Choose your favorite theme"),
        ("Statistics", "chart.bar", "Statistical calculations"),
        ("About", "info.circle", "About this app"),
        ("Help", "questionmark.circle", "Get help and support")
    ]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }
    
    private func setupUI() {
        title = "More"
        view.backgroundColor = CalculatorTheme.shared.backgroundColor
        
        navigationController?.navigationBar.prefersLargeTitles = true
        
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "MenuItemCell")
        tableView.separatorStyle = .singleLine
        tableView.backgroundColor = CalculatorTheme.shared.backgroundColor
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return menuItems.count
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "MenuItemCell", for: indexPath)
        
        let item = menuItems[indexPath.row]
        cell.textLabel?.text = item.0
        cell.detailTextLabel?.text = item.2
        cell.imageView?.image = UIImage(systemName: item.1)
        cell.backgroundColor = CalculatorTheme.shared.backgroundColor
        cell.textLabel?.textColor = CalculatorTheme.shared.textColor
        cell.detailTextLabel?.textColor = CalculatorTheme.shared.textColor.withAlphaComponent(0.6)
        cell.accessoryType = .disclosureIndicator
        
        return cell
    }
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        
        let item = menuItems[indexPath.row].0
        
        switch item {
        case "History":
            showHistory()
        case "Settings":
            showSettings()
        case "Themes":
            showThemes()
        case "Statistics":
            showStatistics()
        case "About":
            showAbout()
        case "Help":
            showHelp()
        default:
            break
        }
    }
    
    private func showHistory() {
        let storyboard = UIStoryboard(name: "History", bundle: nil)
        let historyVC = storyboard.instantiateViewController(withIdentifier: "CalculatorHistoryViewController") as! CalculatorHistoryViewController
        navigationController?.pushViewController(historyVC, animated: true)
    }
    
    private func showSettings() {
        let storyboard = UIStoryboard(name: "Settings", bundle: nil)
        let settingsVC = storyboard.instantiateViewController(withIdentifier: "CalculatorSettingsViewController") as! CalculatorSettingsViewController
        navigationController?.pushViewController(settingsVC, animated: true)
    }
    
    private func showThemes() {
        let themesVC = ThemesViewController()
        navigationController?.pushViewController(themesVC, animated: true)
    }
    
    private func showStatistics() {
        let statisticsVC = StatisticsViewController()
        navigationController?.pushViewController(statisticsVC, animated: true)
    }
    
    private func showAbout() {
        let aboutVC = AboutViewController()
        navigationController?.pushViewController(aboutVC, animated: true)
    }
    
    private func showHelp() {
        let helpVC = HelpViewController()
        navigationController?.pushViewController(helpVC, animated: true)
    }
}

// MARK: - Additional View Controllers
class ThemesViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Themes"
        view.backgroundColor = CalculatorTheme.shared.backgroundColor
        
        // Theme selection implementation
        setupThemeSelection()
    }
    
    private func setupThemeSelection() {
        let stackView = UIStackView()
        stackView.axis = .vertical
        stackView.spacing = 20
        stackView.translatesAutoresizingMaskIntoConstraints = false
        
        let themes = ["Light", "Dark", "Blue", "Green", "Purple", "Sunset"]
        
        for theme in themes {
            let button = UIButton(type: .system)
            button.setTitle(theme, for: .normal)
            button.backgroundColor = CalculatorTheme.shared.buttonBackgroundColor
            button.setTitleColor(CalculatorTheme.shared.textColor, for: .normal)
            button.layer.cornerRadius = 12
            button.heightAnchor.constraint(equalToConstant: 50).isActive = true
            
            button.addAction(UIAction { _ in
                CalculatorTheme.shared.setTheme(theme.lowercased())
                self.dismiss(animated: true)
            }, for: .touchUpInside)
            
            stackView.addArrangedSubview(button)
        }
        
        view.addSubview(stackView)
        
        NSLayoutConstraint.activate([
            stackView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            stackView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
            stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
            stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20)
        ])
    }
}

class StatisticsViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Statistics"
        view.backgroundColor = CalculatorTheme.shared.backgroundColor
        
        // Statistics implementation
        setupStatisticsUI()
    }
    
    private func setupStatisticsUI() {
        let label = UILabel()
        label.text = "Statistical Calculator\n\nComing Soon!\n\nFeatures:\n• Mean, Median, Mode\n• Standard Deviation\n• Variance\n• Correlation\n• Regression Analysis"
        label.textAlignment = .center
        label.numberOfLines = 0
        label.textColor = CalculatorTheme.shared.textColor
        label.font = UIFont.systemFont(ofSize: 18)
        
        view.addSubview(label)
        label.translatesAutoresizingMaskIntoConstraints = false
        
        NSLayoutConstraint.activate([
            label.centerXAnchor.constraint(equalTo: view.centerXAnchor),
            label.centerYAnchor.constraint(equalTo: view.centerYAnchor),
            label.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 20),
            label.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -20)
        ])
    }
}

class AboutViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "About"
        view.backgroundColor = CalculatorTheme.shared.backgroundColor
        
        setupAboutUI()
    }
    
    private func setupAboutUI() {
        let scrollView = UIScrollView()
        let contentView = UIView()
        
        let titleLabel = UILabel()
        titleLabel.text = "Swift iOS Calculator"
        titleLabel.font = UIFont.boldSystemFont(ofSize: 24)
        titleLabel.textAlignment = .center
        
        let versionLabel = UILabel()
        versionLabel.text = "Version 1.0.0"
        versionLabel.textAlignment = .center
        versionLabel.textColor = CalculatorTheme.shared.textColor.withAlphaComponent(0.7)
        
        let descriptionLabel = UILabel()
        descriptionLabel.text = """
        A comprehensive calculator application for iOS featuring:
        
        • Basic arithmetic operations
        • Scientific functions
        • Programmer tools
        • Unit conversions
        • Currency exchange
        • Graphing capabilities
        • Multiple themes
        • Calculation history
        
        Created with ā¤ļø by RSK World
        """
        descriptionLabel.numberOfLines = 0
        descriptionLabel.textAlignment = .center
        
        let contactLabel = UILabel()
        contactLabel.text = """
        Developer: Molla Samser
        Designer: Rima Khatun
        
        Contact: info@rskworld.com
        Website: https://rskworld.in
        Phone: +91 93305 39277
        
        Address: Nutanhat, Mongolkote
        Purba Burdwan, West Bengal
        India - 713147
        """
        contactLabel.numberOfLines = 0
        contactLabel.textAlignment = .center
        contactLabel.font = UIFont.systemFont(ofSize: 14)
        contactLabel.textColor = CalculatorTheme.shared.textColor.withAlphaComponent(0.8)
        
        [titleLabel, versionLabel, descriptionLabel, contactLabel].forEach {
            $0.textColor = CalculatorTheme.shared.textColor
            contentView.addSubview($0)
            $0.translatesAutoresizingMaskIntoConstraints = false
        }
        
        scrollView.addSubview(contentView)
        view.addSubview(scrollView)
        
        scrollView.translatesAutoresizingMaskIntoConstraints = false
        contentView.translatesAutoresizingMaskIntoConstraints = false
        
        NSLayoutConstraint.activate([
            scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
            scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
            
            contentView.topAnchor.constraint(equalTo: scrollView.topAnchor),
            contentView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
            contentView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
            contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
            contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor),
            
            titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 20),
            titleLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
            titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
            
            versionLabel.topAnchor.constraint(equalTo: titleLabel.bottomAnchor, constant: 10),
            versionLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
            versionLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
            
            descriptionLabel.topAnchor.constraint(equalTo: versionLabel.bottomAnchor, constant: 30),
            descriptionLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
            descriptionLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
            
            contactLabel.topAnchor.constraint(equalTo: descriptionLabel.bottomAnchor, constant: 30),
            contactLabel.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
            contactLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
            contactLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -20)
        ])
    }
}

class HelpViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Help"
        view.backgroundColor = CalculatorTheme.shared.backgroundColor
        
        setupHelpUI()
    }
    
    private func setupHelpUI() {
        let scrollView = UIScrollView()
        let contentView = UIView()
        
        let helpText = """
        Calculator Help Guide
        
        BASIC CALCULATOR
        • Tap numbers and operations to perform calculations
        • Use C to clear, AC to clear all
        • Swipe left on display to delete last digit
        
        SCIENTIFIC CALCULATOR
        • Access advanced functions like sin, cos, tan
        • Use memory functions (MC, MR, M+, M-)
        • Switch between degrees and radians
        
        PROGRAMMER CALCULATOR
        • Work with binary, octal, decimal, hexadecimal
        • Perform bitwise operations (AND, OR, XOR, NOT)
        • Choose bit length (8, 16, 32, 64 bits)
        
        UNIT CONVERTER
        • Convert between different units
        • Categories: Length, Weight, Temperature, Volume, Area, Speed, Time
        • Swap units with the ⇄ button
        
        CURRENCY CONVERTER
        • Convert between 20+ currencies
        • Real-time exchange rates
        • Save favorite currency pairs
        
        GRAPHING CALCULATOR
        • Plot mathematical functions
        • Support for multiple functions
        • Zoom in/out and pan functionality
        
        TIPS & TRICKS
        • Long press buttons for additional options
        • Use themes to customize appearance
        • Enable haptic feedback in settings
        • Check history for previous calculations
        
        For more help, contact: info@rskworld.com
        """
        
        let label = UILabel()
        label.text = helpText
        label.numberOfLines = 0
        label.textColor = CalculatorTheme.shared.textColor
        label.font = UIFont.systemFont(ofSize: 16)
        
        contentView.addSubview(label)
        scrollView.addSubview(contentView)
        view.addSubview(scrollView)
        
        scrollView.translatesAutoresizingMaskIntoConstraints = false
        contentView.translatesAutoresizingMaskIntoConstraints = false
        label.translatesAutoresizingMaskIntoConstraints = false
        
        NSLayoutConstraint.activate([
            scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
            scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
            scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
            scrollView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
            
            contentView.topAnchor.constraint(equalTo: scrollView.topAnchor),
            contentView.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
            contentView.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
            contentView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
            contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor),
            
            label.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 20),
            label.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 20),
            label.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -20),
            label.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -20)
        ])
    }
}
552 lines•22.3 KB
swift
ScientificCalculatorViewController.swift
Raw Download
Find: Go to:
//
//  ScientificCalculatorViewController.swift
//  Swift iOS Calculator
//
//  Created by RSK World on 23/01/2026.
//  Copyright Ā© 2026 RSK World. All rights reserved.
//
//  Developer: Molla Samser (Founder, RSK World)
//  Designer & Tester: Rima Khatun
//  Contact: info@rskworld.com, +91 93305 39277
//  Website: https://rskworld.in
//  Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India - 713147
//

import UIKit

class ScientificCalculatorViewController: UIViewController {
    
    // MARK: - Outlets
    @IBOutlet weak var displayLabel: UILabel!
    @IBOutlet weak var secondaryDisplayLabel: UILabel!
    
    // MARK: - Properties
    private var calculator = CalculatorLogic()
    private var isUserTyping = false
    private var isScientificMode = false
    
    // MARK: - Lifecycle
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
    }
    
    // MARK: - UI Setup
    private func setupUI() {
        displayLabel.text = "0"
        displayLabel.font = UIFont.systemFont(ofSize: 42, weight: .light)
        displayLabel.textAlignment = .right
        displayLabel.textColor = .label
        
        secondaryDisplayLabel.text = ""
        secondaryDisplayLabel.font = UIFont.systemFont(ofSize: 18, weight: .regular)
        secondaryDisplayLabel.textAlignment = .right
        secondaryDisplayLabel.textColor = .secondaryLabel
    }
    
    // MARK: - Basic Number Actions
    @IBAction func numberButtonPressed(_ sender: UIButton) {
        guard let number = sender.currentTitle else { return }
        
        if isUserTyping {
            if displayLabel.text != "0" {
                displayLabel.text?.append(number)
            } else {
                displayLabel.text = number
            }
        } else {
            displayLabel.text = number
            isUserTyping = true
        }
    }
    
    @IBAction func operationButtonPressed(_ sender: UIButton) {
        guard let operation = sender.currentTitle else { return }
        
        if isUserTyping {
            calculator.setNumber(displayLabel.text ?? "0")
            isUserTyping = false
        }
        
        updateSecondaryDisplay(operation)
        
        if let result = calculator.calculate(symbol: operation) {
            displayLabel.text = formatNumber(result)
        } else {
            displayLabel.text = "Error"
        }
    }
    
    @IBAction func clearButtonPressed(_ sender: UIButton) {
        displayLabel.text = "0"
        secondaryDisplayLabel.text = ""
        isUserTyping = false
        calculator.clear()
    }
    
    @IBAction func decimalButtonPressed(_ sender: UIButton) {
        if isUserTyping && !(displayLabel.text?.contains(".") ?? true) {
            displayLabel.text?.append(".")
        } else if !isUserTyping {
            displayLabel.text = "0."
            isUserTyping = true
        }
    }
    
    @IBAction func plusMinusButtonPressed(_ sender: UIButton) {
        guard let currentText = displayLabel.text, currentText != "0" else { return }
        
        if currentText.hasPrefix("-") {
            displayLabel.text = String(currentText.dropFirst())
        } else {
            displayLabel.text = "-" + currentText
        }
    }
    
    @IBAction func percentageButtonPressed(_ sender: UIButton) {
        guard let currentText = displayLabel.text,
              let number = Double(currentText) else { return }
        
        let result = number / 100
        displayLabel.text = formatNumber(result)
        isUserTyping = false
    }
    
    // MARK: - Scientific Function Actions
    @IBAction func scientificFunctionPressed(_ sender: UIButton) {
        guard let function = sender.currentTitle else { return }
        
        if isUserTyping {
            calculator.setNumber(displayLabel.text ?? "0")
            isUserTyping = false
        }
        
        updateSecondaryDisplay(function)
        
        if let result = calculator.performScientificOperation(function) {
            displayLabel.text = formatNumber(result)
        } else {
            displayLabel.text = "Error"
        }
    }
    
    @IBAction func memoryFunctionPressed(_ sender: UIButton) {
        guard let memoryFunction = sender.currentTitle else { return }
        
        switch memoryFunction {
        case "MC":
            calculator.memoryClear()
        case "MR":
            if let memoryValue = calculator.memoryRecall() {
                displayLabel.text = formatNumber(memoryValue)
                isUserTyping = false
            }
        case "M+":
            if let currentText = displayLabel.text, let number = Double(currentText) {
                calculator.memoryAdd(number)
            }
        case "M-":
            if let currentText = displayLabel.text, let number = Double(currentText) {
                calculator.memorySubtract(number)
            }
        default:
            break
        }
    }
    
    @IBAction func constantButtonPressed(_ sender: UIButton) {
        guard let constant = sender.currentTitle else { return }
        
        switch constant {
        case "Ļ€":
            displayLabel.text = formatNumber(.pi)
            isUserTyping = false
        case "e":
            displayLabel.text = formatNumber(.e)
            isUserTyping = false
        default:
            break
        }
    }
    
    // MARK: - Helper Methods
    private func formatNumber(_ number: Double) -> String {
        if number.isNaN || number.isInfinite {
            return "Error"
        }
        
        if number.truncatingRemainder(dividingBy: 1) == 0 {
            return String(Int(number))
        } else {
            return String(number)
        }
    }
    
    private func updateSecondaryDisplay(_ operation: String) {
        if let currentText = displayLabel.text {
            secondaryDisplayLabel.text = "\(currentText) \(operation)"
        }
    }
    
    // MARK: - Mode Toggle
    @IBAction func toggleCalculatorMode(_ sender: UIButton) {
        isScientificMode.toggle()
        // Update UI to show/hide scientific buttons
        // This would typically involve showing/hiding constraints or views
    }
}
198 lines•6.2 KB
swift
šŸš€ Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ā¤ļø

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer