Hundred Days Swift (Day 18)-Project 1: Part 3

百日 学 Swift (Day 18) – Project 1, part three (Project 1: Part 3)

Picker who selected the number of people yesterday was too ugly and the experience was not good. Similar to what is said in the tutorial, this kind of control should not be used in this place, at least it must be changed to TextField. I changed to a stepper. After all, big parties of more than 10 people are rare (of course, you can also adjust the value range of the stepper), and fine-tuned the interface.

1. Project inventory

(1) Section in the Form divides the form into one area, you can bring a title, so it looks more comfortable

(2) The default in Section is the form controls arranged one by one. If you want to add labels to TextField and other controls, you can consider HStack. In fact, I personally think that Section is a collection of HStack.

(3) The parent view in SwiftUI can only contain no more than 10 child views. (That is, there can be at most 10 HStacks of the same level in a VStack)

When (4) TextField control input, try using the .keyboardTypedecorator, it will greatly improve the user experience.

(5) The .navigationBarTitledecorator should be added to the Form, because the NavigationView may include a lot of content. If you use the modifier here, SwiftUI may not be able to understand where you want to put the title.

(6) It is impossible to use calculated attributes @State, huh, huh.

(7) Display Digital Text parameter can specifierbe set format. The typical format with two decimal places is:%.2f

2. Challenge

(1) Use TextField to enter the number of people

(2) If there is no consumption, the font of the total consumption and per capita subtotal is blue

The source code of the project can be viewed on GitHub .

Published 77 original articles · Like 16 · Visitors 40,000+

Guess you like

Origin blog.csdn.net/hh680821/article/details/105213184