283 lines
8.8 KiB
Objective-C
283 lines
8.8 KiB
Objective-C
//
|
|
// XPRoomInfoView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/10/11.
|
|
//
|
|
|
|
#import "XPRoomInfoContainerView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <MarqueeLabel.h>
|
|
#import <YYText/YYLabel.h>
|
|
///Tool
|
|
#import "UIImage+Utils.h"
|
|
#import "UIButton+EnlargeTouchArea.h"
|
|
#import "XPMacro.h"
|
|
#import "ThemeColor.h"
|
|
///Model
|
|
#import "RoomInfoModel.h"
|
|
|
|
@interface XPRoomInfoContainerView ()
|
|
///返回按钮
|
|
@property (nonatomic,strong) UIButton *backButton;
|
|
///容器
|
|
@property (nonatomic,strong) UIStackView *nickStackView;
|
|
///
|
|
@property (nonatomic,strong) UIStackView *titleStackView;
|
|
///房间名字
|
|
@property (nonatomic,strong) MarqueeLabel *titleLabel;
|
|
///礼物特效
|
|
@property (nonatomic,strong) UIImageView *giftEffectImageView;
|
|
///锁房标识
|
|
@property (nonatomic,strong) UIImageView *lockRoomImageView;
|
|
///
|
|
@property (nonatomic,strong) UIStackView *onlineStackView;
|
|
///绿色的小圆点
|
|
@property (nonatomic,strong) UIView * greenDotView;
|
|
///音游id和在线人数
|
|
@property (nonatomic,strong) YYLabel *idLabel;
|
|
///收藏
|
|
@property (nonatomic,strong) UIButton *collectButton;
|
|
///分享
|
|
@property (nonatomic,strong) UIButton *shareButton;
|
|
///设置
|
|
@property (nonatomic,strong) UIButton *settingButton;
|
|
@end
|
|
|
|
@implementation XPRoomInfoContainerView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Response
|
|
- (void)backButtonAction:(UIButton *)sender {
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xpRoomInfoContainerView:didClickBackButton:)]) {
|
|
[self.delegate xpRoomInfoContainerView:self didClickBackButton:sender];
|
|
}
|
|
}
|
|
|
|
- (void)shareButtonAction:(UIButton *)sender{
|
|
|
|
}
|
|
|
|
- (void)settingButtonAction:(UIButton *)sender {
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xpRoomInfoContainerView:didClickSettingButton:)]) {
|
|
[self.delegate xpRoomInfoContainerView:self didClickSettingButton:sender];
|
|
}
|
|
}
|
|
|
|
|
|
#pragma mark - Private Method
|
|
|
|
- (void)initSubViews {
|
|
[self addSubview:self.backButton];
|
|
[self addSubview:self.nickStackView];
|
|
[self addSubview:self.collectButton];
|
|
[self addSubview:self.shareButton];
|
|
[self addSubview:self.settingButton];
|
|
|
|
[self.nickStackView addArrangedSubview:self.titleStackView];
|
|
[self.nickStackView addArrangedSubview:self.onlineStackView];
|
|
|
|
[self.onlineStackView addArrangedSubview:self.greenDotView];
|
|
[self.onlineStackView addArrangedSubview:self.idLabel];
|
|
|
|
[self.titleStackView addArrangedSubview:self.titleLabel];
|
|
[self.titleStackView addArrangedSubview:self.giftEffectImageView];
|
|
[self.titleStackView addArrangedSubview:self.lockRoomImageView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self).offset(14);
|
|
make.bottom.equalTo(self).offset(-14);
|
|
make.height.width.equalTo(@22);
|
|
}];
|
|
|
|
// 设置
|
|
[self.settingButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-14);
|
|
make.centerY.mas_equalTo(self.backButton);
|
|
make.width.height.mas_equalTo(20);
|
|
}];
|
|
|
|
[self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.equalTo(self.settingButton.mas_left).offset(-17);
|
|
make.centerY.mas_equalTo(self.backButton);
|
|
make.width.height.mas_equalTo(20);
|
|
}];
|
|
|
|
[self.collectButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.equalTo(self.backButton);
|
|
make.left.equalTo(self.nickStackView.mas_right).offset(5);
|
|
make.width.mas_equalTo(@53);
|
|
make.height.mas_equalTo(@22);
|
|
}];
|
|
|
|
[self.nickStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.mas_equalTo(self.backButton);
|
|
make.left.mas_equalTo(self.backButton.mas_right).offset(10);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_lessThanOrEqualTo(100);
|
|
}];
|
|
|
|
[self.greenDotView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(3,3));
|
|
}];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (void)setRoomInfo:(RoomInfoModel *)roomInfo {
|
|
_roomInfo = roomInfo;
|
|
if (_roomInfo) {
|
|
self.titleLabel.text = _roomInfo.title;
|
|
self.idLabel.text = [NSString stringWithFormat:@"音游号:%ld %ld人在线", (long)_roomInfo.erbanNo, (long)(_roomInfo.onlineNum > 0 ? _roomInfo.onlineNum : 0)];
|
|
self.giftEffectImageView.hidden = !_roomInfo.hasAnimationEffect;
|
|
|
|
}
|
|
}
|
|
|
|
- (UIButton *)backButton{
|
|
if (!_backButton) {
|
|
_backButton = [[UIButton alloc] init];
|
|
[_backButton setImage:[UIImage imageNamed:@"room_info_back"] forState:UIControlStateNormal];
|
|
[_backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[_backButton setEnlargeEdgeWithTop:15 right:15 bottom:15 left:15];
|
|
}
|
|
return _backButton;
|
|
}
|
|
|
|
- (UIButton *)shareButton {
|
|
if(!_shareButton){
|
|
_shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_shareButton setImage:[UIImage imageNamed:@"room_info_share"] forState:UIControlStateNormal];
|
|
[_shareButton addTarget:self action:@selector(shareButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[_shareButton setEnlargeEdgeWithTop:8 right:8 bottom:8 left:8];
|
|
_shareButton.hidden = YES;
|
|
}
|
|
return _shareButton;
|
|
}
|
|
|
|
- (UIButton *)settingButton {
|
|
if (!_settingButton) {
|
|
_settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_settingButton setImage:[UIImage imageNamed:@"room_info_setting"] forState:UIControlStateNormal];
|
|
[_settingButton addTarget:self action:@selector(settingButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[_settingButton setEnlargeEdgeWithTop:8 right:8 bottom:8 left:8];
|
|
}
|
|
return _settingButton;
|
|
}
|
|
|
|
|
|
- (UIButton *)collectButton {
|
|
if (!_collectButton) {
|
|
_collectButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[_collectButton setTitle:@"收藏" forState:UIControlStateNormal];
|
|
[_collectButton setTitle:@"已收藏" forState:UIControlStateSelected];
|
|
[_collectButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateNormal];
|
|
[_collectButton setTitleColor:[ThemeColor mainTextColor] forState:UIControlStateSelected];
|
|
[_collectButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(53, 22)] forState:UIControlStateNormal];
|
|
_collectButton.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
_collectButton.layer.cornerRadius = 11;
|
|
_collectButton.layer.masksToBounds = YES;
|
|
_collectButton.hidden = YES;
|
|
}
|
|
return _collectButton;
|
|
}
|
|
|
|
- (UIStackView *)nickStackView {
|
|
if (!_nickStackView) {
|
|
_nickStackView = [[UIStackView alloc] init];
|
|
_nickStackView.axis = UILayoutConstraintAxisVertical;
|
|
_nickStackView.distribution = UIStackViewDistributionFill;
|
|
_nickStackView.alignment = UIStackViewAlignmentLeading;
|
|
_nickStackView.spacing = 3;
|
|
}
|
|
return _nickStackView;
|
|
}
|
|
|
|
- (UIStackView *)titleStackView {
|
|
if (!_titleStackView) {
|
|
_titleStackView = [[UIStackView alloc] init];
|
|
_titleStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
_titleStackView.distribution = UIStackViewDistributionFill;
|
|
_titleStackView.alignment = UIStackViewAlignmentCenter;
|
|
_titleStackView.spacing = 5;
|
|
}
|
|
return _titleStackView;
|
|
}
|
|
|
|
|
|
- (MarqueeLabel *)titleLabel{
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[MarqueeLabel alloc] init];
|
|
_titleLabel.scrollDuration = 8.0;
|
|
_titleLabel.fadeLength = 6.0f;
|
|
_titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size:14];
|
|
_titleLabel.textColor = [ThemeColor mainTextColor];
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UIImageView *)giftEffectImageView {
|
|
if (!_giftEffectImageView) {
|
|
_giftEffectImageView = [[UIImageView alloc] init];
|
|
_giftEffectImageView.userInteractionEnabled = YES;
|
|
_giftEffectImageView.image = [UIImage imageNamed:@"room_info_gift_effect"];
|
|
}
|
|
return _giftEffectImageView;
|
|
}
|
|
|
|
- (UIImageView *)lockRoomImageView {
|
|
if (!_lockRoomImageView) {
|
|
_lockRoomImageView = [[UIImageView alloc] init];
|
|
_lockRoomImageView.userInteractionEnabled = YES;
|
|
_lockRoomImageView.image = [UIImage imageNamed:@"room_info_lock_room"];
|
|
_lockRoomImageView.hidden = YES;
|
|
}
|
|
return _lockRoomImageView;
|
|
}
|
|
|
|
- (UIStackView *)onlineStackView {
|
|
if (!_onlineStackView) {
|
|
_onlineStackView = [[UIStackView alloc] init];
|
|
_onlineStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
_onlineStackView.distribution = UIStackViewDistributionFill;
|
|
_onlineStackView.alignment = UIStackViewAlignmentCenter;
|
|
_onlineStackView.spacing = 2;
|
|
}
|
|
return _onlineStackView;
|
|
}
|
|
|
|
- (UIView *)greenDotView {
|
|
if (!_greenDotView) {
|
|
_greenDotView = [[UIView alloc] init];
|
|
_greenDotView.backgroundColor = [ThemeColor roomOnLineIdenColor];
|
|
_greenDotView.layer.masksToBounds = YES;
|
|
_greenDotView.layer.cornerRadius = 1.5;
|
|
}
|
|
return _greenDotView;
|
|
}
|
|
|
|
- (YYLabel *)idLabel {
|
|
if (!_idLabel) {
|
|
_idLabel = [[YYLabel alloc] init];
|
|
_idLabel.textColor = [ThemeColor secondTextColor];
|
|
_idLabel.font = [UIFont systemFontOfSize:9];
|
|
}
|
|
return _idLabel;
|
|
}
|
|
|
|
|
|
|
|
@end
|