mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-20 21:29:00 +00:00
minor fixes. ensure size in layoutSpecThatFits:
This commit is contained in:
parent
f30bf32a47
commit
e1544f0f59
@ -71,12 +71,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
* @abstract Delegate method invoked in layoutSpecThatFits:
|
* @abstract Delegate method invoked in layoutSpecThatFits:
|
||||||
* @param videoPlayer
|
* @param videoPlayer
|
||||||
* @param controls - Dictionary of controls which are used in videoPlayer; Dictionary keys are ASVideoPlayerNodeControlType
|
* @param controls - Dictionary of controls which are used in videoPlayer; Dictionary keys are ASVideoPlayerNodeControlType
|
||||||
* @param constrainedSize - ASSizeRange for ASVideoPlayerNode
|
* @param maxSize - Maximum size for ASVideoPlayerNode
|
||||||
* @discussion - Developer can layout whole ASVideoPlayerNode as he wants. ASVideoNode is locked and it can't be changed
|
* @discussion - Developer can layout whole ASVideoPlayerNode as he wants. ASVideoNode is locked and it can't be changed
|
||||||
*/
|
*/
|
||||||
- (ASLayoutSpec *)videoPlayerNodeLayoutSpec:(ASVideoPlayerNode *)videoPlayer
|
- (ASLayoutSpec *)videoPlayerNodeLayoutSpec:(ASVideoPlayerNode *)videoPlayer
|
||||||
forControls:(NSDictionary *)controls
|
forControls:(NSDictionary *)controls
|
||||||
forConstrainedSize:(ASSizeRange)constrainedSize;
|
forMaximumSize:(CGSize)maxSize;
|
||||||
|
|
||||||
#pragma mark Text delegate methods
|
#pragma mark Text delegate methods
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -391,6 +391,15 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)videoNodeWasTapped:(ASVideoNode *)videoNode
|
||||||
|
{
|
||||||
|
if (videoNode.playerState == ASVideoNodePlayerStatePlaying) {
|
||||||
|
[videoNode pause];
|
||||||
|
} else {
|
||||||
|
[videoNode play];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Actions
|
#pragma mark - Actions
|
||||||
- (void)playbackButtonTapped:(ASControlNode*)node
|
- (void)playbackButtonTapped:(ASControlNode*)node
|
||||||
{
|
{
|
||||||
@ -471,25 +480,35 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
|||||||
#pragma mark - Layout
|
#pragma mark - Layout
|
||||||
- (ASLayoutSpec*)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec*)layoutSpecThatFits:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
_videoNode.preferredFrameSize = constrainedSize.max;
|
CGSize maxSize = constrainedSize.max;
|
||||||
|
if (!CGSizeEqualToSize(self.preferredFrameSize, CGSizeZero)) {
|
||||||
|
maxSize = self.preferredFrameSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent crashes through if infinite width or height
|
||||||
|
if (isinf(maxSize.width) || isinf(maxSize.height)) {
|
||||||
|
ASDisplayNodeAssert(NO, @"Infinite width or height in ASVideoPlayerNode");
|
||||||
|
maxSize = CGSizeZero;
|
||||||
|
}
|
||||||
|
_videoNode.preferredFrameSize = maxSize;
|
||||||
|
|
||||||
ASLayoutSpec *layoutSpec;
|
ASLayoutSpec *layoutSpec;
|
||||||
|
|
||||||
if (_delegateFlags.delegateLayoutSpecForControls) {
|
if (_delegateFlags.delegateLayoutSpecForControls) {
|
||||||
layoutSpec = [_delegate videoPlayerNodeLayoutSpec:self forControls:_cachedControls forConstrainedSize:constrainedSize];
|
layoutSpec = [_delegate videoPlayerNodeLayoutSpec:self forControls:_cachedControls forMaximumSize:maxSize];
|
||||||
} else {
|
} else {
|
||||||
layoutSpec = [self defaultLayoutSpecThatFits:constrainedSize];
|
layoutSpec = [self defaultLayoutSpecThatFits:maxSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
ASOverlayLayoutSpec *overlaySpec = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:_videoNode overlay:layoutSpec];
|
ASOverlayLayoutSpec *overlaySpec = [ASOverlayLayoutSpec overlayLayoutSpecWithChild:_videoNode overlay:layoutSpec];
|
||||||
overlaySpec.sizeRange = ASRelativeSizeRangeMakeWithExactCGSize(constrainedSize.max);
|
overlaySpec.sizeRange = ASRelativeSizeRangeMakeWithExactCGSize(maxSize);
|
||||||
|
|
||||||
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[overlaySpec]];
|
return [ASStaticLayoutSpec staticLayoutSpecWithChildren:@[overlaySpec]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (ASLayoutSpec*)defaultLayoutSpecThatFits:(ASSizeRange)constrainedSize
|
- (ASLayoutSpec*)defaultLayoutSpecThatFits:(CGSize)maxSize
|
||||||
{
|
{
|
||||||
_scrubberNode.preferredFrameSize = CGSizeMake(constrainedSize.max.width, 44.0);
|
_scrubberNode.preferredFrameSize = CGSizeMake(maxSize.width, 44.0);
|
||||||
|
|
||||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||||
spacer.flexGrow = YES;
|
spacer.flexGrow = YES;
|
||||||
@ -534,7 +553,7 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
|||||||
_delegateFlags.delegateScrubberThumbTintColor = [_delegate respondsToSelector:@selector(videoPlayerNodeScrubberThumbTint:)];
|
_delegateFlags.delegateScrubberThumbTintColor = [_delegate respondsToSelector:@selector(videoPlayerNodeScrubberThumbTint:)];
|
||||||
_delegateFlags.delegateScrubberThumbImage = [_delegate respondsToSelector:@selector(videoPlayerNodeScrubberThumbImage:)];
|
_delegateFlags.delegateScrubberThumbImage = [_delegate respondsToSelector:@selector(videoPlayerNodeScrubberThumbImage:)];
|
||||||
_delegateFlags.delegateTimeLabelAttributes = [_delegate respondsToSelector:@selector(videoPlayerNodeTimeLabelAttributes:timeLabelType:)];
|
_delegateFlags.delegateTimeLabelAttributes = [_delegate respondsToSelector:@selector(videoPlayerNodeTimeLabelAttributes:timeLabelType:)];
|
||||||
_delegateFlags.delegateLayoutSpecForControls = [_delegate respondsToSelector:@selector(videoPlayerNodeLayoutSpec:forControls:forConstrainedSize:)];
|
_delegateFlags.delegateLayoutSpecForControls = [_delegate respondsToSelector:@selector(videoPlayerNodeLayoutSpec:forControls:forMaximumSize:)];
|
||||||
_delegateFlags.delegateVideoNodeDidPlayToTime = [_delegate respondsToSelector:@selector(videoPlayerNode:didPlayToTime:)];
|
_delegateFlags.delegateVideoNodeDidPlayToTime = [_delegate respondsToSelector:@selector(videoPlayerNode:didPlayToTime:)];
|
||||||
_delegateFlags.delegateVideoNodeWillChangeState = [_delegate respondsToSelector:@selector(videoPlayerNode:willChangeVideoNodeState:toVideoNodeState:)];
|
_delegateFlags.delegateVideoNodeWillChangeState = [_delegate respondsToSelector:@selector(videoPlayerNode:willChangeVideoNodeState:toVideoNodeState:)];
|
||||||
_delegateFlags.delegateVideoNodePlaybackDidFinish = [_delegate respondsToSelector:@selector(videoPlayerNodeDidPlayToEnd:)];
|
_delegateFlags.delegateVideoNodePlaybackDidFinish = [_delegate respondsToSelector:@selector(videoPlayerNodeDidPlayToEnd:)];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user