SwiftUI: モーダル表示した画面のシンプルな開閉管理をEnvironment+Bindingで実現する

p0dee
1 min readMay 29, 2020

モーダル表示したNavigationを含む画面を、Navigationの遷移先画面から明示的に閉じる方法について、EnvironmentBindingを組み合わせることで、スマートに実装できる例がStack Overflowで紹介されていた。

モーダル画面内のNavigation有無に限らず、一貫して応用できるので良いと思った。

Dismiss a parent modal in SwiftUI from a NavigationView

これを真似して、非常に単純な例を実装してみた。

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response