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-15 18:59:44 +08:00
|
|
|
#import "TTPopup.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"
|
2021-11-15 18:59:44 +08:00
|
|
|
///VC
|
|
|
|
#import "XPMineRechargeViewController.h"
|
|
|
|
#import "XPWebViewController.h"
|
2021-11-10 18:42:27 +08:00
|
|
|
|
2021-11-15 18:59:44 +08:00
|
|
|
@interface XPSendGiftView ()<XPGiftCountViewDelegate, XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate>
|
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-15 18:59:44 +08:00
|
|
|
///代理
|
|
|
|
@property (nonatomic,weak) id<RoomHostDelegate> delegate;
|
2021-11-10 18:42:27 +08:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation XPSendGiftView
|
2021-11-15 18:59:44 +08:00
|
|
|
- (void)dealloc {
|
|
|
|
NSLog(@"六面板销毁了");
|
|
|
|
}
|
2021-11-10 18:42:27 +08:00
|
|
|
|
2021-11-15 18:59:44 +08:00
|
|
|
- (instancetype)initWithType:(SendGiftType)type uid:(NSString *)uid delegate:(id<RoomHostDelegate>)delegate {
|
2021-11-10 18:42:27 +08:00
|
|
|
if (self = [super init]) {
|
2021-11-11 18:39:12 +08:00
|
|
|
self.roomUid = uid;
|
2021-11-15 18:59:44 +08:00
|
|
|
self.delegate = delegate;
|
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];
|
|
|
|
}
|
|
|
|
|
2021-11-15 18:59:44 +08:00
|
|
|
#pragma mark - Public Method
|
|
|
|
- (void)updateMicro:(NSArray<MicroQueueModel *> *)micros {
|
|
|
|
[self.userView microQueueUpdate:micros];
|
2021-11-11 18:39:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
|
|
|
///充值
|
2021-11-15 18:59:44 +08:00
|
|
|
- (void)xPGiftBarViewDidClickRecharge:(XPGiftBarView *)view {
|
|
|
|
[TTPopup dismiss];
|
|
|
|
XPMineRechargeViewController * rechargeVC = [[XPMineRechargeViewController alloc] init];
|
|
|
|
[self.delegate.getCurrentNav pushViewController:rechargeVC animated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - XPGiftInfoViewDelegate
|
|
|
|
- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickPlayRule:(NSString *)ruleUrl {
|
|
|
|
[TTPopup dismiss];
|
|
|
|
XPWebViewController * webVC = [[XPWebViewController alloc] init];
|
|
|
|
webVC.url = ruleUrl;
|
|
|
|
[self.delegate.getCurrentNav pushViewController:webVC animated:YES];
|
2021-11-11 18:39:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - XPGiftProtocol
|
|
|
|
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo {
|
|
|
|
self.giftBarView.walletInfoModel = balanceInfo;
|
|
|
|
}
|
2021-11-15 18:59:44 +08:00
|
|
|
///背包礼物
|
2021-11-11 18:39:12 +08:00
|
|
|
- (void)getPacketGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
|
2021-11-12 19:30:53 +08:00
|
|
|
self.giftInfoView.packOriginArray = giftList;
|
2021-11-11 18:39:12 +08:00
|
|
|
}
|
|
|
|
|
2021-11-15 18:59:44 +08:00
|
|
|
///普通礼物 /幸运礼物
|
2021-11-11 18:39:12 +08:00
|
|
|
- (void)getNormalGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
|
2021-11-12 19:30:53 +08:00
|
|
|
self.giftInfoView.normalOriginArray = 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];
|
2021-11-15 18:59:44 +08:00
|
|
|
_giftInfoView.delegate = self;
|
2021-11-10 18:42:27 +08:00
|
|
|
}
|
|
|
|
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
|