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
// | |
// ZoomTransitionAnimator.swift | |
// ScrapBeta | |
// | |
// Created by Li-Heng Hsu on 06/12/2017. | |
// Copyright © 2017 Li-Heng Hsu. All rights reserved. | |
// | |
import UIKit |
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
// | |
// UITextView+isEditableWhenBeingDataDetectable.swift | |
// | |
// Created by Li-Heng Hsu on 15/05/2018. | |
// Copyright © 2018 narrativesaw. All rights reserved. | |
// | |
import UIKit | |
extension UITextView { |
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
// | |
// UITextView+placeholder.swift | |
// | |
// Created by Li-Heng Hsu on 02/06/2018. | |
// Copyright © 2018 narrativesaw. All rights reserved. | |
// | |
import UIKit | |
private let defaultPlaceholderColor = UIColor.gray |
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 | |
// 基礎協定 | |
// 每個套用 Endpoint 的型別都有固定的回傳型別,所以如果回傳的型別不同,就要宣告不同的 Endpoint 型別。 | |
protocol Endpoint { | |
// Endpoint 所關聯的回傳型別 | |
associatedtype Result: Codable | |
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
@dynamicMemberLookup | |
public struct FluentInterface<Root> { | |
public let root: Root | |
public subscript<Value>(dynamicMember keyPath: WritableKeyPath<Root, Value>) -> (Value) -> Self { | |
var root = self.root | |
return { newValue in | |
root[keyPath: keyPath] = newValue | |
return FluentInterface(root: root) | |
} |
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
// MARK: Core | |
public typealias DeactivateHandler = () -> Void | |
public struct AsyncTask<Success, Failure> where Failure: Error { | |
public var activate: (@escaping (Success) -> Void, @escaping (Failure) -> Void) -> DeactivateHandler | |
} | |
extension AsyncTask where Failure == Never { |
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 makeObject() -> (getter: () -> String, setter: (String) -> Void) { | |
var text = "Hello " | |
return ( | |
getter: { text }, | |
setter: { text = $0 } | |
) | |
} | |
let object = makeObject() |
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 | |
typealias MutableContext<Value> = (@escaping (inout Value) -> Void) -> Void | |
class MasterViewController: UITableViewController { | |
var models = [String]() | |
// 點選 cell 時會呼叫的工廠方法。 | |
func makeDetailViewController(indexPath: IndexPath) -> DetailViewController? { |
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
@dynamicMemberLookup | |
protocol JSONType { | |
subscript(dynamicMember member: String) -> JSONType? { get set } | |
} | |
extension JSONType { | |
subscript(dynamicMember member: String) -> JSONType? { | |
get { nil } | |
set { } | |
} | |
subscript<T>(type: T.Type) -> T? { |
OlderNewer