mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-29 11:25:38 +00:00
Updates to expectedImageSize
* renamed property to requestedLayoutSize * moved property to ASDisplayNode
This commit is contained in:
parent
eae76d26b7
commit
496cc43337
@ -185,6 +185,15 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)();
|
||||
*/
|
||||
@property (nonatomic, readonly, assign) ASSizeRange constrainedSizeForCalculatedLayout;
|
||||
|
||||
/**
|
||||
* @abstract Used by some implementations of measureWithSizeRange: to provide an intrisic content size
|
||||
* to a node when one cannot be computed from its subnodes
|
||||
*
|
||||
* @return The requested size of this node
|
||||
*/
|
||||
@property (atomic, assign, readwrite) CGSize requestedLayoutSize;
|
||||
|
||||
|
||||
/** @name Managing the nodes hierarchy */
|
||||
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
@synthesize flexShrink = _flexShrink;
|
||||
@synthesize flexBasis = _flexBasis;
|
||||
@synthesize alignSelf = _alignSelf;
|
||||
@synthesize requestedLayoutSize = _requestedLayoutSize;
|
||||
|
||||
BOOL ASDisplayNodeSubclassOverridesSelector(Class subclass, SEL selector)
|
||||
{
|
||||
@ -135,6 +136,7 @@ void ASDisplayNodePerformBlockOnMainThread(void (^block)())
|
||||
_methodOverrides = overrides;
|
||||
|
||||
_flexBasis = ASRelativeDimensionUnconstrained;
|
||||
_requestedLayoutSize = CGSizeZero;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
@ -1333,6 +1335,18 @@ static NSInteger incrementIfFound(NSInteger i) {
|
||||
return _constrainedSize;
|
||||
}
|
||||
|
||||
-(void)setRequestedLayoutSize:(CGSize)requestedLayoutSize
|
||||
{
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
_requestedLayoutSize = requestedLayoutSize;
|
||||
}
|
||||
|
||||
- (CGSize)requestedLayoutSize
|
||||
{
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
return _requestedLayoutSize;
|
||||
}
|
||||
|
||||
- (UIImage *)placeholderImage
|
||||
{
|
||||
return nil;
|
||||
|
||||
@ -111,7 +111,9 @@
|
||||
- (CGSize)calculateSizeThatFits:(CGSize)constrainedSize
|
||||
{
|
||||
ASDN::MutexLocker l(_imageLock);
|
||||
if (_image)
|
||||
if (CGSizeEqualToSize(self.requestedLayoutSize, CGSizeZero) == NO)
|
||||
return CGSizeMake(MIN(constrainedSize.width, self.requestedLayoutSize.width), MIN(constrainedSize.height, self.requestedLayoutSize.height));
|
||||
else if (_image)
|
||||
return _image.size;
|
||||
else
|
||||
return CGSizeZero;
|
||||
|
||||
@ -51,11 +51,6 @@
|
||||
*/
|
||||
@property (atomic, strong, readwrite) UIImage *defaultImage;
|
||||
|
||||
/**
|
||||
* The expected size of the image that will download
|
||||
*/
|
||||
@property (atomic, assign, readwrite) CGSize expectedImageSize;
|
||||
|
||||
/**
|
||||
* The URL of a new image to download and display.
|
||||
*
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
|
||||
NSURL *_URL;
|
||||
UIImage *_defaultImage;
|
||||
CGSize _expectedImageSize;
|
||||
|
||||
NSUUID *_cacheUUID;
|
||||
id _imageDownload;
|
||||
@ -45,7 +44,6 @@
|
||||
_cache = cache;
|
||||
_downloader = downloader;
|
||||
_shouldCacheImage = YES;
|
||||
_expectedImageSize = CGSizeZero;
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -113,18 +111,6 @@
|
||||
return _defaultImage;
|
||||
}
|
||||
|
||||
-(void)setExpectedImageSize:(CGSize)expectedImageSize
|
||||
{
|
||||
ASDN::MutexLocker l(_lock);
|
||||
_expectedImageSize = expectedImageSize;
|
||||
}
|
||||
|
||||
- (CGSize)expectedImageSize
|
||||
{
|
||||
ASDN::MutexLocker l(_lock);
|
||||
return _expectedImageSize;
|
||||
}
|
||||
|
||||
- (void)setDelegate:(id<ASNetworkImageNodeDelegate>)delegate
|
||||
{
|
||||
ASDN::MutexLocker l(_lock);
|
||||
@ -167,15 +153,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (CGSize)calculateSizeThatFits:(CGSize)constrainedSize
|
||||
{
|
||||
ASDN::MutexLocker l(_lock);
|
||||
if (CGSizeEqualToSize(CGSizeZero, _expectedImageSize))
|
||||
return [super calculateSizeThatFits:constrainedSize];
|
||||
else
|
||||
return _expectedImageSize;
|
||||
}
|
||||
|
||||
#pragma mark - Private methods -- only call with lock.
|
||||
|
||||
- (void)_cancelImageDownload
|
||||
|
||||
@ -83,7 +83,7 @@ static const CGFloat kInnerPadding = 10.0f;
|
||||
_imageNode.URL = [NSURL URLWithString:[NSString stringWithFormat:@"http://placekitten.com/%zd/%zd",
|
||||
(NSInteger)roundl(_kittenSize.width),
|
||||
(NSInteger)roundl(_kittenSize.height)]];
|
||||
_imageNode.expectedImageSize = CGSizeMake(kImageSize, kImageSize);
|
||||
_imageNode.requestedLayoutSize = CGSizeMake(kImageSize, kImageSize);
|
||||
// _imageNode.contentMode = UIViewContentModeCenter;
|
||||
[self addSubnode:_imageNode];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user