Skip to content

Instantly share code, notes, and snippets.

View 0xLeif's full-sized avatar
🇺🇦
Updating projects to Swift 6

Leif 0xLeif

🇺🇦
Updating projects to Swift 6
  • 🏔️
  • 06:15 (UTC -06:00)
View GitHub Profile
@0xLeif
0xLeif / DynamicTable.swift
Created January 20, 2020 23:04
DynamicTable
//
// DynamicTable.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 1/19/20.
//
import UIKit
@available(iOS 9.0, *)
@0xLeif
0xLeif / fb.swift
Created February 1, 2020 21:15
@_functionBuilder example
import UIKit
@_functionBuilder
public struct StringBuilder {
public static func buildBlock(_ string: String) -> String { string }
public static func buildBlock(_ strings: String...) -> String {
strings.joined(separator: "")
}
@0xLeif
0xLeif / BrandedLoadingView.swift
Created February 18, 2020 16:11
SwiftUIKit Custom Loading View
class BrandedLoadingView: UIView {
fileprivate var spinnerView = View()
fileprivate var topLeftSpinnerView = View()
.layer { $0.addSublayer(dotLayer()) }
fileprivate var bottomRightSpinnerView = View()
.configure {
$0.transform = $0.transform.rotated(by: .pi)
}
.layer { $0.addSublayer(dotLayer()) }
@0xLeif
0xLeif / GitHub_repos.swift
Created February 20, 2020 19:48
Init Call for GitHubSocial
import Foundation
import UIKit
import Combine
extension AnyPublisher {
func value(_ closure: @escaping ((Output) -> Void)) -> AnyCancellable {
sink(receiveCompletion: { _ in }, receiveValue: closure)
}
}
@0xLeif
0xLeif / SwiftFormat.sh
Created March 15, 2020 17:08
Format All Swift Files in a Project
find -path "./.*" -prune -o -name "*.swift" | grep -i ".swift" | xargs swift format -in-place
@0xLeif
0xLeif / tableExample.swift
Last active May 22, 2020 18:35
TableView_DidSelectRow_Issue
import UIKit
import SwiftUIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.embed {
TableView().register(cells: [DataCell.self])
@0xLeif
0xLeif / StyleView.swift
Created June 24, 2020 23:34
Simple StyleView in SwiftUI
//
// ContentView.swift
// Shared
//
// Created by Zach Eriksen on 6/24/20.
//
import SwiftUI
import SF
@0xLeif
0xLeif / Switched.swift
Created July 7, 2020 19:49
One Line Switch
func switched<T: Hashable, O>(_ value: T,
cases: [T: O?],
default defaultCase: O? = nil) -> O? {
guard let switchCase = cases[value] else {
return defaultCase
}
return switchCase
}
@0xLeif
0xLeif / color-gen.swift
Created August 4, 2020 20:58
ColorDump
import Combine
var bag = [AnyCancellable]()
struct Color {
let name: String
let hex: String
}
extension Color: CustomStringConvertible {
@0xLeif
0xLeif / build_iOS.yml
Created August 5, 2020 22:38
Swift iOS GitHub Action
iOS:
runs-on: macOS-latest
steps:
- name: Select latest available Xcode
uses: maxim-lobanov/[email protected]
with:
xcode-version: latest
- name: Checkout code
uses: actions/checkout@v2
# Since we want to be running our tests from Xcode, we need to