-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add reload method and hold(value:) modifier
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Luke Zhao on 3/14/23. | ||
// | ||
|
||
import Foundation | ||
|
||
struct HoldValueComponent: Component { | ||
let child: Component | ||
let value: Any | ||
func layout(_ constraint: Constraint) -> RenderNode { | ||
HoldValueRenderNode(child: child.layout(constraint), value: value) | ||
} | ||
} | ||
|
||
struct HoldValueRenderNode: WrapperRenderNode { | ||
let child: RenderNode | ||
let value: Any? | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Luke Zhao on 3/14/23. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol WrapperRenderNode: RenderNode { | ||
var child: RenderNode { get } | ||
} | ||
|
||
public extension WrapperRenderNode { | ||
var size: CGSize { | ||
child.size | ||
} | ||
|
||
var positions: [CGPoint] { | ||
[.zero] | ||
} | ||
|
||
var children: [RenderNode] { | ||
[child] | ||
} | ||
} |