AccompanyStudentEvaCell.m 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // AccompanyStudentEvaCell.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/4/6.
  6. //
  7. #import "AccompanyStudentEvaCell.h"
  8. #import "KSStarView.h"
  9. @interface AccompanyStudentEvaCell ()
  10. @property (weak, nonatomic) IBOutlet UILabel *tipsMsg;
  11. @property (weak, nonatomic) IBOutlet UIView *emptyView;
  12. @property (weak, nonatomic) IBOutlet KSStarView *starView;
  13. @property (weak, nonatomic) IBOutlet UILabel *contentLabel;
  14. @property (weak, nonatomic) IBOutlet UIView *evaluateView;
  15. @property (nonatomic, copy) CourseEvaluateCallback callback;
  16. @end
  17. @implementation AccompanyStudentEvaCell
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. // Initialization code
  21. self.selectionStyle = UITableViewCellSelectionStyleNone;
  22. self.starView.allowMark = NO;
  23. self.starView.hidden = YES; // 隐藏星级
  24. }
  25. - (void)configWithEvaluateMessage:(NSString *)evaluateMessage courseStatus:(NSString *)courseStatus starNum:(NSInteger)starNum hasEvaluate:(BOOL)hasEvaluate callback:(CourseEvaluateCallback)callback {
  26. if (callback) {
  27. self.callback = callback;
  28. }
  29. NSString *tipsDesc = @"";
  30. if ([courseStatus isEqualToString:@"COMPLETE"]) {
  31. tipsDesc = @"课程已结束,请对老师的教学进行评价";
  32. if (hasEvaluate) {
  33. self.emptyView.hidden = YES;
  34. self.evaluateView.hidden = YES;
  35. if (![NSString isEmptyString:evaluateMessage]) {
  36. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  37. [paragraphStyle setLineSpacing:4];//调整行间距
  38. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:evaluateMessage attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:13.0f],NSForegroundColorAttributeName:HexRGB(0x333333)}];
  39. self.contentLabel.attributedText = attr;
  40. }
  41. else {
  42. self.contentLabel.attributedText = nil;
  43. }
  44. }
  45. else {
  46. self.emptyView.hidden = NO;
  47. self.contentLabel.attributedText = nil;
  48. self.evaluateView.hidden = NO;
  49. }
  50. }
  51. else {
  52. tipsDesc = @"课程结束之后记得对老师的教学进行评价哦";
  53. self.emptyView.hidden = NO;
  54. self.evaluateView.hidden = YES;
  55. self.contentLabel.attributedText = nil;
  56. }
  57. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  58. [paragraphStyle setLineSpacing:4];//调整行间距
  59. NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:tipsDesc attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:13.0f],NSForegroundColorAttributeName:HexRGB(0x999999)}];
  60. self.tipsMsg.attributedText = attr;
  61. }
  62. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  63. [super setSelected:selected animated:animated];
  64. // Configure the view for the selected state
  65. }
  66. - (IBAction)evaluateAction:(id)sender {
  67. if (self.callback) {
  68. self.callback();
  69. }
  70. }
  71. @end