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

support toast item #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Yvent
Copy link

@Yvent Yvent commented Oct 12, 2023

support toast item

@Yvent
Copy link
Author

Yvent commented Oct 15, 2023

@elai950 hi, I submitted some code, I hope it will be useful, can you review it?

Copy link

@nathanfallet nathanfallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love to see this merged as using an item is a common use

/// - item: Binding<Item?>
/// - alert: (Item?) -> AlertToast
/// - Returns: `AlertToast`
func toast<Item>(item: Binding<Item?>, duration: Double = 2, tapToDismiss: Bool = true, offsetY: CGFloat = 0, alert: @escaping (Item?) -> AlertToast, onTap: (() -> ())? = nil, completion: (() -> ())? = nil) -> some View{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to make Item identifiable like in SwiftUI's alert?

Suggested change
func toast<Item>(item: Binding<Item?>, duration: Double = 2, tapToDismiss: Bool = true, offsetY: CGFloat = 0, alert: @escaping (Item?) -> AlertToast, onTap: (() -> ())? = nil, completion: (() -> ())? = nil) -> some View{
func toast<Item>(item: Binding<Item?>, duration: Double = 2, tapToDismiss: Bool = true, offsetY: CGFloat = 0, alert: @escaping (Item?) -> AlertToast, onTap: (() -> ())? = nil, completion: (() -> ())? = nil) -> some View where Item : Identifiable {

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.

None yet

2 participants