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 | |
import WebKit | |
class WKWebViewController: UIViewController { | |
var request: URLRequest? | |
weak var uiDelegate: WKUIDelegate? | |
weak var navigationDelegate: WKNavigationDelegate? | |
lazy var webView: WKWebView = { |
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 Constraint = (UIView, UIView) -> NSLayoutConstraint | |
func equal<L, Axis>(_ to: KeyPath<UIView, L>, constant: CGFloat = 0, priority: UILayoutPriority? = nil) -> Constraint where L: NSLayoutAnchor<Axis> { | |
return equal(to, to, constant: constant, priority: priority) | |
} | |
func equal<L, Axis>(_ from: KeyPath<UIView, L>, _ to: KeyPath<UIView, L>, constant: CGFloat = 0, priority: UILayoutPriority? = nil) -> Constraint where L: NSLayoutAnchor<Axis> { | |
return { view1, view2 in |
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
pre_install do |installer| | |
installer.pod_targets.each do |target| | |
if ['Mockingjay', 'URITemplate'].include? target.name | |
target.root_spec.swift_version = '4.2' | |
else | |
target.root_spec.swift_version = '5.0' | |
end | |
end | |
end |
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
var directory: ObjCBool = false | |
var exists: Bool = FileManager.default.fileExists(atPath: "…", isDirectory: &directory) | |
if exists { | |
if directory.boolValue { | |
// Exists. Directory. | |
} else { | |
// Exists. | |
} | |
} else { |
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
public struct FirebasePreprocessorToken { | |
public static let `default` = FirebasePreprocessorToken() | |
private init() { | |
#if RELEASE | |
let googleServiceInfoPlist = "GoogleService-Info" | |
#elseif STAGING | |
let googleServiceInfoPlist = "GoogleService-Info-Stg" | |
#else | |
let googleServiceInfoPlist = "GoogleService-Info-Dev" |
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 | |
extension Date { | |
var elasticDateFormat: String { | |
let calendar = Calendar.current | |
let date = Date() | |
let dateInterval = calendar.dateInterval(of: .month, for: self) | |
if calendar.dateInterval(of: .day, for: self)!.contains(date) { | |
return "HH:mm" |
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 Hoge: Storagable { | |
let id: Int | |
let name: String | |
} | |
protocol Storagable: Codable {} | |
extension Storagable { | |
func save(key: String = "\(Self.self)", userDefaults: UserDefaults = .standard) throws { | |
let data = try JSONEncoder().encode(self) |
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
let labelColorStyle = { set(\UILabel.textColor, $0) } | |
let primaryLabelStyle = labelColorStyle(UIColor.green) | |
let label = UILabel() |> primaryLabelStyle |
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 | |
let paragraphStyle = NSMutableParagraphStyle() | |
paragraphStyle.alignment = .center | |
NSMutableParagraphStyle() |> (prop(\.alignment)) { _ in .center } | |
func set<Root, Value>( | |
_ kp: WritableKeyPath<Root, Value>, | |
_ value: 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
func prop<Root, Value>( | |
_ kp: WritableKeyPath<Root, Value> | |
) | |
-> (@escaping (Value) -> Value) | |
-> (Root) -> Root { | |
return { transformPart in | |
return { root in | |
var root = root | |
root[keyPath: kp] = transformPart(root[keyPath: kp]) | |
return root |