Refactoring views
Our views have too much code, and we should refactor them a bit. Dealing with small chunks of code makes it easier to manage as well as being able to reuse views. We refactor each of the three main views, but if you see a place where you can refactor, have at it.
Refactoring ContentView
The first view we are going to refactor is inside of ContentView
. Open ContentView
and highlight everything inside of ForEach
, and then hit Command + X (cut). Then, open DraftRoundItemView
and highlight Text("Draft Round Item View")
and hit Command + V (paste) to replace this Text
view. Go back to ContentView()
and cut the background variable from ContentView()
and paste it after the body
variable in DraftRoundItemView()
. Hit Save.
Back inside of ContentView
again, add DraftRoundItemView()
inside of ForEach
. When you're finished, ContentView
should look like the following:
struct ContentView: View { var body: some View { ...