房间更多操作按钮

This commit is contained in:
fengshuo
2021-12-11 18:53:07 +08:00
parent fdd50ad5d9
commit bc1da10967
20 changed files with 537 additions and 2 deletions

View File

@@ -305,6 +305,11 @@
E8DEC98F27643EB30078CB70 /* XPCandyTreeAnimationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */; };
E8DEC992276441AA0078CB70 /* XPCandyTreeAnimationModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */; };
E8DEC99527648FA50078CB70 /* ClientConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC99427648FA50078CB70 /* ClientConfig.m */; };
E8DEC99E2764A5B60078CB70 /* XPRoomMoreMenuViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC99D2764A5B60078CB70 /* XPRoomMoreMenuViewController.m */; };
E8DEC9A12764A5D20078CB70 /* XPRoomMoreItemModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC9A02764A5D20078CB70 /* XPRoomMoreItemModel.m */; };
E8DEC9A42764A6600078CB70 /* XPMoreMenuPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC9A32764A6600078CB70 /* XPMoreMenuPresenter.m */; };
E8DEC9A82764A68B0078CB70 /* Api+MoreMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC9A72764A68B0078CB70 /* Api+MoreMenu.m */; };
E8DEC9AC2764A6CD0078CB70 /* XPRoomMoreMenuCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC9AB2764A6CD0078CB70 /* XPRoomMoreMenuCollectionViewCell.m */; };
E8E70D7726F2F15100F03460 /* XPMineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E70D7626F2F15100F03460 /* XPMineViewController.m */; };
E8E70D7A26F2F16600F03460 /* XPMinePresent.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E70D7926F2F16600F03460 /* XPMinePresent.m */; };
E8E70D7E26F2F19D00F03460 /* Api+Mine.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E70D7D26F2F19D00F03460 /* Api+Mine.m */; };
@@ -924,6 +929,17 @@
E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationModel.m; sourceTree = "<group>"; };
E8DEC99327648FA50078CB70 /* ClientConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClientConfig.h; sourceTree = "<group>"; };
E8DEC99427648FA50078CB70 /* ClientConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ClientConfig.m; sourceTree = "<group>"; };
E8DEC99C2764A5B60078CB70 /* XPRoomMoreMenuViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMoreMenuViewController.h; sourceTree = "<group>"; };
E8DEC99D2764A5B60078CB70 /* XPRoomMoreMenuViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMoreMenuViewController.m; sourceTree = "<group>"; };
E8DEC99F2764A5D20078CB70 /* XPRoomMoreItemModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMoreItemModel.h; sourceTree = "<group>"; };
E8DEC9A02764A5D20078CB70 /* XPRoomMoreItemModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMoreItemModel.m; sourceTree = "<group>"; };
E8DEC9A22764A6600078CB70 /* XPMoreMenuPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMoreMenuPresenter.h; sourceTree = "<group>"; };
E8DEC9A32764A6600078CB70 /* XPMoreMenuPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMoreMenuPresenter.m; sourceTree = "<group>"; };
E8DEC9A52764A6760078CB70 /* XPMoreMenuProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMoreMenuProtocol.h; sourceTree = "<group>"; };
E8DEC9A62764A68B0078CB70 /* Api+MoreMenu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Api+MoreMenu.h"; sourceTree = "<group>"; };
E8DEC9A72764A68B0078CB70 /* Api+MoreMenu.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "Api+MoreMenu.m"; sourceTree = "<group>"; };
E8DEC9AA2764A6CD0078CB70 /* XPRoomMoreMenuCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMoreMenuCollectionViewCell.h; sourceTree = "<group>"; };
E8DEC9AB2764A6CD0078CB70 /* XPRoomMoreMenuCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMoreMenuCollectionViewCell.m; sourceTree = "<group>"; };
E8E70D7526F2F15100F03460 /* XPMineViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineViewController.h; sourceTree = "<group>"; };
E8E70D7626F2F15100F03460 /* XPMineViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineViewController.m; sourceTree = "<group>"; };
E8E70D7826F2F16600F03460 /* XPMinePresent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMinePresent.h; sourceTree = "<group>"; };
@@ -2297,6 +2313,7 @@
isa = PBXGroup;
children = (
E8A1E4462761F8EA00B294CA /* CandyTree */,
E8DEC9962764A51F0078CB70 /* MoreView */,
E838D99D275E1B6C0079E0B5 /* AnimationView */,
E82325EA274E2D52003A3332 /* UserCard */,
E8AEAED4271412EC0017FCE0 /* XPRoomViewController.h */,
@@ -2544,6 +2561,72 @@
path = SubViews;
sourceTree = "<group>";
};
E8DEC9962764A51F0078CB70 /* MoreView */ = {
isa = PBXGroup;
children = (
E8DEC99B2764A5620078CB70 /* Model */,
E8DEC99A2764A55C0078CB70 /* Api */,
E8DEC9992764A54C0078CB70 /* View */,
E8DEC9982764A5400078CB70 /* Presenter */,
E8DEC9972764A5340078CB70 /* Protocol */,
);
path = MoreView;
sourceTree = "<group>";
};
E8DEC9972764A5340078CB70 /* Protocol */ = {
isa = PBXGroup;
children = (
E8DEC9A52764A6760078CB70 /* XPMoreMenuProtocol.h */,
);
path = Protocol;
sourceTree = "<group>";
};
E8DEC9982764A5400078CB70 /* Presenter */ = {
isa = PBXGroup;
children = (
E8DEC9A22764A6600078CB70 /* XPMoreMenuPresenter.h */,
E8DEC9A32764A6600078CB70 /* XPMoreMenuPresenter.m */,
);
path = Presenter;
sourceTree = "<group>";
};
E8DEC9992764A54C0078CB70 /* View */ = {
isa = PBXGroup;
children = (
E8DEC9A92764A6AF0078CB70 /* Cell */,
E8DEC99C2764A5B60078CB70 /* XPRoomMoreMenuViewController.h */,
E8DEC99D2764A5B60078CB70 /* XPRoomMoreMenuViewController.m */,
);
path = View;
sourceTree = "<group>";
};
E8DEC99A2764A55C0078CB70 /* Api */ = {
isa = PBXGroup;
children = (
E8DEC9A62764A68B0078CB70 /* Api+MoreMenu.h */,
E8DEC9A72764A68B0078CB70 /* Api+MoreMenu.m */,
);
path = Api;
sourceTree = "<group>";
};
E8DEC99B2764A5620078CB70 /* Model */ = {
isa = PBXGroup;
children = (
E8DEC99F2764A5D20078CB70 /* XPRoomMoreItemModel.h */,
E8DEC9A02764A5D20078CB70 /* XPRoomMoreItemModel.m */,
);
path = Model;
sourceTree = "<group>";
};
E8DEC9A92764A6AF0078CB70 /* Cell */ = {
isa = PBXGroup;
children = (
E8DEC9AA2764A6CD0078CB70 /* XPRoomMoreMenuCollectionViewCell.h */,
E8DEC9AB2764A6CD0078CB70 /* XPRoomMoreMenuCollectionViewCell.m */,
);
path = Cell;
sourceTree = "<group>";
};
E8E70D6E26F2EB1200F03460 /* Mine */ = {
isa = PBXGroup;
children = (
@@ -2929,6 +3012,7 @@
9B7D80502753AA9D003DAC0C /* UITableView+NIMScrollToBottom.m in Sources */,
18E7B22626E8CDCF0064BC9B /* XplanFlutterBoostDelegate.m in Sources */,
E8EEB8F326FC2050007C6EBA /* SDWaitingView.m in Sources */,
E8DEC9A12764A5D20078CB70 /* XPRoomMoreItemModel.m in Sources */,
18F404B7276095D700A6C548 /* SessionChatLimitView.m in Sources */,
E8788942273A55AD00BF1D57 /* XPGiftUsersView.m in Sources */,
E8659909273E800D00EE349D /* XPGiftCollectionViewFlowLayout.m in Sources */,
@@ -2951,6 +3035,7 @@
E8AC723526F49939007D6E91 /* XPMineNotificaPresenter.m in Sources */,
18EE3FE22750C29D00A452BF /* NIMBadgeView.m in Sources */,
E82EE0F8272FDDFA00D15DC1 /* UserPrivacyView.m in Sources */,
E8DEC9A42764A6600078CB70 /* XPMoreMenuPresenter.m in Sources */,
189DD53426DE255300AB55B1 /* TabbarViewController.m in Sources */,
E87A26F927587C62002DDC7A /* XPHomeContainerPresenter.m in Sources */,
18EE401A2754BA9F00A452BF /* NIMMessageMaker.m in Sources */,
@@ -3013,11 +3098,13 @@
E816C11527608A7500C84014 /* XPRoomMiniManager.m in Sources */,
E8EEB91726FC7B35007C6EBA /* XPMineUserInfoDesViewController.m in Sources */,
180806FB2729A354001FD836 /* ThemeColor+Room.m in Sources */,
E8DEC99E2764A5B60078CB70 /* XPRoomMoreMenuViewController.m in Sources */,
E82325F2274E2DE6003A3332 /* XPUserCardViewController.m in Sources */,
E8E70D8626F2F55C00F03460 /* XPMineAccountView.m in Sources */,
E8C6FFCA27548120004DC9F0 /* XPHomePresenter.m in Sources */,
E878893C273A54C300BF1D57 /* Api+Gift.m in Sources */,
E81C279026EB314D0031E639 /* LoginForgetEditView.m in Sources */,
E8DEC9A82764A68B0078CB70 /* Api+MoreMenu.m in Sources */,
E8AC721026F43955007D6E91 /* UIImageConstant.m in Sources */,
E81C27A026EEF83D0031E639 /* XPHtmlUrl.m in Sources */,
E8A03DF0276303D40098D9EA /* XPCandyTreeRankTableViewCell.m in Sources */,
@@ -3119,6 +3206,7 @@
E87A27032758BC81002DDC7A /* XPRoomSearchContainerViewController.m in Sources */,
E884C3722743AEDE00E1EBED /* CustomAttachmentDecoder.m in Sources */,
18EE3FEE2750CE6D00A452BF /* NIMMessageUtils.m in Sources */,
E8DEC9AC2764A6CD0078CB70 /* XPRoomMoreMenuCollectionViewCell.m in Sources */,
9B7D804A2753783D003DAC0C /* SessionViewController.m in Sources */,
E8B846BC26FD7C1200A777FE /* UploadImage.m in Sources */,
186A534D26FC6ED900D67B2C /* TTActionSheetView.m in Sources */,

View File

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_more_menu_gift_value_close@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_more_menu_gift_value_close@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_more_menu_gift_value_open@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_more_menu_gift_value_open@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -22,7 +22,7 @@
#import "XPRoomSendTextView.h"
#import "XPSendGiftView.h"
#import "SessionListViewController.h"
#import "XPRoomMoreMenuViewController.h"
@interface XPRoomMenuContainerView ()
@@ -93,6 +93,12 @@
SessionListViewController * sessionList = [[SessionListViewController alloc] initWithType:SessionListOpenTypeRoom];
[self.delegate.getCurrentNav pushViewController:sessionList animated:YES];
}
break;
case XPRoomMenuItemType_More: {
XPRoomMoreMenuViewController * moreMenuVC = [[XPRoomMoreMenuViewController alloc] initDelegate:self.delegate];
[TTPopup popupView:moreMenuVC.view style:TTPopupStyleActionSheet];
}
break;
default:
break;
}
@@ -241,7 +247,6 @@
[_moreButton setImage:[UIImage imageNamed:@"room_menu_more"] forState:UIControlStateSelected];
_moreButton.tag = XPRoomMenuItemType_More;
[_moreButton addTarget:self action:@selector(menuButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_moreButton.hidden = YES;
}
return _moreButton;
}

View File

@@ -0,0 +1,16 @@
//
// Api+MoreMenu.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/11.
//
#import "Api.h"
NS_ASSUME_NONNULL_BEGIN
@interface Api (MoreMenu)
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// Api+MoreMenu.m
// xplan-ios
//
// Created by on 2021/12/11.
//
#import "Api+MoreMenu.h"
@implementation Api (MoreMenu)
@end

View File

@@ -0,0 +1,29 @@
//
// XPRoomMoreItemModel.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/11.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, RoomMoreMenuType) {
///礼物值
RoomMoreMenuType_Gift_Value = 1,
};
@interface XPRoomMoreItemModel : NSObject
///
@property (nonatomic,copy) NSString *imageName;
///显示的文字
@property (nonatomic,copy) NSString *title;
///类型
@property (nonatomic,assign) RoomMoreMenuType type;
+(XPRoomMoreItemModel *)initWithTitle:(NSString *)title imageName:(NSString *)imageName type:(RoomMoreMenuType)type;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,20 @@
//
// XPRoomMoreItemModel.m
// xplan-ios
//
// Created by on 2021/12/11.
//
#import "XPRoomMoreItemModel.h"
@implementation XPRoomMoreItemModel
+ (XPRoomMoreItemModel *)initWithTitle:(NSString *)title imageName:(NSString *)imageName type:(RoomMoreMenuType)type {
XPRoomMoreItemModel * model = [[self alloc] init];
model.title = title;
model.imageName = imageName;
model.type = type;
return model;
}
@end

View File

@@ -0,0 +1,18 @@
//
// XPMoreMenuPresenter.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/11.
//
#import "BaseMvpPresenter.h"
NS_ASSUME_NONNULL_BEGIN
@class RoomInfoModel;
@interface XPMoreMenuPresenter : BaseMvpPresenter
///获取更多菜单
- (void)getMoreMenuDataSource:(RoomInfoModel *)roomInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,23 @@
//
// XPMoreMenuPresenter.m
// xplan-ios
//
// Created by on 2021/12/11.
//
#import "XPMoreMenuPresenter.h"
#import "XPRoomMoreItemModel.h"
#import "RoomInfoModel.h"
#import "XPMoreMenuProtocol.h"
@implementation XPMoreMenuPresenter
- (void)getMoreMenuDataSource:(RoomInfoModel *)roomInfo {
NSString * giftValueTitle = roomInfo.showGiftValue ? @"关闭礼物值" : @"开启礼物值";
NSString * giftValueImage = roomInfo.showGiftValue ? @"room_more_menu_gift_value_close" : @"room_more_menu_gift_value_open";
XPRoomMoreItemModel * giftValue = [XPRoomMoreItemModel initWithTitle:giftValueTitle imageName:giftValueImage type:RoomMoreMenuType_Gift_Value];
NSArray * array = @[giftValue];
[[self getView] getMoreMenuDataSuccess:array];
}
@end

View File

@@ -0,0 +1,19 @@
//
// XPMoreMenuProtocol.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/11.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class XPRoomMoreItemModel;
@protocol XPMoreMenuProtocol <NSObject>
///更多菜单要展示的内容
- (void)getMoreMenuDataSuccess:(NSArray<XPRoomMoreItemModel *> *)list;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,17 @@
//
// XPRoomMoreMenuTableViewCell.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/11.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class XPRoomMoreItemModel;
@interface XPRoomMoreMenuCollectionViewCell : UICollectionViewCell
@property (nonatomic,strong) XPRoomMoreItemModel *itemModel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,71 @@
//
// XPRoomMoreMenuTableViewCell.m
// xplan-ios
//
// Created by on 2021/12/11.
//
#import "XPRoomMoreMenuCollectionViewCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor+Room.h"
///Model
#import "XPRoomMoreItemModel.h"
@interface XPRoomMoreMenuCollectionViewCell ()
///
@property (nonatomic,strong) UIImageView *logoImageView;
///
@property (nonatomic,strong) UILabel *titleLabel;
@end
@implementation XPRoomMoreMenuCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self.contentView addSubview:self.logoImageView];
[self.contentView addSubview:self.titleLabel];
}
- (void)initSubViewConstraints {
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(30, 30));
make.top.centerX.mas_equalTo(self.contentView);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.contentView);
make.top.mas_equalTo(self.logoImageView.mas_bottom).offset(12);
}];
}
#pragma mark - Getters And Setters
- (UIImageView *)logoImageView {
if (!_logoImageView) {
_logoImageView = [[UIImageView alloc] init];
_logoImageView.userInteractionEnabled = YES;
}
return _logoImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.font = [UIFont systemFontOfSize:10];
_titleLabel.textColor = [ThemeColor mainTextColor];
}
return _titleLabel;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPRoomMoreMenuViewController.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/11.
//
#import "MvpViewController.h"
#import "RoomHostDelegate.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomMoreMenuViewController : MvpViewController
- (instancetype)initDelegate:(id<RoomHostDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,151 @@
//
// XPRoomMoreMenuViewController.m
// xplan-ios
//
// Created by on 2021/12/11.
//
#import "XPRoomMoreMenuViewController.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "XPMacro.h"
#import "TTPopup.h"
///View
#import "XPRoomMoreMenuCollectionViewCell.h"
///P
#import "XPMoreMenuPresenter.h"
#import "XPMoreMenuProtocol.h"
@interface XPRoomMoreMenuViewController ()<UICollectionViewDelegate, UICollectionViewDataSource,XPMoreMenuProtocol>
///View
@property (nonatomic,strong) UIView * topView;
///View
@property (nonatomic,strong) UIView * contentView;
///
@property (nonatomic,strong) UICollectionView *collectionView;
///
@property (nonatomic,strong) NSArray<XPRoomMoreItemModel *> *datasource;
///host
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
@end
@implementation XPRoomMoreMenuViewController
- (instancetype)initDelegate:(id<RoomHostDelegate>)delegate {
if (self = [super init]) {
self.hostDelegate = delegate;
}
return self;
}
- (XPMoreMenuPresenter *)createPresenter {
return [[XPMoreMenuPresenter alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
[self.presenter getMoreMenuDataSource:self.hostDelegate.getRoomInfo];
}
#pragma mark - Private Method
- (void)initSubViews {
self.view.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.topView];
[self.view addSubview:self.contentView];
[self.contentView addSubview:self.collectionView];
}
- (void)initSubViewConstraints {
[self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.contentView.mas_top);
}];
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self.view);
make.height.mas_equalTo(0);
}];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.contentView);
}];
}
#pragma mark - XPMoreMenuProtocol
- (void)getMoreMenuDataSuccess:(NSArray<XPRoomMoreItemModel *> *)list {
self.datasource = list;
[self.collectionView reloadData];
CGFloat contentHeight= 24 + 36;
CGFloat itemHeight = 52;
int page = list.count % 4;
int scale = page / 4;
if (scale > 0) {
contentHeight += ((page+1) *itemHeight + page * 10);
} else {
contentHeight += (page *itemHeight + (page -1) * 10);
}
CAShapeLayer * layer = [CAShapeLayer layer];
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KScreenWidth, contentHeight) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)];
layer.path = path.CGPath;
self.contentView.layer.mask = layer;
[self.contentView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(contentHeight);
}];
}
#pragma mark - UICollectionViewDelegate And UICollectionViewDatasource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.datasource.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPRoomMoreMenuCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPRoomMoreMenuCollectionViewCell class]) forIndexPath:indexPath];
cell.itemModel = [self.datasource objectAtIndex:indexPath.row];
return cell;
}
#pragma mark - Event Response
- (void)disMissRecognizer {
[TTPopup dismiss];
}
#pragma mark - Getters And Setters
- (UICollectionView *)collectionView{
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.sectionInset = UIEdgeInsetsMake(24, 0, 36, 0);
layout.itemSize = CGSizeMake(KScreenWidth /5, 52);
layout.minimumLineSpacing = 10;
layout.minimumInteritemSpacing = 0;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.backgroundColor = [UIColor clearColor];
[_collectionView registerClass:[XPRoomMoreMenuCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPRoomMoreMenuCollectionViewCell class])];
}
return _collectionView;
}
- (UIView *)topView {
if (!_topView) {
_topView = [[UIView alloc] init];
_topView.backgroundColor = [UIColor clearColor];
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(disMissRecognizer)];
[_topView addGestureRecognizer:tap];
}
return _topView;
}
- (UIView *)contentView {
if (!_contentView) {
_contentView = [[UIView alloc] init];
_contentView.backgroundColor = [UIColor blackColor];
_contentView.alpha = 0.9;
}
return _contentView;
}
@end