feat(ui): 统一实现卡片背景趋势与大数值布局
This commit is contained in:
@@ -17,6 +17,7 @@ struct ChartTooltipPreference: PreferenceKey {
|
||||
/// Measures the actual localized tooltip, then keeps it inside the card.
|
||||
struct ChartTooltipLayer: Layout {
|
||||
let point: CGPoint
|
||||
var minimumY: CGFloat = 0
|
||||
|
||||
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
|
||||
proposal.replacingUnspecifiedDimensions()
|
||||
@@ -30,7 +31,7 @@ struct ChartTooltipLayer: Layout {
|
||||
let x = min(max(10, point.x + 12), max(10, bounds.width - size.width - 10))
|
||||
let below = point.y + 10
|
||||
let preferredY = below + size.height <= bounds.height - 10 ? below : point.y - size.height - 10
|
||||
let y = min(max(10, preferredY), max(10, bounds.height - size.height - 10))
|
||||
let y = min(max(max(10, minimumY), preferredY), max(10, bounds.height - size.height - 10))
|
||||
tooltip.place(at: CGPoint(x: bounds.minX + x, y: bounds.minY + y), anchor: .topLeading, proposal: tooltipProposal)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user