小游戏进房的UI

This commit is contained in:
fengshuo
2022-01-21 19:47:46 +08:00
committed by chenguilong
parent 6477042b4e
commit 29f0fa6658
30 changed files with 699 additions and 1 deletions

View File

@@ -252,6 +252,10 @@
E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = E81C27AA26EF2D920031E639 /* ThirdUserInfo.m */; };
E81C27AE26EF39AB0031E639 /* AppDelegate+ThirdConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E81C27AD26EF39AB0031E639 /* AppDelegate+ThirdConfig.m */; };
E81D58822720082A003063FE /* MicroWaveView.m in Sources */ = {isa = PBXBuildFile; fileRef = E81D58812720082A003063FE /* MicroWaveView.m */; };
E81EF6DC279AB5CC00FF3EDE /* XPLittleGameRoomOpenView.m in Sources */ = {isa = PBXBuildFile; fileRef = E81EF6DB279AB5CC00FF3EDE /* XPLittleGameRoomOpenView.m */; };
E81EF6E0279AB7D900FF3EDE /* XPCreateLittleGameCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E81EF6DF279AB7D900FF3EDE /* XPCreateLittleGameCollectionViewCell.m */; };
E81EF6E4279AB92E00FF3EDE /* LittleGameInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E81EF6E3279AB92E00FF3EDE /* LittleGameInfoModel.m */; };
E81EF6E8279AC21E00FF3EDE /* Api+LittleGame.m in Sources */ = {isa = PBXBuildFile; fileRef = E81EF6E7279AC21E00FF3EDE /* Api+LittleGame.m */; };
E82109AD26F1C8A000FC3319 /* CountDownHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E82109AC26F1C8A000FC3319 /* CountDownHelper.m */; };
E82109B026F1D83500FC3319 /* LoginBindPhonePresent.m in Sources */ = {isa = PBXBuildFile; fileRef = E82109AF26F1D83500FC3319 /* LoginBindPhonePresent.m */; };
E82325E6274CCAFA003A3332 /* XPShareInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E82325E5274CCAFA003A3332 /* XPShareInfoModel.m */; };
@@ -1071,6 +1075,14 @@
E81D587B271FBC3B003063FE /* RtcInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RtcInterface.h; sourceTree = "<group>"; };
E81D58802720082A003063FE /* MicroWaveView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicroWaveView.h; sourceTree = "<group>"; };
E81D58812720082A003063FE /* MicroWaveView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicroWaveView.m; sourceTree = "<group>"; };
E81EF6DA279AB5CC00FF3EDE /* XPLittleGameRoomOpenView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPLittleGameRoomOpenView.h; sourceTree = "<group>"; };
E81EF6DB279AB5CC00FF3EDE /* XPLittleGameRoomOpenView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPLittleGameRoomOpenView.m; sourceTree = "<group>"; };
E81EF6DE279AB7D900FF3EDE /* XPCreateLittleGameCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCreateLittleGameCollectionViewCell.h; sourceTree = "<group>"; };
E81EF6DF279AB7D900FF3EDE /* XPCreateLittleGameCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCreateLittleGameCollectionViewCell.m; sourceTree = "<group>"; };
E81EF6E2279AB92E00FF3EDE /* LittleGameInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LittleGameInfoModel.h; sourceTree = "<group>"; };
E81EF6E3279AB92E00FF3EDE /* LittleGameInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LittleGameInfoModel.m; sourceTree = "<group>"; };
E81EF6E6279AC21E00FF3EDE /* Api+LittleGame.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Api+LittleGame.h"; sourceTree = "<group>"; };
E81EF6E7279AC21E00FF3EDE /* Api+LittleGame.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "Api+LittleGame.m"; sourceTree = "<group>"; };
E82109AB26F1C8A000FC3319 /* CountDownHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CountDownHelper.h; sourceTree = "<group>"; };
E82109AC26F1C8A000FC3319 /* CountDownHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CountDownHelper.m; sourceTree = "<group>"; };
E82109AE26F1D83500FC3319 /* LoginBindPhonePresent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoginBindPhonePresent.h; sourceTree = "<group>"; };
@@ -3116,6 +3128,45 @@
path = AppDelegate;
sourceTree = "<group>";
};
E81EF6D9279AB59100FF3EDE /* LittleGame */ = {
isa = PBXGroup;
children = (
E81EF6E5279AC20D00FF3EDE /* Api */,
E81EF6E1279AB90E00FF3EDE /* Model */,
E81EF6DD279AB7AD00FF3EDE /* Cell */,
E81EF6DA279AB5CC00FF3EDE /* XPLittleGameRoomOpenView.h */,
E81EF6DB279AB5CC00FF3EDE /* XPLittleGameRoomOpenView.m */,
);
path = LittleGame;
sourceTree = "<group>";
};
E81EF6DD279AB7AD00FF3EDE /* Cell */ = {
isa = PBXGroup;
children = (
E81EF6DE279AB7D900FF3EDE /* XPCreateLittleGameCollectionViewCell.h */,
E81EF6DF279AB7D900FF3EDE /* XPCreateLittleGameCollectionViewCell.m */,
);
path = Cell;
sourceTree = "<group>";
};
E81EF6E1279AB90E00FF3EDE /* Model */ = {
isa = PBXGroup;
children = (
E81EF6E2279AB92E00FF3EDE /* LittleGameInfoModel.h */,
E81EF6E3279AB92E00FF3EDE /* LittleGameInfoModel.m */,
);
path = Model;
sourceTree = "<group>";
};
E81EF6E5279AC20D00FF3EDE /* Api */ = {
isa = PBXGroup;
children = (
E81EF6E6279AC21E00FF3EDE /* Api+LittleGame.h */,
E81EF6E7279AC21E00FF3EDE /* Api+LittleGame.m */,
);
path = Api;
sourceTree = "<group>";
};
E82109AA26F1C86E00FC3319 /* CountDown */ = {
isa = PBXGroup;
children = (
@@ -4112,6 +4163,7 @@
children = (
9B92C01A27E0BAEB0044C5EA /* NobleTrumpet */,
9B7B605827BB52FD0070BB72 /* AnchorView */,
E81EF6D9279AB59100FF3EDE /* LittleGame */,
E880B396278BD3D800A83B0D /* AcrossRoomPK */,
E8412F9A2779BAC2006E1101 /* Setting */,
E84150B027747A7400A7F548 /* FirstRecharge */,
@@ -4949,6 +5001,7 @@
E8DEC992276441AA0078CB70 /* XPCandyTreeAnimationModel.m in Sources */,
9B1EF3D527E8294B00554295 /* XPMineDressEmptyCollectionViewCell.m in Sources */,
E890BC07273CF1800007C46B /* XPGiftCountCollectionViewCell.m in Sources */,
E81EF6E8279AC21E00FF3EDE /* Api+LittleGame.m in Sources */,
E8EEB91126FC6AE2007C6EBA /* XPMineUserInfoEditProtocol.h in Sources */,
180116FC279E8CCE00F2CBC0 /* NVDate.m in Sources */,
E8EEB90326FC31DC007C6EBA /* XPMineUserInfoProtocol.h in Sources */,
@@ -5067,6 +5120,7 @@
E8DEC9A42764A6600078CB70 /* XPMoreMenuPresenter.m in Sources */,
9B2A12D82783F42300CED41B /* XPNoblePrivilegeContentCell.m in Sources */,
189DD53426DE255300AB55B1 /* TabbarViewController.m in Sources */,
E81EF6E4279AB92E00FF3EDE /* LittleGameInfoModel.m in Sources */,
E87A26F927587C62002DDC7A /* XPHomeContainerPresenter.m in Sources */,
18EE401A2754BA9F00A452BF /* NIMMessageMaker.m in Sources */,
E8EEB91D26FC9D58007C6EBA /* XPMineUserInfoDateView.m in Sources */,
@@ -5280,6 +5334,7 @@
E824544B26F5BBB800BE8163 /* XPMineModifPayPwdViewController.m in Sources */,
E81C1B2227705F950020D1E4 /* Api+ArrangeMic.m in Sources */,
E8ACEFF527C8EF0500F66D1A /* XPHomeHotRoomViewController.m in Sources */,
E81EF6DC279AB5CC00FF3EDE /* XPLittleGameRoomOpenView.m in Sources */,
E84150C227747BF700A7F548 /* FirstRechargeModel.m in Sources */,
9B1EF3D227E81C0600554295 /* XPMineDressUpBubbleViewController.m in Sources */,
E8A1E4512762082A00B294CA /* Api+CandyTree.m in Sources */,
@@ -5337,6 +5392,7 @@
E87E91552796B6DE00A7B3F2 /* XPRoomInviteUserViewController.m in Sources */,
E880B3B5278C1FE400A83B0D /* XPAcrossRoomPKPresenter.m in Sources */,
186A534626FC6ED900D67B2C /* TTPopup.m in Sources */,
E81EF6E0279AB7D900FF3EDE /* XPCreateLittleGameCollectionViewCell.m in Sources */,
E896EFB62771D55500AD2CC1 /* FansInfoModel.m in Sources */,
E81C278C26EAFAF60031E639 /* Base64.m in Sources */,
E8C1CD7027D894B800376F83 /* RoomFaceTitleItemModel.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_little_game_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_little_game_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

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

View File

@@ -10,11 +10,13 @@
#import <Masonry/Masonry.h>
#import <flutter_boost/FlutterBoost.h>
///Tool
#import "TTPopup.h"
#import "XPMacro.h"
#import "XPHtmlUrl.h"
#import "UIButton+EnlargeTouchArea.h"
#import "StatisticsServiceHelper.h"
#import "XPConstant.h"
#import "Api+Room.h"
///Model
#import "XPMineItemModel.h"
#import "UserInfoModel.h"
@@ -27,6 +29,7 @@
#import "XPMineHeadItemTableViewCell.h"
#import "XPMineHeadView.h"
#import "XPMineSkillTipView.h"
#import "XPLittleGameRoomOpenView.h"
///VC
#import "XPMineSettingViewController.h"
#import "XPMineTeenagerViewController.h"
@@ -196,7 +199,21 @@
case XPMineItemType_My_Room:
{
NSString* roomUid = [NSString stringWithFormat:@"%ld", (long)self.userInfo.uid];
[Api getRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data];
roomInfo.isReselect = YES;
if (roomInfo.isReselect) {
XPLittleGameRoomOpenView * roomOpenView = [[XPLittleGameRoomOpenView alloc] init];
[TTPopup popupView:roomOpenView style:TTPopupStyleActionSheet];
} else {
[XPRoomViewController openRoom:roomUid viewController:self];
}
} else {
[self showErrorToast:msg];
}
} uid:roomUid intoUid:roomUid];
}
break;
case XPMineItemType_My_Dressup:

View File

@@ -119,6 +119,12 @@ typedef NS_ENUM(NSInteger, RoomDatingStateChangeType) {
@property (nonatomic,assign) RoomDatingStateChangeType datingState;
///是否切换了房间类型(本地字段)
@property (nonatomic, assign) BOOL hadChangeRoomType;
///是否需要重新选择小游戏,原有小游戏玩法不在最新配置里面是需要重新选择
@property (nonatomic, assign) BOOL isReselect;
///小游戏ID
@property (nonatomic, copy) NSString *mgId;
///小游戏名称
@property (nonatomic, copy) NSString *mgName;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,18 @@
//
// Api+LittleGame.h
// xplan-ios
//
// Created by 冯硕 on 2022/1/21.
//
#import "Api.h"
NS_ASSUME_NONNULL_BEGIN
@interface Api (LittleGame)
/// 获取小游戏列表
/// @param completion 完成
+ (void)getLittleGameList:(HttpRequestHelperCompletion)completion;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,18 @@
//
// Api+LittleGame.m
// xplan-ios
//
// Created by on 2022/1/21.
//
#import "Api+LittleGame.h"
@implementation Api (LittleGame)
///
/// @param completion
+ (void)getLittleGameList:(HttpRequestHelperCompletion)completion {
[self makeRequest:@"miniGame/record/miniGameList" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, nil];
}
@end

View File

@@ -0,0 +1,17 @@
//
// XPCreateLittleGameCollectionViewCell.h
// xplan-ios
//
// Created by 冯硕 on 2022/1/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class LittleGameInfoModel;
@interface XPCreateLittleGameCollectionViewCell : UICollectionViewCell
///游戏的信息
@property (nonatomic,strong) LittleGameInfoModel *gameInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,76 @@
//
// XPCreateLittleGameCollectionViewCell.m
// xplan-ios
//
// Created by on 2022/1/21.
//
#import "XPCreateLittleGameCollectionViewCell.h"
///Third
#import <Masonry/Masonry.h>
#import "NetImageView.h"
#import "ThemeColor.h"
///Model
#import "LittleGameInfoModel.h"
@interface XPCreateLittleGameCollectionViewCell ()
///
@property (nonatomic, strong) NetImageView *logoImageView;
@end
@implementation XPCreateLittleGameCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
- (void)initSubViews {
[self.contentView addSubview:self.logoImageView];
self.backgroundColor = [UIColor clearColor];
}
- (void)initSubViewConstraints {
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.centerY.mas_equalTo(self);
make.size.mas_equalTo(CGSizeMake(90, 110));
}];
}
- (void)initViews {
[self.contentView addSubview:self.logoImageView];
self.backgroundColor = [UIColor clearColor];
}
- (void)setGameInfo:(LittleGameInfoModel *)gameInfo{
if (gameInfo) {
NSString *encodedUrl = [gameInfo.pic stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
self.logoImageView.imageUrl = gameInfo.pic;
if (gameInfo.isSelect) {
self.logoImageView.layer.borderWidth = 2;
self.logoImageView.layer.borderColor = [ThemeColor appMainColor].CGColor;
} else {
self.logoImageView.layer.borderWidth = 0;
self.logoImageView.layer.borderColor = [UIColor clearColor].CGColor;
}
}
}
#pragma mark - Getter && Setter
- (NetImageView *)logoImageView {
if (!_logoImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_logoImageView = [[NetImageView alloc] initWithConfig:config];
_logoImageView.layer.masksToBounds = YES;
_logoImageView.layer.cornerRadius = 12;
}
return _logoImageView;
}
@end

View File

@@ -0,0 +1,23 @@
//
// LittleGameInfoModel.h
// xplan-ios
//
// Created by 冯硕 on 2022/1/21.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface LittleGameInfoModel : NSObject
///游戏ID
@property (nonatomic, copy) NSString *mgId;
///名称
@property (nonatomic, copy) NSString *name;
///封面
@property (nonatomic, copy) NSString *pic;
///是否选择
@property (nonatomic,assign) BOOL isSelect;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// LittleGameInfoModel.m
// xplan-ios
//
// Created by on 2022/1/21.
//
#import "LittleGameInfoModel.h"
@implementation LittleGameInfoModel
@end

View File

@@ -0,0 +1,16 @@
//
// XPLittleGameRoomOpenView.h
// xplan-ios
//
// Created by 冯硕 on 2022/1/21.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPLittleGameRoomOpenView : UIView
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,301 @@
//
// XPLittleGameRoomOpenView.m
// xplan-ios
//
// Created by on 2022/1/21.
//
#import "XPLittleGameRoomOpenView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
#import "UIImage+Utils.h"
#import "TTPopup.h"
#import "XPMacro.h"
#import "Api+LittleGame.h"
///Model
#import "LittleGameInfoModel.h"
///View
#import "XPCreateLittleGameCollectionViewCell.h"
@interface XPLittleGameRoomOpenView ()<UICollectionViewDelegate, UICollectionViewDataSource>
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) UILabel *playModeLabel;
///
@property (nonatomic,strong) UIButton *closeButton;
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) UIStackView *modelStackView;
///
@property (nonatomic,strong) UIButton *normalRoomButton;
///
@property (nonatomic,strong) UIButton *gameRoomButton;
///
@property (nonatomic,strong) UICollectionView *collectionView;
///
@property (nonatomic,strong) UIButton *createRoomButton;
///
@property (nonatomic,strong) NSArray *datasource;
///
@property (nonatomic,strong) LittleGameInfoModel *selectGameInfo;
@end
@implementation XPLittleGameRoomOpenView
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
[self initHttpRequest];
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initHttpRequest {
[Api getLittleGameList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray * array = [LittleGameInfoModel modelsWithArray:data.data];
self.datasource = array;
[self.collectionView reloadData];
}
}];
}
- (void)initSubViews {
self.layer.masksToBounds = YES;
self.layer.cornerRadius = 12;
self.backgroundColor = [ThemeColor appBackgroundColor];
[self addSubview:self.backImageView];
[self addSubview:self.titleLabel];
[self addSubview:self.closeButton];
[self addSubview:self.playModeLabel];
[self addSubview:self.stackView];
[self addSubview:self.createRoomButton];
[self.stackView addArrangedSubview:self.modelStackView];
[self.stackView addArrangedSubview:self.collectionView];
[self.modelStackView addArrangedSubview:self.normalRoomButton];
[self.modelStackView addArrangedSubview:self.gameRoomButton];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(430);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.bottom.mas_equalTo(0);
make.size.mas_equalTo(CGSizeMake(141, 123));
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.mas_equalTo(16);
make.height.mas_equalTo(22);
}];
[self.playModeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(24);
make.left.mas_equalTo(self.titleLabel);
make.height.mas_equalTo(17);
}];
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(16);
make.right.mas_equalTo(-11);
make.width.height.mas_equalTo(22);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.playModeLabel.mas_bottom).mas_offset(3);
make.left.mas_equalTo(16);
make.right.mas_equalTo(self).offset(-16);
}];
[self.createRoomButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self).inset(68);
make.height.mas_equalTo(40);
make.top.mas_equalTo(self.stackView.mas_bottom).mas_offset(51);
}];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(118);
}];
[self.normalRoomButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(135);
}];
[self.gameRoomButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(135);
}];
[self.modelStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(65);
}];
}
#pragma mark - UICollectionViewDelegate And UICollectionViewDatasource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.datasource.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPCreateLittleGameCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPCreateLittleGameCollectionViewCell class]) forIndexPath:indexPath];
LittleGameInfoModel * gameInfo = [self.datasource objectAtIndex:indexPath.row];
if (gameInfo.mgId == self.selectGameInfo.mgId) {
gameInfo.isSelect = YES;
} else {
gameInfo.isSelect = NO;
}
cell.gameInfo = gameInfo;
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
LittleGameInfoModel * gameInfo = [self.datasource objectAtIndex:indexPath.row];
self.selectGameInfo = gameInfo;
[self.collectionView reloadData];
self.createRoomButton.enabled = YES;
}
#pragma mark - Event Response
- (void)gameRoomButtonAction:(UIButton *)sender {
self.normalRoomButton.selected = NO;
sender.selected = YES;
if (self.datasource.count > 0) {
self.collectionView.hidden = NO;
}
}
- (void)normalRoomButtonAction:(UIButton *)sender {
self.gameRoomButton.selected = NO;
sender.selected = YES;
self.collectionView.hidden = YES;
}
- (void)closeButtonAction:(UIButton *)sender {
[TTPopup dismiss];
}
#pragma mark - Getters And Setters
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.image = [UIImage imageNamed:@"room_little_game_bg"];
}
return _backImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textColor = [ThemeColor mainTextColor];
_titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold];
_titleLabel.text = @"新建房间";
}
return _titleLabel;
}
- (UILabel *)playModeLabel {
if (!_playModeLabel) {
_playModeLabel = [[UILabel alloc] init];
_playModeLabel.textColor = [ThemeColor secondTextColor];
_playModeLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_playModeLabel.textAlignment = NSTextAlignmentCenter;
_playModeLabel.text = @"房间玩法";
}
return _playModeLabel;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = 16;
}
return _stackView;
}
- (UICollectionView *)collectionView {
if (!_collectionView) {
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumLineSpacing = 0;
flowLayout.minimumInteritemSpacing = 7;
flowLayout.itemSize = CGSizeMake(98, 118);
flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.showsVerticalScrollIndicator = NO;
_collectionView.showsHorizontalScrollIndicator = NO;
[_collectionView registerClass:[XPCreateLittleGameCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPCreateLittleGameCollectionViewCell class])];
_collectionView.hidden = YES;
_collectionView.backgroundColor = [UIColor clearColor];
}
return _collectionView;
}
- (UIStackView *)modelStackView {
if (!_modelStackView) {
_modelStackView = [[UIStackView alloc] init];
_modelStackView.axis = UILayoutConstraintAxisHorizontal;
_modelStackView.distribution = UIStackViewDistributionFill;
_modelStackView.alignment = UIStackViewAlignmentFill;
_modelStackView.spacing = 10;
}
return _modelStackView;
}
- (UIButton *)normalRoomButton {
if (!_normalRoomButton) {
_normalRoomButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_normalRoomButton setImage:[UIImage imageNamed:@"room_little_game_normal_room"] forState:UIControlStateNormal];
[_normalRoomButton setImage:[UIImage imageNamed:@"room_little_game_normal_room_select"] forState:UIControlStateSelected];
[_normalRoomButton addTarget:self action:@selector(normalRoomButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _normalRoomButton;
}
- (UIButton *)gameRoomButton {
if (!_gameRoomButton) {
_gameRoomButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_gameRoomButton setImage:[UIImage imageNamed:@"room_little_game_game_room"] forState:UIControlStateNormal];
[_gameRoomButton setImage:[UIImage imageNamed:@"room_little_game_game_room_select"] forState:UIControlStateSelected];
[_gameRoomButton addTarget:self action:@selector(gameRoomButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _gameRoomButton;
}
- (UIButton *)createRoomButton {
if (!_createRoomButton) {
_createRoomButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_createRoomButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeUpleftToLowright imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_createRoomButton setTitle:@"创建房间" forState:UIControlStateNormal];
_createRoomButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
_createRoomButton.titleLabel.textColor = [ThemeColor confirmButtonTextColor];
_createRoomButton.layer.cornerRadius = 20;
_createRoomButton.layer.masksToBounds = YES;
}
return _createRoomButton;
}
- (UIButton *)closeButton {
if (!_closeButton) {
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_closeButton setImage:[UIImage imageNamed:@"room_little_game_close"] forState:UIControlStateNormal];
[_closeButton setImage:[UIImage imageNamed:@"room_little_game_close"] forState:UIControlStateSelected];
[_closeButton addTarget:self action:@selector(closeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _closeButton;
}
@end