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 Combine | |
class Driver<Output>: Publisher { | |
typealias Output = Output | |
typealias Failure = Never | |
private let anyPublisher: AnyPublisher<Output, Never> | |
private var bag = Set<AnyCancellable>() |
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 | |
precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence } | |
infix operator ^^ : PowerPrecedence | |
func ^^ (radix: Int, power: Int) -> Int { | |
return Int(pow(Double(radix), Double(power))) | |
} | |
/// First approach | |
/// |
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
// | |
// Localization.swift | |
// | |
// | |
// Created by David on 2021/3/30. | |
// | |
import Foundation | |
import Lokalise | |
import Domain |
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
#if canImport(swiftUI) && DEBUG | |
import UIKit | |
import SwiftUI | |
/// This is a UIKit preview in SwiftUI extension | |
/// With this extension, you will have a `.preview` property to get a swift ui preview view | |
@available(iOS 13.0, *) | |
extension UIViewController { | |
private struct Preview: UIViewControllerRepresentable { |
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 | |
public struct Heap<T> { | |
/** The array that stores the heap's nodes. */ | |
var nodes = [T]() | |
/** | |
* Determines how to compare two nodes in the heap. | |
* Use '>' for a max-heap or '<' for a min-heap, |
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
protocol CoordinatorType: AnyObject { | |
func start() | |
var children: [CoordinatorType] { get set } | |
} |
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
final class AppFlowController: UIViewController { | |
override func viewDidLayoutSubviews() { | |
super.viewDidLayoutSubviews() | |
childViewControllers.first?.view.frame = view.bounds | |
} | |
} |
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 DependencyContainer: AuthServiceContainer, PhoneServiceContainer, NetworkingServiceContainer, | |
LocationServiceContainer, MapServiceContainer, HealthServiceContainer { | |
let authService: AuthServiceProtocol | |
let phoneService: PhoneService | |
let networkingService: NetworkingService | |
let locationService: LocationService | |
let mapService: MapService | |
let healthService: HealthService |
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 UIView { | |
static func vstack( | |
_ views: UIView..., | |
spacing: CGFloat = 0, | |
alignment: UIStackView.Alignment = .fill, | |
distribution: UIStackView.Distribution = .fill | |
) -> UIStackView { |
NewerOlder