Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
paulz committed Jun 6, 2022
1 parent f0f3bb3 commit 8ce618b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 22 deletions.
3 changes: 2 additions & 1 deletion Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@
4B9C5728284DE251001DE13A /* PreviewGroup.swift */,
4B9C572A284DE262001DE13A /* PreviewGroupRoot.swift */,
);
path = PreviewGroup;
name = PreviewGroup;
path = ../Sources/PreviewGroup;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand Down
5 changes: 2 additions & 3 deletions Sources/PreviewGroup/PreviewGroup.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import SwiftUI

public struct PreviewGroup<Content: View>: View {
var content: () -> Content

public init(@ViewBuilder content: @escaping () -> Content) {
self.content = content
}

@ViewBuilder
var content: ()->Content

public var body: some View {
_VariadicView.Tree(PreviewGroupRoot(), content: content)
Expand Down
5 changes: 1 addition & 4 deletions Sources/PreviewGroup/Private/PreviewGroupRoot.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import SwiftUI

struct PreviewGroupRoot: _VariadicView_UnaryViewRoot {
static var hosts: [UIViewController] = []

static var elements: [_VariadicView.Children.Element] = []

init() {
Self.hosts = []
Self.elements = []
}

func body(children: _VariadicView.Children) -> some View {
children.forEach {
Self.elements.append($0)
Self.hosts.append(UIHostingController(rootView: $0))
}
return children
}
Expand Down
14 changes: 0 additions & 14 deletions Sources/ViewSnapshotTesting/verifySnapshot.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@ public func verifySnapshot<P>(_ preview: P.Type = P.self, _ name: String? = nil,
name.removeLast(commonPreviewSuffix.count)
}

// let f = preview.previews
// print(f)
// print(f.self)
// print(type(of: f))
// print(type(of: f.self))
// print(preview.previews)
// let mirror = Mirror(reflecting: f)
// let content = mirror.children.first!.value
// let mirror2 = Mirror(reflecting: content)
// let mirror3 = Mirror(reflecting: mirror2.children.first!.value)
// mirror3.children.makeIterator().forEach { child in
// print(child.label)
// }
// let iterView = ViewBuilder.buildEither(first: f)
verifySnapshot(preview.previews, name, colorAccuracy: colorAccuracy, file: file, line: line)
}

Expand Down

0 comments on commit 8ce618b

Please sign in to comment.