mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[ASTextKitFontSizeAdjuster] Use the constrainedSize’s height to adjust font scaling (#2309)
* refactor shrinking logic # Conflicts: # AsyncDisplayKit/TextKit/ASTextKitFontSizeAdjuster.mm * fix ASTraitCollection sample * updated comments. * fix build errors * adlai’s comments
This commit is contained in:
@@ -77,7 +77,7 @@ static const CGFloat kInnerPadding = 10.0f;
|
||||
// kitten image, with a solid background colour serving as placeholder
|
||||
_imageNode = [[ASNetworkImageNode alloc] init];
|
||||
_imageNode.backgroundColor = ASDisplayNodeDefaultPlaceholderColor();
|
||||
_imageNode.size = ASRelativeSizeRangeMakeWithExactCGSize(_kittenSize);
|
||||
_imageNode.style.size = (ASLayoutableSize){ .width = ASDimensionMake(_kittenSize.width), .height = ASDimensionMake(_kittenSize.height) };
|
||||
[_imageNode addTarget:self action:@selector(imageTapped:) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
|
||||
CGFloat scale = [UIScreen mainScreen].scale;
|
||||
@@ -91,8 +91,8 @@ static const CGFloat kInnerPadding = 10.0f;
|
||||
_textNode = [[ASTextNode alloc] init];
|
||||
_textNode.attributedText = [[NSAttributedString alloc] initWithString:[self kittyIpsum]
|
||||
attributes:[self textStyle]];
|
||||
_textNode.flexShrink = YES;
|
||||
_textNode.flexGrow = YES;
|
||||
_textNode.style.flexShrink = YES;
|
||||
_textNode.style.flexGrow = YES;
|
||||
[self addSubnode:_textNode];
|
||||
|
||||
return self;
|
||||
@@ -141,10 +141,10 @@ static const CGFloat kInnerPadding = 10.0f;
|
||||
[stackSpec setChildren:@[_imageNode, _textNode]];
|
||||
|
||||
if (self.asyncTraitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular) {
|
||||
_imageNode.alignSelf = ASStackLayoutAlignSelfStart;
|
||||
_imageNode.style.alignSelf = ASStackLayoutAlignSelfStart;
|
||||
stackSpec.direction = ASStackLayoutDirectionHorizontal;
|
||||
} else {
|
||||
_imageNode.alignSelf = ASStackLayoutAlignSelfCenter;
|
||||
_imageNode.style.alignSelf = ASStackLayoutAlignSelfCenter;
|
||||
stackSpec.direction = ASStackLayoutDirectionVertical;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user