This file contains hidden or 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
struct RecursivelyGlowInTheDarkViewModifier: ViewModifier { | |
let colors: [Color] | |
func body(content: Content) -> some View { | |
var modifiedColors = colors // First create a local variable | |
let nextColor: Color? | |
if !modifiedColors.isEmpty { // if it is not empty, remove the first element to use it | |
nextColor = modifiedColors.remove(at: 0) | |
} else { // or set as nil | |
nextColor = nil | |
} |
This file contains hidden or 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
struct GlowInTheDarkViewModifier: ViewModifier { | |
let active: Bool | |
@ViewBuilder func body(content: Content) -> some View { | |
if active { | |
content | |
.shadow(color: .yellow, radius: 5) | |
.shadow(color: .white, radius: 5) | |
.shadow(color: .green, radius: 5) | |
.shadow(color: .blue, radius: 5) | |
.shadow(color: .green, radius: 5) |
This file contains hidden or 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
private struct GroundReflectionViewModifier: ViewModifier { | |
let offsetY: CGFloat | |
func body(content: Content) -> some View { | |
content // base content | |
.background( // using background to duplicate the content with the View | |
content // using the same content here to duplicate | |
// this will create a flip in the axis Y with the anchor in the bottom | |
.scaleEffect(x: 1.0, y: -1.0, anchor: .bottom) | |
// adding the opacity | |
.opacity(0.3) |
This file contains hidden or 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
private struct GroundReflectionViewModifier: ViewModifier { | |
let offsetY: CGFloat | |
func body(content: Content) -> some View { | |
content | |
.background( | |
content | |
.mask( | |
LinearGradient( | |
gradient: Gradient(stops: [.init(color: .white, location: 0.0), .init(color: .clear, location: 0.6)]), | |
startPoint: .bottom, |
This file contains hidden or 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
private struct XXLTextViewModifier: ViewModifier { | |
let size: CGFloat | |
func body(content: Content) -> some View { | |
content | |
.font(.system(size: size*40)) | |
} | |
} | |
extension View { | |
func xxlText(_ size: CGFloat = 2) -> some View { |
This file contains hidden or 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
struct XXLTextView: View { | |
let text: String | |
let size: CGFloat | |
var body: some View { | |
Text(text) | |
.font(.system(size: size*40)) | |
} | |
} | |
struct XXLTextViewModifier_Previews: PreviewProvider { |