// // YMDynamicDetailInfoCellViewModel.m // MSYOUPAI // // Created by YoMi on 2024/3/21. // Copyright © 2024 MS. All rights reserved. // #import "YMDynamicDetailInfoCellViewModel.h" #import "YMDynamicDetailModel.h" @interface YMDynamicDetailInfoCellViewModel() /// 用户Id @property (nonatomic, assign, readwrite) NSInteger userId; /// 用户头像 @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 *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 YMDynamicDetailInfoCellViewModel - (void)ym_initialize{ [super ym_initialize]; if ([self.params[ParamsModel] isKindOfClass:[YMDynamicDetailModel class]]) { YMDynamicDetailModel *model = self.params[ParamsModel]; self.userId = model.user.user_id; self.userAvatar = model.user.avatar; self.userNickname = model.user.nickname; if (model.is_vip != 1) { self.userNicknameColor = HexColorFromRGB(0x333333); } else { self.userNicknameColor = HexColorFromRGB(0x954403); } NSMutableString *desc = [NSMutableString string]; if (model.user.age != 0) { [desc appendFormat:@"%ld岁 | ",model.user.age]; } if (!OCStringIsEmpty(model.user.height)) { [desc appendFormat:@"%@ | ",model.user.height]; } if (!OCStringIsEmpty(model.user.weight)) { [desc appendFormat:@"%@ | ",model.user.weight]; } self.userDesc = [desc substringToIndex:desc.length - 2]; self.isHideVIPIcon = model.is_vip == 1 ? NO : YES; self.isHideHeartbeatButton = self.userId != model.user.user_id ? YES : NO; self.userContent = model.content; self.albumDataArray = [model.images.rac_sequence map:^(YMDynamicImageModel * _Nullable value) { YMDynamicDetailInfoAlbumCellViewModel *viewModel = [[YMDynamicDetailInfoAlbumCellViewModel 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