Skip to content

Commit f22edbc

Browse files
committed
🎯 View optimization methods
1 parent b580d27 commit f22edbc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

‎Sources/ShinySwiftUI/Extensions/SwiftUI/View/View+Button.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private struct _HoverView<T>: View where T: View {
9090
}
9191
HStack(spacing: .xs) {
9292
ForEach(symbols, id: \.self) { Image(systemName: $0) }
93-
Text(string)
93+
Text(string).id(string)
9494
}
9595
.imageScale(.small)
9696
.padding(.xs)

‎Sources/ShinySwiftUI/Extensions/SwiftUI/View/View.swift‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,16 @@ public extension View {
358358
func debug() -> some View {
359359
background(Color.yellow.opacity(.quarter))
360360
}
361+
362+
/**
363+
Adds and removes padding around a view with `.drawingGroup()` applied.
364+
365+
- parameter padding: The padding spacing to apply. Use this to accomodate for offset, rotation, scaling, etc. used in your views.
366+
*/
367+
@ViewBuilder
368+
func paddedDrawingGroup(_ padding: CGFloat = .s) -> some View {
369+
self.padding(padding).drawingGroup().padding(-1.0 * padding)
370+
}
361371
}
362372

363373
#if os(iOS)

0 commit comments

Comments
 (0)