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
| static const CGFloat kFontWeightEpsilon = FLT_EPSILON; | |
| @implementation UIFont (CustomizedDynamicType) | |
| + (nonnull UIFont *)preferredFontWithDefaultSize:(CGFloat)size | |
| textStyle:(nonnull UIFontTextStyle)textStyle { | |
| return [self preferredFontWithDefaultSize:size | |
| textStyle:textStyle | |
| fontWeight:UIFontWeightRegular | |
| italic:NO]; |
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 Data { | |
| init?(hexString: String) { | |
| let count = hexString.count / 2 | |
| var data = Data(capacity: count) | |
| var i = hexString.startIndex | |
| for _ in 0 ..< count { | |
| let j = hexString.index(after: i) | |
| if var byte = UInt8(hexString[i ... j], radix: 16) { | |
| data.append(&byte, count: 1) | |
| } 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
| // | |
| // EmptySwiftUIModifiers.swift | |
| // Architectory | |
| // | |
| // Created by Nikita Patskov on 09.09.2020. | |
| // | |
| import SwiftUI | |
| struct TestView: View { |
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
| let queue = DispatchQueue(label: "Queue", qos: .default, attributes: [.concurrent], autoreleaseFrequency: .workItem, target: .global(qos: .default)) | |
| let cancellable = [1, 2, 3, 4, 5].publisher | |
| .receive(on: queue) | |
| .map { longRunningFunc(value: $0) } | |
| .receive(on: DispatchQueue.main) | |
| .sink (receiveCompletion: { completion in | |
| Swift.print(completion) | |
| }, receiveValue: { value in | |
| Swift.print(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
| struct __ValueType__ { | |
| } | |
| struct __ValueType__Key: EnvironmentKey { | |
| static var defaultValue = __ValueType__() | |
| } | |
| extension EnvironmentValues { | |
| var __KeyName__: __ValueType__ { | |
| get { |
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 Result { | |
| public func `catch`(_ handler: () throws -> Success) -> Result<Success, Error> { | |
| flatMapError { _ in | |
| .init { try handler() } | |
| } | |
| } | |
| public func `catch`(_ handler: (Failure) throws -> Success) -> Result<Success, Error> { | |
| flatMapError { error in | |
| .init { try handler(error) } |
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
| // Copyright © 2020 Michael Gubik. All rights reserved. Created on 2020-05-16. | |
| import Foundation | |
| #if TEST | |
| import Sentry | |
| #endif | |
| // maybe look into os_log: https://stackoverflow.com/a/25951564/11588848 | |
| private enum LogLevel: 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
| import SwiftUI | |
| @available(iOS 14.0, *) | |
| public struct ColorPickerWithoutLabel: UIViewRepresentable { | |
| @Binding var selection: Color | |
| var supportsAlpha: Bool = true | |
| public init(selection: Binding<Color>, supportsAlpha: Bool = true) { | |
| self._selection = selection | |
| self.supportsAlpha = supportsAlpha |
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 ContentView: View { | |
| var body: some View { | |
| Image(nsImage: NSImage(named: .init(NSImage.applicationIconName))!) | |
| .resizable() | |
| .frame(width: 100, height: 100) | |
| .tapWithHighlight(onTap: { | |
| print("Tap") | |
| }, onLongPress: { | |
| print("Long Press") | |
| }) |
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 ViewController: UIViewController { | |
| @IBAction func onSearch(_ sender: Any) { | |
| let fakeWindow = UIWindow(windowScene: view.window!.windowScene!) | |
| let fakeTextField = UITextField() | |
| fakeTextField.autocorrectionType = .no | |
| fakeWindow.addSubview(fakeTextField) | |
| fakeWindow.makeKeyAndVisible() | |
| fakeTextField.becomeFirstResponder() |