feat: add a custom display mode for arbitrary toast content#8
Merged
Conversation
Add `DisplayMode.custom` and a `customView` initializer so callers can
present any SwiftUI view as a toast:
AlertToast {
HStack { ProgressView(); Text("Uploading…") }
}
The custom view is presented centered and animated exactly like `.alert`
(the two cases share the same presentation path), and it respects the
existing `duration` / `tapToDismiss` behavior. A `style:` argument is
still accepted for background / glass customization.
Reimplements the idea from fanxiangyang's elai950#113 on top
of the current code (the original branch predated the visionOS, subtitle,
and glass changes and bundled an unrelated timer-cancel change).
Adds a unit test and a README "Custom view" section.
Co-Authored-By: fanxiangyang <fanxiangyang@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
patro85
added a commit
that referenced
this pull request
Jun 4, 2026
Bump the version to 1.5.0 in the podspec and README (badge + SwiftPM and CocoaPods install snippets). Since 1.4.0 this release adds the custom-view display mode (DisplayMode.custom, #8) and fixes the animated checkmark drawing mirrored under right-to-left layout (#9). Co-authored-by: gambit1185_church <patrickmayo@churchofjesuschrist.org> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
DisplayMode.customand a trailing-closure initializer so callers can present any SwiftUI view as a toast:Behavior
.alert— the two cases share the same presentation path (combinedswitchcases), so there's no duplicated logic.duration/tapToDismiss.style:for background / Liquid Glass customization (souseGlassEffect: falseworks here too).Credit
Reimplements @fanxiangyang's PR elai950#113 on top of current
master. The original branch predated the visionOS / subtitle / glass work and also bundled an unrelated "cancel timer on disappear" change, which is left out to keep this focused.Verification
swift buildandswift testpass (addedtestCustomViewInit). README gains a Custom view section.🤖 Generated with Claude Code