From 965c53b3b6216454a2c7301f92b5ea7b68fd2b2e Mon Sep 17 00:00:00 2001 From: Ben Myers Date: Tue, 22 Mar 2022 20:25:11 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=81=20Small=20optimizations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/ShinySwiftUI/Extensions/SwiftUI/Text.swift | 7 +------ .../Extensions/SwiftUI/View/View+Highlight.swift | 3 ++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Sources/ShinySwiftUI/Extensions/SwiftUI/Text.swift b/Sources/ShinySwiftUI/Extensions/SwiftUI/Text.swift index f945f61..16bb0d4 100644 --- a/Sources/ShinySwiftUI/Extensions/SwiftUI/Text.swift +++ b/Sources/ShinySwiftUI/Extensions/SwiftUI/Text.swift @@ -19,11 +19,6 @@ public extension Text { - parameter value: The value to animate. */ func transition(_ t: AnyTransition, value: String) -> some View { - TextTransitionIDGenerator.count += 1 - return self.transition(t).id("_t\(TextTransitionIDGenerator.count)\(value)") + return self.transition(t).id("_t\(value)") } } - -fileprivate struct TextTransitionIDGenerator { - static var count: Int = 0 -} diff --git a/Sources/ShinySwiftUI/Extensions/SwiftUI/View/View+Highlight.swift b/Sources/ShinySwiftUI/Extensions/SwiftUI/View/View+Highlight.swift index e25bb43..be4d5b1 100644 --- a/Sources/ShinySwiftUI/Extensions/SwiftUI/View/View+Highlight.swift +++ b/Sources/ShinySwiftUI/Extensions/SwiftUI/View/View+Highlight.swift @@ -41,7 +41,8 @@ fileprivate struct HighlightView: View where Content: View { content .overlay( RoundedRectangle(cornerRadius: .xs) - .stroke(.yellow.if(value == index), lineWidth: 2.0) + .stroke(value.wrappedValue == index ? .yellow : .clear, lineWidth: 2.0) + .animation(.none, value: value.wrappedValue) ) .slickAnimation(value: value.wrappedValue) .onAppear { animate = true }