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

[CAT-195] Icon 버튼 추가 및 툴팁 개선 #21

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@ struct TooltipDetailView: View {
@State var downDirectionWithDimTooltip: DownDirectionWithDimTooltip?
@State var upDirectionWithDimTooltip: UpDirectionWithDimTooltip?

let downDirectionTooltip_ = DownDirectionTooltip()
let upDirectionTooltip_ = UpDirectionTooltip()
let downDirectionWithDimTooltip_ = DownDirectionWithDimTooltip()
let upDirectionWithDimTooltip_ = UpDirectionWithDimTooltip()


var body: some View {
VStack {
Button(
title: "Direction: .down, Color: .white, dim: false",
action: {
downDirectionTooltip = downDirectionTooltip_
downDirectionTooltip = .init()
}
)
.buttonStyle(.box(size: .large, color: .primary))
Expand All @@ -36,7 +30,7 @@ struct TooltipDetailView: View {
Button(
title: "Direction: .up, Color: .black, dim: false",
action: {
upDirectionTooltip = upDirectionTooltip_
upDirectionTooltip = .init()
}
)
.buttonStyle(.box(size: .large, color: .primary))
Expand All @@ -45,7 +39,7 @@ struct TooltipDetailView: View {
Button(
title: "Direction: .down, Color: .white, dim: true",
action: {
downDirectionWithDimTooltip = downDirectionWithDimTooltip_
downDirectionWithDimTooltip = .init()
}
)
.buttonStyle(.box(size: .large, color: .primary))
Expand All @@ -54,7 +48,7 @@ struct TooltipDetailView: View {
Button(
title: "Direction: .up, Color: .black, dim: true",
action: {
upDirectionWithDimTooltip = upDirectionWithDimTooltip_
upDirectionWithDimTooltip = .init()
}
)
.buttonStyle(.box(size: .large, color: .primary))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

public protocol Tooltip: Hashable {
public protocol Tooltip: Equatable {
var title: Text { get }
var color: TooltipColor { get }
var direction: TooltipDirection { get }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ struct TooltipTarget: View {
}

extension View {
public func setTooltipTarget(tooltip: some Tooltip) -> some View {
public func setTooltipTarget<T: Tooltip>(tooltip: T.Type) -> some View {
return self
.background(
TooltipTarget(identifier: tooltip)
TooltipTarget(identifier: ObjectIdentifier(tooltip))
)
}

public func tooltipDestination(tooltip: Binding<(some Tooltip)?>) -> some View {
public func tooltipDestination<T: Tooltip>(tooltip: Binding<T?>) -> some View {
return self
.overlayWithOnPreferenceChange(FrameMeasurePreferenceKey.self) { value in
if let content = tooltip.wrappedValue, let position = value[content] {
if let content = tooltip.wrappedValue, let position = value[ObjectIdentifier(type(of: content))] {
devMinseok marked this conversation as resolved.
Show resolved Hide resolved
TooltipView(content: content, position: position)
.transition(.opacity.animation(.easeInOut))
.onTapGesture {
Expand Down