SwiftUI: Global Overlay That Can Be Triggered From Any View : <p>I'm quite new to the SwiftUI framework and I haven't wrapped my head around all of it yet so please bear with me.</p>

<p>Is there a way to trigger an "overlay view" from inside "another view" when its binding changes? See illustration below:</p>

<p><a href="https://i.stack.imgur.com/sziqy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sziqy.png" alt="enter image description here"></a></p>

<p>I figure this "overlay view" would wrap all my views. I'm not sure how to do this yet - maybe using <code>ZIndex</code>. I also guess I'd need some sort of callback when the binding changes, but I'm also not sure how to do that either.</p>

<p>This is what I've got so far:</p>

<p><strong>ContentView</strong></p>

<pre><code>struct ContentView : View {
    @State private var liked: Bool = false

    var body: some View {
        VStack {
            LikeButton(liked: $liked)
        }
    }
}
</code></pre>

<p><strong>LikeButton</strong></p>

<pre><code>struct LikeButton : View {
    @Binding var liked: Bool

    var body: some View {
        Button(action: { self.toggleLiked() }) {
            Image(systemName: liked ? "heart" : "heart.fill")
        }
    }

    private func toggleLiked() {
        self.liked = !self.liked
        // NEED SOME SORT OF TOAST CALLBACK HERE
    }
}
</code></pre>

<p>I feel like I need some sort of callback inside my <code>LikeButton</code>, but I'm not sure how this all works in Swift.</p>

<p>Any help with this would be appreciated. Thanks in advance!</p>
