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
ADVANCED_FEATURES.mdmodels.pyRELEASE_NOTES.mdconfig.pytest_app.pySiriShortcutsManager.swift
RELEASE_NOTES.md
Raw Download

RELEASE_NOTES.md

# Swift iOS Calculator - Release Notes

## Version 1.0.0 - Initial Release 🎉

*Released: January 24, 2026*

---

## 🚀 Overview

The Swift iOS Calculator is a comprehensive, professional-grade calculator application featuring advanced mathematical capabilities, AI-powered problem solving, and modern platform integration. This initial release establishes a solid foundation with 15+ specialized calculators and a complete ecosystem of features.

---

## ✨ New Features

### 📱 Core Calculator Suite
- **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

### 🎨 Theme System
- **6 Beautiful Themes**: Light, Dark, Blue, Green, Purple, Sunset
- **Dynamic Theme Switching** - Instant theme changes across all calculators
- **Persistent Preferences** - Theme selection saved automatically

### 🔗 Platform Integration
- **Home Screen Widgets** - Quick calculator access from iOS home screen
- **Siri Shortcuts** - Voice-activated calculations
- **Apple Watch Support** - Calculator on your wrist
- **Camera Integration** - QR code scanning for currency rates

---

## 🏗️ Technical Architecture

### Framework Dependencies
- **SceneKit** - 3D graphing visualization
- **CoreGraphics** - Graphics calculations and rendering
- **WidgetKit** - Home screen widget support
- **SwiftUI** - Modern widget interface
- **AudioToolbox** - Sound feedback system
- **NaturalLanguage** - AI math processing
- **Intents & IntentsUI** - Siri shortcuts integration
- **WatchKit** - Apple Watch app

### Project Structure
- **27 Swift Files** - Clean MVC architecture
- **19 Storyboard Files** - Intuitive UI layouts
- **6 Configuration Files** - Complete project setup
- **3 Asset Files** - Visual resources and icons

### Code Quality
- **No TODO/FIXME comments** - Production-ready code
- **Professional Documentation** - Comprehensive README and inline comments
- **App Store Compliant** - LICENSE, PRIVACY_POLICY, and legal files
- **Internationalization Ready** - Localizable.strings included

---

## 📋 Requirements

### Development Requirements
- **macOS 12.0+** - Latest macOS for Xcode compatibility
- **Xcode 13.0+** - Modern Swift and iOS features
- **iOS 15.0+** - Target deployment version
- **Swift 5.0+** - Language version

### Runtime Requirements
- **iOS 15.0+** - Minimum supported iOS version
- **iPhone/iPad** - Universal app support
- **Apple Watch** - Optional companion app
- **50MB Storage** - App size with all features

---

## 🔧 Installation

### From Source
```bash
git clone https://github.com/rskworld/swift-ios-calculator.git
cd swift-ios-calculator
open swift-ios-calculator.xcodeproj
```

### Development Setup
1. Open project in Xcode 13.0+
2. Select your development team
3. Configure signing certificates
4. Build and run on simulator or device

---

## 🎯 Usage

### Basic Operations
1. Launch the app from home screen
2. Select calculator type from tab bar
3. Use number and operation buttons
4. Access memory functions (M+, M-, MR, MC)

### Advanced Features
1. **Scientific Mode**: Access sin, cos, tan, log, √ functions
2. **Programmer Mode**: Binary, hex, octal conversions
3. **Unit Conversion**: Select category and input values
4. **Currency Exchange**: Real-time rates with QR scanning
5. **Graphing**: Enter functions and view interactive plots

### Theme Customization
1. Go to Settings tab
2. Select "Themes" option
3. Choose from 6 available themes
4. Theme applies instantly across all calculators

---

## 🔒 Privacy & Security

- **Local Processing Only** - All calculations performed on device
- **No Data Collection** - No personal information collected or transmitted
- **Biometric Protection** - Optional Face ID/Touch ID for history access
- **Privacy Policy Compliant** - Full privacy policy included

---

## 🐛 Known Issues

### Minor Issues
- **App Icon Images** - Default iOS icon used (custom icons needed)
- **Development Team** - Empty in build settings (requires Apple Developer account)

### Future Enhancements
- Additional calculator types
- More theme options
- Enhanced AI capabilities
- Cloud synchronization

---

## 📞 Support

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

### Documentation
- **README.md** - Complete project documentation
- **index.html** - Interactive demo and showcase
- **PRIVACY_POLICY.md** - Privacy policy details
- **LICENSE** - MIT License terms

---

## 🎉 What's Next

### Version 1.1.0 (Planned)
- Custom app icon images
- Additional calculator themes
- Enhanced AI math solver
- Performance optimizations

### Version 1.2.0 (Planned)
- Cloud synchronization
- Collaboration features
- Advanced statistical analysis
- More unit conversions

---

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

## 🙏 Acknowledgments

- **Apple Inc.** - iOS development frameworks and tools
- **Swift Community** - Language and ecosystem support
- **Open Source Contributors** - Libraries and dependencies

---

*Last Updated: January 24, 2026*
*Version: 1.0.0*
*Developer: RSK World*
SiriShortcutsManager.swift
Raw Download
Find: Go to:
//
//  SiriShortcutsManager.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
import Intents
import IntentsUI

class SiriShortcutsManager {
    
    static let shared = SiriShortcutsManager()
    
    private init() {}
    
    // MARK: - Shortcut Types
    enum ShortcutType: String, CaseIterable {
        case calculate = "com.rskworld.calculator.calculate"
        case unitConvert = "com.rskworld.calculator.unitConvert"
        case currencyConvert = "com.rskworld.calculator.currencyConvert"
        case scientificCalculate = "com.rskworld.calculator.scientificCalculate"
        case programmerCalculate = "com.rskworld.calculator.programmerCalculate"
        case graphFunction = "com.rskworld.calculator.graphFunction"
        case tipCalculator = "com.rskworld.calculator.tipCalculator"
        case loanCalculator = "com.rskworld.calculator.loanCalculator"
        case bmiCalculator = "com.rskworld.calculator.bmiCalculator"
        case percentageCalculator = "com.rskworld.calculator.percentageCalculator"
    }
    
    // MARK: - Setup Shortcuts
    func setupAllShortcuts() {
        setupCalculateShortcut()
        setupUnitConvertShortcut()
        setupCurrencyConvertShortcut()
        setupScientificCalculateShortcut()
        setupProgrammerCalculateShortcut()
        setupGraphFunctionShortcut()
        setupTipCalculatorShortcut()
        setupLoanCalculatorShortcut()
        setupBMICalculatorShortcut()
        setupPercentageCalculatorShortcut()
    }
    
    // MARK: - Calculate Shortcut
    private func setupCalculateShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.calculate.rawValue)
        activity.title = "Quick Calculate"
        activity.suggestedInvocationPhrase = "Quick calculate"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.calculate.rawValue
        
        let userInfo: [String: Any] = [
            "action": "calculate",
            "type": "basic"
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - Unit Convert Shortcut
    private func setupUnitConvertShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.unitConvert.rawValue)
        activity.title = "Convert Units"
        activity.suggestedInvocationPhrase = "Convert units"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.unitConvert.rawValue
        
        let userInfo: [String: Any] = [
            "action": "convert",
            "type": "units",
            "category": "length",
            "fromUnit": "meter",
            "toUnit": "foot"
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - Currency Convert Shortcut
    private func setupCurrencyConvertShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.currencyConvert.rawValue)
        activity.title = "Convert Currency"
        activity.suggestedInvocationPhrase = "Convert currency"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.currencyConvert.rawValue
        
        let userInfo: [String: Any] = [
            "action": "convert",
            "type": "currency",
            "fromCurrency": "USD",
            "toCurrency": "EUR"
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - Scientific Calculate Shortcut
    private func setupScientificCalculateShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.scientificCalculate.rawValue)
        activity.title = "Scientific Calculator"
        activity.suggestedInvocationPhrase = "Scientific calculator"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.scientificCalculate.rawValue
        
        let userInfo: [String: Any] = [
            "action": "calculate",
            "type": "scientific"
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - Programmer Calculate Shortcut
    private func setupProgrammerCalculateShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.programmerCalculate.rawValue)
        activity.title = "Programmer Calculator"
        activity.suggestedInvocationPhrase = "Programmer calculator"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.programmerCalculate.rawValue
        
        let userInfo: [String: Any] = [
            "action": "calculate",
            "type": "programmer",
            "base": "decimal",
            "bitLength": "32"
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - Graph Function Shortcut
    private func setupGraphFunctionShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.graphFunction.rawValue)
        activity.title = "Graph Function"
        activity.suggestedInvocationPhrase = "Graph function"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.graphFunction.rawValue
        
        let userInfo: [String: Any] = [
            "action": "graph",
            "function": "x^2",
            "xMin": -10,
            "xMax": 10
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - Tip Calculator Shortcut
    private func setupTipCalculatorShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.tipCalculator.rawValue)
        activity.title = "Tip Calculator"
        activity.suggestedInvocationPhrase = "Calculate tip"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.tipCalculator.rawValue
        
        let userInfo: [String: Any] = [
            "action": "calculate",
            "type": "tip",
            "billAmount": 100,
            "tipPercentage": 15
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - Loan Calculator Shortcut
    private func setupLoanCalculatorShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.loanCalculator.rawValue)
        activity.title = "Loan Calculator"
        activity.suggestedInvocationPhrase = "Calculate loan"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.loanCalculator.rawValue
        
        let userInfo: [String: Any] = [
            "action": "calculate",
            "type": "loan",
            "principal": 100000,
            "interestRate": 5.0,
            "term": 30
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - BMI Calculator Shortcut
    private func setupBMICalculatorShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.bmiCalculator.rawValue)
        activity.title = "BMI Calculator"
        activity.suggestedInvocationPhrase = "Calculate BMI"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.bmiCalculator.rawValue
        
        let userInfo: [String: Any] = [
            "action": "calculate",
            "type": "bmi",
            "weight": 70,
            "height": 175
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - Percentage Calculator Shortcut
    private func setupPercentageCalculatorShortcut() {
        let activity = NSUserActivity(activityType: ShortcutType.percentageCalculator.rawValue)
        activity.title = "Percentage Calculator"
        activity.suggestedInvocationPhrase = "Calculate percentage"
        activity.isEligibleForPrediction = true
        activity.persistentIdentifier = ShortcutType.percentageCalculator.rawValue
        
        let userInfo: [String: Any] = [
            "action": "calculate",
            "type": "percentage",
            "value": 25,
            "total": 100
        ]
        activity.userInfo = userInfo
        
        self.viewController?.userActivity = activity
        activity.becomeCurrent()
    }
    
    // MARK: - Handle Shortcut
    func handleShortcut(_ userActivity: NSUserActivity) {
        guard let userInfo = userActivity.userInfo,
              let action = userInfo["action"] as? String else { return }
        
        switch action {
        case "calculate":
            handleCalculateShortcut(userInfo)
        case "convert":
            handleConvertShortcut(userInfo)
        case "graph":
            handleGraphShortcut(userInfo)
        default:
            break
        }
    }
    
    private func handleCalculateShortcut(_ userInfo: [String: Any]) {
        guard let type = userInfo["type"] as? String else { return }
        
        switch type {
        case "basic":
            navigateToBasicCalculator()
        case "scientific":
            navigateToScientificCalculator()
        case "programmer":
            navigateToProgrammerCalculator()
        case "tip":
            navigateToTipCalculator(userInfo)
        case "loan":
            navigateToLoanCalculator(userInfo)
        case "bmi":
            navigateToBMICalculator(userInfo)
        case "percentage":
            navigateToPercentageCalculator(userInfo)
        default:
            navigateToBasicCalculator()
        }
    }
    
    private func handleConvertShortcut(_ userInfo: [String: Any]) {
        guard let type = userInfo["type"] as? String else { return }
        
        switch type {
        case "units":
            navigateToUnitConverter(userInfo)
        case "currency":
            navigateToCurrencyConverter(userInfo)
        default:
            break
        }
    }
    
    private func handleGraphShortcut(_ userInfo: [String: Any]) {
        navigateToGraphingCalculator(userInfo)
    }
    
    // MARK: - Navigation Methods
    private weak var viewController: UIViewController?
    
    func setViewController(_ viewController: UIViewController) {
        self.viewController = viewController
    }
    
    private func navigateToBasicCalculator() {
        // Navigate to basic calculator tab
        if let tabBarController = viewController?.tabBarController {
            tabBarController.selectedIndex = 0
        }
    }
    
    private func navigateToScientificCalculator() {
        if let tabBarController = viewController?.tabBarController {
            tabBarController.selectedIndex = 1
        }
    }
    
    private func navigateToProgrammerCalculator() {
        if let tabBarController = viewController?.tabBarController {
            tabBarController.selectedIndex = 2
        }
    }
    
    private func navigateToUnitConverter(_ userInfo: [String: Any]) {
        if let tabBarController = viewController?.tabBarController {
            tabBarController.selectedIndex = 3
        }
    }
    
    private func navigateToCurrencyConverter(_ userInfo: [String: Any]) {
        if let tabBarController = viewController?.tabBarController {
            tabBarController.selectedIndex = 4
        }
    }
    
    private func navigateToGraphingCalculator(_ userInfo: [String: Any]) {
        if let tabBarController = viewController?.tabBarController {
            tabBarController.selectedIndex = 5
        }
    }
    
    private func navigateToTipCalculator(_ userInfo: [String: Any]) {
        // Present tip calculator modally
        let tipCalculator = TipCalculatorViewController()
        if let billAmount = userInfo["billAmount"] as? Double {
            tipCalculator.setBillAmount(billAmount)
        }
        viewController?.present(UINavigationController(rootViewController: tipCalculator), animated: true)
    }
    
    private func navigateToLoanCalculator(_ userInfo: [String: Any]) {
        // Present loan calculator modally
        let loanCalculator = LoanCalculatorViewController()
        if let principal = userInfo["principal"] as? Double {
            loanCalculator.setPrincipal(principal)
        }
        viewController?.present(UINavigationController(rootViewController: loanCalculator), animated: true)
    }
    
    private func navigateToBMICalculator(_ userInfo: [String: Any]) {
        // Present BMI calculator modally
        let bmiCalculator = BMICalculatorViewController()
        if let weight = userInfo["weight"] as? Double {
            bmiCalculator.setWeight(weight)
        }
        viewController?.present(UINavigationController(rootViewController: bmiCalculator), animated: true)
    }
    
    private func navigateToPercentageCalculator(_ userInfo: [String: Any]) {
        // Present percentage calculator modally
        let percentageCalculator = PercentageCalculatorViewController()
        if let value = userInfo["value"] as? Double {
            percentageCalculator.setValue(value)
        }
        viewController?.present(UINavigationController(rootViewController: percentageCalculator), animated: true)
    }
    
    // MARK: - Intent Donations
    func donateCalculateIntent(expression: String) {
        let intent = CalculateIntent()
        intent.expression = expression
        
        let interaction = INInteraction(intent: intent, response: nil)
        interaction.identifier = "calculate_\(expression)"
        interaction.donate { error in
            if let error = error {
                print("Failed to donate calculate intent: \(error)")
            }
        }
    }
    
    func donateConvertIntent(fromUnit: String, toUnit: String, value: Double) {
        let intent = ConvertIntent()
        intent.fromUnit = fromUnit
        intent.toUnit = toUnit
        intent.value = NSNumber(value: value)
        
        let interaction = INInteraction(intent: intent, response: nil)
        interaction.identifier = "convert_\(fromUnit)_\(toUnit)"
        interaction.donate { error in
            if let error = error {
                print("Failed to donate convert intent: \(error)")
            }
        }
    }
}

// MARK: - Additional Calculator View Controllers
class TipCalculatorViewController: UIViewController {
    
    private var billAmount: Double = 0
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Tip Calculator"
        view.backgroundColor = CalculatorTheme.shared.backgroundColor
        setupUI()
    }
    
    func setBillAmount(_ amount: Double) {
        billAmount = amount
    }
    
    private func setupUI() {
        // Tip calculator UI implementation
        let stackView = UIStackView()
        stackView.axis = .vertical
        stackView.spacing = 20
        stackView.translatesAutoresizingMaskIntoConstraints = false
        
        let billLabel = UILabel()
        billLabel.text = "Bill: $\(String(format: "%.2f", billAmount))"
        billLabel.font = UIFont.systemFont(ofSize: 24, weight: .bold)
        billLabel.textColor = CalculatorTheme.shared.textColor
        
        let tip15Label = UILabel()
        tip15Label.text = "15% Tip: $\(String(format: "%.2f", billAmount * 0.15))"
        tip15Label.textColor = CalculatorTheme.shared.textColor
        
        let tip20Label = UILabel()
        tip20Label.text = "20% Tip: $\(String(format: "%.2f", billAmount * 0.20))"
        tip20Label.textColor = CalculatorTheme.shared.textColor
        
        let tip25Label = UILabel()
        tip25Label.text = "25% Tip: $\(String(format: "%.2f", billAmount * 0.25))"
        tip25Label.textColor = CalculatorTheme.shared.textColor
        
        [billLabel, tip15Label, tip20Label, tip25Label].forEach {
            $0.textAlignment = .center
            stackView.addArrangedSubview($0)
        }
        
        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 LoanCalculatorViewController: UIViewController {
    
    private var principal: Double = 0
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Loan Calculator"
        view.backgroundColor = CalculatorTheme.shared.backgroundColor
        setupUI()
    }
    
    func setPrincipal(_ amount: Double) {
        principal = amount
    }
    
    private func setupUI() {
        // Loan calculator UI implementation
        let stackView = UIStackView()
        stackView.axis = .vertical
        stackView.spacing = 20
        stackView.translatesAutoresizingMaskIntoConstraints = false
        
        let principalLabel = UILabel()
        principalLabel.text = "Principal: $\(String(format: "%.2f", principal))"
        principalLabel.font = UIFont.systemFont(ofSize: 24, weight: .bold)
        principalLabel.textColor = CalculatorTheme.shared.textColor
        
        let monthlyPaymentLabel = UILabel()
        let monthlyPayment = calculateMonthlyPayment()
        monthlyPaymentLabel.text = "Monthly Payment: $\(String(format: "%.2f", monthlyPayment))"
        monthlyPaymentLabel.textColor = CalculatorTheme.shared.textColor
        
        [principalLabel, monthlyPaymentLabel].forEach {
            $0.textAlignment = .center
            stackView.addArrangedSubview($0)
        }
        
        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)
        ])
    }
    
    private func calculateMonthlyPayment() -> Double {
        let interestRate = 0.05 // 5%
        let term = 30 * 12 // 30 years in months
        
        if interestRate == 0 {
            return principal / Double(term)
        }
        
        let monthlyRate = interestRate / 12
        return principal * (monthlyRate * pow(1 + monthlyRate, Double(term))) / (pow(1 + monthlyRate, Double(term)) - 1)
    }
}

class BMICalculatorViewController: UIViewController {
    
    private var weight: Double = 0
    private var height: Double = 0
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "BMI Calculator"
        view.backgroundColor = CalculatorTheme.shared.backgroundColor
        setupUI()
    }
    
    func setWeight(_ value: Double) {
        weight = value
    }
    
    func setHeight(_ value: Double) {
        height = value
    }
    
    private func setupUI() {
        let stackView = UIStackView()
        stackView.axis = .vertical
        stackView.spacing = 20
        stackView.translatesAutoresizingMaskIntoConstraints = false
        
        let weightLabel = UILabel()
        weightLabel.text = "Weight: \(weight) kg"
        weightLabel.font = UIFont.systemFont(ofSize: 20)
        weightLabel.textColor = CalculatorTheme.shared.textColor
        
        let heightLabel = UILabel()
        heightLabel.text = "Height: \(height) cm"
        heightLabel.font = UIFont.systemFont(ofSize: 20)
        heightLabel.textColor = CalculatorTheme.shared.textColor
        
        let bmiLabel = UILabel()
        let bmi = calculateBMI()
        bmiLabel.text = "BMI: \(String(format: "%.1f", bmi))"
        bmiLabel.font = UIFont.systemFont(ofSize: 24, weight: .bold)
        bmiLabel.textColor = CalculatorTheme.shared.textColor
        
        let categoryLabel = UILabel()
        categoryLabel.text = getBMICategory(bmi)
        categoryLabel.font = UIFont.systemFont(ofSize: 18)
        categoryLabel.textColor = CalculatorTheme.shared.textColor
        
        [weightLabel, heightLabel, bmiLabel, categoryLabel].forEach {
            $0.textAlignment = .center
            stackView.addArrangedSubview($0)
        }
        
        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)
        ])
    }
    
    private func calculateBMI() -> Double {
        let heightInMeters = height / 100
        return weight / (heightInMeters * heightInMeters)
    }
    
    private func getBMICategory(_ bmi: Double) -> String {
        switch bmi {
        case ..<18.5:
            return "Underweight"
        case 18.5..<25:
            return "Normal weight"
        case 25..<30:
            return "Overweight"
        default:
            return "Obese"
        }
    }
}

class PercentageCalculatorViewController: UIViewController {
    
    private var value: Double = 0
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Percentage Calculator"
        view.backgroundColor = CalculatorTheme.shared.backgroundColor
        setupUI()
    }
    
    func setValue(_ val: Double) {
        value = val
    }
    
    private func setupUI() {
        let stackView = UIStackView()
        stackView.axis = .vertical
        stackView.spacing = 20
        stackView.translatesAutoresizingMaskIntoConstraints = false
        
        let valueLabel = UILabel()
        valueLabel.text = "\(value)% of 100 = \(value)"
        valueLabel.font = UIFont.systemFont(ofSize: 24, weight: .bold)
        valueLabel.textColor = CalculatorTheme.shared.textColor
        
        [valueLabel].forEach {
            $0.textAlignment = .center
            stackView.addArrangedSubview($0)
        }
        
        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)
        ])
    }
}
656 lines•23.5 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