100 days of swiftui: 18
https://www.hackingwithswift.com/100/swiftui/18
Section("Amount per person") {
Text(totalPerPerson, format: .currency(code: "USD"))
}
var totalAmount: Double {
return checkAmount * (1 + Double(tipPercentage) / 100)
}
// ...
Section("Total amount") {
Text(totalAmount, format: .currency(code: "USD"))
}
Section("How much do you want to tip?") {
Picker("Tip percentage", selection: $tipPercentage) {
ForEach(0..<101) {
Text($0, format: .percent)
}
}
.pickerStyle(.navigationLink)
완성 화면
코드 파일
https://github.com/soaringwave/Ios-WeSplit/blob/main/WeSplit/WeSplit/ContentView.swift