YMPersonalDynamicCellViewModel.m 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // YMPersonalDynamicCellViewModel.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/3/3.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMPersonalDynamicCellViewModel.h"
  9. #import "YMDynamicListModel.h"
  10. @interface YMPersonalDynamicCellViewModel()
  11. /// 用户Id
  12. @property (nonatomic, assign, readwrite) NSInteger userId;
  13. @property (nonatomic, assign, readwrite) NSInteger dynamic_id;
  14. /// 用户头像
  15. @property (nonatomic, strong, readwrite) NSString *userAvatar;
  16. /// 用户昵称
  17. @property (nonatomic, strong, readwrite) NSString *userNickname;
  18. /// 用户昵称颜色
  19. @property (nonatomic, strong, readwrite) UIColor *userNicknameColor;
  20. /// 用户描述
  21. @property (nonatomic, strong, readwrite) NSString *userDesc;
  22. /// 是否隐藏VIP图标
  23. @property (nonatomic, assign, readwrite) BOOL isHideVIPIcon;
  24. /// 是否隐藏心动按钮
  25. @property (nonatomic, assign, readwrite) BOOL isHideHeartbeatButton;
  26. /// 用户内容
  27. @property (nonatomic, strong, readwrite) NSString *userContent;
  28. /// 相册数据
  29. @property (nonatomic, strong, readwrite) NSArray <YMPersonalDynamicAlbumCellViewModel*>*albumDataArray;
  30. /// 日期
  31. @property (nonatomic, strong, readwrite) NSString *date;
  32. /// 评论图片
  33. @property (nonatomic, strong, readwrite) UIImage *commentsImage;
  34. /// 评论数量
  35. @property (nonatomic, strong, readwrite) NSString *commentsNumber;
  36. /// 点赞图片
  37. @property (nonatomic, strong, readwrite) UIImage *likesImage;
  38. /// 点赞数量
  39. @property (nonatomic, strong, readwrite) NSString *likesNumber;
  40. @end
  41. @implementation YMPersonalDynamicCellViewModel
  42. - (void)ym_initialize{
  43. [super ym_initialize];
  44. if ([self.params[ParamsModel] isKindOfClass:[YMDynamicListModel class]]) {
  45. YMDynamicListModel *model = self.params[ParamsModel];
  46. self.userId = model.user_id;
  47. self.userAvatar = model.avatar;
  48. self.userNickname = model.nickname;
  49. self.dynamic_id = model.dynamic_id;
  50. if (model.vip != 1) {
  51. self.userNicknameColor = HexColorFromRGB(0x333333);
  52. } else {
  53. self.userNicknameColor = HexColorFromRGB(0x954403);
  54. }
  55. NSMutableString *desc = [NSMutableString string];
  56. if (model.age != 0) {
  57. [desc appendFormat:@"%ld岁 | ",model.age];
  58. }
  59. if (!OCStringIsEmpty(model.height)) {
  60. [desc appendFormat:@"%@ | ",model.height];
  61. }
  62. if (!OCStringIsEmpty(model.weight)) {
  63. [desc appendFormat:@"%@ | ",model.weight];
  64. }
  65. self.userDesc = [desc substringToIndex:desc.length - 2];
  66. self.isHideVIPIcon = model.vip == 1 ? NO : YES;
  67. self.isHideHeartbeatButton = self.userId == model.user_id ? YES : NO;
  68. self.userContent = model.content;
  69. self.albumDataArray = [model.images.rac_sequence map:^(YMDynamicImageModel * _Nullable value) {
  70. YMPersonalDynamicAlbumCellViewModel *viewModel = [[YMPersonalDynamicAlbumCellViewModel alloc]initWithParams:@{
  71. ParamsModel:value
  72. }];
  73. return viewModel;
  74. }].array;
  75. self.date = model.create_time;
  76. self.commentsImage = ImageByName(@"ym_dynamic_comments_icon");
  77. self.commentsNumber = model.comment_count == 0 ? @"评论" : model.comment_count> 99 ? @"99+" : stringFormat(@"%ld",model.comment_count);
  78. self.likesImage = ImageByName(@"ym_dynamic_likes_normal_icon");
  79. self.likesNumber = model.like_count == 0 ? @"点赞" : model.like_count> 99 ? @"99+" : stringFormat(@"%ld",model.like_count);
  80. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  81. }
  82. }
  83. @end