航海/糖果树折叠

This commit is contained in:
chenguilong
2022-09-28 18:28:59 +08:00
parent 49f8c6f86c
commit 32c51a1778
6 changed files with 366 additions and 61 deletions

View File

@@ -246,6 +246,8 @@
9BA8A48327C726E8000365A3 /* ThemeColor+SkillCard.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BA8A48227C726E8000365A3 /* ThemeColor+SkillCard.m */; };
9BAA5FED277A1BBE007453F3 /* XPPrivacyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAA5FEC277A1BBE007453F3 /* XPPrivacyViewController.m */; };
9BAA5FF0277A23F4007453F3 /* XPPermissionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAA5FEF277A23F4007453F3 /* XPPermissionsViewController.m */; };
9BAC92EE28E6989400147DD8 /* XPRoomActivityPlayView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAC92ED28E6989400147DD8 /* XPRoomActivityPlayView.m */; };
9BAC92F228E6A05600147DD8 /* XPRoomActivityPlayModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAC92F128E6A05600147DD8 /* XPRoomActivityPlayModel.m */; };
9BAD41AC28C6EB13005E47B3 /* XPInRoomRecordPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAD41AB28C6EB13005E47B3 /* XPInRoomRecordPresenter.m */; };
9BB549592782E6A30090CD26 /* XPNobleCenterPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BB549582782E6A30090CD26 /* XPNobleCenterPresenter.m */; };
9BB5495C2782E79E0090CD26 /* NobleCenterModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BB5495B2782E79E0090CD26 /* NobleCenterModel.m */; };
@@ -1658,6 +1660,10 @@
9BAA5FEC277A1BBE007453F3 /* XPPrivacyViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPPrivacyViewController.m; sourceTree = "<group>"; };
9BAA5FEE277A23F4007453F3 /* XPPermissionsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPPermissionsViewController.h; sourceTree = "<group>"; };
9BAA5FEF277A23F4007453F3 /* XPPermissionsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPPermissionsViewController.m; sourceTree = "<group>"; };
9BAC92EC28E6989400147DD8 /* XPRoomActivityPlayView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomActivityPlayView.h; sourceTree = "<group>"; };
9BAC92ED28E6989400147DD8 /* XPRoomActivityPlayView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomActivityPlayView.m; sourceTree = "<group>"; };
9BAC92F028E6A05600147DD8 /* XPRoomActivityPlayModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomActivityPlayModel.h; sourceTree = "<group>"; };
9BAC92F128E6A05600147DD8 /* XPRoomActivityPlayModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomActivityPlayModel.m; sourceTree = "<group>"; };
9BAD41AA28C6EB13005E47B3 /* XPInRoomRecordPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPInRoomRecordPresenter.h; sourceTree = "<group>"; };
9BAD41AB28C6EB13005E47B3 /* XPInRoomRecordPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPInRoomRecordPresenter.m; sourceTree = "<group>"; };
9BAD41AD28C6ECBA005E47B3 /* XPInRoomRecordProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPInRoomRecordProtocol.h; sourceTree = "<group>"; };
@@ -4673,6 +4679,15 @@
path = Api;
sourceTree = "<group>";
};
9BAC92EF28E6A03E00147DD8 /* Model */ = {
isa = PBXGroup;
children = (
9BAC92F028E6A05600147DD8 /* XPRoomActivityPlayModel.h */,
9BAC92F128E6A05600147DD8 /* XPRoomActivityPlayModel.m */,
);
path = Model;
sourceTree = "<group>";
};
9BB549632782F96F0090CD26 /* SubViews */ = {
isa = PBXGroup;
children = (
@@ -7283,8 +7298,11 @@
E8AEAEE527141ACC0017FCE0 /* ActivityContainerView */ = {
isa = PBXGroup;
children = (
9BAC92EF28E6A03E00147DD8 /* Model */,
E8AE427127153A3500BEEBB2 /* XPRoomActivityContainerView.h */,
E8AE427227153A3500BEEBB2 /* XPRoomActivityContainerView.m */,
9BAC92EC28E6989400147DD8 /* XPRoomActivityPlayView.h */,
9BAC92ED28E6989400147DD8 /* XPRoomActivityPlayView.m */,
);
path = ActivityContainerView;
sourceTree = "<group>";
@@ -8986,6 +9004,7 @@
E8E859C128264C2300EE4857 /* MyHTTPConnection.m in Sources */,
9BDA3E7A27FD43EF00517FE6 /* XPAnchorFansTeamEntranceView.m in Sources */,
E81C279826EB3AC40031E639 /* LoginForgetPasswordProtocol.h in Sources */,
9BAC92F228E6A05600147DD8 /* XPRoomActivityPlayModel.m in Sources */,
E8C6FFD42754AA87004DC9F0 /* XPNoteView.m in Sources */,
9BD8D4E328911E9900AE03FF /* XPMineCollectRoomListViewController.m in Sources */,
9B2EA7C628041EFC00ED17BF /* XPAnchorPkPanelView.m in Sources */,
@@ -9251,6 +9270,7 @@
E8E859C428264C2300EE4857 /* HTTPDynamicFileResponse.m in Sources */,
E8E859D028264C2300EE4857 /* DDData.m in Sources */,
E800162F2803FF6200D6D17A /* GuildPersonIncomeRecordModel.m in Sources */,
9BAC92EE28E6989400147DD8 /* XPRoomActivityPlayView.m in Sources */,
E83ABEFD280EB5E200322EE4 /* ContentOpenLiveInfoModel.m in Sources */,
E8E5E1A027C36E3F00F457D8 /* HomeBannerInfoModel.m in Sources */,
E800807F27FD859E0055A8AB /* ClanDetailInfoModel.m in Sources */,

View File

@@ -0,0 +1,27 @@
//
// XPRoomActivityPlayModel.h
// xplan-ios
//
// Created by GreenLand on 2022/9/30.
//
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, RoomActivityPlayType) {
RoomActivityPlayTypeSailing,//航海
RoomActivityPlayTypeCandyTree,//糖果树
};
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomActivityPlayModel : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *imageName;
@property (nonatomic, assign) RoomActivityPlayType playType;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// XPRoomActivityPlayModel.m
// xplan-ios
//
// Created by GreenLand on 2022/9/30.
//
#import "XPRoomActivityPlayModel.h"
@implementation XPRoomActivityPlayModel
@end

View File

@@ -23,6 +23,7 @@
#import "ActivityInfoModel.h"
#import "AttachmentModel.h"
#import "FirstRechargeModel.h"
#import "XPRoomActivityPlayModel.h"
///View
#import "XPRoomHalfWebView.h"
#import "XPCandyTreeViewController.h"
@@ -32,16 +33,17 @@
#import "XPFirstRechargeSuccessView.h"
#import "XPArrangeMicViewController.h"
#import "XPSailingViewController.h"
#import "XPRoomActivityPlayView.h"
@interface XPRoomActivityContainerView ()<SDCycleScrollViewDelegate>
@interface XPRoomActivityContainerView ()<SDCycleScrollViewDelegate, XPRoomActivityPlayViewDelegate>
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) SDCycleScrollView *cycleScrollView;
///
@property (nonatomic,strong) UIView * placeHolderView;
///
@property (nonatomic,strong) NetImageView *candyTreeImageView;
///
@property (nonatomic, strong) XPRoomActivityPlayView *playModeView;
///
@property (nonatomic,strong) UIImageView *firstRechargeImageView;
///
@@ -52,10 +54,15 @@
@property (nonatomic,copy) NSMutableArray<ActivityInfoModel *> *activityList;
///
@property (nonatomic,strong) NSMutableArray<NSString *> *imageUrlList;
///
@property (nonatomic,strong) UIImageView *sailingImageView;
///
@property (nonatomic,assign) BOOL isLoadActivity;
///
@property (nonatomic, strong) NSMutableArray *playModeArray;
///
@property (nonatomic, strong) XPRoomActivityPlayModel *sailingModel;
///
@property (nonatomic, strong) XPRoomActivityPlayModel *candyTreeModel;
@end
@implementation XPRoomActivityContainerView
@@ -78,39 +85,48 @@
[self.stackView addArrangedSubview:self.cycleScrollView];
[self.stackView addArrangedSubview:self.placeHolderView];
[self.stackView addArrangedSubview:self.firstRechargeImageView];
[self.stackView addArrangedSubview:self.sailingImageView];
[self.stackView addArrangedSubview:self.candyTreeImageView];
[self.stackView addArrangedSubview:self.joinDatingView];
[self addSubview:self.playModeView];
}
- (void)initSubViewConstraints {
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
make.left.top.right.mas_equalTo(self);
make.bottom.mas_equalTo(self);
}];
CGFloat itemWidth = KScreenHeight > 667 ? 65 : 55 * kScreenHeightScale;
CGFloat itemWidth = KScreenHeight > 667 ? 65 : 55 * kScreenHeightScale;
[self.playModeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self);
make.top.mas_equalTo(itemWidth + 9);
make.width.mas_equalTo(18);
make.height.mas_equalTo(53);
}];
[self.cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth , itemWidth));
}];
[self.sailingImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth));
}];
[self.firstRechargeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth));
}];
[self.candyTreeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemWidth));
}];
[self.joinDatingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(35* kScreenHeightScale);
}];
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
for (NSInteger i = (self.subviews.count - 1) ; i >= 0 ; i--) {
UIView * subView = [self.subviews objectAtIndex:i];
CGPoint convertPoint = [subView convertPoint:point fromView:self];
if (CGRectContainsPoint(subView.bounds, convertPoint)) {
return [subView hitTest:convertPoint withEvent:event];
}
}
[self xPRoomActivityPlayViewHideMorePlay];
return nil;
}
- (void)requestActivityList {
NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
[Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@@ -146,14 +162,16 @@
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 (![self.playModeArray containsObject:self.candyTreeModel]) {
[self.playModeArray addObject:self.candyTreeModel];
}
if (roomInfo.boxSwitchVo.openBoxIcon.length > 0) {
self.candyTreeImageView.imageUrl = roomInfo.boxSwitchVo.openBoxIcon;
self.candyTreeModel.imageName = roomInfo.boxSwitchVo.openBoxIcon;
} else {
self.candyTreeImageView.image = [UIImage imageNamed:@"openBoxIcon"];
self.candyTreeModel.imageName = @"openBoxIcon";
}
} else {
self.candyTreeImageView.hidden = YES;
[self.playModeArray removeObject:self.candyTreeModel];
}
}
@@ -202,6 +220,21 @@
}
}
///
BOOL hadSailing = NO;
for (ActivityInfoModel *activityInfo in self.activityList) {
if ([activityInfo.bannerName isEqualToString:@"航海"]) {
hadSailing = YES;
}
}
if ([ClientConfig shareConfig].configInfo.linearlyPoolOpenLevel <= self.hostDelegate.getUserInfo.userLevelVo.experLevelSeq && !hadSailing) {
ActivityInfoModel * activityInfo = [[ActivityInfoModel alloc] init];
activityInfo.bannerPic = @"room_sailiing_enter";
activityInfo.bannerName = @"航海";
[self.activityList insertObject:activityInfo atIndex:0];
[self.imageUrlList insertObject:activityInfo.bannerPic atIndex:0];
}
if (self.imageUrlList.count > 0) {
self.cycleScrollView.imageURLStringsGroup = self.imageUrlList;
[self.cycleScrollView setAutoScroll:YES];
@@ -211,13 +244,16 @@
- (void)dealRoomInfoChangeActivity {
__block ActivityInfoModel * firstRechargeActivity;
__block ActivityInfoModel * candyActivity;
__block ActivityInfoModel * candyActivity;
__block ActivityInfoModel * sailingActivity;
[self.activityList enumerateObjectsUsingBlock:^(ActivityInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj.bannerName isEqualToString:@"首充有礼"]) {
firstRechargeActivity = obj;
} else if([obj.bannerName isEqualToString:@"糖果树"]) {
candyActivity = obj;
}
} else if ([obj.bannerName isEqualToString:@"航海"]) {
sailingActivity = obj;
}
}];
if (firstRechargeActivity && [self.activityList containsObject:firstRechargeActivity]) {
@@ -231,6 +267,11 @@
[self.imageUrlList removeObjectAtIndex:index];
[self.activityList removeObject:candyActivity];
}
if (sailingActivity && [self.activityList containsObject:sailingActivity]) {
NSInteger index = [self.activityList indexOfObject:sailingActivity];
[self.imageUrlList removeObjectAtIndex:index];
[self.activityList removeObject:sailingActivity];
}
}
#pragma mark - RoomGuestDelegat
@@ -239,8 +280,8 @@
UserInfoModel * userInfo = self.hostDelegate.getUserInfo;
if (roomInfo.type == RoomType_MiniGame) {
self.firstRechargeImageView.hidden = YES;
self.candyTreeImageView.hidden = YES;
self.sailingImageView.hidden = YES;
[self.playModeArray removeAllObjects];
[self updatePlayModeView];
if (self.isLoadActivity) {
[self configLittleGameActivity];
} else {
@@ -248,7 +289,6 @@
}
} else {
[self dealRoomInfoChangeActivity];
[self configCandyTree];
self.firstRechargeImageView.hidden = !userInfo.isFirstCharge;
if (roomInfo.roomModeType == RoomModeType_Open_Blind || roomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
@@ -274,10 +314,14 @@
}
if ([ClientConfig shareConfig].configInfo.linearlyPoolOpenLevel <= self.hostDelegate.getUserInfo.userLevelVo.experLevelSeq) {
self.sailingImageView.hidden = NO;
if (![self.playModeArray containsObject:self.sailingModel]) {
[self.playModeArray addObject:self.sailingModel];
}
} else {
self.sailingImageView.hidden = YES;
[self.playModeArray removeObject:self.sailingModel];
}
[self configCandyTree];
[self updatePlayModeView];
}
}
@@ -285,6 +329,20 @@
[self onRoomUpdate];
}
- (void)updatePlayModeView {
CGFloat height = 53;
if (self.playModeArray.count) {
[self.playModeView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(height);
}];
} else {
self.playModeView.playArray = nil;
[self.playModeView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(0);
}];
}
}
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
@@ -400,10 +458,35 @@
}];
}
- (void)sailTapRecognizer {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid];
[self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil];
#pragma mark - XPRoomActivityPlayViewDelegate
///
- (void)xPRoomActivityPlayViewShowMorePlay {
self.playModeView.playArray = self.playModeArray;
CGFloat itemWidth = 45;
[self.playModeView mas_updateConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth * 2 + 20, 53));
}];
}
///
- (void)xPRoomActivityPlayViewHideMorePlay {
self.playModeView.playArray = nil;
[self.playModeView mas_updateConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(18, 53));
}];
}
///
- (void)xPRoomActivityPlayViewDidClickPlay:(XPRoomActivityPlayModel *)model {
if (model.playType == RoomActivityPlayTypeSailing) {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid];
[self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil];
} else if (model.playType == RoomActivityPlayTypeCandyTree) {
XPCandyTreeViewController * candyTreeVC = [[XPCandyTreeViewController alloc] initWithDelegate:self.hostDelegate];
candyTreeVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self.hostDelegate.getCurrentNav presentViewController:candyTreeVC animated:YES completion:nil];
}
}
#pragma mark - Getters And Setters
@@ -433,7 +516,6 @@
return _placeHolderView;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
@@ -445,21 +527,6 @@
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;
}
- (UIImageView *)firstRechargeImageView {
if (!_firstRechargeImageView) {
_firstRechargeImageView = [[UIImageView alloc] init];
@@ -491,17 +558,39 @@
return _activityList;
}
- (UIImageView *)sailingImageView {
if (!_sailingImageView) {
_sailingImageView = [[UIImageView alloc] init];
_sailingImageView.image = [UIImage imageNamed:@"room_sailiing_enter"];
_sailingImageView.userInteractionEnabled = YES;
_sailingImageView.hidden = YES;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sailTapRecognizer)];
[_sailingImageView addGestureRecognizer:tap];
}
return _sailingImageView;
- (NSMutableArray *)playModeArray {
if (!_playModeArray) {
_playModeArray = [NSMutableArray array];
}
return _playModeArray;
}
- (XPRoomActivityPlayModel *)sailingModel {
if (!_sailingModel) {
_sailingModel = [[XPRoomActivityPlayModel alloc] init];
_sailingModel.name = @"航海";
_sailingModel.imageName = @"room_sailiing_enter";
_sailingModel.playType = RoomActivityPlayTypeSailing;
}
return _sailingModel;
}
- (XPRoomActivityPlayModel *)candyTreeModel {
if (!_candyTreeModel) {
_candyTreeModel = [[XPRoomActivityPlayModel alloc] init];
_candyTreeModel.name = @"糖果树";
_candyTreeModel.imageName = @"room_candy_tree_enter";
_candyTreeModel.playType = RoomActivityPlayTypeCandyTree;
}
return _candyTreeModel;
}
- (XPRoomActivityPlayView *)playModeView {
if (!_playModeView) {
_playModeView = [[XPRoomActivityPlayView alloc] init];
_playModeView.delegate = self;
}
return _playModeView;
}
@end

View File

@@ -0,0 +1,32 @@
//
// XPRoomActivityPlayView.h
// xplan-ios
//
// Created by GreenLand on 2022/9/30.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class XPRoomActivityPlayModel;
@protocol XPRoomActivityPlayViewDelegate <NSObject>
///展示更多玩法
- (void)xPRoomActivityPlayViewShowMorePlay;
///隐藏更多玩法
- (void)xPRoomActivityPlayViewHideMorePlay;
///点击了某个玩法
- (void)xPRoomActivityPlayViewDidClickPlay:(XPRoomActivityPlayModel *)model;
@end
@interface XPRoomActivityPlayView : UIView
@property (nonatomic, strong) NSMutableArray *playArray;
@property (nonatomic, weak) id<XPRoomActivityPlayViewDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,125 @@
//
// XPRoomActivityPlayView.m
// xplan-ios
//
// Created by GreenLand on 2022/9/30.
//
#import "XPRoomActivityPlayView.h"
///Third
#import <Masonry/Masonry.h>
#import "XPMacro.h"
#import "ThemeColor.h"
///Model
#import "XPRoomActivityPlayModel.h"
#import "NetImageView.h"
@interface XPRoomActivityPlayView()
@property (nonatomic, strong) UIButton *moreButton;
@end
@implementation XPRoomActivityPlayView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.moreButton.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomLeft cornerRadii:CGSizeMake(8, 8)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.moreButton.bounds;
maskLayer.path = maskPath.CGPath;
self.moreButton.layer.mask = maskLayer;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.moreButton];
}
- (void)initSubViewConstraints {
[self.moreButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.bottom.mas_equalTo(self);
make.width.mas_equalTo(18);
}];
}
- (void)moreButtonAction:(UIButton *)sender {
if (self.frame.size.width > 18) {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomActivityPlayViewHideMorePlay)]) {
[self.delegate xPRoomActivityPlayViewHideMorePlay];
}
} else {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomActivityPlayViewShowMorePlay)]) {
[self.delegate xPRoomActivityPlayViewShowMorePlay];
}
}
}
- (void)imageTapRecognizer:(UITapGestureRecognizer *)ges {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomActivityPlayViewDidClickPlay:)]) {
XPRoomActivityPlayModel *model = self.playArray[ges.view.tag];
[self.delegate xPRoomActivityPlayViewDidClickPlay:model];
}
}
- (void)setPlayArray:(NSMutableArray *)playArray {
_playArray = playArray;
if (playArray.count) {
CGFloat itemWidth = 45;
for (int i = 0; i<playArray.count; i++) {
XPRoomActivityPlayModel *model = playArray[i];
NetImageView *imageView = [[NetImageView alloc] init];
if (model.playType == RoomActivityPlayTypeCandyTree) {
imageView.imageUrl = model.imageName;
} else {
imageView.image = [UIImage imageNamed:model.imageName];
}
imageView.tag = i;
if (i == 0) {
imageView.frame = CGRectMake(18, (53 - itemWidth ) * 0.5, itemWidth, itemWidth);
} else {
imageView.frame = CGRectMake(18 + i * (itemWidth+2), (53 - itemWidth ) * 0.5, itemWidth, itemWidth);
}
imageView.backgroundColor = UIColorRGBAlpha(0xD7D7D7, 0.2);
imageView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapRecognizer:)];
[imageView addGestureRecognizer:tap];
[self addSubview:imageView];
}
} else {
for (UIView *view in self.subviews) {
if (view != self.moreButton) {
[view removeFromSuperview];
}
}
}
}
- (UIButton *)moreButton {
if (!_moreButton) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.titleLabel.font = [UIFont systemFontOfSize:10];
[button addTarget:self action:@selector(moreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"更多玩法" forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;//
button.titleLabel.numberOfLines = 0;
button.backgroundColor = UIColorFromRGB(0x7B2FE0);
button.titleLabel.textAlignment = NSTextAlignmentCenter;
_moreButton = button;
}
return _moreButton;
}
@end