Skip to content

Instantly share code, notes, and snippets.

@michaelevensen
Last active January 5, 2023 21:15
Show Gist options
  • Save michaelevensen/d29f5dec0b7c03473e61bd6bd74b2315 to your computer and use it in GitHub Desktop.
Save michaelevensen/d29f5dec0b7c03473e61bd6bd74b2315 to your computer and use it in GitHub Desktop.
Use `@ViewBuilder` in extensions. Basically cast to `AnyView`.
extension ButtonStyle where Self == InputFieldButtonStyle<AnyView> {
internal static func input<Content: View>(mimicksDropdown: Bool = false,
@ViewBuilder placeholderContent: @escaping () -> Content? = { nil }) -> InputFieldButtonStyle<AnyView> {
InputFieldButtonStyle(mimicksDropdown: mimicksDropdown,
placeholderContent: {
AnyView(placeholderContent())
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment