Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Day 73: Project 14: PlaceCase (Part Six)

Follow along at https://www.hackingwithswift.com/100/swiftui/73.


📒 Field Notes

This day covers Part Six of Project 14 in the 100 Days of SwiftUI Challenge. (Project 14 files can be found in the directory for Part One.)

In addition to recapping the material covered during the project's other days, Day 67 focuses on extending the project according to a set of challenges.


🥅 Challenges

Challenge 1

Our + button is rather hard to tap. Try moving all its modifiers to the image inside the button – what difference does it make, and can you think why?

We don't quite need to put all modifiers inside the button -- but certainly the ones that would determine the surface area of the content:

Button(action: {
    self.createNewLocation()
}) {
    Image(systemName: "plus.rectangle.fill")
        .font(.title)
        .padding(24)
        .background(Color.accentColor.opacity(0.8))
        .foregroundColor(.white)
}
.clipShape(Circle())
.padding(.trailing)

Challenge 2

Having a complex if condition in the middle of ContentView isn’t easy to read – can you rewrite it so that the MapView, Circle, and Button are part of their own view?

TBH, ContentView is usually the first file I delete in a new project 😂. Organizing views under a Scenes folder and also composing them from various "container views" can go a long way to preventing the sort of problem mentioned above.

With a container view that handles authentication, it can conditionally show an "authed" view which, itself, is solely focused on its standard layout:

struct LocationCollectionView: View {

    var body: some View {
        ZStack {
            mapUnderlay

            centerIndicator

            addLocationButton
        }
    }
}

Challenge 3

Our app silently fails when errors occur during biometric authentication. Add code to show those errors in an alert. But be careful: you can only add one alert() modifier to each view.