mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-20 13:19:16 +00:00
updated example
This commit is contained in:
parent
d0345549f6
commit
ae5440ad11
@ -485,6 +485,7 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
||||
#pragma mark - Helpers
|
||||
- (NSString *)timeStringForCMTime:(CMTime)time
|
||||
{
|
||||
//TODO: ask Max if delegate for this thing will be useful;
|
||||
NSUInteger dTotalSeconds = CMTimeGetSeconds(time);
|
||||
|
||||
NSUInteger dHours = floor(dTotalSeconds / 3600);
|
||||
@ -493,9 +494,9 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext;
|
||||
|
||||
NSString *videoDurationText;
|
||||
if (dHours > 0) {
|
||||
videoDurationText = [NSString stringWithFormat:@"%i:%01i:%02i", (int)dHours, (int)dMinutes, (int)dSeconds];
|
||||
videoDurationText = [NSString stringWithFormat:@"%i:%02i:%02i", (int)dHours, (int)dMinutes, (int)dSeconds];
|
||||
} else {
|
||||
videoDurationText = [NSString stringWithFormat:@"%01i:%02i", (int)dMinutes, (int)dSeconds];
|
||||
videoDurationText = [NSString stringWithFormat:@"%02i:%02i", (int)dMinutes, (int)dSeconds];
|
||||
}
|
||||
return videoDurationText;
|
||||
}
|
||||
|
||||
@ -81,12 +81,12 @@
|
||||
|
||||
if (timeLabelType == ASVideoPlayerNodeControlTypeElapsedText) {
|
||||
options = @{
|
||||
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:13.0],
|
||||
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:16.0],
|
||||
NSForegroundColorAttributeName: [UIColor orangeColor]
|
||||
};
|
||||
} else if (timeLabelType == ASVideoPlayerNodeControlTypeDurationText) {
|
||||
options = @{
|
||||
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:13.0],
|
||||
NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Medium" size:16.0],
|
||||
NSForegroundColorAttributeName: [UIColor redColor]
|
||||
};
|
||||
}
|
||||
@ -98,19 +98,53 @@
|
||||
forControls:(NSDictionary *)controls
|
||||
forConstrainedSize:(ASSizeRange)constrainedSize
|
||||
{
|
||||
ASDisplayNode *scrubber = controls[@(ASVideoPlayerNodeControlTypeScrubber)];
|
||||
if (scrubber) {
|
||||
scrubber.preferredFrameSize = CGSizeMake(constrainedSize.max.width, 44.0);
|
||||
|
||||
NSMutableArray *bottomControls = [[NSMutableArray alloc] init];
|
||||
NSMutableArray *topControls = [[NSMutableArray alloc] init];
|
||||
|
||||
ASDisplayNode *scrubberNode = controls[@(ASVideoPlayerNodeControlTypeScrubber)];
|
||||
ASDisplayNode *playbackButtonNode = controls[@(ASVideoPlayerNodeControlTypePlaybackButton)];
|
||||
ASTextNode *elapsedTexNode = controls[@(ASVideoPlayerNodeControlTypeElapsedText)];
|
||||
ASTextNode *durationTexNode = controls[@(ASVideoPlayerNodeControlTypeDurationText)];
|
||||
|
||||
if (playbackButtonNode) {
|
||||
[bottomControls addObject:playbackButtonNode];
|
||||
}
|
||||
|
||||
if (scrubberNode) {
|
||||
scrubberNode.preferredFrameSize = CGSizeMake(constrainedSize.max.width, 44.0);
|
||||
[bottomControls addObject:scrubberNode];
|
||||
}
|
||||
|
||||
if (elapsedTexNode) {
|
||||
[topControls addObject:elapsedTexNode];
|
||||
}
|
||||
|
||||
if (durationTexNode) {
|
||||
[topControls addObject:durationTexNode];
|
||||
}
|
||||
|
||||
ASLayoutSpec *spacer = [[ASLayoutSpec alloc] init];
|
||||
spacer.flexGrow = YES;
|
||||
|
||||
ASStackLayoutSpec *topBarSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
||||
spacing:10.0
|
||||
justifyContent:ASStackLayoutJustifyContentCenter
|
||||
alignItems:ASStackLayoutAlignItemsCenter
|
||||
children:topControls];
|
||||
|
||||
|
||||
|
||||
UIEdgeInsets topBarSpecInsets = UIEdgeInsetsMake(20.0, 10.0, 0.0, 10.0);
|
||||
|
||||
ASInsetLayoutSpec *topBarSpecInsetSpec = [ASInsetLayoutSpec insetLayoutSpecWithInsets:topBarSpecInsets child:topBarSpec];
|
||||
topBarSpecInsetSpec.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||
|
||||
ASStackLayoutSpec *controlbarSpec = [ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal
|
||||
spacing:10.0
|
||||
justifyContent:ASStackLayoutJustifyContentStart
|
||||
alignItems:ASStackLayoutAlignItemsCenter
|
||||
children: @[scrubber] ];
|
||||
children:bottomControls];
|
||||
controlbarSpec.alignSelf = ASStackLayoutAlignSelfStretch;
|
||||
|
||||
UIEdgeInsets insets = UIEdgeInsetsMake(10.0, 10.0, 10.0, 10.0);
|
||||
@ -123,7 +157,7 @@
|
||||
spacing:0.0
|
||||
justifyContent:ASStackLayoutJustifyContentStart
|
||||
alignItems:ASStackLayoutAlignItemsStart
|
||||
children:@[spacer,controlbarInsetSpec]];
|
||||
children:@[ topBarSpecInsetSpec, spacer, controlbarInsetSpec ]];
|
||||
|
||||
|
||||
return mainVerticalStack;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user