1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- //
- // TeacherShowCell.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2022/4/22.
- //
- #import "TeacherShowCell.h"
- #import "KSVideoHelper.h"
- #import "UIButton+EnlargeEdge.h"
- @interface TeacherShowCell ()
- @property (weak, nonatomic) IBOutlet UIImageView *videoCover;
- @property (weak, nonatomic) IBOutlet UILabel *descLabel;
- @property (weak, nonatomic) IBOutlet UIImageView *teacherAvatar;
- @property (weak, nonatomic) IBOutlet UILabel *teacherNameLabel;
- @property (weak, nonatomic) IBOutlet UILabel *watchCount;
- @property (weak, nonatomic) IBOutlet UILabel *durationLabel;
- @property (weak, nonatomic) IBOutlet UIButton *playButton;
- @property (nonatomic, copy) TeacherStylePlay callback;
- @property (nonatomic, strong) TeacherStyleModel *model;
- @end
- @implementation TeacherShowCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- [self.playButton setEnlargeEdgeWithTop:10 right:5 bottom:10 left:10];
- }
- - (void)configWithStyleModel:(TeacherStyleModel *)sourceModel callback:(TeacherStylePlay)callback {
- if (callback) {
- self.callback = callback;
- }
- self.model = sourceModel;
- [KSVideoHelper getVideoPreviewImageUrl:sourceModel.videoUrl forImageView:self.videoCover placeholder:[UIImage imageNamed:@"video_placeholder"]];
- self.descLabel.text = [NSString returnNoNullStringWithString:sourceModel.describe];
- [self.teacherAvatar sd_setImageWithURL:[NSURL URLWithString:sourceModel.avatar] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
- self.teacherNameLabel.text = [NSString returnNoNullStringWithString:sourceModel.username];
- self.watchCount.text = [NSString stringWithFormat:@"%@已观看",sourceModel.browse];
-
- // if (![NSString isEmptyString:sourceModel.browse] && ![sourceModel.browse isEqualToString:@"0"]) {
- // self.watchCount.text = [NSString stringWithFormat:@"%@已观看",sourceModel.browse];
- // }
- // else {
- // self.watchCount.text = @"";
- // }
- NSInteger duration = [KSVideoHelper getVideoDuration:sourceModel.videoUrl];
- NSString *durationString = @"00:00";
- if (duration / 60 > 0) {
- durationString = [NSString stringWithFormat:@"%2ld:%2ld", duration / 60, duration % 60];
- }
- else {
- durationString = [NSString stringWithFormat:@"00:%2ld", duration];
- }
- self.durationLabel.text = durationString;
- }
- - (IBAction)playButtonAction:(id)sender {
- if (self.callback) {
- self.callback(self.model.videoUrl);
- }
- }
- @end
|