Files
peko-ios/YuMi/Modules/YMNewHome/View/Cell/XPNewHomePartyTableViewCell.m

404 lines
14 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// XPNewHomePartyTableViewCell.m
// YuMi
//
// Created by YuMi on 2022/10/8.
//
#import "XPNewHomePartyTableViewCell.h"
///Third
#import <Masonry/Masonry.h>
2023-09-22 12:20:43 +08:00
#import <SVGA.h>
2023-07-14 18:50:55 +08:00
///Tool
#import "DJDKMIMOMColor.h"
#import "NetImageView.h"
///Model
#import "HomePlayRoomModel.h"
#import "HomeRecommendRoomModel.h"
2023-09-05 11:45:21 +08:00
#import "XPNewHomePartyTagView.h"
#import "XPNewHomePartyAudioView.h"
2023-07-14 18:50:55 +08:00
2023-09-07 19:01:31 +08:00
@interface XPNewHomePartyTableViewCell ()<XPNewHomePartyAudioViewDelegate>
2023-07-14 18:50:55 +08:00
///
@property (nonatomic,strong) NetImageView *avatarImageView;
///
@property (nonatomic,strong) UIView *bgView;
///
@property (nonatomic,strong) UILabel *titleLabel;
2023-09-07 19:01:31 +08:00
///
@property(nonatomic,strong) UIButton *nameTapBtn;
2023-09-05 11:45:21 +08:00
///
@property(nonatomic,strong) XPNewHomePartyTagView *tagView;
///绿
@property(nonatomic,strong) UIView *greenView;
///
@property (nonatomic,strong) UIImageView *borderImageView;
///
@property(nonatomic,strong) UIImageView *gameBgView;
///
@property(nonatomic,strong) UIImageView *gameIconView;
///
@property(nonatomic,strong) XPNewHomePartyAudioView *audioView;
///
@property(nonatomic,strong) UIButton *chatBtn;
///
@property(nonatomic,strong) UIButton *birthdayView;
///
@property(nonatomic,strong) NetImageView *wealthView;
///
@property(nonatomic,strong) NetImageView *charmView;
2023-09-05 15:37:02 +08:00
@property(nonatomic,strong) NSDateFormatter *dateFormatter;
2023-09-22 12:20:43 +08:00
2023-07-14 18:50:55 +08:00
@end
@implementation XPNewHomePartyTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.bgView];
2023-09-05 11:45:21 +08:00
[self.bgView addSubview:self.borderImageView];
[self.bgView addSubview:self.avatarImageView];
[self.bgView addSubview:self.gameBgView];
[self.bgView addSubview:self.gameIconView];
[self.bgView addSubview:self.greenView];
2023-09-07 19:01:31 +08:00
2023-09-05 11:45:21 +08:00
[self.bgView addSubview:self.tagView];
[self.bgView addSubview:self.audioView];
[self.bgView addSubview:self.chatBtn];
2023-09-07 19:01:31 +08:00
[self.bgView addSubview:self.titleLabel];
[self.bgView addSubview:self.birthdayView];
[self.bgView addSubview:self.wealthView];
[self.bgView addSubview:self.charmView];
2023-07-14 18:50:55 +08:00
2023-09-07 19:01:31 +08:00
[self.bgView addSubview:self.nameTapBtn];
2023-07-14 18:50:55 +08:00
}
- (void)initSubViewConstraints {
2023-09-05 11:45:21 +08:00
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(0));
make.width.mas_equalTo(kGetScaleWidth(351));
make.height.mas_equalTo(kGetScaleWidth(96));
make.centerX.equalTo(self.contentView);
}];
[self.borderImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(10));
make.width.height.mas_equalTo(kGetScaleWidth(68));
make.top.mas_equalTo(kGetScaleWidth(14));
}];
2023-07-14 18:50:55 +08:00
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
2023-09-05 11:45:21 +08:00
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(60), kGetScaleWidth(60)));
make.center.equalTo(self.borderImageView);
2023-07-14 18:50:55 +08:00
}];
2023-09-05 11:45:21 +08:00
[self.greenView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(10));
make.leading.mas_equalTo(kGetScaleWidth(60));
make.top.mas_equalTo(kGetScaleWidth(64));
}];
2023-09-07 19:01:31 +08:00
[self.gameBgView mas_makeConstraints:^(MASConstraintMaker *make) {
2023-09-05 11:45:21 +08:00
make.top.mas_equalTo(kGetScaleWidth(48));
make.leading.mas_equalTo(kGetScaleWidth(14));
make.width.mas_equalTo(kGetScaleWidth(60));
make.height.mas_equalTo(kGetScaleWidth(30));
}];
[self.gameIconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(57));
make.leading.mas_equalTo(kGetScaleWidth(26));
make.width.mas_equalTo(kGetScaleWidth(37));
make.height.mas_equalTo(kGetScaleWidth(17));
}];
2023-09-07 19:01:31 +08:00
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
2023-09-05 11:45:21 +08:00
make.top.mas_equalTo(kGetScaleWidth(10));
2023-09-07 19:01:31 +08:00
make.leading.mas_equalTo(kGetScaleWidth(84));
make.height.mas_equalTo(kGetScaleWidth(20));
2023-09-05 11:45:21 +08:00
}];
2023-09-07 19:01:31 +08:00
2023-09-05 11:45:21 +08:00
[self.birthdayView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(28));
make.height.mas_equalTo(kGetScaleWidth(14));
2023-09-07 19:01:31 +08:00
make.leading.equalTo(self.titleLabel.mas_trailing).mas_offset(kGetScaleWidth(4));
make.centerY.equalTo(self.titleLabel);
2023-09-05 11:45:21 +08:00
}];
[self.wealthView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(36));
make.height.mas_equalTo(kGetScaleWidth(18));
2023-09-07 19:01:31 +08:00
make.leading.equalTo(self.birthdayView.mas_trailing).mas_offset(kGetScaleWidth(4));
make.centerY.equalTo(self.titleLabel);
2023-09-05 11:45:21 +08:00
}];
[self.charmView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(36));
make.height.mas_equalTo(kGetScaleWidth(18));
2023-09-07 19:01:31 +08:00
make.leading.equalTo(self.wealthView.mas_trailing).mas_offset(kGetScaleWidth(4));
make.centerY.equalTo(self.titleLabel);
2023-09-05 11:45:21 +08:00
}];
[self.chatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(34));
make.trailing.mas_equalTo(-kGetScaleWidth(10));
make.height.mas_equalTo(kGetScaleWidth(28));
make.width.mas_equalTo(kGetScaleWidth(60));
}];
[self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(84));
make.top.mas_equalTo(kGetScaleWidth(34));
make.height.mas_equalTo(kGetScaleWidth(18));
make.trailing.equalTo(self.chatBtn.mas_leading).mas_offset(-kGetScaleWidth(5));
}];
2023-09-05 15:37:02 +08:00
[self.audioView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(84));
make.height.mas_equalTo(kGetScaleWidth(26));
make.top.equalTo(self.tagView.mas_bottom).mas_offset(kGetScaleWidth(6));
make.trailing.equalTo(self.tagView);
}];
2023-09-07 19:01:31 +08:00
[self.nameTapBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.leading.equalTo(self.titleLabel);
make.trailing.equalTo(self.charmView);
}];
2023-07-14 18:50:55 +08:00
}
#pragma mark - Getters And Setters
- (void)setRoomInfo:(HomePlayRoomModel *)roomInfo {
_roomInfo = roomInfo;
if (_roomInfo) {
2023-09-05 15:37:02 +08:00
self.avatarImageView.imageUrl = _roomInfo.avatar;
2023-09-07 19:01:31 +08:00
NSString *nick = _roomInfo.nick;
if(nick.length > 7){
nick = [NSString stringWithFormat:@"%@...",[_roomInfo.nick substringToIndex:7]];
}
self.titleLabel.text = nick;
_tagView.itemWidthist = _roomInfo.labelsWidthList;
2023-09-05 15:37:02 +08:00
_tagView.itemList = [NSMutableArray arrayWithArray:_roomInfo.labels];
[_birthdayView setTitle:[NSString getAgeWithBirth:_roomInfo.birth] forState:UIControlStateNormal];
2023-09-07 19:01:31 +08:00
_birthdayView.backgroundColor = _roomInfo.gender == GenderType_Male ? UIColorFromRGB(0x6BB3FF) :UIColorFromRGB(0xFF80CC);
2023-09-27 20:17:09 +08:00
self.birthdayView.titleEdgeInsets = _roomInfo.gender != GenderType_Male ? UIEdgeInsetsMake(0, 2, 0, 0):UIEdgeInsetsMake(0, -1, 0, 0);
2023-09-26 17:57:39 +08:00
self.birthdayView.selected = _roomInfo.gender != GenderType_Male;
2023-09-05 15:37:02 +08:00
_gameBgView.hidden = YES;
_gameIconView.hidden = YES;
_borderImageView.hidden = YES;
_greenView.hidden = YES;
[_chatBtn setTitle:YMLocalizedString(@"XPSessionSayHelloTableViewCell0") forState:UIControlStateNormal];
if(_roomInfo.inMic == YES){
_gameBgView.hidden = NO;
_gameIconView.hidden = NO;
_borderImageView.hidden = NO;
[_chatBtn setTitle:YMLocalizedString(@"XPSessionFindNewAlertView2") forState:UIControlStateNormal];
2023-09-21 17:44:59 +08:00
}else{
if(_roomInfo.inOnline == YES){
_greenView.hidden = NO;
}
2023-09-05 15:37:02 +08:00
}
2023-09-21 17:44:59 +08:00
2023-09-07 19:01:31 +08:00
_wealthView.imageUrl = _roomInfo.userLevelVo.experUrl;
_charmView.imageUrl = _roomInfo.userLevelVo.charmUrl;
2023-09-27 20:17:09 +08:00
if(_roomInfo.userVoice.length == 0 && _roomInfo.userDesc.length == 0){
_roomInfo.userDesc = YMLocalizedString(@"XPMineFriendTableViewCell0");
}
2023-09-05 15:37:02 +08:00
if(_roomInfo.userVoice.length > 0){
_audioView.voiceDura = _roomInfo.voiceDura;
_audioView.userVoice = _roomInfo.userVoice;
2023-09-07 19:01:31 +08:00
_audioView.isHiddenVew = NO;
2023-09-05 15:37:02 +08:00
}else{
2023-09-07 19:01:31 +08:00
if(_roomInfo.userDesc.length > 0){
_audioView.isHiddenVew = NO;
_audioView.userDesc = _roomInfo.userDesc;
}else{
_audioView.isHiddenVew = YES;
}
2023-09-05 15:37:02 +08:00
}
2023-07-14 18:50:55 +08:00
}
}
2023-09-07 19:01:31 +08:00
///svga
-(void)setPlaySoundStatus:(BOOL)isPlay{
_audioView.isPlay = isPlay;
if(isPlay == NO){
_audioView.voiceDura = _roomInfo.voiceDura;
}
}
///
-(void)setPlaySoundTime:(NSInteger)time{
_audioView.voiceDura = @(time).stringValue;
}
2023-09-27 21:38:09 +08:00
2023-07-14 18:50:55 +08:00
2023-09-05 15:37:02 +08:00
-(void)didSelectItemAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(xPNewHomePartyTableViewCell:didSelectItem:)]){
[self.delegate xPNewHomePartyTableViewCell:self didSelectItem:self.roomInfo];
}
}
-(void)didSelectChatAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(xPNewHomePartyTableViewCell:didSelectChat:)]){
[self.delegate xPNewHomePartyTableViewCell:self didSelectChat:self.roomInfo];
}
}
2023-09-07 19:01:31 +08:00
#pragma mark - XPNewHomePartyAudioViewDelegate
- (void)xPNewHomePartyAudioView:(XPNewHomePartyAudioView *)view didClickPlaySound:(BOOL)isPlay{
if(self.delegate && [self.delegate respondsToSelector:@selector(xPNewHomePartyTableViewCell:didPlayVoice:didClickPlaySound:)]){
[self.delegate xPNewHomePartyTableViewCell:self didPlayVoice:self.roomInfo didClickPlaySound:isPlay];
}
}
2023-07-14 18:50:55 +08:00
- (NetImageView *)avatarImageView {
if (!_avatarImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
_avatarImageView.layer.masksToBounds = YES;
2023-09-05 15:37:02 +08:00
_avatarImageView.layer.cornerRadius = kGetScaleWidth(60)/2;
_avatarImageView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didSelectItemAction)];
[_avatarImageView addGestureRecognizer:tap];
2023-07-14 18:50:55 +08:00
}
return _avatarImageView;
}
- (UIView *)bgView {
if (!_bgView) {
_bgView = [[UIView alloc] init];
2023-09-05 11:45:21 +08:00
_bgView.backgroundColor = [UIColor whiteColor];
2023-07-14 18:50:55 +08:00
_bgView.layer.masksToBounds = YES;
2023-09-05 11:45:21 +08:00
_bgView.layer.cornerRadius = kGetScaleWidth(12);
2023-07-14 18:50:55 +08:00
}
return _bgView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
2023-09-07 19:01:31 +08:00
_titleLabel.font = kFontMedium(14);
2023-07-14 18:50:55 +08:00
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
}
return _titleLabel;
}
2023-09-05 11:45:21 +08:00
- (UIImageView *)borderImageView {
if (!_borderImageView) {
_borderImageView = [[UIImageView alloc] init];
_borderImageView.userInteractionEnabled = YES;
_borderImageView.layer.cornerRadius = kGetScaleWidth(68)/2;
_borderImageView.layer.masksToBounds = YES;
_borderImageView.layer.borderWidth = kGetScaleWidth(2);
_borderImageView.layer.borderColor = UIColorFromRGB(0xA974FF).CGColor;
}
return _borderImageView;
2023-07-14 18:50:55 +08:00
}
2023-09-05 11:45:21 +08:00
- (UIView *)greenView{
if(!_greenView){
_greenView = [UIView new];
_greenView.backgroundColor = UIColorFromRGB(0x3FE05F);
_greenView.layer.cornerRadius = kGetScaleWidth(10)/2;
_greenView.layer.masksToBounds = YES;
_greenView.layer.borderWidth = 1;
_greenView.layer.borderColor = [UIColor whiteColor].CGColor;
}
return _greenView;
2023-07-14 18:50:55 +08:00
}
2023-09-05 11:45:21 +08:00
- (UIImageView *)gameBgView{
if(!_gameBgView){
_gameBgView = [UIImageView new];
_gameBgView.image = kImage(@"home_palying_bg");
}
return _gameBgView;
2023-07-14 18:50:55 +08:00
}
2023-09-05 11:45:21 +08:00
- (UIImageView *)gameIconView{
if(!_gameIconView){
_gameIconView = [UIImageView new];
2024-04-17 16:02:42 +08:00
_gameIconView.image = [UIImage getLanguageImage:@"home_palying_icon"];
2023-09-05 11:45:21 +08:00
}
return _gameIconView;
}
- (UIButton *)chatBtn{
if(!_chatBtn){
_chatBtn = [UIButton new];
_chatBtn.backgroundColor = UIColorFromRGB(0x9168FA);
[_chatBtn setTitle:YMLocalizedString(@"XPSessionSayHelloTableViewCell0") forState:UIControlStateNormal];
_chatBtn.titleLabel.font = kFontMedium(12);
[_chatBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_chatBtn.layer.cornerRadius = kGetScaleWidth(28)/2;
_chatBtn.layer.masksToBounds = YES;
2023-09-05 15:37:02 +08:00
[_chatBtn addTarget:self action:@selector(didSelectChatAction) forControlEvents:UIControlEventTouchUpInside];
2023-09-05 11:45:21 +08:00
}
return _chatBtn;
}
2023-09-07 19:01:31 +08:00
2023-09-05 11:45:21 +08:00
- (UIButton *)birthdayView{
if(!_birthdayView){
_birthdayView = [UIButton new];
[_birthdayView setImage:kImage(@"home_age_boy_icon") forState:UIControlStateNormal];
[_birthdayView setImage:kImage(@"home_age_girl_icon") forState:UIControlStateSelected];
_birthdayView.titleLabel.font = kFontMedium(10);
[_birthdayView setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
2023-09-07 19:01:31 +08:00
_birthdayView.imageEdgeInsets = UIEdgeInsetsMake(0, -kGetScaleWidth(2), 0, 0);
_birthdayView.layer.cornerRadius = kGetScaleWidth(14)/2;
_birthdayView.layer.masksToBounds = YES;
2024-04-10 17:39:37 +08:00
2023-09-05 11:45:21 +08:00
}
return _birthdayView;
}
- (NetImageView *)wealthView{
if(!_wealthView){
_wealthView = [[NetImageView alloc]init];
}
return _wealthView;
}
- (NetImageView *)charmView{
if(!_charmView){
_charmView = [[NetImageView alloc]init];
}
return _charmView;
2023-07-14 18:50:55 +08:00
}
2023-09-05 15:37:02 +08:00
- (NSDateFormatter *)dateFormatter {
if (!_dateFormatter) {
_dateFormatter = [[NSDateFormatter alloc] init];
_dateFormatter.dateFormat = @"yyyy-MM-dd";
}
return _dateFormatter;
}
2023-09-07 19:01:31 +08:00
- (XPNewHomePartyTagView *)tagView{
if(!_tagView){
_tagView = [[XPNewHomePartyTagView alloc]initWithFrame:CGRectZero];
}
return _tagView;
}
- (XPNewHomePartyAudioView *)audioView{
if(!_audioView){
_audioView = [[XPNewHomePartyAudioView alloc]initWithFrame:CGRectZero];
_audioView.delegate = self;
}
return _audioView;
}
- (UIButton *)nameTapBtn{
if(!_nameTapBtn){
_nameTapBtn = [UIButton new];
[_nameTapBtn addTarget:self action:@selector(didSelectItemAction) forControlEvents:UIControlEventTouchUpInside];
}
return _nameTapBtn;
}
2023-07-14 18:50:55 +08:00
@end