2021-11-10 18:42:27 +08:00
|
|
|
//
|
|
|
|
// XPSendGiftView.m
|
|
|
|
// xplan-ios
|
|
|
|
//
|
|
|
|
// Created by 冯硕 on 2021/11/9.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "XPSendGiftView.h"
|
|
|
|
///Third
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
///Tool
|
|
|
|
#import "XPMacro.h"
|
2021-11-11 18:39:12 +08:00
|
|
|
#import "XPGiftPresenter.h"
|
2021-11-10 18:42:27 +08:00
|
|
|
#import "ThemeColor+SendGift.h"
|
|
|
|
///View
|
|
|
|
#import "XPGiftUsersView.h"
|
|
|
|
#import "XPGiftInfoView.h"
|
|
|
|
#import "XPGiftBarView.h"
|
2021-11-11 18:39:12 +08:00
|
|
|
#import "XPGiftCountView.h"
|
|
|
|
///P
|
|
|
|
#import "XPGiftProtocol.h"
|
|
|
|
#import "MicroQueueProtocol.h"
|
2021-11-10 18:42:27 +08:00
|
|
|
|
2021-11-11 18:39:12 +08:00
|
|
|
@interface XPSendGiftView ()<XPGiftCountViewDelegate, XPGiftBarViewDelegate, XPGiftProtocol, MicroQueueProtocol>
|
2021-11-10 18:42:27 +08:00
|
|
|
///
|
|
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
|
|
///送礼物的人
|
|
|
|
@property (nonatomic,strong) XPGiftUsersView *userView;
|
|
|
|
///送的什么礼物
|
|
|
|
@property (nonatomic,strong) XPGiftInfoView *giftInfoView;
|
|
|
|
///送多少礼物
|
|
|
|
@property (nonatomic,strong) XPGiftBarView *giftBarView;
|
2021-11-11 18:39:12 +08:00
|
|
|
///送礼物的个数
|
|
|
|
@property (nonatomic,strong) XPGiftCountView *giftCountView;
|
|
|
|
///
|
|
|
|
@property (nonatomic,strong) XPGiftPresenter *giftPresenter;
|
|
|
|
///房主的uid
|
|
|
|
@property (nonatomic,copy) NSString *roomUid;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation XPSendGiftView
|
|
|
|
|
|
|
|
- (instancetype)initWithType:(SendGiftType)type uid:(NSString *)uid {
|
|
|
|
if (self = [super init]) {
|
2021-11-11 18:39:12 +08:00
|
|
|
self.roomUid = uid;
|
2021-11-10 18:42:27 +08:00
|
|
|
[self initSubViews];
|
|
|
|
[self initSubViewConstraints];
|
2021-11-11 18:39:12 +08:00
|
|
|
[self initHttpRequest];
|
2021-11-10 18:42:27 +08:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Private Method
|
|
|
|
- (void)initSubViews {
|
|
|
|
self.backgroundColor = [ThemeColor giftBackGroundColor];
|
|
|
|
[self addSubview:self.stackView];
|
2021-11-11 18:39:12 +08:00
|
|
|
[self addSubview:self.giftCountView];
|
2021-11-10 18:42:27 +08:00
|
|
|
[self.stackView addArrangedSubview:self.userView];
|
|
|
|
[self.stackView addArrangedSubview:self.giftInfoView];
|
|
|
|
[self.stackView addArrangedSubview:self.giftBarView];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.width.mas_equalTo(KScreenWidth);
|
|
|
|
make.bottom.mas_equalTo(self.stackView.mas_bottom);
|
|
|
|
}];
|
|
|
|
|
|
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.left.right.top.mas_equalTo(self);
|
|
|
|
}];
|
2021-11-11 18:39:12 +08:00
|
|
|
|
|
|
|
[self.giftCountView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.right.mas_equalTo(-15);
|
|
|
|
make.bottom.mas_equalTo(self.giftBarView.mas_top).offset(-6);
|
|
|
|
make.height.mas_equalTo(250);
|
|
|
|
make.width.mas_equalTo(135);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)initHttpRequest {
|
|
|
|
[self.giftPresenter getUserWallInfo];
|
|
|
|
[self.giftPresenter getNormalGiftList:self.roomUid];
|
|
|
|
[self.giftPresenter getPackGiftList];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - MicroQueueProtocol
|
|
|
|
///房间麦序发生变化
|
|
|
|
- (void)onMicroQueueUpdate:(NSMutableDictionary<NSString *,MicroQueueModel *> *)queue {
|
|
|
|
[self.userView microQueueUpdate:queue.allValues];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - XPGiftCountViewDelegate
|
|
|
|
- (void)xPGiftCountView:(XPGiftCountView *)view didClickItem:(XPGiftCountModel *)model {
|
|
|
|
self.giftCountView.hidden = YES;
|
|
|
|
self.giftBarView.giftCountModel = model;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - XPGiftBarViewDelegate
|
|
|
|
- (void)xPGiftBarView:(XPGiftBarView *)view didClickSendGift:(XPGiftCountModel *)giftCount {
|
|
|
|
|
|
|
|
}
|
|
|
|
///选择个数
|
|
|
|
- (void)xPGiftBarView:(XPGiftBarView *)view didClickCountButton:(UIButton *)sender {
|
|
|
|
self.giftCountView.hidden = !sender.selected;
|
|
|
|
}
|
|
|
|
|
|
|
|
///充值
|
|
|
|
- (void)xPGiftBarView:(XPGiftBarView *)view didClickRechargeButton:(UIButton *)sender {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - XPGiftProtocol
|
|
|
|
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo {
|
|
|
|
self.giftBarView.walletInfoModel = balanceInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
///普通礼物 /幸运礼物
|
|
|
|
- (void)getPacketGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
|
|
|
|
self.giftInfoView.packGiftArray = giftList;
|
|
|
|
}
|
|
|
|
|
|
|
|
///背包礼物
|
|
|
|
- (void)getNormalGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
|
|
|
|
self.giftInfoView.normalGiftArray = giftList;
|
2021-11-10 18:42:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
- (XPGiftUsersView *)userView {
|
|
|
|
if (!_userView) {
|
|
|
|
_userView = [[XPGiftUsersView alloc] initWithType:SendGiftType_Room];
|
|
|
|
}
|
|
|
|
return _userView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (XPGiftInfoView *)giftInfoView {
|
|
|
|
if (!_giftInfoView) {
|
|
|
|
_giftInfoView = [[XPGiftInfoView alloc] init];
|
|
|
|
}
|
|
|
|
return _giftInfoView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (XPGiftBarView *)giftBarView {
|
|
|
|
if (!_giftBarView) {
|
|
|
|
_giftBarView = [[XPGiftBarView alloc] init];
|
2021-11-11 18:39:12 +08:00
|
|
|
_giftBarView.delegate = self;
|
2021-11-10 18:42:27 +08:00
|
|
|
}
|
|
|
|
return _giftBarView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIStackView *)stackView {
|
|
|
|
if (!_stackView) {
|
|
|
|
_stackView = [[UIStackView alloc] init];
|
|
|
|
_stackView.axis = UILayoutConstraintAxisVertical;
|
|
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
|
|
_stackView.alignment = UIStackViewAlignmentFill;
|
|
|
|
_stackView.spacing = 0;
|
|
|
|
_stackView.backgroundColor = [UIColor clearColor];
|
|
|
|
}
|
|
|
|
return _stackView;
|
|
|
|
}
|
|
|
|
|
2021-11-11 18:39:12 +08:00
|
|
|
- (XPGiftCountView *)giftCountView {
|
|
|
|
if (!_giftCountView) {
|
|
|
|
_giftCountView = [[XPGiftCountView alloc] init];
|
|
|
|
_giftCountView.delegate = self;
|
|
|
|
_giftCountView.hidden = YES;
|
|
|
|
}
|
|
|
|
return _giftCountView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (XPGiftPresenter *)giftPresenter {
|
|
|
|
if (!_giftPresenter) {
|
|
|
|
_giftPresenter = [[XPGiftPresenter alloc] init];
|
|
|
|
[_giftPresenter attatchView:self];
|
|
|
|
}
|
|
|
|
return _giftPresenter;
|
|
|
|
}
|
|
|
|
|
2021-11-10 18:42:27 +08:00
|
|
|
@end
|