2025-11-06 16:05:28 +08:00
|
|
|
|
//
|
|
|
|
|
|
// HomeMainVC.m
|
|
|
|
|
|
// keyBoard
|
|
|
|
|
|
//
|
|
|
|
|
|
// Created by Mac on 2025/11/6.
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import "HomeMainVC.h"
|
|
|
|
|
|
#import "HomeHeadView.h"
|
|
|
|
|
|
#import "KBPanModalView.h"
|
2025-11-11 19:39:33 +08:00
|
|
|
|
#import "KBGuideVC.h" // 首次安装指引页
|
2025-11-06 16:05:28 +08:00
|
|
|
|
|
|
|
|
|
|
@interface HomeMainVC ()
|
|
|
|
|
|
@property (nonatomic, strong) HomeHeadView *headView;
|
2025-11-06 21:38:58 +08:00
|
|
|
|
@property (nonatomic, strong) KBPanModalView *simplePanModalView;
|
2025-11-06 16:05:28 +08:00
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation HomeMainVC
|
|
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
2025-11-06 21:38:58 +08:00
|
|
|
|
UIImageView *bgImageView = [[UIImageView alloc] init];
|
2025-11-07 00:12:28 +08:00
|
|
|
|
bgImageView.image = [UIImage imageNamed:@"home_bg_image"];
|
2025-11-06 21:38:58 +08:00
|
|
|
|
[self.view addSubview:bgImageView];
|
|
|
|
|
|
[bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.edges.equalTo(self.view);
|
|
|
|
|
|
}];
|
2025-11-07 14:21:03 +08:00
|
|
|
|
// CGFloat topV = (500);
|
2025-11-06 16:05:28 +08:00
|
|
|
|
|
2025-11-07 14:21:03 +08:00
|
|
|
|
[self.view addSubview:self.headView];
|
|
|
|
|
|
[self setupMas];
|
2025-11-06 16:05:28 +08:00
|
|
|
|
// 创建sheetVC
|
2025-11-06 21:38:58 +08:00
|
|
|
|
self.simplePanModalView = [[KBPanModalView alloc] init];
|
2025-11-06 16:05:28 +08:00
|
|
|
|
// 使用宏,避免误写成函数指针判断导致恒为 true
|
|
|
|
|
|
if (KB_DEVICE_HAS_NOTCH) {
|
2025-11-07 14:21:03 +08:00
|
|
|
|
self.simplePanModalView.minHeight = 473 - 44 + KB_NAV_TOTAL_HEIGHT;
|
2025-11-06 16:05:28 +08:00
|
|
|
|
}else{
|
2025-11-07 14:21:03 +08:00
|
|
|
|
self.simplePanModalView.minHeight = 473 - 44 + KB_NAV_TOTAL_HEIGHT;
|
2025-11-06 16:05:28 +08:00
|
|
|
|
//
|
|
|
|
|
|
}
|
2025-11-06 21:38:58 +08:00
|
|
|
|
self.simplePanModalView.topInset = 100;
|
|
|
|
|
|
[self.simplePanModalView presentInView:self.view];
|
2025-11-06 16:05:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-11 19:39:33 +08:00
|
|
|
|
// 在界面可见后做“首次安装”检查,避免在 viewDidLoad 期间 push 引起的转场警告
|
|
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
|
|
[self kb_showGuideIfFirstLaunch];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 首次安装进入首页时,跳转到 KBGuideVC
|
|
|
|
|
|
- (void)kb_showGuideIfFirstLaunch {
|
|
|
|
|
|
static NSString *const kKBHasLaunchedOnce = @"KBHasLaunchedOnce";
|
|
|
|
|
|
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
|
if (![ud boolForKey:kKBHasLaunchedOnce]) {
|
|
|
|
|
|
[ud setBool:YES forKey:kKBHasLaunchedOnce];
|
|
|
|
|
|
[ud synchronize];
|
|
|
|
|
|
|
|
|
|
|
|
// 避免重复 push;同时确保在主线程执行
|
|
|
|
|
|
if (self.navigationController && self.presentedViewController == nil) {
|
|
|
|
|
|
KBGuideVC *vc = [KBGuideVC new];
|
|
|
|
|
|
vc.hidesBottomBarWhenPushed = YES;
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-07 14:21:03 +08:00
|
|
|
|
- (void)setupMas{
|
2025-11-06 16:05:28 +08:00
|
|
|
|
[self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.left.right.equalTo(self.view);
|
2025-11-07 14:21:03 +08:00
|
|
|
|
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT);
|
|
|
|
|
|
make.height.mas_equalTo(473 - 44);
|
2025-11-06 16:05:28 +08:00
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - lazy
|
|
|
|
|
|
- (HomeHeadView *)headView{
|
|
|
|
|
|
if (!_headView) {
|
|
|
|
|
|
_headView = [[HomeHeadView alloc] init];
|
|
|
|
|
|
}
|
|
|
|
|
|
return _headView;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@end
|