From 835e61c7ee0cabd613c281402d93edd2e28095b0 Mon Sep 17 00:00:00 2001 From: Vincent DeAugustine <32307897+vdeaugustine@users.noreply.github.com> Date: Mon, 5 Feb 2024 02:08:51 -0800 Subject: [PATCH] Update GlowBorder to not use AnyView Refactor GlowBorder to use @ViewBuilder for improved performance and type safety --- GlowBorder.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/GlowBorder.swift b/GlowBorder.swift index 6bdd8ea..4ef0f4d 100644 --- a/GlowBorder.swift +++ b/GlowBorder.swift @@ -5,14 +5,15 @@ struct GlowBorder: ViewModifier { var lineWidth: Int func body(content: Content) -> some View { - applyShadow(content: AnyView(content), lineWidth: lineWidth) + applyShadow(content: content, lineWidth: lineWidth) } - func applyShadow(content: AnyView, lineWidth: Int) -> AnyView { + @ViewBuilder + func applyShadow(content: Content, lineWidth: Int) -> some View { if lineWidth == 0 { - return content + content } else { - return applyShadow(content: AnyView(content.shadow(color: color, radius: 1)), lineWidth: lineWidth - 1) + applyShadow(content: content.shadow(color: color, radius: 1), lineWidth: lineWidth - 1) } } }