6
This commit is contained in:
@@ -234,7 +234,7 @@
|
||||
- (UIButton *)buyButton {
|
||||
if (!_buyButton) {
|
||||
_buyButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_buyButton setTitle:@"Recharge Now" forState:UIControlStateNormal];
|
||||
[_buyButton setTitle:KBLocalized(@"Recharge Now") forState:UIControlStateNormal];
|
||||
[_buyButton setTitleColor:[UIColor colorWithHex:0x1B1F1A] forState:UIControlStateNormal];
|
||||
_buyButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
|
||||
[_buyButton setBackgroundImage:[UIImage imageNamed:@"recharge_now_icon"] forState:UIControlStateNormal];
|
||||
|
||||
@@ -52,9 +52,44 @@
|
||||
}
|
||||
|
||||
- (void)onToggle {
|
||||
KBLocalizationManager *mgr = [KBLocalizationManager shared];
|
||||
NSString *next = [mgr.currentLanguageCode.lowercaseString hasPrefix:@"zh"] ? @"en" : @"zh-Hans";
|
||||
[mgr setCurrentLanguageCode:next persist:YES];
|
||||
// 弹出系统提示,确认后再切换语言并重建根控制器
|
||||
NSString *title = KBLocalized(@"Change Language");
|
||||
NSString *msg = KBLocalized(@"Changing language will reload the Home screen.");
|
||||
|
||||
UIAlertController *ac = [UIAlertController alertControllerWithTitle:title
|
||||
message:msg
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
UIAlertAction *cancel = [UIAlertAction actionWithTitle:KBLocalized(@"Cancel")
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil];
|
||||
__weak typeof(self) weakSelf = self;
|
||||
UIAlertAction *ok = [UIAlertAction actionWithTitle:KBLocalized(@"Confirm")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(__unused UIAlertAction * _Nonnull action) {
|
||||
__strong typeof(weakSelf) self = weakSelf;
|
||||
if (!self) return;
|
||||
|
||||
KBLocalizationManager *mgr = [KBLocalizationManager shared];
|
||||
NSString *next = [mgr.currentLanguageCode.lowercaseString hasPrefix:@"zh"] ? @"en" : @"zh-Hans";
|
||||
[mgr setCurrentLanguageCode:next persist:YES];
|
||||
|
||||
// 语言切换后重新进入根控制器
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
id<UIApplicationDelegate> appDelegate = UIApplication.sharedApplication.delegate;
|
||||
if ([appDelegate respondsToSelector:@selector(setupRootVC)]) {
|
||||
// 使用 AppDelegate 的统一入口
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
[appDelegate performSelector:@selector(setupRootVC)];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
[ac addAction:cancel];
|
||||
[ac addAction:ok];
|
||||
[self presentViewController:ac animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user