This commit is contained in:
2025-11-17 18:51:06 +08:00
parent ea4b8168b7
commit ee433db4ad
3 changed files with 202 additions and 11 deletions

View File

@@ -22,6 +22,9 @@
#import "IAPVerifyTransactionObj.h"
#import "FGIAPManager.h"
#import "KBSexSelVC.h"
#import <SystemConfiguration/CaptiveNetwork.h>
#import <CoreTelephony/CTCellularData.h>
// bundle id target
// PRODUCT_BUNDLE_IDENTIFIER
// CustomKeyboard target com.loveKey.nyx.CustomKeyboard
@@ -36,11 +39,11 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
// Skip TabBar
BOOL hasShownSexVC = [[NSUserDefaults standardUserDefaults] boolForKey:KBSexSelectShownKey];
// if (hasShownSexVC) {
// [self setupRootVC];
// } else {
if (hasShownSexVC) {
[self setupRootVC];
} else {
[self setupSexSelectRootVC];
// }
}
// 访
[KBNetworkManager shared].enabled = YES;
@@ -57,11 +60,13 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
[Bugly startWithAppId:BuglyId config:buglyConfig];
#endif
// KBGuideVC
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application{}
- (void)applicationDidBecomeActive:(UIApplication *)application{
// [self kb_checkNetworkAndShowAlertIfNeeded];
}
- (void)setupRootVC{
@@ -204,6 +209,9 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
/// 使
/// 访使
- (void)kb_fireStartupNetworkRequest {
// [[KBNetworkManager shared] GET:@"https://www.apple.com" parameters:nil headers:nil completion:^(id _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
//
// }];
NSURL *url = [NSURL URLWithString:@"https://www.apple.com"];
if (!url) { return; }
@@ -252,5 +260,127 @@ static BOOL KBIsKeyboardEnabled(void) {
return NO;
}
#pragma mark - Network check & alert
- (void)kb_checkNetworkAndShowAlertIfNeeded {
AFNetworkReachabilityStatus status = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus;
//
if (status == AFNetworkReachabilityStatusNotReachable ||
status == AFNetworkReachabilityStatusUnknown) {
[self kb_showNoNetworkAlert];
}
}
- (void)kb_showNoNetworkAlert {
UIViewController *rootVC = self.window.rootViewController;
if (!rootVC) return;
// alert
if ([rootVC.presentedViewController isKindOfClass:[UIAlertController class]]) {
return;
}
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"网络不可用"
message:@"请在“设置”中检查本应用的无线数据权限或网络连接。"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *settings = [UIAlertAction actionWithTitle:@"去设置"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
[self kb_openAppSettings]; //
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消"
style:UIAlertActionStyleCancel
handler:nil];
[alert addAction:settings];
[alert addAction:cancel];
[rootVC presentViewController:alert animated:YES completion:nil];
}
///*
//
// */
//- (void)networkStatus:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// //2.
// CTCellularData *cellularData = [[CTCellularData alloc] init];
// /*
//
// */
// cellularData.cellularDataRestrictionDidUpdateNotifier = ^(CTCellularDataRestrictedState state) {
// switch (state) {
// case kCTCellularDataRestricted:
//
// NSLog(@"Restricted");
// //2.1
//
// break;
// case kCTCellularDataNotRestricted:
//
// NSLog(@"NotRestricted");
// //2.2
// [self addReachabilityManager:application didFinishLaunchingWithOptions:launchOptions];
// break;
// case kCTCellularDataRestrictedStateUnknown:
//
// NSLog(@"Unknown");
//
// break;
//
// default:
// break;
// }
// };
//}
//
///**
//
// */
//- (void)addReachabilityManager:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// AFNetworkReachabilityManager *afNetworkReachabilityManager = [AFNetworkReachabilityManager sharedManager];
//
//
// [afNetworkReachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
// switch (status) {
// case AFNetworkReachabilityStatusNotReachable:{
// NSLog(@"网络不通:%@",@(status) );
// break;
// }
// case AFNetworkReachabilityStatusReachableViaWiFi:{
// NSLog(@"网络通过WIFI连接%@",@(status));
//
// [self getInfo_application:application didFinishLaunchingWithOptions:launchOptions];
//
// break;
// }
// case AFNetworkReachabilityStatusReachableViaWWAN:{
// NSLog(@"网络通过无线连接:%@",@(status) );
//
// [self getInfo_application:application didFinishLaunchingWithOptions:launchOptions];
//
// break;
// }
// default:
// break;
// }
// }];
//
// [afNetworkReachabilityManager startMonitoring]; //
//}
//
////- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions
//- (void)getInfo_application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//
//// [self.updateBusiness checkUpdateWithBothApi];//app
//
////APP
// [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil];
//}
//
//
//
@end

View File

@@ -7,6 +7,13 @@
#import "KBSexSelVC.h"
///
typedef NS_ENUM(NSInteger, KBSexOption) {
KBSexOptionMale = 0,
KBSexOptionFemale,
KBSexOptionOther
};
@interface KBSexSelVC ()
//
@@ -38,6 +45,9 @@
//@property (nonatomic, strong) CAGradientLayer *topGradientLayer;
@property (nonatomic, strong) UIImageView *bgImageView; //
///
@property (nonatomic, assign) KBSexOption selectedSex;
@end
@implementation KBSexSelVC
@@ -54,6 +64,9 @@
make.edges.equalTo(self.view);
}];
[self setupUI];
// Male
[self kb_updateSelection:KBSexOptionMale];
}
- (void)viewDidLayoutSubviews {
@@ -88,7 +101,14 @@
//
[self.view addSubview:self.confirmButton];
//
UITapGestureRecognizer *tapMale = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onMaleCardTapped)];
[self.maleCardView addGestureRecognizer:tapMale];
UITapGestureRecognizer *tapFemale = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onFemaleCardTapped)];
[self.femaleCardView addGestureRecognizer:tapFemale];
UITapGestureRecognizer *tapOther = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onOtherCardTapped)];
[self.otherCardView addGestureRecognizer:tapOther];
//
@@ -188,6 +208,21 @@
#pragma mark - Actions
///
- (void)onMaleCardTapped {
[self kb_updateSelection:KBSexOptionMale];
}
///
- (void)onFemaleCardTapped {
[self kb_updateSelection:KBSexOptionFemale];
}
///
- (void)onOtherCardTapped {
[self kb_updateSelection:KBSexOptionOther];
}
///
- (void)onSkipTapped {
// AppDelegate TabBar
@@ -208,6 +243,22 @@
[[NSUserDefaults standardUserDefaults] synchronize];
}
/// UI
- (void)kb_updateSelection:(KBSexOption)sex {
self.selectedSex = sex;
[self kb_updateCard:self.maleCardView selected:(sex == KBSexOptionMale)];
[self kb_updateCard:self.femaleCardView selected:(sex == KBSexOptionFemale)];
[self kb_updateCard:self.otherCardView selected:(sex == KBSexOptionOther)];
}
/// /
- (void)kb_updateCard:(UIView *)card selected:(BOOL)selected {
card.layer.borderWidth = selected ? 2.0 : 0.0;
card.layer.borderColor = selected ? [UIColor colorWithHex:KBColorValue].CGColor : [UIColor clearColor].CGColor;
card.backgroundColor = selected ? [UIColor whiteColor] : [UIColor colorWithHex:0xFAFAFA];
}
#pragma mark - Lazy UI
@@ -257,10 +308,12 @@
- (UIView *)maleCardView {
if (!_maleCardView) {
_maleCardView = [UIView new];
_maleCardView.backgroundColor = [UIColor whiteColor];
//
_maleCardView.backgroundColor = [UIColor colorWithHex:0xFAFAFA];
_maleCardView.layer.cornerRadius = 24.0;
_maleCardView.layer.masksToBounds = YES;
_maleCardView.layer.borderWidth = 2.0;
// kb_updateSelection
_maleCardView.layer.borderWidth = 0.0;
_maleCardView.layer.borderColor = [UIColor colorWithHex:KBColorValue].CGColor;
}
return _maleCardView;

View File

@@ -8,6 +8,8 @@
#import "UIColor+Extension.h"
#import "KBPersonInfoVC.h"
#import "KBMyKeyBoardVC.h"
#import "KBJfPay.h"
#import "KBVipPay.h"
@interface KBMyHeaderView ()
@property (nonatomic, strong) UILabel *titleLabel;
@@ -202,7 +204,13 @@
KBPersonInfoVC *vc = [[KBPersonInfoVC alloc] init];
[KB_CURRENT_NAV pushViewController:vc animated:true];
}
- (void)onLeftCardTap { if (self.onLeftCardTapped) { self.onLeftCardTapped(); } }
- (void)onRightCardTap { if (self.onRightCardTapped) { self.onRightCardTapped(); } }
- (void)onLeftCardTap {
KBVipPay *vc = [[KBVipPay alloc] init];
[KB_CURRENT_NAV pushViewController:vc animated:true];
}
- (void)onRightCardTap {
KBJfPay *vc = [[KBJfPay alloc] init];
[KB_CURRENT_NAV pushViewController:vc animated:true];
}
@end