Skip to content

Commit d53c4ce

Browse files
committed
100 Days of SwiftUI - Days 23 and 24
Project 3 Challenge #2 - Go back to project 1 and use a conditional modifier to change the total amount text view to red if the user selects a 0% tip.
1 parent 02e09e7 commit d53c4ce

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

SwiftUI/Projects/WeSplit/WeSplit/ContentView.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ struct ContentView: View {
5555
}
5656

5757
Section(header: Text("Total amount")) {
58-
Text("$\(Double(checkAmount) ?? 0, specifier: "%.2f") + $\(tipValue, specifier: "%.2f") = $\(grandTotal, specifier: "%.2f")")
58+
HStack {
59+
Text("$\(Double(checkAmount) ?? 0, specifier: "%.2f")")
60+
Text("+")
61+
Text("$\(tipValue, specifier: "%.2f")")
62+
.foregroundColor(tipPercentages[tipPercentage] > 0 ? .black : .red)
63+
Text("=")
64+
Text("$\(grandTotal, specifier: "%.2f")")
65+
}
5966
}
6067
}
6168
.navigationBarTitle("WeSplit")

0 commit comments

Comments
 (0)