Book Image

SwiftUI Projects

By : Craig Clayton
Book Image

SwiftUI Projects

By: Craig Clayton

Overview of this book

Released by Apple during WWDC 2019, SwiftUI provides an innovative and exceptionally simple way to build user interfaces for all Apple platforms with the power of Swift. This practical guide involves six real-world projects built from scratch, with two projects each for iPhone, iPad, and watchOS, built using Swift programming and Xcode. Starting with the basics of SwiftUI, you’ll gradually delve into building these projects. You’ll learn the fundamental concepts of SwiftUI by working with views, layouts, and dynamic types. This SwiftUI book will also help you get hands-on with declarative programming for building apps that can run on multiple platforms. Throughout the book, you’ll work on a chart app (watchOS), NBA draft app (watchOS), financial app (iPhone), Tesla form app (iPhone), sports news app (iPad), and shoe point-of-sale system (iPad), which will enable you to understand the core elements of a SwiftUI project. By the end of the book, you’ll have built fully functional projects for multiple platforms and gained the knowledge required to become a professional SwiftUI developer.
Table of Contents (13 chapters)

Standings

We will work on one more module together before you get to work on the next challenge. Before we jump into StandingsModuleView, we need to update StandingItem.

StandingItem

We have a few things we need to add to StandingItem:

  1. First, we will add the following Team variable:
    var item: Team
  2. Next, we'll update the team name with the following code:
    Text(item.shortName)
  3. Now, add the following for the team's record:
    Text(item.record())
  4. We need to update the winning percentage with the following updates:
    Text(item.winPct)
  5. Let's now update the games behind:
    Text(item.gamesBehind)
  6. Finally, make sure you update the preview with the following:
    static var previews: some View {
        StandingItem(item: Team.default).previewLayout(.
        fixed(width: 600, height: 25))
    }

With that, we've made all the changes we need to StandingItem. Let's wrap up our dashboard by making a few changes to StandingsModuleView...