Files
yinmeng-ios/xplan-ios/Base/UI/SendGiftView/View/XPSendGiftView.m

199 lines
5.4 KiB
Mathematica
Raw Normal View History

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"
#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"
#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;
///
@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]) {
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];
[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];
[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);
}];
[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];
}
#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];
}
#pragma mark - XPGiftProtocol
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo {
self.giftBarView.walletInfoModel = balanceInfo;
}
2021-11-15 18:59:44 +08:00
///
- (void)getPacketGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList {
2021-11-12 19:30:53 +08:00
self.giftInfoView.packOriginArray = giftList;
}
2021-11-15 18:59:44 +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];
_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;
}
- (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