Devlog: February 2, 2023

My family has been sick for a bit, so I’ve been mostly working on taking care of them and trying to not get sick myself. Finally starting to get back to a bit of normalcy now.

Today I added a button.

🥳

It’s a details button next to a name. It will open the details of that person in The Movie Database. I don’t want to make a full TMDb client. So my current plan is to just link to their pages. A pretty straightforward

A screen recording of opening the details of Aidan Cook in The Movie DatabaseI don't like where the button is...

Along with that, I added a setting to open the details in the app or in Safari. The in-app browser uses SFSafariViewController. This is the one that comes with the done button, the open in Safari button, etc. I first tried WKWebView but that just displays a webpage with none of the other stuff. When the setting is enabled to open details in Safari, instead of using Link, I use openUrl environment variable. Pretty nifty.

struct DetailsLink: View {
    @AppStorage(SettingsKeys.openDetailsInBrowser) var openDetailsInBrowser = false
    @Environment(\.openURL) var openUrl
    
    var body: some View {
        Button {
            if openDetailsInBrowser {
                openUrl(url)
            } else {
                // Show 
            }
        } label: {
            Label("Details", systemImage: "info.circle")
        }
    }
}

I’m using @AppStorage for saving the setting. It is simple, but I’m not 100% sold on it yet. It requires a lot of duplication. If I want to use the setting in multiple places, I need to define a default in multiple places, which feels odd to me. Just found this article about an alternative that looks interesting. Going to give that a closer read.



Date
February 2, 2023