Created
March 15, 2023 14:45
-
-
Save js/32b532c7497bfda63a187629114e3afd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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