123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- //
- // YOUPAILPFollowContentView.m
- // zhimi
- //
- // Created by 张灿 on 2019/1/28.
- // Copyright © 2019年 caiPro. All rights reserved.
- //
- #import "YOUPAILPFollowContentView.h"
- #import "YOUPAILPFollowAttachment.h"
- #import "YOUPAILZLiveGradeModel.h"
- #import "YOUPAILZLevelView.h"
- @interface YOUPAILPFollowContentView()
- @property(nonatomic,strong)UIView* backView;
- //@property(nonatomic,strong)UILabel* topTitle;
- //@property(nonatomic,strong)UILabel* timeTitle;
- //@property(nonatomic,strong)UIView* botmView;
- //@property(nonatomic,assign)CGFloat currentY;
- @end
- @implementation YOUPAILPFollowContentView
- - (instancetype)initSessionMessageContentView{
- self = [super initSessionMessageContentView];
- if (self) {
- self.opaque = YES;
- UIView* testView = [[UIView alloc] initWithFrame:CGRectZero];
- testView.backgroundColor= UIColor.whiteColor;
- // testView.layer.cornerRadius = 10.0;
- UITapGestureRecognizer* tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHandel:)];
- [testView addGestureRecognizer:tap];
- self.backView = testView;
- self.bubbleImageView.hidden = YES;
- [self addSubview:testView];
-
- // UILabel* topTitle = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, KScreenWidth-70, 60)];
- // self.topTitle = topTitle;
- // topTitle.font = [UIFont systemFontOfSize:24];
- // topTitle.textColor = LCTextBlack;
- // [self.backView addSubview:topTitle];
-
-
- }
- return self;
- }
- - (void)refresh:(NIMMessageModel *)data{
- [super refresh:data];
- NIMCustomObject *customObject = (NIMCustomObject*)data.message.messageObject;
- id attachment = customObject.attachment;
- if ([attachment isKindOfClass:[YOUPAILPFollowAttachment class]]) {
- for (UIView* subView in self.backView.subviews) {
- [subView removeFromSuperview];
- }
-
- YOUPAILPFollowAttachment* attachment = (YOUPAILPFollowAttachment*)customObject.attachment;
- UILabel* topTitle = [[UILabel alloc]initWithFrame:CGRectMake(14.0f, 0, KScreenWidth-28.0f, 16.0f)];
- topTitle.font = LCFont16;
- topTitle.textColor = LZ273145Color;
- //modify by leo v1.0.7
- NSLog(@"类型 == %ld",attachment.type);
- if(attachment.type == 16)
- topTitle.text = @"新增粉丝";
- else if(attachment.type == 17)
- topTitle.text = @"发布动态";
- else if(attachment.type == 19)
- topTitle.text = @"发布视频";
- else
- topTitle.text = @"上线啦!";
- [self.backView addSubview:topTitle];
-
- // UIView* followView = [[UIView alloc]initWithFrame:CGRectMake(0, 60, KScreenWidth-30, 80)];
- // [self.backView addSubview:followView];
- //
- UIImageView* avatarImgV = [[UIImageView alloc]init];
- avatarImgV.contentMode = UIViewContentModeScaleAspectFill;
- avatarImgV.layer.masksToBounds = YES;
- avatarImgV.layer.cornerRadius = 22.0f;
- [self.backView addSubview:avatarImgV];
- [avatarImgV makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(14);
- make.top.equalTo(topTitle.mas_bottom).offset(17);
- make.size.mas_equalTo(CGSizeMake(44.0f, 44.0f));
- }];
- //
- UILabel* nickLab = [[UILabel alloc]init];
- nickLab.textColor = LZ273145Color;
- nickLab.font = LCFont14;
- [self.backView addSubview:nickLab];
- [nickLab makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(avatarImgV.right).offset(@10);
- make.top.equalTo(avatarImgV.top).offset(@5);
- }];
-
- UIImageView *sexV = [[UIImageView alloc] init];
- [self.backView addSubview:sexV];
- [sexV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(nickLab.mas_right).offset(3.0f);
- make.centerY.equalTo(nickLab);
- make.size.mas_offset(CGSizeMake(15.0f, 15.0f));
- }];
-
- YOUPAILZLevelView *levelView = [[YOUPAILZLevelView alloc] init];
- [self.backView addSubview:levelView];
- [levelView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(sexV.mas_right).offset(5.0f);
- make.centerY.equalTo(nickLab);
- }];
-
- UIButton *hiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- // hiBtn.layer.borderWidth = 0.5f;
- // hiBtn.layer.borderColor = HexColorFromRGB(0xF4003F).CGColor;
- hiBtn.layer.cornerRadius = 11.0f;
- hiBtn.clipsToBounds = YES;
- hiBtn.backgroundColor = HexColorFromRGB(0xF4003F);
- [hiBtn setTitle:@"去打招呼" forState:UIControlStateNormal];
- [hiBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- hiBtn.titleLabel.font = LCFont12;
- [hiBtn addTarget:self action:@selector(hiBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [self.backView addSubview:hiBtn];
- [hiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-14.0f);
- make.centerY.equalTo(avatarImgV);
- make.size.mas_offset(CGSizeMake(64.0f, 22.0f));
- }];
-
- UILabel *signL = [[UILabel alloc] init];
- signL.textColor = HexColorFromRGB(0x9F9DA5);
- signL.font = LCFont12;
- [self.backView addSubview:signL];
- [signL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(avatarImgV.mas_right).offset(10.0f);
- make.top.equalTo(nickLab.mas_bottom).offset(8.0f);
- make.right.equalTo(hiBtn.mas_left).offset(-10.0f);
- }];
- [avatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:attachment.avatar]];
- nickLab.text = attachment.nickname;
- if (attachment.sex == 1) {
- sexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_woman"];
- }else{
- sexV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_man"];
- }
- YOUPAILZLiveGradeModel *model = [YOUPAILZLiveGradeModel mj_objectWithKeyValues:attachment.grade];
- [levelView youpaifreloadWithIcon:model.youpaipimg1 iconWidth:model.youpaipicon_width bgImg:model.youpaipimg2 bgImgWidth:model.youpaipicon1_width levelName:model.youpaipgrade_name level:model.youpaipgrade];
- [levelView mas_updateConstraints:^(MASConstraintMaker *make) {
- make.size.mas_offset(levelView.mj_size);
- }];
- signL.text = attachment.sign.length == 0 ? @" " : attachment.sign;
- }
-
- }
- - (void)tapHandel:(UITapGestureRecognizer*)tap{
- if (tap.state == UIGestureRecognizerStateEnded) {
- // NIMKitEvent *event = [[NIMKitEvent alloc] init];
- // event.eventName = NIMKitEventNameTapContent;
- // event.messageModel = self.model;
- // [self.delegate onCatchEvent:event];
- NIMCustomObject *customObject = (NIMCustomObject*)self.model.message.messageObject;
- YOUPAILPFollowAttachment* attachment = (YOUPAILPFollowAttachment*)customObject.attachment;
- attachment.type = 16;
-
- NIMKitEvent *event = [[NIMKitEvent alloc] init];
- event.eventName = NIMKitEventNameTapContent;
- event.messageModel = self.model;
- [self.delegate onCatchEvent:event];
- }
- }
- - (void)hiBtnClick{
- NIMCustomObject *customObject = (NIMCustomObject*)self.model.message.messageObject;
- YOUPAILPFollowAttachment* attachment = (YOUPAILPFollowAttachment*)customObject.attachment;
- attachment.type = 1;
-
- NIMKitEvent *event = [[NIMKitEvent alloc] init];
- event.eventName = NIMKitEventNameTapContent;
- event.messageModel = self.model;
- [self.delegate onCatchEvent:event];
- }
- - (void)onTouchUpInside:(id)sender
- {
- NIMKitEvent *event = [[NIMKitEvent alloc] init];
- event.eventName = NIMKitEventNameTapContent;
- event.messageModel = self.model;
- [self.delegate onCatchEvent:event];
- }
- - (void)layoutSubviews{
- [super layoutSubviews];
- UIEdgeInsets contentInsets = self.model.contentViewInsets;
- CGSize contentsize = [self.model contentSize:KScreenWidth];
- CGRect imageViewFrame = CGRectMake(contentInsets.left, contentInsets.top, contentsize.width, contentsize.height);
- self.backView.frame = imageViewFrame;
-
- }
- @end
|