This file contains 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 | |
extension UITabBarController { | |
/// Extends the size of the `UITabBarController` view frame, pushing the tab bar controller off screen. | |
/// - Parameters: | |
/// - hidden: Hide or Show the `UITabBar` | |
/// - animated: Animate the change | |
func setTabBarHidden(_ hidden: Bool, animated: Bool) { | |
guard let vc = selectedViewController else { return } | |
guard tabBarHidden != hidden else { return } |
This file contains 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 | |
import SwiftUI | |
#if canImport(UIKit) | |
import UIKit | |
#elseif canImport(AppKit) | |
import AppKit | |
#endif | |
extension Image { | |
/// Initializes a SwiftUI `Image` from data. |
This file contains 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
/// This is a list of Hypertext Transfer Protocol (HTTP) response status codes. | |
/// It includes codes from IETF internet standards, other IETF RFCs, other specifications, and some additional commonly used codes. | |
/// The first digit of the status code specifies one of five classes of response; an HTTP client must recognise these five classes at a minimum. | |
#if canImport(Foundation) | |
import Foundation | |
#else | |
import FoundationNetworking | |
#endif |
This file contains 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 MKCoordinateRegion { | |
/// Initialize a `MKCoordinateRegion` from a set of `MKAnnotations` | |
/// - Parameter annotations: Annotations | |
init(for annotations: [MKAnnotation]) { | |
var minLat: CLLocationDegrees = 90.0 | |
var maxLat: CLLocationDegrees = -90.0 | |
var minLon: CLLocationDegrees = 180.0 | |
var maxLon: CLLocationDegrees = -180.0 | |
for annotation in annotations { |
This file contains 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
/// Property wrapper that provides control over whether to explicitly encode nil values to json or not. | |
/// - Parameters: | |
/// - wrappedValue: the value to be encoded. | |
/// - encodeNil: Should the value be explicitly encoded as "null" in json if nil. | |
/// - Note: | |
/// Usage: | |
/// | |
/// ```swift | |
/// struct MyStruct: Codable { | |
/// @NilCodable var myNullable: String? // defaults to omitting null (codable default behavior) |
This file contains 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
/// Resizes to fit its content. Or until size reaches provided constraints. | |
final class ContentResizingTableView: UITableView { | |
override var contentSize: CGSize { | |
didSet { | |
invalidateIntrinsicContentSize() | |
} | |
} | |
override var intrinsicContentSize: CGSize { | |
layoutIfNeeded() |
This file contains 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 | |
/// Standard HTTP Methods | |
enum HTTPMethod: String { | |
case options = "OPTIONS" | |
case get = "GET" | |
case head = "HEAD" | |
case post = "POST" | |
case put = "PUT" | |
case patch = "PATCH" |
This file contains 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 | |
/// Static properties for all preview devices. | |
/// | |
/// Usage: | |
/// | |
/// ```swift | |
/// struct TestView_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// Group { |
This file contains 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 extension View { | |
/// Exposes the size of the specified view | |
/// - Parameter onChange: This function will be called when the size of a view changes. | |
/// - Returns: some View | |
func onSizeChange(onChange: @escaping (CGSize) -> Void) -> some View { | |
modifier(SizeReader(onChange: onChange)) | |
} | |
} |
This file contains 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 extension View { | |
func onSafeAreaChange(onChange: @escaping (EdgeInsets) -> Void) -> some View { | |
modifier(SafeAreaReader(onChange: onChange)) | |
} | |
} | |
internal struct SafeAreaReader: ViewModifier { | |
var onChange: (EdgeInsets) -> Void |
OlderNewer