diff --git a/Sources/Purace/Views/Basic/Snackbar/PuraceSnackbarView.swift b/Sources/Purace/Views/Basic/Snackbar/PuraceSnackbarView.swift index c2aeb38..5ec94b4 100644 --- a/Sources/Purace/Views/Basic/Snackbar/PuraceSnackbarView.swift +++ b/Sources/Purace/Views/Basic/Snackbar/PuraceSnackbarView.swift @@ -82,12 +82,16 @@ struct PuraceSnackbarViewModifier: ViewModifier { var buttonTitle: String? var type: PuraceSnackbarType var buttonOnTap: (() -> Void)? + var onDissappear: (() -> Void)? func body(content: Content) -> some View { ZStack { content if isVisibleAux { PuraceSnackbarView(title: title, type: type, isVisible: $isVisible, buttonTitle: buttonTitle, buttonOnTap: buttonOnTap) + .onDisappear { + onDissappear?() + } } }.onChange(of: isVisible) { newValue in if !newValue { @@ -103,7 +107,7 @@ struct PuraceSnackbarViewModifier: ViewModifier { public extension View { - func snackBar(title: String, isVisible: Binding, type: PuraceSnackbarType = .info, buttonTitle: String? = nil, buttonOnTap: (() -> Void)? = nil) -> some View { - modifier(PuraceSnackbarViewModifier(isVisible: isVisible, title: title, buttonTitle: buttonTitle, type: type, buttonOnTap: buttonOnTap)) + func snackBar(title: String, isVisible: Binding, type: PuraceSnackbarType = .info, buttonTitle: String? = nil, buttonOnTap: (() -> Void)? = nil, onDissappear: (() -> Void)? = nil) -> some View { + modifier(PuraceSnackbarViewModifier(isVisible: isVisible, title: title, buttonTitle: buttonTitle, type: type, buttonOnTap: buttonOnTap, onDissappear: onDissappear)) } }