feat: add find keyboard shortcut

This commit is contained in:
dscyrescotti
2024-07-14 16:03:05 +07:00
parent 00d9a8e5f9
commit ca93472cd4
12 changed files with 123 additions and 17 deletions

View File

@@ -0,0 +1,29 @@
//
// 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))
}
}