2025-11-06 13:18:27 +08:00
//
// KBTestVC . m
// keyBoard
//
// Created by Mac on 2025 / 11 / 6.
//
# import "KBTestVC.h"
2025-11-24 20:47:36 +08:00
# import "LSTPopView.h"
2025-11-06 13:18:27 +08:00
# import "KBGuideVC.h"
# import "KBLangTestVC.h"
2025-11-24 20:47:36 +08:00
# import "KBLoginPopView.h"
2025-11-06 13:18:27 +08:00
@ interface KBTestVC ( ) < UITableViewDelegate , UITableViewDataSource >
@ property ( nonatomic , strong ) UITextView * textView ; // 作 为 表 头 , 保 持 原 有 键 盘 测 试
@ property ( nonatomic , strong ) BaseTableView * tableView ; // 首 页 列 表
@ property ( nonatomic , copy ) NSArray < NSString * > * items ; // 简 单 数 据 源
@ end
@ implementation KBTestVC
- ( 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 ] ;
// 列 表
2025-11-19 14:54:45 +08:00
self . tableView = [ [ BaseTableView alloc ] initWithFrame : CGRectMake ( 0 , KB_NAV _TOTAL _HEIGHT , KB_SCREEN _WIDTH , KB_SCREEN _HEIGHT - KB_NAV _TOTAL _HEIGHT ) style : UITableViewStyleInsetGrouped ] ;
2025-11-06 13:18:27 +08:00
self . tableView . autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight ;
self . tableView . delegate = self ;
self . tableView . dataSource = self ;
self . tableView . tableHeaderView = header ;
[ self . view addSubview : self . tableView ] ;
2026-03-07 13:29:29 +08:00
self . items = @ [ KBLocalized ( @ "home_item_lang_test" ) , KBLocalized ( @ "home_item_keyboard_permission" ) , KBLocalized ( @ "Skin Center" ) , KBLocalized ( @ "Sign in with Apple" ) ] ;
2025-11-06 13:18:27 +08:00
dispatch_async ( dispatch_get _main _queue ( ) , ^ { [ self . textView becomeFirstResponder ] ; } ) ;
2025-12-03 13:54:57 +08:00
[ [ KBNetworkManager shared ] GET : KB_API _APP _CONFIG parameters : nil headers : nil completion : ^ ( NSDictionary * _Nullable json , NSURLResponse * _Nullable response , NSError * _Nullable error ) {
2025-11-06 13:18:27 +08:00
NSLog ( @ "====" ) ;
} ] ;
}
- ( void ) viewWillAppear : ( BOOL ) animated {
[ super viewWillAppear : animated ] ;
2025-11-24 20:47:36 +08:00
self . title = KBLocalized ( @ "Test" ) ;
2026-03-07 13:29:29 +08:00
self . items = @ [ KBLocalized ( @ "home_item_lang_test" ) , KBLocalized ( @ "home_item_keyboard_permission" ) , KBLocalized ( @ "Skin Center" ) , KBLocalized ( @ "Sign in with Apple" ) ] ;
2025-11-06 13:18:27 +08:00
[ 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 ] ; }
2025-11-24 20:47:36 +08:00
} else if ( indexPath . row = = 3 ) {
[ self goLogin ] ;
2025-11-06 13:18:27 +08:00
}
}
2025-11-24 20:47:36 +08:00
- ( void ) goLogin {
dispatch_after ( dispatch_time ( DISPATCH_TIME _NOW , ( int64_t ) ( 0.25 * NSEC_PER _SEC ) ) , dispatch_get _main _queue ( ) , ^ {
KBLoginPopView * view = [ [ KBLoginPopView alloc ] initWithFrame : CGRectMake ( 0 , 0 , KB_SCREEN _WIDTH , KB_SCREEN _WIDTH ) ] ;
// 创 建 并 弹 出
LSTPopView * pop = [ LSTPopView initWithCustomView : view
parentView : nil
popStyle : LSTPopStyleSmoothFromBottom
dismissStyle : LSTDismissStyleSmoothToBottom ] ;
pop . hemStyle = LSTHemStyleBottom ;
pop . bgColor = [ [ UIColor blackColor ] colorWithAlphaComponent : 0.4 ] ;
pop . isClickBgDismiss = YES ; // 点 击 背 景 关 闭
pop . cornerRadius = 0 ; // 自 定 义 view 自 处 理 圆 角
__weak typeof ( pop ) weakPop = pop ;
view . appleLoginHandler = ^ {
[ weakPop dismiss ] ;
// 交 给 VM 统 一 处 理 Apple 登 录 + 服 务 端 登 录
[ [ KBLoginVM shared ] signInWithAppleFromViewController : KB_CURRENT _NAV completion : ^ ( BOOL success , NSError * _Nullable error ) {
if ( success ) {
[ KBHUD showInfo : KBLocalized ( @ "Signed in successfully" ) ] ;
} else {
NSString * msg = error . localizedDescription ? : KBLocalized ( @ "Sign-in failed" ) ;
[ KBHUD showInfo : msg ] ;
}
} ] ;
} ;
view . closeHandler = ^ { [ weakPop dismiss ] ; } ;
[ pop pop ] ;
} ) ;
}
2025-11-06 13:18:27 +08:00
@ end