Skip to content

Commit

Permalink
1.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
nathantannar4 committed Oct 10, 2024
1 parent fafea4c commit 96ca809
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 9 deletions.
90 changes: 82 additions & 8 deletions Sources/Engine/Sources/ViewAlias.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public struct ViewAliasSourceModifier<
}

public func body(content: Content) -> some View {
content.modifier(Modifier(source: source))
UnaryViewAdaptor {
content.modifier(Modifier(source: source))
}
}

private struct Modifier: GraphInputsModifier {
Expand Down Expand Up @@ -235,6 +237,11 @@ struct ViewAlias_Previews: PreviewProvider {

static var previews: some View {
Group {
ZStack {
PreviewAlias()
}
.previewDisplayName("DefaultBody")

ZStack {
VStack {
PreviewAlias()
Expand All @@ -248,21 +255,88 @@ struct ViewAlias_Previews: PreviewProvider {
.previewDisplayName("Text")

ZStack {
VStack {
HStack {
VStack {
PreviewAlias()
}
.viewAlias(PreviewAlias.self) {
ForEach(0...2, id: \.self) { index in
Text(index.description)
}
}

VStack {
ForEach(0...2, id: \.self) { index in
PreviewAlias()
}
.viewAlias(PreviewAlias.self) {
Text("Hello, World")
}
}
}
}
.previewDisplayName("ForEach")


ZStack {
ConditionalView(if: true) {
ZStack {
PreviewAlias()
}
.viewAlias(PreviewAlias.self) {
Text("Hello, World")
}
}
}
.previewDisplayName("ConditionalContent")

ZStack {
AnyView(PreviewAlias())
.viewAlias(PreviewAlias.self) {
Text("Hello, World")
}
}
.previewDisplayName("AnyView")

ZStack {
ScrollView {
PreviewAlias()
}
.viewAlias(PreviewAlias.self) {
ForEach(0...2, id: \.self) { index in
Text(index.description)
}
Text("Hello, World")
}
}
.previewDisplayName("ForEach")
.previewDisplayName("ScrollView")

#if os(iOS)
ZStack {
PreviewAlias()
HostingViewBridge {
PreviewAlias()
}
.viewAlias(PreviewAlias.self) {
Text("Hello, World")
}
}
.previewDisplayName("DefaultBody")
.previewDisplayName("HostingViewBridge")
#endif
}
}

#if os(iOS)
struct HostingViewBridge<Content: View>: UIViewControllerRepresentable {
@ViewBuilder var content: Content

func makeUIViewController(
context: Context
) -> HostingController<Content> {
HostingController(content: content)
}

func updateUIViewController(
_ uiViewController: HostingController<Content>,
context: Context
) {
}
}
#endif
}
2 changes: 1 addition & 1 deletion Sources/Engine/Sources/ViewStackAxisReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct ViewStackAxisReader_Previews: PreviewProvider {
}
}

if #available(iOS 16.0, macOS 13.0, *) {
if #available(iOS 16.0, tvOS 16.0, macOS 13.0, watchOS 9.0, *) {
Grid(verticalSpacing: 8) {
CustomDivider()

Expand Down

0 comments on commit 96ca809

Please sign in to comment.