Skip to content

Commit

Permalink
🧹 Clean up views
Browse files Browse the repository at this point in the history
  • Loading branch information
benlmyers committed Feb 26, 2022
1 parent c1e41ee commit fe46147
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions Sources/ShinySwiftUI/Extensions/SwiftUI/View/View+Tooltip.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ fileprivate struct TooltipView<Content, TooltipContent>: View where Content: Vie
var hover: Binding<Bool>?
var extraOffset: CGFloat = 0.0
@State private var autoHover: Bool = false
@State private var contentHeight: CGFloat = 0.0

var show: Bool {
if let hover = hover {
Expand All @@ -42,27 +41,22 @@ fileprivate struct TooltipView<Content, TooltipContent>: View where Content: Vie
}

var body: some View {
GeometryReader { proxy in
content
.onAppear {
contentHeight = proxy.size.height
content
.onHover {
if hover == nil {
autoHover = $0
}
}
.onHover {
if hover == nil {
autoHover = $0
}
}
.overlay(
tooltipContent
.padding(.xs)
.background(background)
.cornerRadius(.s)
.roundedBorder(Color.primary.opacity(0.2), cornerRadius: .s)
.opacity(show ? .opaque : .invisible)
.offset(y: show ? -35.0 - extraOffset : -25.0)
.slickAnimation(value: show)
)
.overlay(
tooltipContent
.padding(.xs)
.background(background)
.cornerRadius(.s)
.roundedBorder(Color.primary.opacity(0.2), cornerRadius: .s)
.opacity(show ? .opaque : .invisible)
.offset(y: show ? -35.0 - extraOffset : -25.0)
.slickAnimation(value: show)
)
}

var background: some View {
Expand Down

0 comments on commit fe46147

Please sign in to comment.