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 { | |
public func fuzzilyMatches(string: String, separatorsSet: CharacterSet = .whitespacesAndNewlines) -> Bool { | |
let matchComponents = string.lowercased().components(separatedBy: separatorsSet) | |
return lowercased() | |
.components(separatedBy: separatorsSet) | |
.contains { candidate in | |
matchComponents.contains { | |
candidate.contains($0) |
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 Foundation | |
public extension UIView { | |
func compactSystemLayoutFittingSizeFor(width: CGFloat) -> CGSize { | |
let targetSize = CGSize( | |
width: width, | |
height: UIView.layoutFittingCompressedSize.height | |
) |
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
public extension Array where Element: Hashable { | |
func withoutDuplicates() -> [Element] { | |
var seen = Set<Element>() | |
return filter { seen.insert($0).inserted } | |
} | |
} |
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 Foundation | |
public extension String { | |
func calculateSize(attributes: [NSAttributedString.Key: Any], constrainedSize: CGSize) -> CGSize { | |
let rect = (self as NSString).boundingRect( | |
with: constrainedSize, | |
options: [.usesLineFragmentOrigin, .usesFontLeading], | |
attributes: attributes, | |
context: nil |
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
private let hashableId = UUID() | |
@propertyWrapper | |
public struct IgnoreHashable<T>: Hashable { | |
public let wrappedValue: T | |
public init(wrappedValue: T) { | |
if wrappedValue is AnyHashable { | |
AssertionFailure("Hashable types shouldn't ignore its hash 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
import SwiftUI | |
public class HostingCollectionReusableView<Content: View>: UICollectionReusableView { | |
private let hostingController = UIHostingController<Content?>(rootView: nil, ignoreSafeArea: true) | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
setup() | |
} |
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 UIKit | |
public extension UIControl { | |
typealias OnTouchUpInside = () -> Void | |
private struct Constants { | |
static var callbackKey = "UIControl.OnTouchUpInsideAssociatedKey" | |
} | |
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 | |
extension UIHostingController { | |
convenience public init(rootView: Content, ignoreSafeArea: Bool) { | |
self.init(rootView: rootView) | |
if ignoreSafeArea { | |
disableSafeArea() | |
} |