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

Make it easier to support multiple messages and message types #12

Closed
svenoaks opened this issue Jul 24, 2021 · 1 comment
Closed

Make it easier to support multiple messages and message types #12

svenoaks opened this issue Jul 24, 2021 · 1 comment

Comments

@svenoaks
Copy link

svenoaks commented Jul 24, 2021

Is your feature request related to a problem? Please describe.
There is only a toast(isPresenting: Binding<Bool>...) function. It is cumbersome to add multiple messages and/or multiple message types.

Describe the solution you'd like
There should be a toast<Item>(item: Binding<Item?>...) function that allows defining the message in the item. This would be similar to several SwiftUI apis like alert(item:..). When the item changes the alert is displayed.

Describe alternatives you've considered
If we want to add multiple messages and/or have multiple message type, we must have multiple calls of toast(), or some other redundancy to allow this.

@heecheon92
Copy link

heecheon92 commented Feb 4, 2023

I just added view extension and seems to work with single ".toast" modifier
`

@ViewBuilder func toast(isPresenting: Binding<Bool>,
           duration: Double = 2,
           tapToDismiss: Bool = true,
           offsetY: CGFloat = 0,
           displayMode: AlertToast.DisplayMode,
           alertType: AlertToast.AlertType,
           title: String? = nil,
           subtitle: String? = nil,
           alertStyle: AlertToast.AlertStyle? = nil,
           onTap: (() -> ())? = nil, completion: (() -> ())? = nil) -> some View {
    
    modifier(AlertToastModifier(isPresenting: isPresenting,
                                duration: duration,
                                tapToDismiss: tapToDismiss,
                                offsetY: offsetY,
                                alert: { AlertToast(displayMode: displayMode,
                                                    type: alertType,
                                                    title: title,
                                                    subTitle: subtitle,
                                                    style: alertStyle) },
                                onTap: onTap,
                                completion: completion))
}

`

@elai950 elai950 closed this as completed Feb 12, 2023
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

3 participants