2022-06-02 18:53:45 +08:00
|
|
|
|
//
|
|
|
|
|
// XPHomeNewUserGreetView.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by 冯硕 on 2022/6/2.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "XPNewUserGreetRoomAlertView.h"
|
|
|
|
|
///Third
|
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
|
///Tool
|
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
|
#import "NetImageView.h"
|
|
|
|
|
#import "XPMacro.h"
|
|
|
|
|
#import "TTPopup.h"
|
|
|
|
|
///Model
|
|
|
|
|
#import "NewUserGreetModel.h"
|
|
|
|
|
///View
|
|
|
|
|
#import "XPRoomViewController.h"
|
|
|
|
|
|
|
|
|
|
@interface XPNewUserGreetRoomAlertView ()
|
|
|
|
|
///关闭按钮
|
|
|
|
|
@property (nonatomic,strong) UIButton *closeButton;
|
|
|
|
|
///头像覆盖
|
|
|
|
|
@property (nonatomic,strong) UIImageView *avatarCoverView;
|
|
|
|
|
///头像
|
|
|
|
|
@property (nonatomic,strong) NetImageView *avatarImageView;
|
|
|
|
|
///昵称
|
|
|
|
|
@property (nonatomic,strong) UIButton *nickButton;
|
|
|
|
|
///id
|
|
|
|
|
@property (nonatomic,strong) UILabel *idLabel;
|
|
|
|
|
///打招呼
|
|
|
|
|
@property (nonatomic,strong) UIImageView *greetImageView;
|
|
|
|
|
///打招呼文案
|
|
|
|
|
@property (nonatomic,strong) UILabel *greetLabel;
|
|
|
|
|
///开始浪漫之旅
|
|
|
|
|
@property (nonatomic,strong) UIButton *startButton;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@implementation XPNewUserGreetRoomAlertView
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
|
if (self) {
|
|
|
|
|
[self initSubViews];
|
|
|
|
|
[self initSubViewConstraints];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
- (void)initSubViews {
|
|
|
|
|
[self addSubview:self.closeButton];
|
|
|
|
|
[self addSubview:self.avatarImageView];
|
|
|
|
|
[self addSubview:self.avatarCoverView];
|
|
|
|
|
[self addSubview:self.nickButton];
|
|
|
|
|
[self addSubview:self.idLabel];
|
|
|
|
|
[self addSubview:self.greetImageView];
|
|
|
|
|
[self addSubview:self.greetLabel];
|
|
|
|
|
[self addSubview:self.startButton];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
|
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.width.mas_equalTo(KScreenWidth);
|
|
|
|
|
make.bottom.mas_equalTo(self.startButton.mas_bottom);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(22, 22));
|
|
|
|
|
make.top.mas_equalTo(self);
|
|
|
|
|
make.right.mas_equalTo(self).offset(-52);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.avatarCoverView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(253, 219));
|
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
|
make.top.mas_equalTo(self.closeButton.mas_bottom).offset(32);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(150, 150));
|
|
|
|
|
make.centerX.mas_equalTo(self.avatarCoverView);
|
|
|
|
|
make.top.mas_equalTo(self.avatarCoverView).offset(60);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.nickButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(165, 28));
|
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
|
make.top.mas_equalTo(self.avatarCoverView.mas_bottom).offset(3);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
|
make.top.mas_equalTo(self.nickButton.mas_bottom).offset(7);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.greetImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(289, 86));
|
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
|
make.top.mas_equalTo(self.idLabel.mas_bottom).offset(15);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.greetLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.mas_equalTo(self.greetImageView).inset(48);
|
|
|
|
|
make.centerY.mas_equalTo(self.greetImageView);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.startButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.size.mas_equalTo(CGSizeMake(240, 47));
|
|
|
|
|
make.centerX.mas_equalTo(self);
|
|
|
|
|
make.top.mas_equalTo(self.greetImageView.mas_bottom).offset(36);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
#pragma mark - Event Response
|
|
|
|
|
- (void)closeButtonAction:(UIButton *)sender {
|
|
|
|
|
[TTPopup dismiss];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)startButtonAction:(UIButton *)sender {
|
|
|
|
|
[TTPopup dismiss];
|
|
|
|
|
if (self.greetInfo.roomUid.length > 0) {
|
2022-06-07 16:16:27 +08:00
|
|
|
|
[XPRoomViewController openRoom:self.greetInfo.roomUid fromNick:self.greetInfo.sayHelloUserNickname fromType:UserEnterRoomFromType_New_User_Greet fromUid:self.greetInfo.roomUid viewController:self.currentVC];
|
2022-06-02 18:53:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
|
- (void)setGreetInfo:(NewUserGreetModel *)greetInfo {
|
|
|
|
|
_greetInfo = greetInfo;
|
|
|
|
|
if (_greetInfo) {
|
|
|
|
|
self.avatarImageView.imageUrl = _greetInfo.sayHelloUserAvatar;
|
|
|
|
|
NSString * nick = _greetInfo.sayHelloUserNickname;
|
|
|
|
|
if (nick.length > 6) {
|
|
|
|
|
nick = [nick substringToIndex:6];
|
|
|
|
|
}
|
|
|
|
|
[self.nickButton setTitle:nick forState:UIControlStateNormal];
|
|
|
|
|
self.idLabel.text = [NSString stringWithFormat:@"ID:%@", _greetInfo.sayHelloUserErbanNo];
|
2022-09-22 14:08:26 +08:00
|
|
|
|
self.greetLabel.text = _greetInfo.sayHelloMsg.length > 0 ? _greetInfo.sayHelloMsg : @"欢迎来到魔力,Ta已经等待你很久啦,快来一起玩吧~";
|
2022-06-02 18:53:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)closeButton {
|
|
|
|
|
if (!_closeButton) {
|
|
|
|
|
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_closeButton setImage:[UIImage imageNamed:@"home_new_user_greet_close"] forState:UIControlStateNormal];
|
|
|
|
|
[_closeButton setImage:[UIImage imageNamed:@"home_new_user_greet_close"] forState:UIControlStateSelected];
|
|
|
|
|
[_closeButton addTarget:self action:@selector(closeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
}
|
|
|
|
|
return _closeButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIImageView *)avatarCoverView {
|
|
|
|
|
if (!_avatarCoverView) {
|
|
|
|
|
_avatarCoverView = [[UIImageView alloc] init];
|
|
|
|
|
_avatarCoverView.userInteractionEnabled = YES;
|
|
|
|
|
_avatarCoverView.image = [UIImage imageNamed:@"home_new_user_greet_avatar_bg"];
|
|
|
|
|
}
|
|
|
|
|
return _avatarCoverView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NetImageView *)avatarImageView {
|
|
|
|
|
if (!_avatarImageView) {
|
|
|
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
|
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
|
|
|
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
|
|
|
|
|
_avatarImageView.layer.masksToBounds = YES;
|
|
|
|
|
_avatarImageView.layer.cornerRadius = 150/2;
|
|
|
|
|
}
|
|
|
|
|
return _avatarImageView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)nickButton {
|
|
|
|
|
if (!_nickButton) {
|
|
|
|
|
_nickButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_nickButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
|
|
_nickButton.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
|
|
|
[_nickButton setBackgroundImage:[UIImage imageNamed:@"home_new_user_greet_nick_bg"] forState:UIControlStateNormal];
|
|
|
|
|
}
|
|
|
|
|
return _nickButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)idLabel {
|
|
|
|
|
if (!_idLabel) {
|
|
|
|
|
_idLabel = [[UILabel alloc] init];
|
|
|
|
|
_idLabel.font = [UIFont systemFontOfSize:12];
|
|
|
|
|
_idLabel.textColor = [UIColor whiteColor];
|
|
|
|
|
}
|
|
|
|
|
return _idLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIImageView *)greetImageView {
|
|
|
|
|
if (!_greetImageView) {
|
|
|
|
|
_greetImageView = [[UIImageView alloc] init];
|
|
|
|
|
_greetImageView.userInteractionEnabled = YES;
|
|
|
|
|
_greetImageView.image = [UIImage imageNamed:@"home_new_user_greet_bg"];
|
|
|
|
|
}
|
|
|
|
|
return _greetImageView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)greetLabel {
|
|
|
|
|
if (!_greetLabel) {
|
|
|
|
|
_greetLabel = [[UILabel alloc] init];
|
|
|
|
|
_greetLabel.font = [UIFont systemFontOfSize:12];
|
|
|
|
|
_greetLabel.textColor = UIColorFromRGB(0xA00BBB);
|
|
|
|
|
_greetLabel.numberOfLines = 3;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return _greetLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)startButton {
|
|
|
|
|
if (!_startButton) {
|
|
|
|
|
_startButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_startButton setTitle:@"开启浪漫之旅" forState:UIControlStateNormal];
|
|
|
|
|
[_startButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
|
|
_startButton.titleLabel.font = [UIFont systemFontOfSize:20 weight:UIFontWeightBold];
|
|
|
|
|
[_startButton setBackgroundImage:[UIImage imageNamed:@"home_new_user_greet_start_bg"] forState:UIControlStateNormal];
|
|
|
|
|
[_startButton addTarget:self action:@selector(startButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
}
|
|
|
|
|
return _startButton;
|
|
|
|
|
}
|
|
|
|
|
@end
|