半屏聊天的完善
This commit is contained in:
@@ -24,6 +24,24 @@
|
||||
if ([rootViewController isKindOfClass:NSClassFromString(@"MMDrawerController")]) {
|
||||
rootViewController = (UIViewController *)[rootViewController valueForKey:@"centerViewController"];
|
||||
}
|
||||
|
||||
///兼容房间内私聊的
|
||||
UIWindow * currentWindow;
|
||||
for (int i = 0; i < [UIApplication sharedApplication].windows.count; i++) {
|
||||
UIWindow * window = [[UIApplication sharedApplication].windows objectAtIndex:i];
|
||||
if(window.tag == 1001) {
|
||||
currentWindow = window;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (currentWindow) {
|
||||
[currentWindow.rootViewController.navigationController popViewControllerAnimated:YES];
|
||||
[currentWindow.superview removeFromSuperview];
|
||||
currentWindow.rootViewController = nil;
|
||||
currentWindow.windowLevel = -1;
|
||||
currentWindow = nil;
|
||||
}
|
||||
|
||||
UIViewController *currentVC = [self getCurrentVCFrom:rootViewController];
|
||||
return currentVC;
|
||||
}
|
||||
|
@@ -106,8 +106,16 @@
|
||||
*stop = YES;
|
||||
}
|
||||
}];
|
||||
if ([[XCCurrentVCStackManager shareManager].getCurrentVC isKindOfClass:[XPRoomViewController class]]) {
|
||||
UIViewController * controller = [XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.presentingViewController;
|
||||
if (controller) {
|
||||
[XPRoomViewController openRoom:self.userInfo.uid viewController:controller];
|
||||
}
|
||||
} else {
|
||||
[XPRoomViewController openRoom:self.userInfo.uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
|
@@ -28,6 +28,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
+ (NSString *)cellContent:(NIMMessage *)message;
|
||||
///代理
|
||||
@property (nonatomic,weak) id<MessageCellDelegate> delegate;
|
||||
|
||||
///是否在房间中
|
||||
@property (nonatomic,assign) BOOL isInRoom;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -114,7 +114,7 @@
|
||||
}];
|
||||
self.subTitleLabel.hidden = ![[NIMSDK sharedSDK].userManager isUserInBlackList:self.userId];
|
||||
|
||||
self.reportButton.hidden = [self isSystemAccount];
|
||||
self.reportButton.hidden = [self isSystemAccount] || self.isInRoom;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,11 @@
|
||||
- (void)setIsInRoom:(BOOL)isInRoom {
|
||||
_isInRoom = isInRoom;
|
||||
self.reportButton.hidden = _isInRoom;
|
||||
if (_isInRoom) {
|
||||
[self.backButton mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self).offset(11);
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (UIButton *)backButton {
|
||||
|
@@ -73,14 +73,14 @@
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_session = session;
|
||||
[self initViews];
|
||||
[self initLayout];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self initViews];
|
||||
[self initLayout];
|
||||
[IQKeyboardManager sharedManager].enable = NO;
|
||||
[IQKeyboardManager sharedManager].enableAutoToolbar = NO;
|
||||
[self initHeaderAndFooterRrfresh];
|
||||
@@ -130,6 +130,31 @@
|
||||
|
||||
}
|
||||
|
||||
- (UINavigationController *)getKeyWindowNav {
|
||||
UIWindow * currentWindow;
|
||||
for (int i = 0; i < [UIApplication sharedApplication].windows.count; i++) {
|
||||
UIWindow * window = [[UIApplication sharedApplication].windows objectAtIndex:i];
|
||||
if(window.tag == 1000) {
|
||||
currentWindow = window;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (self.openType == SessionListOpenTypeRoom) {
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
[currentWindow.superview removeFromSuperview];
|
||||
currentWindow.rootViewController = nil;
|
||||
currentWindow.windowLevel = -1;
|
||||
currentWindow = nil;
|
||||
}
|
||||
|
||||
if ([XCCurrentVCStackManager shareManager].currentNavigationController) {
|
||||
return [XCCurrentVCStackManager shareManager].currentNavigationController;
|
||||
}
|
||||
|
||||
return self.navigationController;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initViews {
|
||||
self.sessionNavView.isInRoom = self.openType == SessionListOpenTypeRoom;
|
||||
@@ -141,7 +166,7 @@
|
||||
|
||||
- (void)initLayout {
|
||||
[self.sessionNavView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(kNavigationHeight);
|
||||
make.height.mas_equalTo(self.openType == SessionListOpenTypeRoom ? 44 : kNavigationHeight);
|
||||
make.left.top.right.mas_equalTo(self.view);
|
||||
}];
|
||||
|
||||
@@ -238,7 +263,7 @@
|
||||
if (uid.length > 0) {
|
||||
XPMineUserInfoViewController * infoVC = [[XPMineUserInfoViewController alloc] init];
|
||||
infoVC.uid = uid.integerValue;
|
||||
[self.navigationController pushViewController:infoVC animated:YES];
|
||||
[[self getKeyWindowNav] pushViewController:infoVC animated:YES];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,7 +279,7 @@
|
||||
- (void)sessionNavView:(SessionNavView *)view didClickReport:(UIButton *)sender {
|
||||
SessionInfoViewController * reportVC = [[SessionInfoViewController alloc] init];
|
||||
reportVC.userId = self.session.sessionId;
|
||||
[self.navigationController pushViewController:reportVC animated:YES];
|
||||
[self.getKeyWindowNav pushViewController:reportVC animated:YES];
|
||||
}
|
||||
|
||||
#pragma mark - UITableViewDataSource
|
||||
@@ -343,16 +368,16 @@
|
||||
- (void)onAvatarClick:(NSInteger)uid {
|
||||
XPMineUserInfoViewController * infoVC = [[XPMineUserInfoViewController alloc] init];
|
||||
infoVC.uid = uid;
|
||||
[self.navigationController pushViewController:infoVC animated:YES];
|
||||
[self.getKeyWindowNav pushViewController:infoVC animated:YES];
|
||||
}
|
||||
|
||||
- (void)onFollowInRoom:(NSString *)roomUid {
|
||||
__block BOOL isSameRoom = NO;
|
||||
__block RoomInfoModel *roomModel;
|
||||
[self.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
[self.getKeyWindowNav.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj isKindOfClass:[XPRoomViewController class]]) {
|
||||
XPRoomViewController<RoomHostDelegate> * rooomVC = obj;
|
||||
[self.navigationController popToRootViewControllerAnimated:NO];
|
||||
[[self getKeyWindowNav] popToRootViewControllerAnimated:NO];
|
||||
roomModel = rooomVC.getRoomInfo;
|
||||
if(rooomVC.getRoomInfo.uid == [roomUid integerValue]) {
|
||||
isSameRoom = YES;
|
||||
@@ -397,6 +422,19 @@
|
||||
}
|
||||
|
||||
- (void)didSelectMenuItem:(MessageMenuModel *)info {
|
||||
|
||||
UIWindow * currentWindow;
|
||||
for (int i = 0; i < [UIApplication sharedApplication].windows.count; i++) {
|
||||
UIWindow * window = [[UIApplication sharedApplication].windows objectAtIndex:i];
|
||||
if(window.tag == 1000) {
|
||||
currentWindow = window;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentWindow) {
|
||||
currentWindow.windowLevel = -1;
|
||||
}
|
||||
switch (info.type) {
|
||||
case MessageMenuType_Photo:
|
||||
{
|
||||
|
@@ -47,7 +47,7 @@
|
||||
#pragma mark - Getters And Setters
|
||||
- (UIView *)dismissView {
|
||||
if (!_dismissView) {
|
||||
_dismissView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 200)];
|
||||
_dismissView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 300)];
|
||||
_dismissView.backgroundColor = [UIColor clearColor];
|
||||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissViewTap)];
|
||||
[_dismissView addGestureRecognizer:tap];
|
||||
@@ -61,11 +61,16 @@
|
||||
XPMineContactViewController * vc=[XPMineContactViewController new];
|
||||
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:vc];
|
||||
//创建window,并将window的坐标设置在屏幕底部,设置windowLevel防止获取默认window失败
|
||||
UIWindow *testWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 200, KScreenWidth, KScreenHeight - 200)];
|
||||
UIWindow *testWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 300, KScreenWidth, KScreenHeight - 300)];
|
||||
CAShapeLayer * layer = [CAShapeLayer layer];
|
||||
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KScreenWidth, KScreenHeight-300) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)];
|
||||
layer.path = path.CGPath;
|
||||
testWindow.layer.masksToBounds = YES;
|
||||
testWindow.layer.mask = layer;;
|
||||
testWindow.windowLevel = UIWindowLevelAlert;
|
||||
testWindow.backgroundColor = UIColor.redColor;
|
||||
testWindow.rootViewController = nav;
|
||||
testWindow.hidden = NO;
|
||||
testWindow.tag = 1000;
|
||||
_messageWindow = testWindow;
|
||||
}
|
||||
return _messageWindow;
|
||||
|
@@ -57,8 +57,6 @@
|
||||
@property (nonatomic,strong) UIButton *nobleButton;
|
||||
///代理
|
||||
@property (nonatomic,weak) id<RoomHostDelegate> delegate;
|
||||
///半屏的私聊弹框
|
||||
@property (nonatomic,strong) XPRoomHalfMessageView *halfMessageView;
|
||||
@end
|
||||
|
||||
|
||||
@@ -117,9 +115,8 @@
|
||||
break;
|
||||
case XPRoomMenuItemType_Message:
|
||||
{
|
||||
XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] init];
|
||||
halfMessageView.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
|
||||
[[UIApplication sharedApplication].delegate.window addSubview:halfMessageView];
|
||||
XPRoomHalfMessageView *halfMessageView = [[XPRoomHalfMessageView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)];
|
||||
[self.superview addSubview:halfMessageView];
|
||||
[UIView animateWithDuration:.35 animations:^{
|
||||
CGRect rect = halfMessageView.frame;
|
||||
rect.origin.y = 0;
|
||||
@@ -499,11 +496,4 @@
|
||||
return _scrollView;
|
||||
}
|
||||
|
||||
- (XPRoomHalfMessageView *)halfMessageView {
|
||||
if (!_halfMessageView) {
|
||||
_halfMessageView = [[XPRoomHalfMessageView alloc] init];
|
||||
}
|
||||
return _halfMessageView;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user