Skip to content

Commit

Permalink
fix component builder type issue and make some renderable public
Browse files Browse the repository at this point in the history
  • Loading branch information
lkzhao committed Dec 1, 2023
1 parent 515613f commit 8b9b255
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public protocol ComponentBuilder: Component {
}

extension ComponentBuilder {
public func layout(_ constraint: Constraint) -> some RenderNode {
public func layout(_ constraint: Constraint) -> ResultComponent.R {
build().layout(constraint)
}
}
50 changes: 25 additions & 25 deletions Sources/UIComponent/Core/Model/RenderNode/Renderable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,68 +11,68 @@ public protocol Renderable {
var frame: CGRect { get }
}

struct ViewRenderable: Renderable {
let renderNode: any RenderNode
init(renderNode: any RenderNode) {
public struct ViewRenderable: Renderable {
public let renderNode: any RenderNode
public init(renderNode: any RenderNode) {
self.renderNode = renderNode
}
var userDefinedId: String? {
public var userDefinedId: String? {
renderNode.id
}
var id: String {
public var id: String {
userDefinedId ?? renderNode.keyPath
}
var animator: Animator? {
public var animator: Animator? {
renderNode.animator
}
var frame: CGRect {
public var frame: CGRect {
CGRect(origin: .zero, size: renderNode.size)
}
}

struct OffsetRenderable: Renderable {
let renderable: Renderable
let offset: CGPoint
let index: Int
init(renderable: Renderable, offset: CGPoint, index: Int) {
public struct OffsetRenderable: Renderable {
public let renderable: Renderable
public let offset: CGPoint
public let index: Int
public init(renderable: Renderable, offset: CGPoint, index: Int) {
self.renderable = renderable
self.offset = offset
self.index = index
}
var userDefinedId: String? {
public var userDefinedId: String? {
renderable.userDefinedId
}
var id: String {
public var id: String {
renderable.userDefinedId ?? "\(type(of: self))-\(index).\(renderable.id)"
}
var animator: Animator? {
public var animator: Animator? {
renderable.animator
}
var renderNode: any RenderNode {
public var renderNode: any RenderNode {
renderable.renderNode
}
var frame: CGRect {
public var frame: CGRect {
renderable.frame + offset
}
}

struct IdOverrideRenderable: Renderable {
var id: String
var renderable: Renderable
init(id: String, renderable: Renderable) {
public struct IdOverrideRenderable: Renderable {
public var id: String
public var renderable: Renderable
public init(id: String, renderable: Renderable) {
self.id = id
self.renderable = renderable
}
var userDefinedId: String? {
public var userDefinedId: String? {
renderable.userDefinedId
}
var animator: Animator? {
public var animator: Animator? {
renderable.animator
}
var renderNode: any RenderNode {
public var renderNode: any RenderNode {
renderable.renderNode
}
var frame: CGRect {
public var frame: CGRect {
renderable.frame
}
}

0 comments on commit 8b9b255

Please sign in to comment.