Skip to content

Commit

Permalink
Merge pull request #25 from payan-app/snackbar
Browse files Browse the repository at this point in the history
fix: add snack button handler
  • Loading branch information
juandahurt authored Jul 9, 2022
2 parents 9a3a40d + cbd223a commit c0a2df9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/Purace/Views/Basic/Snackbar/PuraceSnackbarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ struct PuraceSnackbarViewModifier: ViewModifier {
var title: String
var buttonTitle: String?
var type: PuraceSnackbarType
var buttonOnTap: (() -> Void)?

func body(content: Content) -> some View {
ZStack {
content
if isVisibleAux {
PuraceSnackbarView(title: title, type: type, isVisible: $isVisible, buttonTitle: buttonTitle)
PuraceSnackbarView(title: title, type: type, isVisible: $isVisible, buttonTitle: buttonTitle, buttonOnTap: buttonOnTap)
}
}.onChange(of: isVisible) { newValue in
if !newValue {
Expand All @@ -102,7 +103,7 @@ struct PuraceSnackbarViewModifier: ViewModifier {


public extension View {
func snackBar(title: String, isVisible: Binding<Bool>, type: PuraceSnackbarType = .info, buttonTitle: String? = nil) -> some View {
modifier(PuraceSnackbarViewModifier(isVisible: isVisible, title: title, buttonTitle: buttonTitle, type: type))
func snackBar(title: String, isVisible: Binding<Bool>, type: PuraceSnackbarType = .info, buttonTitle: String? = nil, buttonOnTap: (() -> Void)? = nil) -> some View {
modifier(PuraceSnackbarViewModifier(isVisible: isVisible, title: title, buttonTitle: buttonTitle, type: type, buttonOnTap: buttonOnTap))
}
}

0 comments on commit c0a2df9

Please sign in to comment.