mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Don’t floor space between items for ASStackLayoutJustifyContentSpaceBetween and ASStackLayoutJustifyContentSpaceAround
This commit is contained in:
@@ -118,12 +118,13 @@ ASStackPositionedLayout ASStackPositionedLayout::compute(const ASStackUnposition
|
|||||||
return stackedLayout(style, violation, unpositionedLayout, constrainedSize);
|
return stackedLayout(style, violation, unpositionedLayout, constrainedSize);
|
||||||
}
|
}
|
||||||
case ASStackLayoutJustifyContentSpaceBetween: {
|
case ASStackLayoutJustifyContentSpaceBetween: {
|
||||||
|
// Spacing between the items, no spaces at the edges, evenly distributed
|
||||||
const auto numOfSpacings = numOfItems - 1;
|
const auto numOfSpacings = numOfItems - 1;
|
||||||
return stackedLayout(style, 0, std::floor(violation / numOfSpacings), std::fmod(violation, numOfSpacings), unpositionedLayout, constrainedSize);
|
return stackedLayout(style, 0, violation / numOfSpacings, 0, unpositionedLayout, constrainedSize);
|
||||||
}
|
}
|
||||||
case ASStackLayoutJustifyContentSpaceAround: {
|
case ASStackLayoutJustifyContentSpaceAround: {
|
||||||
// Spacing between items are twice the spacing on the edges
|
// Spacing between items are twice the spacing on the edges
|
||||||
CGFloat spacingUnit = std::floor(violation / (numOfItems * 2));
|
CGFloat spacingUnit = violation / (numOfItems * 2);
|
||||||
return stackedLayout(style, spacingUnit, spacingUnit * 2, 0, unpositionedLayout, constrainedSize);
|
return stackedLayout(style, spacingUnit, spacingUnit * 2, 0, unpositionedLayout, constrainedSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -340,14 +340,14 @@ static void setCGSizeToNode(CGSize size, ASDisplayNode *node)
|
|||||||
|
|
||||||
- (void)testJustifiedSpaceBetweenWithRemainingSpace
|
- (void)testJustifiedSpaceBetweenWithRemainingSpace
|
||||||
{
|
{
|
||||||
// width 301px; height 0-300px; 1px remaining
|
// width 301px; height 0-300px;
|
||||||
static ASSizeRange kSize = {{301, 0}, {301, 300}};
|
static ASSizeRange kSize = {{301, 0}, {301, 300}};
|
||||||
[self testStackLayoutSpecWithJustify:ASStackLayoutJustifyContentSpaceBetween flexFactor:0 sizeRange:kSize identifier:nil];
|
[self testStackLayoutSpecWithJustify:ASStackLayoutJustifyContentSpaceBetween flexFactor:0 sizeRange:kSize identifier:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testJustifiedSpaceAroundWithRemainingSpace
|
- (void)testJustifiedSpaceAroundWithRemainingSpace
|
||||||
{
|
{
|
||||||
// width 305px; height 0-300px; 5px remaining
|
// width 305px; height 0-300px;
|
||||||
static ASSizeRange kSize = {{305, 0}, {305, 300}};
|
static ASSizeRange kSize = {{305, 0}, {305, 300}};
|
||||||
[self testStackLayoutSpecWithJustify:ASStackLayoutJustifyContentSpaceAround flexFactor:0 sizeRange:kSize identifier:nil];
|
[self testStackLayoutSpecWithJustify:ASStackLayoutJustifyContentSpaceAround flexFactor:0 sizeRange:kSize identifier:nil];
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Reference in New Issue
Block a user