153 lines
5.0 KiB
Objective-C
153 lines
5.0 KiB
Objective-C
//
|
|
// XPRoomActivityView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/10/12.
|
|
//
|
|
|
|
#import "XPRoomActivityContainerView.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <SDCycleScrollView/SDCycleScrollView.h>
|
|
///Tool
|
|
#import "ClientConfig.h"
|
|
#import "NetImageView.h"
|
|
///Model
|
|
#import "UserInfoModel.h"
|
|
#import "RoomInfoModel.h"
|
|
///View
|
|
#import "XPCandyTreeViewController.h"
|
|
|
|
|
|
@interface XPRoomActivityContainerView ()<SDCycleScrollViewDelegate>
|
|
///容器
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
///轮播图
|
|
@property (nonatomic,strong) SDCycleScrollView *cycleScrollView;
|
|
///
|
|
@property (nonatomic,strong) UIView * placeHolderView;
|
|
///糖果树
|
|
@property (nonatomic,strong) NetImageView *candyTreeImageView;
|
|
///host 代理
|
|
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
|
|
@end
|
|
|
|
@implementation XPRoomActivityContainerView
|
|
|
|
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate {
|
|
self = [super init];
|
|
if (self) {
|
|
self.hostDelegate = delegate;
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
[self configCandyTree];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self addSubview:self.stackView];
|
|
[self.stackView addArrangedSubview:self.cycleScrollView];
|
|
[self.stackView addArrangedSubview:self.candyTreeImageView];
|
|
[self.stackView addArrangedSubview:self.placeHolderView];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self);
|
|
}];
|
|
|
|
[self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(65, 65));
|
|
}];
|
|
|
|
[self.candyTreeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(65, 65));
|
|
}];
|
|
}
|
|
|
|
- (void)configCandyTree {
|
|
UserInfoModel * userInfo = self.hostDelegate.getUserInfo;
|
|
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
|
if (userInfo.userLevelVo.experLevelSeq >= [ClientConfig shareConfig].openCandyTreeLimitLevel && [ClientConfig shareConfig].openCandyTree && roomInfo.boxSwitchVo.openBoxSwitch) {
|
|
self.candyTreeImageView.hidden = NO;
|
|
if (roomInfo.boxSwitchVo.openBoxIcon.length > 0) {
|
|
self.candyTreeImageView.imageUrl = roomInfo.boxSwitchVo.openBoxIcon;
|
|
} else {
|
|
self.candyTreeImageView.image = [UIImage imageNamed:@"openBoxIcon"];
|
|
}
|
|
} else {
|
|
self.candyTreeImageView.hidden = YES;
|
|
}
|
|
}
|
|
|
|
#pragma mark - RoomGuestDelegate
|
|
- (void)onRoomUpdate {
|
|
[self configCandyTree];
|
|
}
|
|
|
|
#pragma mark - Event Response
|
|
- (void)candyTreeTapRecognizer {
|
|
XPCandyTreeViewController * candyTreeVC = [[XPCandyTreeViewController alloc] initWithDelegate:self.hostDelegate];
|
|
candyTreeVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
[self.hostDelegate.getCurrentNav presentViewController:candyTreeVC animated:YES completion:nil];
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (SDCycleScrollView *)cycleScrollView {
|
|
if (!_cycleScrollView) {
|
|
_cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:nil];
|
|
_cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
|
|
_cycleScrollView.currentPageDotColor = [UIColor whiteColor];
|
|
_cycleScrollView.pageDotColor = [UIColor colorWithWhite:1 alpha:0.15];
|
|
_cycleScrollView.currentPageDotImage = [UIImage imageNamed:@"room_activity_banner_select"];
|
|
_cycleScrollView.pageDotImage = [UIImage imageNamed:@"room_activity_banner_normal"];
|
|
_cycleScrollView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.00];
|
|
_cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
|
|
_cycleScrollView.pageControlBottomOffset = -20;
|
|
_cycleScrollView.hidden = YES;
|
|
}
|
|
return _cycleScrollView;
|
|
}
|
|
|
|
- (UIView *)placeHolderView {
|
|
if (!_placeHolderView) {
|
|
_placeHolderView = [[UIView alloc] init];
|
|
_placeHolderView.backgroundColor = [UIColor clearColor];
|
|
[_placeHolderView setContentHuggingPriority:UILayoutPriorityDragThatCanResizeScene forAxis:UILayoutConstraintAxisHorizontal];
|
|
[_placeHolderView setContentCompressionResistancePriority:UILayoutPriorityFittingSizeLevel forAxis:UILayoutConstraintAxisHorizontal];
|
|
}
|
|
return _placeHolderView;
|
|
}
|
|
|
|
|
|
- (UIStackView *)stackView {
|
|
if (!_stackView) {
|
|
_stackView = [[UIStackView alloc] init];
|
|
_stackView.axis = UILayoutConstraintAxisVertical;
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
_stackView.alignment = UIStackViewAlignmentCenter;
|
|
_stackView.spacing = 10;
|
|
}
|
|
return _stackView;
|
|
}
|
|
|
|
- (UIImageView *)candyTreeImageView {
|
|
if (!_candyTreeImageView) {
|
|
NetImageConfig * config = [[NetImageConfig alloc] init];
|
|
config.placeHolder = [UIImage imageNamed:@"room_candy_tree_enter"];
|
|
config.imageType = ImageTypeUserIcon;
|
|
_candyTreeImageView = [[NetImageView alloc] initWithConfig:config];
|
|
_candyTreeImageView.userInteractionEnabled = YES;
|
|
_candyTreeImageView.hidden = YES;
|
|
_candyTreeImageView.image = [UIImage imageNamed:@"room_candy_tree_enter"];
|
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(candyTreeTapRecognizer)];
|
|
[_candyTreeImageView addGestureRecognizer:tap];
|
|
}
|
|
return _candyTreeImageView;
|
|
}
|
|
|
|
|
|
@end
|