Add Core and UIKit subspecs to Gluon.podspec
This commit is contained in:
parent
072c37f693
commit
595b0d41aa
|
@ -2,5 +2,5 @@ platform :ios, '9.0'
|
|||
use_frameworks!
|
||||
|
||||
target 'Gluon_Example' do
|
||||
pod 'Gluon', :path => '../'
|
||||
pod 'Gluon/UIKit', :path => '../'
|
||||
end
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
PODS:
|
||||
- Gluon (0.1.0)
|
||||
- Gluon/Core (0.1.0)
|
||||
- Gluon/UIKit (0.1.0):
|
||||
- Gluon/Core
|
||||
|
||||
DEPENDENCIES:
|
||||
- Gluon (from `../`)
|
||||
- Gluon/UIKit (from `../`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Gluon:
|
||||
:path: "../"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Gluon: 64d89b9a383e0e5d570bd66cba1e5537ece85454
|
||||
Gluon: 72739e8e7543b0e586a01e153f724f4cde917151
|
||||
|
||||
PODFILE CHECKSUM: cc59d174d17ab62ebcc753b893ddecc8b72783bd
|
||||
PODFILE CHECKSUM: 04f303581f66676a6c3d5ee819cb24a969fee974
|
||||
|
||||
COCOAPODS: 1.6.0.beta.2
|
||||
|
|
|
@ -26,11 +26,18 @@ TODO: Add long description of the pod here.
|
|||
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
|
||||
s.author = { 'Max Desiatov' => 'max@desiatov.com' }
|
||||
s.source = { :git => 'https://github.com/maxdesiatov/Gluon.git', :tag => s.version.to_s }
|
||||
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
|
||||
s.social_media_url = 'https://twitter.com/MaxDesiatov'
|
||||
|
||||
s.ios.deployment_target = '9.0'
|
||||
|
||||
s.source_files = 'Gluon/Source/**/*'
|
||||
s.subspec 'Core' do |ss|
|
||||
ss.source_files = 'Sources/Gluon/**/*'
|
||||
end
|
||||
|
||||
s.subspec 'UIKit' do |ss|
|
||||
ss.source_files = 'Sources/GluonUIKit/**/*'
|
||||
ss.dependency 'Gluon/Core'
|
||||
end
|
||||
|
||||
# s.resource_bundles = {
|
||||
# 'Gluon' => ['Gluon/Assets/*.png']
|
||||
|
|
|
@ -1,136 +0,0 @@
|
|||
//
|
||||
// RequiredInit.swift
|
||||
// FBSnapshotTestCase
|
||||
//
|
||||
// Created by Max Desiatov on 07/10/2018.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public typealias Closure<T> = Unique<T>
|
||||
|
||||
protocol ComponentType {
|
||||
}
|
||||
|
||||
open class BaseComponent<Props: Equatable>: ComponentType {
|
||||
private(set) var props: Props
|
||||
private(set) var children: [Node]
|
||||
|
||||
public required init(props: Props, children: [Node]) {
|
||||
self.props = props
|
||||
self.children = children
|
||||
}
|
||||
|
||||
public static func node(_ props: Props, childrenFactory: () -> [Node]) -> Node {
|
||||
let children = childrenFactory()
|
||||
return Node {
|
||||
self.init(props: props, children: children)
|
||||
}
|
||||
}
|
||||
|
||||
public static func node(_ props: Props, childFactory: () -> Node) -> Node {
|
||||
// applying `childFactory` here to avoid `@escaping` attribute
|
||||
let child = childFactory()
|
||||
return Node { self.init(props: props, children: [child]) }
|
||||
}
|
||||
|
||||
public static func node(_ props: Props) -> Node {
|
||||
return Node { self.init(props: props, children: []) }
|
||||
}
|
||||
}
|
||||
|
||||
extension String: ComponentType {
|
||||
}
|
||||
|
||||
final class Fragment: BaseComponent<NoProps> {
|
||||
}
|
||||
|
||||
extension BaseComponent where Props: Default {
|
||||
public static func node(childrenFactory: () -> [Node]) -> Node {
|
||||
return self.node(Props(), childrenFactory: childrenFactory)
|
||||
}
|
||||
|
||||
public static func node(childFactory: () -> Node) -> Node {
|
||||
return self.node(Props(), childFactory: childFactory)
|
||||
}
|
||||
|
||||
public static func node() -> Node {
|
||||
return Node { self.init(props: Props(), children: []) }
|
||||
}
|
||||
}
|
||||
|
||||
public struct Node {
|
||||
fileprivate let factory: () -> ComponentType
|
||||
}
|
||||
|
||||
extension Node: ExpressibleByStringLiteral {
|
||||
public init(stringLiteral: String) {
|
||||
factory = { stringLiteral }
|
||||
}
|
||||
}
|
||||
|
||||
extension Node {
|
||||
public init(_ string: String) {
|
||||
factory = { string }
|
||||
}
|
||||
|
||||
public init(_ nodes: [Node]) {
|
||||
factory = { Fragment(props: NoProps(), children: nodes) }
|
||||
}
|
||||
}
|
||||
|
||||
public final class StackView: BaseComponent<NoProps> {
|
||||
}
|
||||
|
||||
public final class Label: BaseComponent<Label.Props> {
|
||||
public struct Props: Equatable, Default {
|
||||
let fontColor: Color
|
||||
|
||||
public init() {
|
||||
fontColor = .black
|
||||
}
|
||||
|
||||
public init(fontColor: Color) {
|
||||
self.fontColor = fontColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final class Button: BaseComponent<Button.Props> {
|
||||
public struct Props: Equatable {
|
||||
let backgroundColor: Color
|
||||
let fontColor: Color
|
||||
let onPress: Unique<() -> ()>
|
||||
|
||||
public init(backgroundColor: Color = .white, fontColor: Color = .black,
|
||||
onPress: Unique<() -> ()>) {
|
||||
self.backgroundColor = backgroundColor
|
||||
self.fontColor = fontColor
|
||||
self.onPress = onPress
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public protocol CompositeComponent {
|
||||
func render() -> Node
|
||||
}
|
||||
|
||||
public protocol StateType: Default & Equatable {
|
||||
}
|
||||
|
||||
open class StatefulComponent<Props: Equatable, State: StateType>:
|
||||
BaseComponent<Props> {
|
||||
public private(set) var state: State
|
||||
|
||||
public required init(props: Props, children: [Node]) {
|
||||
state = State()
|
||||
super.init(props: props, children: children)
|
||||
}
|
||||
|
||||
public func setState(setter: (inout State) -> ()) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public typealias Component<P: Equatable, S: StateType> =
|
||||
StatefulComponent<P, S> & CompositeComponent
|
|
@ -10,9 +10,10 @@ import Foundation
|
|||
/// Generic undo-redo manager that doesn't require rollback implementation in
|
||||
/// `apply` of a wrapped store. It saves previous snapshots of state in a stack
|
||||
/// and undo/redo actions allow traversing the state history. This might be
|
||||
/// not very efficient in terms of memory, but we also could require an initial
|
||||
/// state and recreate subsequent snapshots by calling `apply` with a sequence
|
||||
/// of actions
|
||||
/// not very efficient in terms of memory, but only requires an initial
|
||||
/// state and can recreate subsequent snapshots by calling `apply` with
|
||||
/// a sequence of actions. This means you can add undo-redo history to
|
||||
/// any `Store`.
|
||||
public struct History<S: Store>: Store {
|
||||
public enum Action {
|
||||
case branch(S.Action)
|
||||
|
@ -57,28 +58,28 @@ public protocol Store {
|
|||
}
|
||||
|
||||
// FIXME: need context working for its implementation
|
||||
public final class StoreProvider<S>: Component<StoreProvider.Props, S>
|
||||
where S: Store & StateType {
|
||||
struct Props: Equatable {
|
||||
/// FIXME: should store comparison be optimised this way?
|
||||
let store: Unique<S>
|
||||
}
|
||||
|
||||
func dispatch(action: S.Action) {
|
||||
setState { $0.apply(action: action) }
|
||||
}
|
||||
|
||||
public func render() -> Node {
|
||||
// FIXME: create a context here
|
||||
return Node(children)
|
||||
}
|
||||
}
|
||||
|
||||
typealias Dispatch<Action> = (Action) -> ()
|
||||
typealias Dispatcher<S: Store> = (state: S.State, dispatch: Dispatch<S.Action>)
|
||||
//public final class StoreProvider<S>: Component<StoreProvider.Props, S>
|
||||
//where S: Store & StateType {
|
||||
// struct Props: Equatable {
|
||||
// /// FIXME: should store comparison be optimised this way?
|
||||
// let store: Unique<S>
|
||||
// }
|
||||
//
|
||||
// func dispatch(action: S.Action) {
|
||||
// setState { $0.apply(action: action) }
|
||||
// }
|
||||
//
|
||||
// public func render() -> Node {
|
||||
// // FIXME: create a context here
|
||||
// return Node(children)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//typealias Dispatch<Action> = (Action) -> ()
|
||||
//typealias Dispatcher<S: Store> = (state: S.State, dispatch: Dispatch<S.Action>)
|
||||
|
||||
// FIXME: when contexts are available read state and dispatch
|
||||
// from the context and pass it to the mapper
|
||||
func storeAccess<S: Store>(_ mapper: (Dispatcher<S>) -> Node) {
|
||||
|
||||
}
|
||||
//func storeAccess<S: Store>(_ mapper: (Dispatcher<S>) -> Node) {
|
||||
//
|
||||
//}
|
||||
|
|
Loading…
Reference in New Issue