refactor: generalize end_editing
might be useful... we shall see Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -24,16 +24,17 @@ public struct DismissKeyboardOnTap: ViewModifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var tapGesture: some Gesture {
|
private var tapGesture: some Gesture {
|
||||||
TapGesture().onEnded(endEditing)
|
TapGesture().onEnded(end_editing)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func endEditing() {
|
}
|
||||||
UIApplication.shared.connectedScenes
|
|
||||||
.filter {$0.activationState == .foregroundActive}
|
func end_editing() {
|
||||||
.map {$0 as? UIWindowScene}
|
UIApplication.shared.connectedScenes
|
||||||
.compactMap({$0})
|
.filter {$0.activationState == .foregroundActive}
|
||||||
.first?.windows
|
.map {$0 as? UIWindowScene}
|
||||||
.filter {$0.isKeyWindow}
|
.compactMap({$0})
|
||||||
.first?.endEditing(true)
|
.first?.windows
|
||||||
}
|
.filter {$0.isKeyWindow}
|
||||||
|
.first?.endEditing(true)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user