送礼物单独送 以及在坑位上和不再坑位的情况
This commit is contained in:
@@ -10,21 +10,27 @@
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "NetImageView.h"
|
||||
#import "ThemeColor.h"
|
||||
///Model
|
||||
#import "UserInfoModel.h"
|
||||
#import "XPGiftUserInfoModel.h"
|
||||
///view
|
||||
#import "XPGiftUserCollectionViewCell.h"
|
||||
@interface XPGiftUsersView ()<UICollectionViewDelegate, UICollectionViewDataSource>
|
||||
///
|
||||
///麦上的送礼物
|
||||
@property (nonatomic,strong) UIStackView *stackView;
|
||||
///全麦
|
||||
@property (nonatomic,strong) UIButton *allMicroButton;
|
||||
///列表
|
||||
@property (nonatomic,strong) UICollectionView *collectionView;
|
||||
///送礼物的类型
|
||||
@property (nonatomic,assign) SendGiftType type;
|
||||
///
|
||||
///单独送一个人礼物
|
||||
@property (nonatomic,strong) UIStackView *oneStackView;
|
||||
///昵称
|
||||
@property (nonatomic,strong) NetImageView *avatarImageView;
|
||||
///头像
|
||||
@property (nonatomic,strong) UILabel *nickLabel;
|
||||
///原始的数据
|
||||
@property (nonatomic,strong) NSArray<XPGiftUserInfoModel *> *userArray;
|
||||
///选中的人
|
||||
@property (nonatomic,strong) NSMutableArray<NSString *> *selectUserArray;
|
||||
@@ -34,8 +40,9 @@
|
||||
|
||||
@implementation XPGiftUsersView
|
||||
|
||||
- (instancetype)initWithType:(SendGiftType)type {
|
||||
if (self = [super init]) {
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
@@ -63,11 +70,13 @@
|
||||
- (void)initSubViews {
|
||||
self.backgroundColor = [UIColor clearColor];;
|
||||
[self addSubview:self.stackView];
|
||||
[self addSubview:self.oneStackView];
|
||||
[self.stackView addArrangedSubview:self.allMicroButton];
|
||||
[self.stackView addArrangedSubview:self.collectionView];
|
||||
if (self.type == SendGiftType_User) {
|
||||
self.allMicroButton.hidden = YES;
|
||||
}
|
||||
|
||||
[self.oneStackView addArrangedSubview:self.avatarImageView];
|
||||
[self.oneStackView addArrangedSubview:self.nickLabel];
|
||||
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
@@ -80,9 +89,19 @@
|
||||
make.top.bottom.mas_equalTo(self);
|
||||
}];
|
||||
|
||||
[self.oneStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self).inset(15);
|
||||
make.top.bottom.mas_equalTo(self);
|
||||
}];
|
||||
|
||||
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(43);
|
||||
}];
|
||||
|
||||
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(38, 38));
|
||||
}];
|
||||
}
|
||||
|
||||
/// 查找麦序 坑位上有人的麦序
|
||||
@@ -94,12 +113,9 @@
|
||||
XPGiftUserInfoModel * userInfo = [users objectAtIndex:i];
|
||||
if (userInfo && userInfo.uid > 0 && userInfo.uid != uid.integerValue) { ///自己在麦上不显示在送礼物列表中
|
||||
NSString * uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
if (self.allMicroButton.selected && ![self.selectUserArray containsObject:uid]) {
|
||||
if (userInfo.isSelect) {
|
||||
[self.selectUserArray addObject:uid];
|
||||
}
|
||||
if ([self.selectUserArray containsObject:uid]){
|
||||
userInfo.isSelect = YES;
|
||||
}
|
||||
[tempArray addObject:userInfo];
|
||||
}
|
||||
}
|
||||
@@ -108,8 +124,19 @@
|
||||
|
||||
#pragma mark - Public Method
|
||||
- (void)configGiftUsers:(NSArray<XPGiftUserInfoModel *> *)users {
|
||||
self.userArray = [self findSendGiftAllUsers:users];
|
||||
[self.collectionView reloadData];
|
||||
if (users.count == 1 && users.firstObject.position == nil) {///只有一个 并且用户不再麦序中的话
|
||||
XPGiftUserInfoModel *userInfo = users.firstObject;
|
||||
self.avatarImageView.imageUrl = userInfo.avatar;
|
||||
self.nickLabel.text = userInfo.nick;
|
||||
[self.selectUserArray addObject:[NSString stringWithFormat:@"%ld", userInfo.uid]];
|
||||
self.stackView.hidden = YES;
|
||||
self.oneStackView.hidden = NO;
|
||||
} else {
|
||||
self.userArray = [self findSendGiftAllUsers:users];
|
||||
[self.collectionView reloadData];
|
||||
self.oneStackView.hidden = YES;
|
||||
self.stackView.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDataSource And UICollectionViewDelegate
|
||||
@@ -157,6 +184,38 @@
|
||||
return _stackView;
|
||||
}
|
||||
|
||||
- (UIStackView *)oneStackView {
|
||||
if (!_oneStackView) {
|
||||
_oneStackView = [[UIStackView alloc] init];
|
||||
_oneStackView.axis = UILayoutConstraintAxisHorizontal;
|
||||
_oneStackView.distribution = UIStackViewDistributionFill;
|
||||
_oneStackView.alignment = UIStackViewAlignmentCenter;
|
||||
_oneStackView.spacing = 10;
|
||||
}
|
||||
return _oneStackView;
|
||||
}
|
||||
|
||||
- (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;
|
||||
_avatarImageView.layer.cornerRadius = 38/2;
|
||||
}
|
||||
return _avatarImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)nickLabel {
|
||||
if (!_nickLabel) {
|
||||
_nickLabel = [[UILabel alloc] init];
|
||||
_nickLabel.font = [UIFont systemFontOfSize:12];
|
||||
_nickLabel.textColor = [ThemeColor mainTextColor];
|
||||
}
|
||||
return _nickLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)allMicroButton {
|
||||
if (!_allMicroButton) {
|
||||
_allMicroButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
|
Reference in New Issue
Block a user