Skip to content

Instantly share code, notes, and snippets.

View yoxisem544's full-sized avatar
🥑

David Lin yoxisem544

🥑
View GitHub Profile
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>()
import UIKit
precedencegroup PowerPrecedence { higherThan: MultiplicationPrecedence }
infix operator ^^ : PowerPrecedence
func ^^ (radix: Int, power: Int) -> Int {
return Int(pow(Double(radix), Double(power)))
}
/// First approach
///
//
// Localization.swift
//
//
// Created by David on 2021/3/30.
//
import Foundation
import Lokalise
import Domain
#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 {
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,
protocol CoordinatorType: AnyObject {
func start()
var children: [CoordinatorType] { get set }
}
final class AppFlowController: UIViewController {
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
childViewControllers.first?.view.frame = view.bounds
}
}
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
@yoxisem544
yoxisem544 / HiddenContainerRecognizer.swift
Created August 17, 2022 04:04
Prevent screenshot view wrapper
import UIKit
/// Beware that if you add view to subview that has been pulled out from this recognizer,
/// calling getter will result in nil value.
struct HiddenContainerRecognizer {
private enum Error: Swift.Error {
case unsupportedIosVersion(version: Float)
case desiredContainerWasNotFound(_ containerName: String)
}
import UIKit
extension UIView {
static func vstack(
_ views: UIView...,
spacing: CGFloat = 0,
alignment: UIStackView.Alignment = .fill,
distribution: UIStackView.Distribution = .fill
) -> UIStackView {