202 lines
5.9 KiB
Objective-C
202 lines
5.9 KiB
Objective-C
//
|
|
// XPRoomViewController.m
|
|
// xplan-ios
|
|
//
|
|
// Created by 冯硕 on 2021/10/11.
|
|
//
|
|
|
|
#import "XPRoomViewController.h"
|
|
///Third
|
|
#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"
|
|
#import "XPRoomMenuContainerView.h"
|
|
#import "XPRoomMessageContainerView.h"
|
|
#import "XPRoomPositionContainView.h"
|
|
#import "XPRoomInfoContainerView.h"
|
|
///P
|
|
#import "XPRoomPresenter.h"
|
|
#import "XPRoomProtocol.h"
|
|
///Category
|
|
#import "XPRoomViewController+RoomInfoContainerView.h"
|
|
|
|
#import "XPIMManager.h"
|
|
|
|
@interface XPRoomViewController ()<XPRoomProtocol>
|
|
///背景
|
|
@property (nonatomic,strong) XPRoomBackContainerView *backContainerView;
|
|
///房间信息
|
|
@property (nonatomic,strong) XPRoomInfoContainerView *roomInfoContainerView;
|
|
///坑位信息
|
|
@property (nonatomic,strong) XPRoomPositionContainView *positionContainerView;
|
|
///公屏
|
|
@property (nonatomic,strong) XPRoomMessageContainerView *messageContainerView;
|
|
///底部操作栏
|
|
@property (nonatomic,strong) XPRoomMenuContainerView *menuContainerView;
|
|
///活动
|
|
@property (nonatomic,strong) XPRoomActivityContainerView *activityContainerView;
|
|
///用户信息
|
|
@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;
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
[super viewWillAppear:animated];
|
|
[self.presenter getRoomInfoWithUid:self.roomUid];
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self.view addSubview:self.backContainerView];
|
|
[self.view addSubview:self.roomInfoContainerView];
|
|
[self.view addSubview:self.positionContainerView];
|
|
[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.roomInfoContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.top.mas_equalTo(self.view);
|
|
make.height.mas_equalTo(kNavigationHeight);
|
|
}];
|
|
|
|
[self.positionContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.mas_equalTo(self.view);
|
|
make.top.mas_equalTo(self.roomInfoContainerView.mas_bottom);
|
|
make.height.mas_equalTo([self.positionContainerView positionContainerViewHeight]);
|
|
}];
|
|
|
|
[self.messageContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.positionContainerView.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 configRoomInfoContainerViewWithRoomInfo:roomInfo]; // S1 没有考虑进房密码的情况
|
|
[self.presenter getUserInfoWithUid:uid];
|
|
} else {
|
|
if ([self.roomUid isEqualToString:uid]) {
|
|
// TODO: 进入自己房间,需要重新开房。
|
|
} else {
|
|
// TODO: 房主已经下线。
|
|
}
|
|
}
|
|
}
|
|
|
|
- (void)getUserInfoSuccess:(UserInfoModel *)userInfo {
|
|
self.usereInfo = userInfo;
|
|
// TODO: 进入云信房间。
|
|
[[XPIMManager shareManager].chatRoomManager enterRoomWithRoomId:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] userInfo:self.usereInfo];
|
|
}
|
|
|
|
- (void)openRoomSuccess:(RoomInfoModel *)roomInfo {
|
|
[self configRoomInfoContainerViewWithRoomInfo:roomInfo];
|
|
// TODO: 进入云信房间。
|
|
}
|
|
|
|
- (void)enterRoomFail {
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
}
|
|
|
|
- (XPRoomBackContainerView *)backContainerView {
|
|
if (!_backContainerView) {
|
|
_backContainerView = [[XPRoomBackContainerView alloc] init];
|
|
}
|
|
return _backContainerView;
|
|
}
|
|
|
|
- (XPRoomInfoContainerView *)roomInfoContainerView {
|
|
if (!_roomInfoContainerView) {
|
|
_roomInfoContainerView = [[XPRoomInfoContainerView alloc] init];
|
|
_roomInfoContainerView.delegate = self;
|
|
}
|
|
return _roomInfoContainerView;
|
|
}
|
|
|
|
- (XPRoomPositionContainView *)positionContainerView {
|
|
if (!_positionContainerView) {
|
|
_positionContainerView = [[XPRoomPositionContainView alloc] init];
|
|
}
|
|
return _positionContainerView;
|
|
}
|
|
|
|
- (XPRoomMessageContainerView *)messageContainerView {
|
|
if (!_messageContainerView) {
|
|
_messageContainerView = [[XPRoomMessageContainerView alloc] init];
|
|
}
|
|
return _messageContainerView;
|
|
}
|
|
|
|
- (XPRoomMenuContainerView *)menuContainerView {
|
|
if (!_menuContainerView) {
|
|
_menuContainerView = [[XPRoomMenuContainerView alloc] init];
|
|
}
|
|
return _menuContainerView;
|
|
}
|
|
|
|
- (XPRoomActivityContainerView *)activityContainerView {
|
|
if (!_activityContainerView) {
|
|
_activityContainerView = [[XPRoomActivityContainerView alloc] init];
|
|
}
|
|
return _activityContainerView;
|
|
}
|
|
|
|
|
|
@end
|