12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // HomeCourseTipsView.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2022/4/22.
- //
- #import "HomeCourseTipsView.h"
- @interface HomeCourseTipsView ()
- @property (weak, nonatomic) IBOutlet UIImageView *teacherAvatar;
- @property (weak, nonatomic) IBOutlet UILabel *courseName;
- @property (weak, nonatomic) IBOutlet UILabel *timeLabel;
- @property (nonatomic, copy) HomeCourseCallback callback;
- @property (nonatomic, strong) RecentCourseModel *courseModel;
- @end
- @implementation HomeCourseTipsView
- + (instancetype)shareInstance {
- HomeCourseTipsView *view = [[[NSBundle mainBundle] loadNibNamed:@"HomeCourseTipsView" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)configWithCourseMessage:(RecentCourseModel *)source {
- self.courseModel = source;
- self.courseName.text = [NSString stringWithFormat:@"%@即将开始",[NSString returnNoNullStringWithString:source.courseGroupName]];
- NSDateFormatter *formatter = [NSObject getDateformatter];
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
- NSDate *beginDate = [formatter dateFromString:source.courseStartTime];
- NSDate *currentDate = [NSDate date];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSString *currentDay = [formatter stringFromDate:currentDate];
- NSString *courseDay = [formatter stringFromDate:beginDate];
- if ([currentDay isEqualToString:courseDay]) {
- [formatter setDateFormat:@"HH:mm"];
- self.timeLabel.text = [NSString stringWithFormat:@"今日 %@", [NSString returnNoNullStringWithString:[formatter stringFromDate:beginDate]]];
- }
- else {
- [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
- self.timeLabel.text = [NSString returnNoNullStringWithString:[formatter stringFromDate:beginDate]];
- }
- [self.teacherAvatar sd_setImageWithURL:[NSURL URLWithString:[source.avatar getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
- }
- - (void)joinRoomCallback:(HomeCourseCallback)callback {
- if (callback) {
- self.callback = callback;
- }
- }
- - (IBAction)joinRoomAction:(id)sender {
- if (self.callback) {
- COURSETYPE type;
- if ([self.courseModel.courseType isEqualToString:@"LIVE"]) {
- type = COURSETYPE_LIVE;
- }
- else if ([self.courseModel.courseType isEqualToString:@"PIANO_ROOM_CLASS"]) {
- type = COURSETYPE_MUSICROOM;
- }
- else {
- type = COURSETYPE_ACCOMPANY;
- }
-
- self.callback(type, self.courseModel);
- }
- }
- + (CGFloat)getViewHeight {
- return 80.0f;
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|