44 lines
947 B
Swift
44 lines
947 B
Swift
//
|
|
// ViewExtensions.swift
|
|
// app
|
|
//
|
|
// Created by Sebastian Pobel on 06.01.20.
|
|
// Copyright © 2020 Marcus Handte. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
typealias UIState = SwiftUI.State
|
|
|
|
extension UIApplication {
|
|
func endEditing(_ force: Bool) {
|
|
self.windows
|
|
.filter{$0.isKeyWindow}
|
|
.first?
|
|
.endEditing(force)
|
|
}
|
|
}
|
|
|
|
struct ResignKeyboardOnDragGesture: ViewModifier {
|
|
var gesture = DragGesture().onChanged{_ in
|
|
UIApplication.shared.endEditing(true)
|
|
}
|
|
func body(content: Content) -> some View {
|
|
content.gesture(gesture)
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func resignKeyboardOnDragGesture() -> some View {
|
|
return modifier(ResignKeyboardOnDragGesture())
|
|
}
|
|
|
|
func eraseToAnyView () -> AnyView {
|
|
AnyView(self)
|
|
}
|
|
}
|
|
|
|
extension Font {
|
|
static var subtitle = Font.system(size: UIFontMetrics(forTextStyle: .headline).scaledValue(for: 20))
|
|
}
|