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

182 lines
4.7 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-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"
#import "MicroQueueProtocol.h"
2021-11-10 18:42:27 +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;
///
@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]) {
self.roomUid = uid;
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];
}
#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];
_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