进入房间请求接口完善逻辑

This commit is contained in:
fengshuo
2021-10-19 18:30:03 +08:00
parent 9327830ad9
commit 92883d25d4
15 changed files with 276 additions and 146 deletions

View File

@@ -10,8 +10,10 @@
#import <Masonry/Masonry.h>
///Tool
#import "XPMacro.h"
#import "AccountInfoStorage.h"
///Model
#import "RoomInfoModel.h"
#import "UserInfoModel.h"
///View
#import "XPRoomActivityContainerView.h"
#import "XPRoomBackContainerView.h"
@@ -19,8 +21,13 @@
#import "XPRoomMessageContainerView.h"
#import "XPRoomPositionContainView.h"
#import "XPRoomInfoContainerView.h"
///P
#import "XPRoomPresenter.h"
#import "XPRoomProtocol.h"
///Category
#import "XPRoomViewController+RoomInfoContainerView.h"
@interface XPRoomViewController ()
@interface XPRoomViewController ()<XPRoomProtocol>
///
@property (nonatomic,strong) XPRoomBackContainerView *backContainerView;
///
@@ -33,10 +40,25 @@
@property (nonatomic,strong) XPRoomMenuContainerView *menuContainerView;
///
@property (nonatomic,strong) XPRoomActivityContainerView *activityContainerView;
///
@property (nonatomic,assign) BOOL isOpenRoom;
///
@property (nonatomic,strong) UserInfoModel *usereInfo;
///
@property (nonatomic,strong) RoomInfoModel *roomInfo;
@end
@implementation XPRoomViewController
- (void)dealloc {
#warning to do -
}
- (XPRoomPresenter *)createPresenter {
return [[XPRoomPresenter alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
@@ -94,11 +116,106 @@
}];
}
///
- (void)requestRoomInfoSuccess:(RoomInfoModel *)roomInfo {
[self hideHUD];
self.roomInfo = roomInfo;
[self configRoomInfoContainerViewWithRoomInfo:roomInfo];
///
if (self.usereInfo == nil) {
[self.presenter getUserInfoWithUid:self.roomUid];
} else {
[self enterChatRoomWithUseInfo:self.usereInfo];
}
}
///dismissVC
- (void)disMissRoomVC {
if (self.presentingViewController) {
[self dismissViewControllerAnimated:YES completion:nil];
}
}
///
- (void)openRoomWithUserInfo {
NSString * title = [NSString stringWithFormat:@"%@的房间", self.usereInfo.nick];
[self.presenter openUserRoomWithTitle:title type:RoomType_Game roomPwd:@"" roomDesc:@"" backPic:@""];
}
- (void)enterChatRoomWithUseInfo:(UserInfoModel *)userInfo {
///
#warning to do -
}
#pragma mark - XPRoomProtocol
- (void)getRoomInfoSuccess:(RoomInfoModel *)roomInfo {
NSString * uid = [AccountInfoStorage instance].getUid;
if ([self.roomUid isEqualToString:uid]) {///
if (roomInfo == nil || roomInfo.valid) {
self.isOpenRoom = YES;
if (self.usereInfo) {
[self openRoomWithUserInfo];
} else {
[self.presenter getUserInfoWithUid:uid];
}
} else {
[self requestRoomInfoSuccess:roomInfo];
}
} else {///
if (roomInfo.valid) {
if (roomInfo.roomPwd.length > 0) {
[self hideHUD];
#warning to do -
} else {
[self requestRoomInfoSuccess:roomInfo];
}
} else {
#warning to do - 线
[self hideHUD];
}
}
}
- (void)getRoomInfoFail {
[self hideHUD];
[self disMissRoomVC];
}
- (void)getUserInfoSuccess:(UserInfoModel *)userInfo {
self.usereInfo = userInfo;
if (self.isOpenRoom) {
[self openRoomWithUserInfo];
} else {
if (self.roomInfo) {
[self enterChatRoomWithUseInfo:userInfo];
}
}
}
- (void)getUserInfoFail {
[self hideHUD];
[self disMissRoomVC];
}
- (void)openRoomSuccess:(RoomInfoModel *)roomInfo {
[self requestRoomInfoSuccess:roomInfo];
}
- (void)openRoomFail {
[self hideHUD];
[self disMissRoomVC];
}
#pragma mark - Getters And Setters
- (void)setRoomInfo:(RoomInfoModel *)roomInfo {
_roomInfo = roomInfo;
self.roomInfoContainerView.roomInfo = _roomInfo;
- (void)setRoomUid:(NSString *)roomUid {
_roomUid = roomUid;
if (_roomUid) {
[self showLoading];
///
[self.presenter getUserInfoWithUid:_roomUid];
///
[self.presenter getRoomInfoWithUid:_roomUid];
}
}
- (XPRoomBackContainerView *)backContainerView {
@@ -111,6 +228,7 @@
- (XPRoomInfoContainerView *)roomInfoContainerView {
if (!_roomInfoContainerView) {
_roomInfoContainerView = [[XPRoomInfoContainerView alloc] init];
_roomInfoContainerView.delegate = self;
}
return _roomInfoContainerView;
}
@@ -143,4 +261,5 @@
return _activityContainerView;
}
@end