added center alignment for tooltips

This commit is contained in:
yaanvar
2023-08-18 14:05:46 +03:00
parent 10e8c7dadc
commit 80422bfa32
26 changed files with 25 additions and 4 deletions
+2
View File
@@ -9668,6 +9668,8 @@
"client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_bottomRight_68x37@3x.png":"divkit/public/client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_bottomRight_68x37@3x.png",
"client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_bottom_67x39@2x.png":"divkit/public/client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_bottom_67x39@2x.png",
"client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_bottom_67x39@3x.png":"divkit/public/client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_bottom_67x39@3x.png",
"client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_center_67x43@2x.png":"divkit/public/client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_center_67x43@2x.png",
"client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_center_67x43@3x.png":"divkit/public/client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_center_67x43@3x.png",
"client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_left_74x32@2x.png":"divkit/public/client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_left_74x32@2x.png",
"client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_left_74x32@3x.png":"divkit/public/client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_left_74x32@3x.png",
"client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_right_74x32@2x.png":"divkit/public/client/ios/Tests/reference_snapshots/TooltipFactorySnapshotTests/Orientations_right_74x32@2x.png",
@@ -398,6 +398,7 @@ extension DivTooltip.Position {
case .bottomRight: return .bottomRight
case .bottom: return .bottom
case .bottomLeft: return .bottomLeft
case .center: return .center
}
}
}
@@ -7,14 +7,15 @@ import Serialization
public final class DivTooltip {
@frozen
public enum Position: String, CaseIterable {
case left = "left"
case left
case topLeft = "top-left"
case top = "top"
case top
case topRight = "top-right"
case right = "right"
case right
case bottomRight = "bottom-right"
case bottom = "bottom"
case bottom
case bottomLeft = "bottom-left"
case center
}
public let animationIn: DivAnimation?
@@ -23,6 +23,7 @@ extension CGRect {
case .bottomRight: return coordinate(ofCorner: .bottomRight)
case .bottom: return CGPoint(x: midX, y: maxY)
case .bottomLeft: return coordinate(ofCorner: .bottomLeft)
case .center: return CGPoint(x: midX, y: midY)
}
}
}
@@ -38,6 +39,7 @@ extension BlockTooltip.Position {
case .bottomRight: return .topLeft
case .bottom: return .top
case .bottomLeft: return .topRight
case .center: return .center
}
}
}
@@ -66,6 +68,8 @@ extension CGRect {
origin = coordinate.movingX(by: -0.5 * size.width).movingY(by: -size.height)
case .bottomLeft:
origin = coordinate.movingY(by: -size.height)
case .center:
origin = coordinate.movingX(by: -0.5 * size.width).movingY(by: -size.height / 2)
}
self.init(origin: origin, size: size)
}
@@ -12,6 +12,7 @@ public struct BlockTooltip: Equatable {
case bottomRight
case bottom
case bottomLeft
case center
}
public let id: String
@@ -66,6 +66,11 @@ extension BlockTooltip.Position {
cornerTailSize,
drawingHandler: { drawCornerTail(style: .topRight, color: color, context: $0) }
)
case .center:
imageHolder = Image.imageOfSize(
cornerTailSize,
drawingHandler: { _ in }
)
}
return ImageBlock(imageHolder: imageHolder!)
}
@@ -130,6 +135,13 @@ extension BlockTooltip.Position {
makeTail(color: theme.backgroundColor),
]
)
case .center:
return try! ContainerBlock(
layoutDirection: .vertical,
horizontalChildrenAlignment: .center,
gaps: [0, -1, 0],
children: [makeTail(color: theme.backgroundColor), child]
)
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB