Comments (5)
I did some experiment in a short trial and I have no idea why, but in the first 0-2.4 seconds it's possible to dismiss the alert however later it is not. I tested and it is receiving the onTapGesture
event and the isPresenting
changes to false
but the alert stays on the screen no matter what regardless isPresenting
false or true. If I tap or set isPresenting
withing 2.4 seconds it works as expected.
from alerttoast.
In a new project I can not reproduce this behaviour so I am looking deeper into it.
from alerttoast.
It seems to works great on my side. Can you please submit the ObservableObject
you're using?
I think that is where the problem.
Also, if RM
is an ObservableObject
, so the implementation should look like this:
Read this article about how to implement Alert Toast with ObservableObject
correctly (the Bonus section):
How to toast an alert in SwiftUI
//Notice the dollar sign
.toast(isPresenting: $RM.pendingNotifications, duration: 3.0) {
AlertToast(displayMode: .hud, type: .systemImage("exclamationmark.triangle.fill", Color.orange), title: "alert alert alert")
}
from alerttoast.
Thanks I have it now. Nothing is wrong with your code. In my case it's a complicated project and the observable object @Published
variable was indirectly connected to a custom property wrapper. For some reason this value is not updating if the new value source is outside of the object.
I could reproduce it in a more simple way with an @AppStorage
wrapper in iOS14. I don't have much experience with @AppStorage
so probably it's a normal behaviour but modifying this from outside of the observable object also preventing the alert to disappear. Probably the change is not pushed down the hierarchy.
Thanks again for this framework, it's awesome.
from alerttoast.
Glad you found a solution 😊
from alerttoast.
Related Issues (20)
- Swipe to dismiss toast HOT 1
- If type is .loading, its background parent view is still clickable HOT 2
- No toast! Have implemented per instructions, but the AlertToast() does not respond with any visualisation. Have traced that it gets called, but nothing happens on screen. - Xcode 14.2, SwiftUI, iOS 16.2, Simulator and physical device. HOT 1
- Long Subtitle text doesn't correctly wrap in DisplayMode "hub" or "banner" HOT 6
- Toast Window Not Large Enough On MacOS: The text gets truncated and replaced with "..."
- Popover cuts off `.hud` alert HOT 5
- Create Example Project HOT 1
- The subtitle line gets cut off on iOS banners HOT 1
- Not usable as global modifier when sheet is presented HOT 7
- Is there any way to set the toast always on the top of screen, instead of on the center of view HOT 1
- System image not being displayed when AlertToast added to a package.
- Issue: App Clip compiler error HOT 1
- Toast can be invisible under the software keyboard HOT 1
- Add accessibilityIdentifier to retrieve alert while testing
- Alert Toast (.hud display mode) large text not fit to the screen HOT 2
- Is there a way to add on any views like system Alert?
- [Feature Request] Vision OS Support HOT 1
- Privacy Manifest HOT 3
- Need an interface to feed in a localized string to title/subtitle
- toast is not close
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alerttoast.