18: project 1, part 3

그루두·2024년 4월 28일
0

100 days of SwiftUI

목록 보기
27/108

100 days of swiftui: 18
https://www.hackingwithswift.com/100/swiftui/18

more challenge

  1. Add a header to the third section, saying “Amount per person”
                Section("Amount per person") {
                    Text(totalPerPerson, format: .currency(code: "USD"))
                }
  1. Add another section showing the total amount for the check – i.e., the original amount plus tip value, without dividing by the number of people.
    var totalAmount: Double {
        return checkAmount * (1 + Double(tipPercentage) / 100)
    }
	// ...
                Section("Total amount") {
                    Text(totalAmount, format: .currency(code: "USD"))
                }
  1. Change the tip percentage picker to show a new screen rather than using a segmented control, and give it a wider range of options – everything from 0% to 100%. Tip: use the range 0..<101 for your range rather than a fixed array.
                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

profile
계속 해보자

0개의 댓글

관련 채용 정보