RQSynExerciseCell.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // RQSynExerciseCell.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2022/5/24.
  6. //
  7. #import "RQSynExerciseCell.h"
  8. @interface RQSynExerciseCell ()
  9. @property (nonatomic, readwrite, strong) RQWrongAndCollectionItemViewModel *viewModel;
  10. @property (weak, nonatomic) IBOutlet QMUIButton *synExerciseBtn;
  11. @end
  12. @implementation RQSynExerciseCell
  13. #pragma mark - PublicMethods
  14. + (instancetype)cellWithTableView:(UITableView *)tableView {
  15. static NSString *ID = @"RQSynExerciseCell";
  16. RQSynExerciseCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  17. if (!cell) {
  18. cell = [self rq_viewFromXib];
  19. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  20. cell.synExerciseBtn.layer.cornerRadius = RQ_FIT_HORIZONTAL(44.f) / 2.f;
  21. }
  22. return cell;
  23. }
  24. - (void)bindViewModel:(RQWrongAndCollectionItemViewModel *)viewModel {
  25. _viewModel = viewModel;
  26. }
  27. #pragma mark - SystemMethods
  28. - (void)awakeFromNib {
  29. [super awakeFromNib];
  30. [_synExerciseBtn setQmui_tapBlock:^(__kindof UIControl *sender) {
  31. [MBProgressHUD rq_showProgressHUD:@"同步中..."];
  32. [RQ_UPDATE_LOCALDATA_MANAGER updateLocalWrongAndCollectionWithComplete:^(BOOL isSuccess, NSError * _Nullable error) {
  33. [MBProgressHUD rq_hideHUD];
  34. if (isSuccess) {
  35. [MBProgressHUD rq_showTips:@"同步成功"];
  36. } else {
  37. [MBProgressHUD rq_showErrorTips:error];
  38. }
  39. [RQ_SDJK_DB_MANAGER refreshWrongAndCollectCount];
  40. }];
  41. }];
  42. }
  43. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  44. [super setSelected:selected animated:animated];
  45. }
  46. @end