Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GlowBorder to not use AnyView #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vdeaugustine
Copy link

Overview

Refactor the GlowBorder ViewModifier implementation. By using @ViewBuilder and avoiding type erasure with AnyView, we achieve a cleaner, more efficient implementation.

Changes

  • Replaced the AnyView type erasure in GlowBorder with a generic Content parameter and @ViewBuilder.
  • Modified the applyShadow function to be recursive without the need for type erasure, thereby preserving the view's type throughout the modification process.
  • Maintains the original functionality of applying a glowing border effect but does so in a more SwiftUI-native approach.

Benefits

  • Performance: By avoiding AnyView, the view hierarchy remains more streamlined, potentially improving rendering performance as SwiftUI can better optimize the view diffing.
  • Type Safety: The use of generic Content and @ViewBuilder ensures that the view types are preserved, leveraging Swift's type system for compile-time checks.
  • Readability and Maintenance: The new approach is more in line with SwiftUI's idiomatic patterns, making the code easier to understand and maintain.

Refactor GlowBorder to use @ViewBuilder for improved performance and type safety
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant