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 LazyView<Content: View>: View { | |
let build: () -> Content | |
init(_ build: @autoclosure @escaping () -> Content) { | |
self.build = build | |
} | |
var body: Content { | |
build() | |
} | |
} |
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
// | |
// FacebookReactions.swift | |
// | |
// Created by Fabio Giolito on 10/06/2019. | |
// Follow me: https://twitter.com/fabiogiolito | |
// | |
import SwiftUI | |
struct FacebookReactions : View { |
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 | |
import CoreFoundation | |
import CoreGraphics | |
import CoreText | |
import Darwin | |
import Foundation | |
import SwiftUI | |
import UIKit | |
import os.log | |
import os |
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
enum Demo { | |
case simple | |
case oneValue(Int) | |
case twoValues(String, Double) | |
case threeValues(one: Int, two: Float, [Int]) | |
} | |
//: # Direct exposition in the enum | |
//: ## Sourcery Template |
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 PlaygroundSupport | |
import SwiftUI | |
extension View { | |
public func offset(by offset: CGPoint) -> Self.Modified<_OffsetEffect> { | |
self.offset(x: offset.x, y: offset.y) | |
} | |
} | |
struct LiveView : View { |
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
@discardableResult | |
public func with<T>(_ value: T, _ builder: (T) -> Void) -> T { | |
builder(value) | |
return value | |
} | |
@discardableResult | |
public func with<T>(_ value: T, _ builder: (T) throws -> Void ) rethrows -> T { | |
try builder(value) | |
return value |
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
// Douglas Hill, December 2018 | |
// Made for https://douglashill.co/reading-app/ | |
// Find the latest version of this file at https://github.com/douglashill/KeyboardKit | |
import UIKit | |
/// A table view that allows navigation and selection using a hardware keyboard. | |
/// Only supports a single section. | |
class KeyboardTableView: UITableView { | |
// These properties may be set or overridden to provide discoverability titles for key commands. |
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
func scrollToSection(_ section: Int) { | |
if let collectionView = collectionView { | |
let indexPath = IndexPath(item: 0, section: section) | |
if | |
let attributes = collectionView.layoutAttributesForItem(at: indexPath), | |
let flowLayout = collectionView.collectionViewLayout as? FlowLayout | |
{ | |
let headerHeight = flowLayout.headerReferenceSize | |
let topSectionInset = flowLayout.sectionInset.top |
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 | |
struct Handler { | |
let handleJSON: (Data) throws -> Void | |
init<T: Decodable>(handler: @escaping (T) -> Void) { | |
handleJSON = { data in | |
let object = try JSONDecoder().decode(T.self, from: data) | |
handler(object) | |
} |
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
#!/usr/bin/env bash | |
<% for type in types.classes { -%> | |
<%_ if type.attributes["final"] != nil || type.attributes["open"] != nil || types.based[type.name]?.isEmpty == false { continue } -%> | |
<%_ _%>git grep -lz 'class <%= type.name %>' | xargs -0 perl -i'' -pE "s/class <%= type.name %>(?=\s|:)/final class <%= type.name %>/g" | |
<% } %> |