Skip to content

Instantly share code, notes, and snippets.

View noxt's full-sized avatar
🌐
Write the code. Change the world.

Dmitry Ivanenko noxt

🌐
Write the code. Change the world.
View GitHub Profile
@noxt
noxt / NSObject+Configurable.swift
Created March 18, 2019 19:35
NSObject+Configurable
import Foundation
protocol InitConfigurable {
init()
}
extension InitConfigurable {
init(configure: (Self) -> Void) {
@noxt
noxt / IdentifiableType.swift
Created February 28, 2019 09:26
IdentifiableType
import Foundation
protocol IdentifiableType: Equatable, CustomStringConvertible {
var identity: String { get }
}
// MARK: - Equatable
@noxt
noxt / UIView+Margins.swift
Last active February 26, 2019 13:51
UIView+Margins
import UIKit
public extension UIView {
public func changeMargings(insets: UIEdgeInsets) {
if #available(iOS 11, *) {
directionalLayoutMargins = NSDirectionalEdgeInsets(top: insets.top, leading: insets.left, bottom: insets.bottom, trailing: insets.right)
} else {
layoutMargins = insets
}
}
@noxt
noxt / UIViewController+SafeAnchor.swift
Last active February 26, 2019 13:51
UIViewController+SafeAnchor
import UIKit
public extension UIViewController {
public var safeTopAnchor: NSLayoutYAxisAnchor {
if #available(iOS 11, *) {
return view.safeAreaLayoutGuide.topAnchor
} else {
return topLayoutGuide.bottomAnchor
}
}
@noxt
noxt / AppDelegate.swift
Created February 19, 2019 11:50
AppDelegate
// App/AppDelegate.swift
import Unicore
typealias AppCore = Core<AppFeature.State>
let core = AppCore(state: .initial, reducer: AppFeature.reduce)
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
@noxt
noxt / AppReducer.swift
Created February 19, 2019 11:46
AppFeature Reducer
// Features/App/AppReducer.swift
extension AppFeature {
static func reduce(_ old: State, with action: Action) -> State {
return State(
accountsState: AccountsFeature.reduce(old.accountsState, with: action),
categoriesState: CategoriesFeature.reduce(old.categoriesState, with: action),
keyboardState: KeyboardFeature.reduce(old.keyboardState, with: action),
transactionState: TransactionFeature.reduce(old.transactionState, with: action)
)
@noxt
noxt / AppState.swift
Created February 19, 2019 11:43
AppFeature State
// Features/App/AppState.swift
extension AppFeature {
struct State: Codable {
let accountsState: AccountsFeature.State
let categoriesState: CategoriesFeature.State
let keyboardState: KeyboardFeature.State
let transactionState: TransactionFeature.State
@noxt
noxt / CategoriesScene.swift
Last active February 19, 2019 11:28
Component Scene
// Components/Categories/CategoriesScene.swift
struct CategoriesScene {
static func makeScene(with repositories: RepositoryProviderProtocol) -> Scene<CategoriesConnector, CategoriesComponent> {
let connector = CategoriesConnector(repositories: repositories)
let component = CategoriesComponent(connector: connector)
return Scene(connector, component)
}
}
@noxt
noxt / CategoriesComponent.swift
Last active February 19, 2019 11:29
Component
// Components/Categories/CategoriesComponent.swift
final class CategoriesComponent: UIViewController, Component {
// Props
private let connector: CategoriesConnector!
var props: CategoriesProps! {
didSet {
guard props != oldValue else {
@noxt
noxt / CategoriesConnector.swift
Last active April 10, 2019 09:44
Component Connector
// Components/Categories/CategoriesConnector.swift
final class CategoriesConnector: Connector {
private let disposer = Disposer()
let repositories: RepositoryProviderProtocol
required init(repositories: RepositoryProviderProtocol) {