AlertToast icon indicating copy to clipboard operation
AlertToast copied to clipboard

One place to modifier toast

Open tospery opened this issue 1 year ago • 3 comments

  1. ContentView is my first View. And, add the .toast modifier to it.
  2. ContentView present(fullScreenCover) the LoginView. And, the LoginView has its own NavigationStack.
  3. When i toggle the toast variable in LoginView. The ContentView will show the toast View. But, the toast View will behind the LoginView. Need close LoginView, you will see the toast.

How to solve this problem? My goal is to modifier toast in the first view so that toast will display normally whenever/anyplace it is triggered.

tospery avatar Nov 08 '24 03:11 tospery

I mean, how can I add the .toast to one place, anywhere in app can trigger it? Similarly, UIKit adds toast to the keyWindow

tospery avatar Nov 08 '24 09:11 tospery

This is demo https://github.com/tospery/AlertViewDemo

tospery avatar Nov 08 '24 13:11 tospery

@tospery I have a similar issue, a single shared toaspresenter that I use on the main view of my app. Whenever a toast is needed, I call the method to set the toast message and show it. However, I am facing a similar issue that it only shows on top of the root views or views pushed into the stack. If the view is presented, the alerts are always behind the view.

ashishsj0 avatar Dec 30 '24 19:12 ashishsj0