Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Example Project #65

Open
Yurssoft opened this issue Mar 25, 2023 · 1 comment
Open

Create Example Project #65

Yurssoft opened this issue Mar 25, 2023 · 1 comment

Comments

@Yurssoft
Copy link

I checked both article and project. No example project. I would recommend adding project used to create demo screens.

@Adamekka
Copy link

You don't really need examples, this is extremely simple, creating one works like popovers, but I'm going to show you an example:

// Init state variable that tracks if toast is shown
@State var toastShown: Bool = false

// Create a button somewhere in view that will show that toast when clicked
Button("Show toast") {
    toastShown = true
}

// Create that toast somewhere in view like you would create a popover
.toast(isPresenting: $toastShown) {
    AlertToast(
        displayMode: .hud, type: .regular, title: "Toast title")
}

Don't just ctrl + c ctrl + v this code, you need to place that button and that toast inside view.
If you want to modify how it looks, then change arguments inside AlertToast.

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

No branches or pull requests

2 participants