From 32c51a1778643faebc4c0bc7fa079f6b03272a1f Mon Sep 17 00:00:00 2001 From: chenguilong <598604202@qq.com> Date: Wed, 28 Sep 2022 18:28:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=88=AA=E6=B5=B7/=E7=B3=96=E6=9E=9C=E6=A0=91?= =?UTF-8?q?=E6=8A=98=E5=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios.xcodeproj/project.pbxproj | 20 ++ .../Model/XPRoomActivityPlayModel.h | 27 +++ .../Model/XPRoomActivityPlayModel.m | 12 + .../XPRoomActivityContainerView.m | 211 +++++++++++++----- .../XPRoomActivityPlayView.h | 32 +++ .../XPRoomActivityPlayView.m | 125 +++++++++++ 6 files changed, 366 insertions(+), 61 deletions(-) create mode 100644 xplan-ios/Main/Room/View/ActivityContainerView/Model/XPRoomActivityPlayModel.h create mode 100644 xplan-ios/Main/Room/View/ActivityContainerView/Model/XPRoomActivityPlayModel.m create mode 100644 xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityPlayView.h create mode 100644 xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityPlayView.m diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 91952fd9..dad5eef0 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -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 = ""; }; 9BAA5FEE277A23F4007453F3 /* XPPermissionsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPPermissionsViewController.h; sourceTree = ""; }; 9BAA5FEF277A23F4007453F3 /* XPPermissionsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPPermissionsViewController.m; sourceTree = ""; }; + 9BAC92EC28E6989400147DD8 /* XPRoomActivityPlayView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomActivityPlayView.h; sourceTree = ""; }; + 9BAC92ED28E6989400147DD8 /* XPRoomActivityPlayView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomActivityPlayView.m; sourceTree = ""; }; + 9BAC92F028E6A05600147DD8 /* XPRoomActivityPlayModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomActivityPlayModel.h; sourceTree = ""; }; + 9BAC92F128E6A05600147DD8 /* XPRoomActivityPlayModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomActivityPlayModel.m; sourceTree = ""; }; 9BAD41AA28C6EB13005E47B3 /* XPInRoomRecordPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPInRoomRecordPresenter.h; sourceTree = ""; }; 9BAD41AB28C6EB13005E47B3 /* XPInRoomRecordPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPInRoomRecordPresenter.m; sourceTree = ""; }; 9BAD41AD28C6ECBA005E47B3 /* XPInRoomRecordProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPInRoomRecordProtocol.h; sourceTree = ""; }; @@ -4673,6 +4679,15 @@ path = Api; sourceTree = ""; }; + 9BAC92EF28E6A03E00147DD8 /* Model */ = { + isa = PBXGroup; + children = ( + 9BAC92F028E6A05600147DD8 /* XPRoomActivityPlayModel.h */, + 9BAC92F128E6A05600147DD8 /* XPRoomActivityPlayModel.m */, + ); + path = Model; + sourceTree = ""; + }; 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 = ""; @@ -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 */, diff --git a/xplan-ios/Main/Room/View/ActivityContainerView/Model/XPRoomActivityPlayModel.h b/xplan-ios/Main/Room/View/ActivityContainerView/Model/XPRoomActivityPlayModel.h new file mode 100644 index 00000000..63868aec --- /dev/null +++ b/xplan-ios/Main/Room/View/ActivityContainerView/Model/XPRoomActivityPlayModel.h @@ -0,0 +1,27 @@ +// +// XPRoomActivityPlayModel.h +// xplan-ios +// +// Created by GreenLand on 2022/9/30. +// + +#import + +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 diff --git a/xplan-ios/Main/Room/View/ActivityContainerView/Model/XPRoomActivityPlayModel.m b/xplan-ios/Main/Room/View/ActivityContainerView/Model/XPRoomActivityPlayModel.m new file mode 100644 index 00000000..2196b2d5 --- /dev/null +++ b/xplan-ios/Main/Room/View/ActivityContainerView/Model/XPRoomActivityPlayModel.m @@ -0,0 +1,12 @@ +// +// XPRoomActivityPlayModel.m +// xplan-ios +// +// Created by GreenLand on 2022/9/30. +// + +#import "XPRoomActivityPlayModel.h" + +@implementation XPRoomActivityPlayModel + +@end diff --git a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m index 6d9ff6e6..3220ff50 100644 --- a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m +++ b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityContainerView.m @@ -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 () +@interface XPRoomActivityContainerView () ///容器 @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 *activityList; ///活动的地址 @property (nonatomic,strong) NSMutableArray *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]; } } @@ -201,7 +219,22 @@ [self.imageUrlList insertObject:activityInfo.bannerPic atIndex:1]; } } - + + ///根据条件加入航海 + 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 diff --git a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityPlayView.h b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityPlayView.h new file mode 100644 index 00000000..ac9c2d36 --- /dev/null +++ b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityPlayView.h @@ -0,0 +1,32 @@ +// +// XPRoomActivityPlayView.h +// xplan-ios +// +// Created by GreenLand on 2022/9/30. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class XPRoomActivityPlayModel; +@protocol XPRoomActivityPlayViewDelegate + +///展示更多玩法 +- (void)xPRoomActivityPlayViewShowMorePlay; +///隐藏更多玩法 +- (void)xPRoomActivityPlayViewHideMorePlay; +///点击了某个玩法 +- (void)xPRoomActivityPlayViewDidClickPlay:(XPRoomActivityPlayModel *)model; + +@end + +@interface XPRoomActivityPlayView : UIView + +@property (nonatomic, strong) NSMutableArray *playArray; + +@property (nonatomic, weak) id delegate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityPlayView.m b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityPlayView.m new file mode 100644 index 00000000..7c9b87db --- /dev/null +++ b/xplan-ios/Main/Room/View/ActivityContainerView/XPRoomActivityPlayView.m @@ -0,0 +1,125 @@ +// +// XPRoomActivityPlayView.m +// xplan-ios +// +// Created by GreenLand on 2022/9/30. +// + +#import "XPRoomActivityPlayView.h" +///Third +#import +#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