国际化
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#import "XPMineLoginPasswordViewController.h"
|
||||
#import "XPMineBlackListViewController.h"
|
||||
#import "XPMaskManagerVC.h"
|
||||
#import "XPMineSwitchLanguageVC.h"
|
||||
///不同模块的VC
|
||||
#import "XPWebViewController.h"
|
||||
#import "XPLoginVerifBindPhoneViewController.h"
|
||||
@@ -58,6 +59,10 @@
|
||||
@end
|
||||
|
||||
@implementation XPMineSettingViewController
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter]removeObserver:self];
|
||||
}
|
||||
- (XPMineSettingPresent *)createPresenter {
|
||||
return [[XPMineSettingPresent alloc] init];
|
||||
}
|
||||
@@ -67,8 +72,22 @@
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
[self.presenter getMineSettingDataSourceWith:self.userInfo];
|
||||
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage:) name:@"kSwitchLanguage" object:nil];
|
||||
}
|
||||
-(void)switchLanguage:(NSNotification *)not{
|
||||
for (UIView *obj in self.view.subviews) {
|
||||
[obj removeFromSuperview];
|
||||
}
|
||||
[self.presenter clearList];
|
||||
self.tableView = nil;
|
||||
self.datasource = nil;
|
||||
self.logoutButton = nil;
|
||||
self.footerView = nil;
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
[self.presenter getMineSettingDataSourceWith:self.userInfo];
|
||||
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
///每次都需要刷新一个userinfo
|
||||
@@ -221,6 +240,11 @@
|
||||
XPMaskManagerVC *vc = [XPMaskManagerVC new];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
break;
|
||||
}
|
||||
case XPMineSettingItemType_Language:
|
||||
{
|
||||
XPMineSwitchLanguageVC*languageVC = [XPMineSwitchLanguageVC new];
|
||||
[self.navigationController pushViewController:languageVC animated:YES];
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
16
YuMi/Modules/YMMine/View/Setting/XPMineSwitchLanguageVC.h
Normal file
16
YuMi/Modules/YMMine/View/Setting/XPMineSwitchLanguageVC.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// XPMineSwitchLanguageVC.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2024/4/8.
|
||||
//
|
||||
|
||||
#import "BaseViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPMineSwitchLanguageVC : BaseViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
133
YuMi/Modules/YMMine/View/Setting/XPMineSwitchLanguageVC.m
Normal file
133
YuMi/Modules/YMMine/View/Setting/XPMineSwitchLanguageVC.m
Normal file
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// XPMineSwitchLanguageVC.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2024/4/8.
|
||||
//
|
||||
|
||||
#import "XPMineSwitchLanguageVC.h"
|
||||
#import "XPMineSettingItemModel.h"
|
||||
#import "XPMineSettingTableViewCell.h"
|
||||
|
||||
@interface XPMineSwitchLanguageVC ()<UITableViewDelegate, UITableViewDataSource>
|
||||
@property(nonatomic,strong) UIButton *saveBtn;
|
||||
@property (nonatomic,strong) UITableView *tableView;
|
||||
///数据源
|
||||
@property (nonatomic,strong) NSArray<XPMineSettingItemModel *> *datasource;
|
||||
@end
|
||||
|
||||
@implementation XPMineSwitchLanguageVC
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
[self installUI];
|
||||
[self installConstraints];
|
||||
}
|
||||
-(void)installUI{
|
||||
self.title = YMLocalizedString(@"XPMineSwitchLanguageVC0");
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.saveBtn];
|
||||
|
||||
[self.view addSubview:self.tableView];
|
||||
}
|
||||
-(void)installConstraints{
|
||||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.view);
|
||||
}];
|
||||
}
|
||||
-(void)saveBtnAction{
|
||||
|
||||
}
|
||||
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return 45;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return self.datasource.count;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
XPMineSettingTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineSettingTableViewCell class])];
|
||||
XPMineSettingItemModel * model = [self.datasource safeObjectAtIndex1:indexPath.row];
|
||||
cell.itemModel = model;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
||||
|
||||
return 0.01f;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
|
||||
return 0.01f;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
NSString *language ;
|
||||
XPMineSettingItemModel * model = [self.datasource safeObjectAtIndex1:indexPath.row] ;
|
||||
if ([model.title isEqualToString:@"English"]){
|
||||
language = @"en";
|
||||
|
||||
}else if ([model.title isEqualToString:@"繁體中文"]){
|
||||
language = @"zh-Hant";
|
||||
|
||||
}else{
|
||||
|
||||
language = @"ar";
|
||||
}
|
||||
[NSBundle setLanguageText:language];
|
||||
[[NSNotificationCenter defaultCenter]postNotificationName:@"kSwitchLanguage" object:language];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5* NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
});
|
||||
|
||||
}
|
||||
#pragma mark - 懒加载
|
||||
- (NSArray<XPMineSettingItemModel *> *)datasource{
|
||||
if(!_datasource){
|
||||
XPMineSettingItemModel *enItme = [XPMineSettingItemModel new];
|
||||
enItme.title = @"English";
|
||||
XPMineSettingItemModel *zhItme = [XPMineSettingItemModel new];
|
||||
zhItme.title = @"繁體中文";
|
||||
XPMineSettingItemModel *arItme = [XPMineSettingItemModel new];
|
||||
arItme.title = @"العربية";
|
||||
_datasource = @[enItme,zhItme,arItme];
|
||||
}
|
||||
return _datasource;
|
||||
}
|
||||
- (UIButton *)saveBtn {
|
||||
if (!_saveBtn) {
|
||||
_saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_saveBtn setFrame:CGRectMake(0, 0, 50, 30)];
|
||||
[_saveBtn setTitle:YMLocalizedString(@"XPMineSwitchLanguageVC1") forState:UIControlStateNormal];
|
||||
[_saveBtn setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateNormal];
|
||||
_saveBtn.titleLabel.font = [UIFont systemFontOfSize:13];
|
||||
[_saveBtn addTarget:self action:@selector(saveBtnAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _saveBtn;
|
||||
}
|
||||
- (UITableView *)tableView {
|
||||
if (!_tableView) {
|
||||
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
|
||||
_tableView.delegate = self;
|
||||
_tableView.dataSource = self;
|
||||
_tableView.showsVerticalScrollIndicator = NO;
|
||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
_tableView.backgroundColor = [UIColor clearColor];
|
||||
[_tableView registerClass:[XPMineSettingTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineSettingTableViewCell class])];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
@end
|
Reference in New Issue
Block a user