Skip to content

feat: add a custom display mode for arbitrary toast content#8

Merged
patro85 merged 1 commit into
masterfrom
feat/custom-view
Jun 1, 2026
Merged

feat: add a custom display mode for arbitrary toast content#8
patro85 merged 1 commit into
masterfrom
feat/custom-view

Conversation

@patro85

@patro85 patro85 commented Jun 1, 2026

Copy link
Copy Markdown
Owner

What

Adds DisplayMode.custom and a trailing-closure initializer so callers can present any SwiftUI view as a toast:

.toast(isPresenting: $show) {
    AlertToast {
        HStack { ProgressView(); Text("Uploading…").font(.headline) }
    }
}

Behavior

  • Presented centered and animated like .alert — the two cases share the same presentation path (combined switch cases), so there's no duplicated logic.
  • Respects existing duration / tapToDismiss.
  • Accepts an optional style: for background / Liquid Glass customization (so useGlassEffect: false works 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 build and swift test pass (added testCustomViewInit). README gains a Custom view section.

🤖 Generated with Claude Code

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 patro85 merged commit 491b1ca into master Jun 1, 2026
@patro85 patro85 deleted the feat/custom-view branch June 1, 2026 19:28
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants