1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // YMPersonalDynamicCellViewModel.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/3.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMPersonalDynamicCellViewModel.h"
- #import "YMDynamicListModel.h"
- @interface YMPersonalDynamicCellViewModel()
- /// 用户Id
- @property (nonatomic, assign, readwrite) NSInteger userId;
- @property (nonatomic, assign, readwrite) NSInteger dynamic_id;
- /// 用户头像
- @property (nonatomic, strong, readwrite) NSString *userAvatar;
- /// 用户昵称
- @property (nonatomic, strong, readwrite) NSString *userNickname;
- /// 用户昵称颜色
- @property (nonatomic, strong, readwrite) UIColor *userNicknameColor;
- /// 用户描述
- @property (nonatomic, strong, readwrite) NSString *userDesc;
- /// 是否隐藏VIP图标
- @property (nonatomic, assign, readwrite) BOOL isHideVIPIcon;
- /// 是否隐藏心动按钮
- @property (nonatomic, assign, readwrite) BOOL isHideHeartbeatButton;
- /// 用户内容
- @property (nonatomic, strong, readwrite) NSString *userContent;
- /// 相册数据
- @property (nonatomic, strong, readwrite) NSArray <YMPersonalDynamicAlbumCellViewModel*>*albumDataArray;
- /// 日期
- @property (nonatomic, strong, readwrite) NSString *date;
- /// 评论图片
- @property (nonatomic, strong, readwrite) UIImage *commentsImage;
- /// 评论数量
- @property (nonatomic, strong, readwrite) NSString *commentsNumber;
- /// 点赞图片
- @property (nonatomic, strong, readwrite) UIImage *likesImage;
- /// 点赞数量
- @property (nonatomic, strong, readwrite) NSString *likesNumber;
- @end
- @implementation YMPersonalDynamicCellViewModel
- - (void)ym_initialize{
- [super ym_initialize];
-
- if ([self.params[ParamsModel] isKindOfClass:[YMDynamicListModel class]]) {
- YMDynamicListModel *model = self.params[ParamsModel];
- self.userId = model.user_id;
- self.userAvatar = model.avatar;
- self.userNickname = model.nickname;
- self.dynamic_id = model.dynamic_id;
- if (model.vip != 1) {
- self.userNicknameColor = HexColorFromRGB(0x333333);
- } else {
- self.userNicknameColor = HexColorFromRGB(0x954403);
- }
-
- NSMutableString *desc = [NSMutableString string];
- if (model.age != 0) {
- [desc appendFormat:@"%ld岁 | ",model.age];
- }
-
- if (!OCStringIsEmpty(model.height)) {
- [desc appendFormat:@"%@ | ",model.height];
- }
-
- if (!OCStringIsEmpty(model.weight)) {
- [desc appendFormat:@"%@ | ",model.weight];
- }
-
- self.userDesc = [desc substringToIndex:desc.length - 2];
-
- self.isHideVIPIcon = model.vip == 1 ? NO : YES;
-
- self.isHideHeartbeatButton = self.userId == model.user_id ? YES : NO;
-
- self.userContent = model.content;
-
- self.albumDataArray = [model.images.rac_sequence map:^(YMDynamicImageModel * _Nullable value) {
- YMPersonalDynamicAlbumCellViewModel *viewModel = [[YMPersonalDynamicAlbumCellViewModel alloc]initWithParams:@{
- ParamsModel:value
- }];
- return viewModel;
- }].array;
-
- self.date = model.create_time;
-
- self.commentsImage = ImageByName(@"ym_dynamic_comments_icon");
- self.commentsNumber = model.comment_count == 0 ? @"评论" : model.comment_count> 99 ? @"99+" : stringFormat(@"%ld",model.comment_count);
-
- self.likesImage = ImageByName(@"ym_dynamic_likes_normal_icon");
- self.likesNumber = model.like_count == 0 ? @"点赞" : model.like_count> 99 ? @"99+" : stringFormat(@"%ld",model.like_count);
-
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
- }
- }
- @end
|