This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension UIApplication { | |
| func addTapGestureRecognizer() { | |
| guard let window = windows.first else { return } | |
| let tapGesture = UITapGestureRecognizer(target: window, action: #selector(UIView.endEditing)) | |
| tapGesture.cancelsTouchesInView = false | |
| tapGesture.delegate = self | |
| tapGesture.name = "MyTapGesture" | |
| window.addGestureRecognizer(tapGesture) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension UIApplication: UIGestureRecognizerDelegate { | |
| public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool { | |
| return false // set to `false` if you don't want to detect tap during other gestures | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @main | |
| struct TestApp: App { | |
| var body: some Scene { | |
| WindowGroup { | |
| ContentView() | |
| .onAppear(perform: UIApplication.shared.addTapGestureRecognizer) | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SceneDelegate: UIResponder, UIWindowSceneDelegate { | |
| var window: UIWindow? | |
| func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
| let contentView = ContentView() | |
| if let windowScene = scene as? UIWindowScene { | |
| let window = UIWindow(windowScene: windowScene) | |
| window.rootViewController = UIHostingController(rootView: contentView) | |
| self.window = window | |
| window.makeKeyAndVisible() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct NumericTextField<T>: UIViewRepresentable { | |
| private var title: String | |
| @Binding var value: T | |
| private var formatter: NumberFormatter | |
| @State var errorMessage = "" | |
| private var keyboardType: UIKeyboardType | |
| init(title: String = "", value: Binding<T>, numberFormatter: NumberFormatter, keyboardType: UIKeyboardType) { | |
| self.title = title | |
| self._value = value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension String { | |
| init?(htmlEncodedString: String) { | |
| guard let data = htmlEncodedString.data(using: .utf8) else { | |
| return nil | |
| } | |
| let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [ | |
| .documentType: NSAttributedString.DocumentType.html, | |
| .characterEncoding: String.Encoding.utf8.rawValue | |
| ] | |
| guard let attributedString = try? NSAttributedString(data: data, options: options, documentAttributes: nil) else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct PostData: Decodable { | |
| let userId: Int | |
| let id: Int | |
| let title: String | |
| let body: String | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // swift-tools-version:5.5 | |
| // The swift-tools-version declares the minimum version of Swift required to build this package. | |
| import PackageDescription | |
| ... | |
| let package = Package( | |
| name: "SwiftNCurses", | |
| products: [, | |
| targets: [ |