Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support @Previewable macro #108

Merged
merged 1 commit into from
Feb 24, 2025
Merged

Support @Previewable macro #108

merged 1 commit into from
Feb 24, 2025

Conversation

BarredEwe
Copy link
Owner

Short description 📝

In #Preview macro, can't use @Previewable or "ungrouped" views. Fix: #106

@Previewable macro not supported... e.g.

#Preview {
     @Previewable @State var count = 1
     Button("Increment \(count)") { count += 1 }
}

or ungrouped views:

#Preview {
     Text("Foo")
     Text("Bar")
}

Solution 📦

Added support for @Previewable.

Implementation 👩‍💻👨‍💻

When @Previewable property is found, the View property is wrapped around.

struct PreviewWrapperTest: SwiftUI.View {
     @State var count = 1
     var body: some SwiftUI.View {
          Text("Foo")
     }
} 

@BarredEwe BarredEwe force-pushed the supportPreviewableMacro branch from ffe60f5 to a2bbfe7 Compare February 24, 2025 08:44
@BarredEwe BarredEwe added the enhancement New feature or request label Feb 24, 2025
@BarredEwe BarredEwe merged commit 100ed9a into main Feb 24, 2025
5 checks passed
@BarredEwe BarredEwe deleted the supportPreviewableMacro branch February 24, 2025 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In #Preview macro, can't use @Previewable or "ungrouped" views.
1 participant