CommentComment

👋🏻 Hi everyone!

The year is slowly drawing to an end, but - at least judging by the number of amazing articles and tweets people have published in the past week, it certainly doesn’t seem like anyone is going to take a break any time soon.

This week, I’ve curated a number of articles about SwiftUI and Combine (did you know Firebase also supports Combine?). There is also quite a bit of async/await, and I also found a number of nice tools that I did want to share with you.

As always, I love to hear your feedback for this newsletter! Just reply to this email, and it will arrive straight in my inbox. Even if you just want to say “Hi!” or send me a picture of where you live - don’t be shy!

Thanks for reading, Peter 🔥

BTW, if you like this newsletter, tell a friend! Or, you know, buy me a coffee ☕.

 

What I am working on

As I continued working on MakeItSo this week, I realised that the app’s navigation bar title looks slightly different than Apple’s Reminder app. Turns out they started using round versions of the San Francisco font a while back.

I don’t know about you, but I’ve got the impression that SwiftUI seems to follow Alan Kay’s adage “Simple things should be simple, complex things should be possible” (source) - specifying which font to use is a prime example of this principle!

SwiftUI defines a number of defaults for font styles most apps will be using over and over again, and these are defined as constants on Font : largeTitle, title, headline, body, caption, and others are text styles you will find in almost any app.

In addition, you can easily string together your own font to meet your app’s needs. For example, here is how you can create a rounded variant of the system font for any text labels that are of the style body:

.font(.system(.body, design: .rounded))

By assigning this to the root view of your application, this font style will now be used in every view of your app’s view hierarchy. Unfortunately, this doesn’t apply to the text labels in the navigation bar. To achieve this, we have to use fall back to UIKit and use the UIAppearance API:

let navGarAppearance = UINavigationBarAppearance)
navBarAppearance. largeTitleTextAttributes[.font] = UIFont.roundedLargeTitle()
navBarAppearance.largeTitleTextAttributes[.foregroundColor] = UIColor(Color.accentcolor)
navBarAppearance.titleTextAttributes[.font] = UIFont.roundedHeadline()

// I purposefully don't set the foreground color for normal text nav bar - 
// in Reminders. app, this isn't tinted as well!
// navBarAppearance. titleTextAttributes[.foregroundColor] = foregroundColor

UINavigationBar .appearance(). standardAppearance = navBarAppearance

Now, while this certainly is one of those cases where we can implement a UI feature that is not (yet) supported by SwiftUI, it certainly feels like an easy-enough addition to the existing APIs that Apple should try and ship in the next point release of SwiftUI. Judging by the number of articles out there explaining how to implement this and the number of questions on StackOverflow, this is an issue many developers are running into. Maybe a good project for one of the interns that the SwiftUI team will be hosting?

Peter Friese  

FirebaseFirebase


SwiftSwift


Combine

Call it perception bias, but it seems to me this week was full of Combine content. First, Antoine took us on a deep dive about when to use use RunLoop.main vs. DispatchQueue.main (definitely worth reading if you care about smooth scrolling). Next, Natascha explained what back-pressure means in Combine and showed us some real-world examples. And finally, Rony gave a useful extension for Publisher that allows us to sink events without creating retain cycles.

 

SwiftUISwiftUI


Tools


Jobs

Fun stuff