送礼物单独送 以及在坑位上和不再坑位的情况

This commit is contained in:
fengshuo
2021-11-30 15:38:00 +08:00
committed by zu
parent 5a9095fb4c
commit dd303d1176
7 changed files with 107 additions and 33 deletions

View File

@@ -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];