Reading time: 6 min

This recipe shows how to play a YouTube video in SwiftUI. The end result looks like this:

Preview iOS

This component is available as a Swift Package in this repo.

This recipe shows only a part of the YouTubePlayer component's functionality, namely that to load a video, play and pause it. Thi...

Continue Reading...

Reading time: 1 min

This recipe shows how to style the progress indicator while using the refreshable on SwiftUI List. The end result looks like this:

preview

This recipe works with the refreshable modifier, which is only available in SwiftUI 3 (iOS 15, macOS 12). If you're interested in custom refresh indicators...

Continue Reading...

Reading time: 1 min

This recipe shows how to set visibility of a SwiftUI view. You can show it, hide it, or remove it from the view hierarchy entirely. The end result looks like this:

preview

We'll adopt a good practice from Android and model the view visibility like this:

enum ViewVisibility: CaseIterable {
  case v...

Continue Reading...

Reading time: 3 min

This recipe shows how to play videos in SwiftUI. It also shows how to add more advanced functionality, such as playing a sequence of videos, adding loop playback and custom end actions. The end result looks like this:

preview

If you wish to know more about what happens in that video, visit th...

Continue Reading...

Reading time: 1 min

This quick recipe shows how to set a @StateObject in a SwiftUI View's initializer. Basically, you're trying to do this:

struct MyView: View {
  @StateObject private var viewModel: ViewModel

  init(someParams: String) {
    viewModel = ViewModel(params: someParams)
  } 

But you keep running i...

Continue Reading...