Reading time: 1 min

This recipe shows how to detect layout direction in your SwiftUI views, which is useful to be able to support both left-to-right (LTR) and right-to-left (RTL) languages. It also shows how to force this setting for testing purposes. The end result looks like this:

preview

Detecting layout direction
...

Continue Reading...

Reading time: 2 min

This recipe shows how to show an alert dialog from anywhere in the SwiftUI app. Normally, alert is tied to a specific view, and its content is handled by that view's state. This solution, however, makes it so that the alert is defined in just a single place and is always presented on top ...

Continue Reading...

04 Feb 2022

SwiftUI Toast

swiftui

Reading time: 2 min

This recipe shows how to implement an Android-like "toast" notification in SwiftUI. The end result looks like this:

preview

Features include:

  • Configurable toast view with custom text, font, foreground and background color. It defaults to Android-style toast with white text on a semi-transparent bl...

Continue Reading...

Reading time: 1 min

This quick recipe shows how to support nested NavigationLinks and allow the user to move back programatically. As always, SwiftUI throws a curveball even on trivial tasks such as this. Here's what the end result looks like:

preview_good

OK, so the situation you have is as following:

  1. You have a multi-le...

Continue Reading...

Reading time: 6 min

This recipe shows how to add easy-to-use segues to your SwiftUI navigation. They allow for presenting views using common UIKIt Segue types - push, modal and popover. The end result looks like this:

preview

Navigating between views/screens in SwiftUI is more difficult and convoluted than it is in UIK...

Continue Reading...