Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Calculator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
7FB724422F8C2C38005B3C2D /* Exceptions for "Calculator" folder in "Calculator" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
TaxLogic.swift,
);
target = 7FB722212F8ACDE7005B3C2D /* Calculator */;
};
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
Expand All @@ -43,9 +40,6 @@
7FB724432F8C2C38005B3C2D /* Exceptions for "Calculator" folder in "Copy Bundle Resources" phase from "Calculator" target */ = {
isa = PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet;
buildPhase = 7FB722202F8ACDE7005B3C2D /* Resources */;
membershipExceptions = (
TaxLogic.swift,
);
};
/* End PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet section */

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Calculator.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
18 changes: 14 additions & 4 deletions Calculator/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
//

import SwiftUI
import Foundation

struct ContentView: View {
@State private var income = ""
@State private var taxRate = ""

@State private var taxAmount: Double = 0
@State private var netIncome: Double = 0

var body: some View {
VStack(alignment: .leading, spacing: 0) {
Text("Tax Calculator")
Expand Down Expand Up @@ -48,7 +51,14 @@ struct ContentView: View {
.shadow(color: .black.opacity(0.08), radius: 3, x: 0, y: 1)
.padding(.bottom, 40)

Button("Calculate Tax") {}
Button("Calculate Tax") {
let incomeValue = Double(income) ?? 0
let taxRateValue = Double(taxRate) ?? 0
let result = calculateTax(income: incomeValue, taxRate: taxRateValue)

taxAmount = result.taxAmount
netIncome = result.netIncome
}
.frame(maxWidth: .infinity)
.frame(height: 55)
.background(Color(hex: "0A7CFF"))
Expand All @@ -62,11 +72,11 @@ struct ContentView: View {
.font(.system(size: 18, weight: .bold))
.foregroundColor(Color(hex: "1C1E21"))

Text("Tax Amount: ₹ 0.00")
Text("Tax Amount: ₹\(taxAmount, specifier: "%.2f")")
.font(.system(size: 16))
.foregroundColor(Color(hex: "D93025"))

Text("Final Income: ₹ 0.00")
Text("Final Income: ₹\(netIncome, specifier: "%.2f")")
.font(.system(size: 18, weight: .bold))
.foregroundColor(Color(hex: "1E8E3E"))
}
Expand Down
7 changes: 4 additions & 3 deletions Calculator/TaxLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/// - Returns: A tuple with the calculated `taxAmount` and the resulting `netIncome`.
import Foundation
func calculateTax(income: Double, taxRate: Double) -> (taxAmount: Double, netIncome: Double) {

return (0, 0)
}
let taxAmount = income * (taxRate / 100)
let netIncome = income - taxAmount
return (taxAmount, netIncome)
}
Loading