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
  • 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
MainTabBarController.swift
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

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