新增 next-chat.mdc 文件以定义对话上下文的规则;在 Assets.xcassets 中添加多个图像资源及其对应的 Contents.json 文件;更新 AttachmentModel.h 中的枚举值以修正飘屏消息类型;在 SessionViewController.h 和 SessionViewController.m 中添加 userInfo 属性并调整相关逻辑;在 SessionListViewController.h 和 SessionListViewController.m 中优化会话列表的展示逻辑;在多个模型和视图文件中进行小幅调整以提升代码可读性和一致性。
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
#import <JXCategoryView/JXCategoryView.h>
|
||||
#import <MJRefresh/MJRefresh.h>
|
||||
#import "SDWebImageManager.h"
|
||||
#import "FirstRechargeManager.h"
|
||||
///Tool
|
||||
#import "Api+Home.h"
|
||||
#import "YUMIMacroUitls.h"
|
||||
@@ -330,8 +329,7 @@ JXCategoryViewDelegate,
|
||||
XPHomeContainerProtocol,
|
||||
XPNewHomeNavViewDelegate,
|
||||
XPNewHomeHeadViewDelegate,
|
||||
XPHomeRecommendOtherRoomViewDelegate,
|
||||
FirstRechargeManagerDelegate>
|
||||
XPHomeRecommendOtherRoomViewDelegate>
|
||||
|
||||
///头视图
|
||||
@property(nonatomic,strong) XPNewHomeHeadView *headView;
|
||||
@@ -359,11 +357,6 @@ FirstRechargeManagerDelegate>
|
||||
|
||||
@property (nonatomic, assign) bool hasLoadAPIs;
|
||||
|
||||
// 首充弹窗引用
|
||||
@property (nonatomic, strong) XPWebViewController *firstChargeWebVC;
|
||||
// 首充弹窗背景视图
|
||||
@property (nonatomic, strong) UIView *firstChargeBackgroundView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPNewHomeViewController
|
||||
@@ -377,7 +370,6 @@ FirstRechargeManagerDelegate>
|
||||
|
||||
-(void)dealloc{
|
||||
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
||||
[FirstRechargeManager sharedManager].delegate = nil;
|
||||
}
|
||||
|
||||
- (BOOL)isHiddenNavBar {
|
||||
@@ -398,12 +390,6 @@ FirstRechargeManagerDelegate>
|
||||
[self initSubViewConstraints];
|
||||
|
||||
[self requestCheckIp];
|
||||
|
||||
// 注册首充管理器监听
|
||||
[FirstRechargeManager sharedManager].delegate = self;
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[[FirstRechargeManager sharedManager] startMonitoring];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,13 +402,10 @@ FirstRechargeManagerDelegate>
|
||||
});
|
||||
self.hasLoadAPIs = YES;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)tokenInvalid {
|
||||
// 停止首充监控
|
||||
[[FirstRechargeManager sharedManager] stopMonitoring];
|
||||
|
||||
[[AccountInfoStorage instance] saveAccountInfo:nil];
|
||||
[[AccountInfoStorage instance] saveTicket:nil];
|
||||
if ([NIMSDK sharedSDK].loginManager.isLogined) {
|
||||
@@ -786,135 +769,7 @@ FirstRechargeManagerDelegate>
|
||||
self.type = index;
|
||||
}
|
||||
|
||||
- (void)getFirstChargeSuccess:(FirstRechargeModel *)model {
|
||||
if (model.chargeStatus == NO) {
|
||||
// TODO: 弹出窗口 web view
|
||||
XPWebViewController *web = [[XPWebViewController alloc] initWithRoomUID:@""];
|
||||
[self addChildViewController:web];
|
||||
[self.view addSubview:web.view];
|
||||
web.view.frame = CGRectMake(0, 0, KScreenWidth/2, KScreenHeight/2);
|
||||
web.view.center = self.view.center;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - FirstRechargeManagerDelegate
|
||||
|
||||
- (void)firstRechargeManager:(FirstRechargeManager *)manager didCheckFirstRecharge:(FirstRechargeModel *)model shouldShow:(BOOL)shouldShow {
|
||||
if (shouldShow && model.chargeStatus == NO) {
|
||||
// 展示首充弹窗
|
||||
[self showFirstRechargePopup:model];
|
||||
|
||||
// 标记今天已展示过(在展示后标记)
|
||||
[[FirstRechargeManager sharedManager] markTodayShown];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showFirstRechargePopup:(FirstRechargeModel *)model {
|
||||
if (model.chargeStatus) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果已经有弹窗在显示,先移除它
|
||||
[self removeFirstChargePopup];
|
||||
|
||||
// 获取 keyWindow 以确保盖在 tabbar 上
|
||||
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
|
||||
if (!keyWindow) {
|
||||
keyWindow = [UIApplication sharedApplication].windows.firstObject;
|
||||
}
|
||||
|
||||
// 创建背景视图,使用 keyWindow 的 bounds
|
||||
self.firstChargeBackgroundView = [[UIView alloc] initWithFrame:keyWindow.bounds];
|
||||
self.firstChargeBackgroundView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
|
||||
|
||||
// 添加点击手势
|
||||
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleBackgroundTap:)];
|
||||
[self.firstChargeBackgroundView addGestureRecognizer:tapGesture];
|
||||
|
||||
// 添加到 keyWindow 上,确保盖在 tabbar 上
|
||||
[keyWindow addSubview:self.firstChargeBackgroundView];
|
||||
|
||||
// 创建并配置 web 视图
|
||||
self.firstChargeWebVC = [[XPWebViewController alloc] initWithRoomUID:@""];
|
||||
self.firstChargeWebVC.isPush = NO;
|
||||
self.firstChargeWebVC.url = URLWithType(kFirstChargeHomeIndex);
|
||||
|
||||
// 获取当前的根视图控制器来添加子控制器
|
||||
UIViewController *rootViewController = keyWindow.rootViewController;
|
||||
if ([rootViewController isKindOfClass:[UINavigationController class]]) {
|
||||
rootViewController = [(UINavigationController *)rootViewController topViewController];
|
||||
} else if ([rootViewController isKindOfClass:[UITabBarController class]]) {
|
||||
UITabBarController *tabBarController = (UITabBarController *)rootViewController;
|
||||
rootViewController = tabBarController.selectedViewController;
|
||||
if ([rootViewController isKindOfClass:[UINavigationController class]]) {
|
||||
rootViewController = [(UINavigationController *)rootViewController topViewController];
|
||||
}
|
||||
}
|
||||
|
||||
[rootViewController addChildViewController:self.firstChargeWebVC];
|
||||
[self.firstChargeBackgroundView addSubview:self.firstChargeWebVC.view];
|
||||
[self.firstChargeWebVC didMoveToParentViewController:rootViewController];
|
||||
|
||||
self.firstChargeWebVC.view.backgroundColor = [UIColor clearColor];
|
||||
self.firstChargeWebVC.webview.backgroundColor = [UIColor clearColor];
|
||||
self.firstChargeWebVC.webview.opaque = NO;
|
||||
self.firstChargeWebVC.webview.scrollView.backgroundColor = [UIColor clearColor];
|
||||
self.firstChargeWebVC.view.frame = CGRectMake(0, 0, KScreenWidth - 40, KScreenHeight*2/3);
|
||||
self.firstChargeWebVC.view.center = self.firstChargeBackgroundView.center;
|
||||
|
||||
// 添加关闭按钮
|
||||
// UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
// [closeButton setTitle:@"✕" forState:UIControlStateNormal];
|
||||
// [closeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
// closeButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightBold];
|
||||
// [closeButton addTarget:self action:@selector(removeFirstChargePopup) forControlEvents:UIControlEventTouchUpInside];
|
||||
// closeButton.frame = CGRectMake(0, 0, 30, 30);
|
||||
// closeButton.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
|
||||
// closeButton.layer.cornerRadius = 15;
|
||||
// [self.firstChargeBackgroundView addSubview:closeButton];
|
||||
//
|
||||
// // 设置关闭按钮位置(webView 右上角)
|
||||
// CGRect webViewFrame = self.firstChargeWebVC.view.frame;
|
||||
// closeButton.center = CGPointMake(CGRectGetMaxX(webViewFrame) - 15, CGRectGetMinY(webViewFrame) + 15);
|
||||
|
||||
// 3秒后自动移除
|
||||
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(4.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// [self removeFirstChargePopup];
|
||||
// });
|
||||
}
|
||||
|
||||
// 处理背景点击事件
|
||||
- (void)handleBackgroundTap:(UITapGestureRecognizer *)gesture {
|
||||
// 获取点击位置
|
||||
CGPoint location = [gesture locationInView:self.firstChargeBackgroundView];
|
||||
|
||||
// 检查是否点击在 webView 区域外
|
||||
if (self.firstChargeWebVC && self.firstChargeWebVC.view) {
|
||||
CGRect webViewFrame = self.firstChargeWebVC.view.frame;
|
||||
if (!CGRectContainsPoint(webViewFrame, location)) {
|
||||
// 点击在 webView 外部,移除弹窗
|
||||
[self removeFirstChargePopup];
|
||||
}
|
||||
} else {
|
||||
// 如果 webView 不存在,直接移除弹窗
|
||||
[self removeFirstChargePopup];
|
||||
}
|
||||
}
|
||||
|
||||
// 修改移除弹窗的方法
|
||||
- (void)removeFirstChargePopup {
|
||||
if (self.firstChargeWebVC) {
|
||||
[self.firstChargeWebVC willMoveToParentViewController:nil];
|
||||
[self.firstChargeWebVC.view removeFromSuperview];
|
||||
[self.firstChargeWebVC removeFromParentViewController];
|
||||
self.firstChargeWebVC = nil;
|
||||
}
|
||||
|
||||
if (self.firstChargeBackgroundView) {
|
||||
[self.firstChargeBackgroundView removeFromSuperview];
|
||||
self.firstChargeBackgroundView = nil;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - XPNewHomeHeadViewDelegate
|
||||
///
|
||||
|
Reference in New Issue
Block a user