Files
keyboard/keyBoard/Class/Home/VC/HomeVC.m

112 lines
4.4 KiB
Objective-C

//
// HomeVC.m
// keyBoard
//
// Created by Mac on 2025/10/29.
//
#import "HomeVC.h"
#import "KBGuideVC.h"
#import "KBLangTestVC.h"
#import "HomeSheetVC.h"
@interface HomeVC () <UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITextView *textView; // 作为表头,保持原有键盘测试
@property (nonatomic, strong) BaseTableView *tableView; // 首页列表
@property (nonatomic, copy) NSArray<NSString *> *items; // 简单数据源
@end
@implementation HomeVC
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
// CGFloat width = [UIScreen mainScreen].bounds.size.width;
// UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, width, 220)];
// CGRect frame = CGRectMake(16, 16, width - 32, 188);
// self.textView = [[UITextView alloc] initWithFrame:frame];
// self.textView.text = KBLocalized(@"home_input_placeholder");
// self.textView.layer.borderColor = [UIColor blackColor].CGColor;
// self.textView.layer.borderWidth = 0.5;
// [header addSubview:self.textView];
//
// // 列表
// self.tableView = [[BaseTableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleInsetGrouped];
// self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// self.tableView.delegate = self;
// self.tableView.dataSource = self;
// self.tableView.tableHeaderView = header;
// [self.view addSubview:self.tableView];
//
// self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
//
// dispatch_async(dispatch_get_main_queue(), ^{ [self.textView becomeFirstResponder]; });
//
// [[KBNetworkManager shared] GET:@"app/config" parameters:nil headers:nil completion:^(id _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
// NSLog(@"====");
// }];
HomeSheetVC *vc = [HomeSheetVC new];
vc.minHeight = 300;
vc.topInset = 100;
[self presentPanModal:vc];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
// self.title = KBLocalized(@"home_title");
// self.items = @[ KBLocalized(@"home_item_lang_test"), KBLocalized(@"home_item_keyboard_permission"), @"皮肤中心" ];
// [self.tableView reloadData];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
// KBGuideVC *vc = [[KBGuideVC alloc] init];
// [self.navigationController pushViewController:vc animated:true];
// [KBHUD showInfo:@"加载中..."];
// [KBHUD show];
// [KBHUD showAllowTapToDismiss:true];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.items.count; }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellId = @"home.cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; }
cell.textLabel.text = self.items[indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == 0) {
// 多语言测试页
KBLangTestVC *vc = [KBLangTestVC new];
[self.navigationController pushViewController:vc animated:YES];
} else if (indexPath.row == 1) {
// 键盘权限引导页
KBGuideVC *vc = [KBGuideVC new];
[self.navigationController pushViewController:vc animated:YES];
} else if (indexPath.row == 2) {
// 皮肤中心
UIViewController *vc = [NSClassFromString(@"KBSkinCenterVC") new];
if (vc) { [self.navigationController pushViewController:vc animated:YES]; }
}
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end