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 lightThemeModel = MyThemeModel( | |
appBgColor: .white, | |
textColor: .black) | |
let darkThemeModel = MyThemeModel( | |
appBgColor: .darkGray, | |
textColor: .white) |
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
@objc protocol Themable { | |
func applyTheme(_ theme: MyTheme) | |
} |
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
// | |
// TitlePosition.swift | |
// PileCollectionVC | |
// | |
// Created by Rik Ki on 11/9/18. | |
// Copyright © 2018 Rik Ki. All rights reserved. | |
// | |
import Foundation |
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 MyTheme { | |
case light | |
case dark | |
var settings: MyThemeSettings { | |
switch self { | |
case .light: return MyThemeSettings.lightTheme | |
case .dark: return MyThemeSettings.darkTheme | |
} | |
} | |
} |
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
@objc enum MyTheme: Int { | |
case light | |
case dark | |
var settings: MyThemeSettings { | |
switch self { | |
case .light: return MyThemeSettings.lightTheme | |
case .dark: return MyThemeSettings.darkTheme | |
} | |
} | |
} |
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 protocol ThemeModelProtocol {} | |
public protocol ThemeProtocol: Equatable { | |
associatedtype Model: ThemeModelProtocol | |
var settings: Model { get } | |
} |
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
extension Themer where Theme == MyTheme { | |
private static var instance: Themer? | |
static var shared: Themer { | |
if instance == nil { | |
instance = Themer(defaultTheme: .light) | |
} | |
return instance! | |
} | |
} |
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 | |
final class ShareReplay<Upstream: Publisher>: Publisher { | |
typealias Output = Upstream.Output | |
typealias Failure = Upstream.Failure | |
var recording = Record<Output, Failure>.Recording() | |
var upstreamShare: AnyPublisher<Output, Failure> | |
let bufferCapacity: Int | |
var subscription: AnyCancellable? |
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 | |
let measurements = PassthroughSubject<Int, Never>() | |
let diagramDataSource = measurements | |
.share(replay: 3) | |
let subscriber1 = diagramDataSource | |
.sink( | |
receiveCompletion: { completion 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
import UIKit | |
import Combine | |
extension UITextField { | |
var textPublisher: AnyPublisher<String?, Never> { | |
NotificationCenter.default | |
.publisher( | |
for: UITextField.textDidChangeNotification, | |
object: self) | |
.map(\.object) |
OlderNewer