房间逻辑再次梳理优化
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
|
||||
#import "XPIMManager.h"
|
||||
|
||||
@interface XPRoomViewController ()<XPRoomProtocol, XPIMRoomDelegate, RoomHostDelegate>
|
||||
@interface XPRoomViewController ()<XPRoomProtocol, RoomHostDelegate>
|
||||
///背景
|
||||
@property (nonatomic,strong) XPRoomBackContainerView *backContainerView;
|
||||
///房间信息
|
||||
@@ -68,111 +68,102 @@
|
||||
|
||||
- (void)dealloc {
|
||||
#warning to dox - 时刻注意这个方法 功能做完的时候删除此方法
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (XPRoomPresenter *)createPresenter {
|
||||
return [[XPRoomPresenter alloc] init];
|
||||
return [[XPRoomPresenter alloc] init];
|
||||
}
|
||||
|
||||
- (BOOL)isHiddenNavBar {
|
||||
return YES;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[self.presenter getRoomInfoWithUid:self.roomUid];
|
||||
[self.presenter initEnterRoom:self.roomUid user:[AccountInfoStorage instance].getUid];
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
||||
[self.view endEditing:YES];
|
||||
[self.view endEditing:YES];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self.view addSubview:self.backContainerView];
|
||||
[self.view addSubview:self.roomHeaderView];
|
||||
[self.view addSubview:self.stageView];
|
||||
[self.view addSubview:self.messageContainerView];
|
||||
[self.view addSubview:self.menuContainerView];
|
||||
[self.view addSubview:self.activityContainerView];
|
||||
[self.view addSubview:self.backContainerView];
|
||||
[self.view addSubview:self.roomHeaderView];
|
||||
[self.view addSubview:self.stageView];
|
||||
[self.view addSubview:self.messageContainerView];
|
||||
[self.view addSubview:self.menuContainerView];
|
||||
[self.view addSubview:self.activityContainerView];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.backContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.view);
|
||||
}];
|
||||
|
||||
[self.roomHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.mas_equalTo(self.view);
|
||||
make.height.mas_equalTo(kNavigationHeight);
|
||||
}];
|
||||
|
||||
[self.stageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.view);
|
||||
make.top.mas_equalTo(self.roomHeaderView.mas_bottom);
|
||||
}];
|
||||
|
||||
[self.messageContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.stageView.mas_bottom);
|
||||
make.bottom.equalTo(self.menuContainerView.mas_top).offset(-5);
|
||||
make.left.equalTo(self.view);
|
||||
make.right.equalTo(self.activityContainerView.mas_left).offset(-10);
|
||||
}];
|
||||
|
||||
[self.menuContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.view);
|
||||
make.bottom.mas_equalTo(-kSafeAreaBottomHeight- 8);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
[self.activityContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.messageContainerView);
|
||||
make.right.mas_equalTo(self.view);
|
||||
make.bottom.mas_equalTo(self.menuContainerView.mas_top).offset(-5);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
[self.backContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.view);
|
||||
}];
|
||||
|
||||
[self.roomHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.mas_equalTo(self.view);
|
||||
make.height.mas_equalTo(kNavigationHeight);
|
||||
}];
|
||||
|
||||
[self.stageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.view);
|
||||
make.top.mas_equalTo(self.roomHeaderView.mas_bottom);
|
||||
}];
|
||||
|
||||
[self.messageContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.stageView.mas_bottom);
|
||||
make.bottom.equalTo(self.menuContainerView.mas_top).offset(-5);
|
||||
make.left.equalTo(self.view);
|
||||
make.right.equalTo(self.activityContainerView.mas_left).offset(-10);
|
||||
}];
|
||||
|
||||
[self.menuContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.view);
|
||||
make.bottom.mas_equalTo(-kSafeAreaBottomHeight- 8);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
[self.activityContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.messageContainerView);
|
||||
make.right.mas_equalTo(self.view);
|
||||
make.bottom.mas_equalTo(self.menuContainerView.mas_top).offset(-5);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - XPRoomProtocol
|
||||
- (void)getRoomInfoSuccess:(RoomInfoModel *)roomInfo {
|
||||
self.roomInfo = roomInfo;
|
||||
///保存一下房间信息 结构调整的时候 改掉就行
|
||||
[[XPIMManager shareManager].chatRoomManager setCurrentRoomInfo:roomInfo];
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
if (roomInfo.valid) {
|
||||
[self.roomHeaderView onRoomUpdate]; // S1 没有考虑进房密码的情况
|
||||
[self.presenter getUserInfoWithUid:uid];
|
||||
} else {
|
||||
if ([self.roomUid isEqualToString:uid]) {
|
||||
if (roomInfo.roomId > 0) {
|
||||
[self.presenter openRoom:roomInfo.title type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:@""];
|
||||
} else {///没有开启过房间 一般都是刚注册账号
|
||||
[self.presenter getUserInfoWithUid:uid];
|
||||
}
|
||||
} else {
|
||||
- (void)initEnterRoomSuccess:(RoomInfoModel *)roomInfo user:(UserInfoModel *)userInfo {
|
||||
self.roomInfo = roomInfo;
|
||||
self.userInfo = userInfo;
|
||||
if (roomInfo.valid) { // 房间有效,直接进入房间
|
||||
// TODO: S1 没有考虑进房密码的情况
|
||||
[self.roomHeaderView onRoomUpdate];
|
||||
[self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo];
|
||||
} else { // 房间无效,分是否为自己房间进行处理
|
||||
if ([self.roomUid isEqualToString:[NSString stringWithFormat:@"%ld", userInfo.uid]]) { // 当前用户进入自己房间
|
||||
if (roomInfo.roomId > 0) { // 存在房间信息,直接使用房间信息开房
|
||||
[self.presenter openRoom:roomInfo.title type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:@""];
|
||||
} else { // 不存在房间信息,全新开房
|
||||
NSString* title = [NSString stringWithFormat:@"%@的房间", userInfo.nick];
|
||||
[self.presenter openRoom:title type:RoomType_Game roomPwd:@"" roomDesc:@"" backPic:@""];
|
||||
}
|
||||
} else { // 当前用户进入别人房间
|
||||
// TODO: 房主已经下线。
|
||||
[self showSuccessToast:@"房主已下线"];
|
||||
[self enterRoomFail];
|
||||
[self showSuccessToast:@"房主已下线"];
|
||||
[self enterRoomFail];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)getUserInfoSuccess:(UserInfoModel *)userInfo {
|
||||
self.userInfo = userInfo;
|
||||
if (self.roomInfo.roomId > 0) {
|
||||
[self.presenter enterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] user:self.userInfo];
|
||||
} else {
|
||||
NSString * title = [NSString stringWithFormat:@"%@的房间", userInfo.nick];
|
||||
[self.presenter openRoom:title type:RoomType_Game roomPwd:@"" roomDesc:@"" backPic:@""];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)openRoomSuccess:(RoomInfoModel *)roomInfo {
|
||||
self.roomInfo = roomInfo;
|
||||
[self.roomHeaderView onRoomUpdate];
|
||||
@@ -204,45 +195,45 @@
|
||||
}
|
||||
|
||||
- (XPRoomBackContainerView *)backContainerView {
|
||||
if (!_backContainerView) {
|
||||
_backContainerView = [[XPRoomBackContainerView alloc] init];
|
||||
}
|
||||
return _backContainerView;
|
||||
if (!_backContainerView) {
|
||||
_backContainerView = [[XPRoomBackContainerView alloc] init];
|
||||
}
|
||||
return _backContainerView;
|
||||
}
|
||||
|
||||
- (RoomHeaderView *)roomHeaderView {
|
||||
if (!_roomHeaderView) {
|
||||
_roomHeaderView = [[RoomHeaderView alloc] initWithDelegate:self];
|
||||
}
|
||||
return _roomHeaderView;
|
||||
if (!_roomHeaderView) {
|
||||
_roomHeaderView = [[RoomHeaderView alloc] initWithDelegate:self];
|
||||
}
|
||||
return _roomHeaderView;
|
||||
}
|
||||
|
||||
- (SocialStageView *)stageView {
|
||||
if (!_stageView) {
|
||||
_stageView = [[SocialStageView alloc] initWithDelegate:self];
|
||||
}
|
||||
return _stageView;
|
||||
if (!_stageView) {
|
||||
_stageView = [[SocialStageView alloc] initWithDelegate:self];
|
||||
}
|
||||
return _stageView;
|
||||
}
|
||||
|
||||
- (XPRoomMessageContainerView *)messageContainerView {
|
||||
if (!_messageContainerView) {
|
||||
_messageContainerView = [[XPRoomMessageContainerView alloc] initWithDelegate:self];
|
||||
}
|
||||
return _messageContainerView;
|
||||
if (!_messageContainerView) {
|
||||
_messageContainerView = [[XPRoomMessageContainerView alloc] initWithDelegate:self];
|
||||
}
|
||||
return _messageContainerView;
|
||||
}
|
||||
|
||||
- (XPRoomMenuContainerView *)menuContainerView {
|
||||
if (!_menuContainerView) {
|
||||
_menuContainerView = [[XPRoomMenuContainerView alloc] initWithDelegate:self];
|
||||
}
|
||||
return _menuContainerView;
|
||||
if (!_menuContainerView) {
|
||||
_menuContainerView = [[XPRoomMenuContainerView alloc] initWithDelegate:self];
|
||||
}
|
||||
return _menuContainerView;
|
||||
}
|
||||
|
||||
- (XPRoomActivityContainerView *)activityContainerView {
|
||||
if (!_activityContainerView) {
|
||||
_activityContainerView = [[XPRoomActivityContainerView alloc] init];
|
||||
}
|
||||
return _activityContainerView;
|
||||
if (!_activityContainerView) {
|
||||
_activityContainerView = [[XPRoomActivityContainerView alloc] init];
|
||||
}
|
||||
return _activityContainerView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user