mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-03-22 01:19:26 +01:00
30 lines
648 B
Swift
30 lines
648 B
Swift
//
|
|
// OnDismissSearchViewModifier.swift
|
|
// Memola
|
|
//
|
|
// Created by Dscyre Scotti on 7/14/24.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
private struct OnDismissSearchViewModifier: ViewModifier {
|
|
@Environment(\.dismissSearch) var dismissSearch
|
|
|
|
@Binding var isActive: Bool
|
|
|
|
func body(content: Content) -> some View {
|
|
content
|
|
.onChange(of: isActive) { oldValue, newValue in
|
|
if !newValue {
|
|
dismissSearch()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func onDismissSearch(isActive: Binding<Bool>) -> some View {
|
|
modifier(OnDismissSearchViewModifier(isActive: isActive))
|
|
}
|
|
}
|