Skip to content

Commit 3ef607e

Browse files
committed
Add environment transform options
1 parent 7c0d61a commit 3ef607e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Sources/LiveViewNative/Views/Text.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ struct Text<R: CustomRegistry>: View {
199199
weight = Font.Weight.light
200200
case "regular":
201201
weight = Font.Weight.regular
202+
case "medium":
203+
weight = Font.Weight.medium
202204
case "semibold":
203205
weight = Font.Weight.semibold
204206
case "thin":

Tests/RenderingTests/assertMatch.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func assertMatch(
1818
_ line: Int = #line,
1919
_ function: StaticString = #function,
2020
@ViewBuilder _ view: () -> some View,
21-
environment: (inout EnvironmentValues) -> () = { _ in }
21+
environment: @escaping (inout EnvironmentValues) -> () = { _ in }
2222
) throws {
2323
try assertMatch(name: "\(URL(filePath: file).lastPathComponent)-\(line)-\(function)", markup, view, environment: environment)
2424
}
@@ -28,16 +28,16 @@ func assertMatch(
2828
name: String,
2929
_ markup: String,
3030
@ViewBuilder _ view: () -> some View,
31-
environment: (inout EnvironmentValues) -> () = { _ in }
31+
environment: @escaping (inout EnvironmentValues) -> () = { _ in }
3232
) throws {
3333
let coordinator = LiveViewCoordinator(URL(string: "http://localhost")!)
3434
let document = try LiveViewNativeCore.Document.parse(markup)
3535
let viewTree = coordinator.builder.fromNodes(
3636
document[document.root()].children(),
3737
context: LiveContext(coordinator: coordinator, url: coordinator.currentURL)
3838
).environment(\.coordinatorEnvironment, CoordinatorEnvironment(coordinator, document: document))
39-
let markupImage = ImageRenderer(content: viewTree).uiImage?.pngData()
40-
let viewImage = ImageRenderer(content: view()).uiImage?.pngData()
39+
let markupImage = ImageRenderer(content: viewTree.transformEnvironment(\.self, transform: environment)).uiImage?.pngData()
40+
let viewImage = ImageRenderer(content: view().transformEnvironment(\.self, transform: environment)).uiImage?.pngData()
4141

4242
if markupImage == viewImage {
4343
XCTAssert(true)

0 commit comments

Comments
 (0)