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 | |
#if DEBUG | |
/// Describes a objects as a dictionary. | |
/// - Used for debugging or testing purpuses. | |
public protocol DictionaryRepresentable {} | |
public extension DictionaryRepresentable { | |
func asDictionary() -> [String: Any] { | |
var dictionary: [String: Any] = .init() | |
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
# General Options | |
--swiftversion 5.7 | |
# File Options | |
--exclude **.generated.swift, **.testing.swift ## use this to exclude whatever you need, in my case I have all generated files and testing utils with the extensions presented here. | |
# Format Options | |
--allman false | |
--binarygrouping none | |
--closingparen balanced |
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 | |
import Introspect | |
import UIKit | |
struct ContentView: View { | |
@ObservedObject private var viewModel = ViewModel() | |
var body: some View { | |
NavigationView { | |
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
// 1. Feature definition (Module entry point / Root) | |
public struct ActivitiesFeatureRoutesHandler: RoutesHandler { | |
public var routes: [SceneRoute.Type] { | |
[ | |
WODListRoute.self, | |
WODRouletteRoute.self, | |
WODDetailsRoute.self | |
] | |
} |
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 | |
protocol ErasedType { | |
var erasedValue: Any { get } | |
} | |
extension ErasedType { | |
func recursivelyUnwrap<T>(as type: T.Type) -> T? { | |
return recrusivelyUnwrapErasedType( | |
value: erasedValue, | |
originalType: T.self, |
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 Combine | |
public struct SomeRepository { | |
// Well defined errors, when possible. | |
public enum Error: Swift.Error { | |
case invalidData | |
} | |
// Public API as closures. | |
public let getList: () -> AnyPublisher<[String], Error> |
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
/// Defines the `SomeRepository` contract. | |
protocol SomeRepositoryProtocol { | |
/// Gets the list from service or cache. | |
/// - Parameter completion: returns the list | |
func getList(then completion: @escaping ([String]?) -> Void) | |
} | |
struct SomeRepository: SomeRepositoryProtocol { | |
// MARK: - Dependencies | |
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
/// Defines the `SomeRepository` contract. | |
protocol SomeRepositoryProtocol { | |
/// Returns the cached data. | |
var cachedList: [String]? { get } | |
/// Gets the list from service or cache. | |
/// - Parameter completion: returns the list | |
func getList(then completion: @escaping ([String]?) -> Void) | |
} |
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
// Implementation | |
public protocol UIKitEnvironmentKey { | |
associatedtype Value | |
static var defaultValue: Value { get } | |
} | |
public struct UIKitEnvironmentValues: CustomStringConvertible { | |
private class Wrapper { | |
init() {} | |
var value: Any? |
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
struct ToSwiftUIView<UIKitView: UIView>: UIViewRepresentable { | |
typealias UIViewType = UIKitView | |
let uikitView: () -> UIKitView | |
func makeUIView(context: Context) -> UIKitView { | |
uikitView() | |
} | |
func updateUIView(_ uiView: UIKitView, context: Context) {} | |
} |
NewerOlder