Skip to content

Instantly share code, notes, and snippets.

@js
Created March 15, 2023 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save js/32b532c7497bfda63a187629114e3afd to your computer and use it in GitHub Desktop.
Save js/32b532c7497bfda63a187629114e3afd to your computer and use it in GitHub Desktop.
import SwiftUI
struct UnderConstructionModifier: ViewModifier {
func body(content: Content) -> some View {
content
.redacted(reason: .placeholder)
.blur(radius: 8)
.overlay(Color.pink.opacity(0.33))
.overlay(
Text("🚧🚧🚧")
.font(.largeTitle)
)
.cornerRadius(.roundedMedium)
}
}
public extension View {
@ViewBuilder
@available(*, deprecated, message: "Don't leave it under construction mate")
func underConstruction(if active: Bool = true) -> some View {
if active {
modifier(UnderConstructionModifier())
} else {
self
}
}
}
struct UnderConstructionModifier_Previews: PreviewProvider {
static var previews: some View {
HStack {
Rectangle()
.fill(.red)
.frame(width: 64, height: 64)
VStack(alignment: .leading) {
Text("Homer Simpson")
.font(.title3)
Text("Nuclear Safety Inspector")
.font(.caption)
}
}
.padding()
.underConstruction()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment