Files
real-e-party-iOS/YuMi/Modules/YMMine/View/PISwitchingEnvironmentVC.m
edwinQQQ a35a711be6 chore: Initial clean commit
- Removed YuMi/Library/ (138 MB, not tracked)
- Removed YuMi/Resources/ (23 MB, not tracked)
- Removed old version assets (566 files, not tracked)
- Excluded Pods/, xcuserdata/ and other build artifacts
- Clean repository optimized for company server deployment
2025-10-09 16:19:14 +08:00

122 lines
4.5 KiB
Objective-C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// PISwitchingEnvironmentVC.m
// YuMi
//
// Created by duoban on 2023/11/8.
//
#import "PISwitchingEnvironmentVC.h"
#import "XPAdImageTool.h"
#import "BaseNavigationController.h"
#import "XPMineSwitchLanguageVC.h"
@interface PISwitchingEnvironmentVC ()
@property(nonatomic,strong) UILabel *titleView;
@end
@implementation PISwitchingEnvironmentVC
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"切换";
NSString *isProduction = [[NSUserDefaults standardUserDefaults]valueForKey:@"kIsProductionEnvironment"];
NSString *text = @"";
if([isProduction isEqualToString:@"YES"]){
text = @"当前环境:正式环境";
}else{
text = @"当前环境:测试环境";
}
self.titleView = [UILabel labelInitWithText:text font:kFontMedium(16) textColor:[DJDKMIMOMColor mainTextColor]];
[self.view addSubview:self.titleView];
UILabel *switchTitle = [UILabel labelInitWithText:@"切换环境" font:kFontMedium(15) textColor:[DJDKMIMOMColor secondTextColor]];
[self.view addSubview:switchTitle];
UISwitch *switchView = [[UISwitch alloc]init];
[switchView setOn:[isProduction isEqualToString:@"YES"]];
[self.view addSubview:switchView];
[switchView addTarget:self action:@selector(switchEnvironmentAction:) forControlEvents:UIControlEventValueChanged];
if (@available(iOS 14.0, *)) {
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(switchLanguage:) name:@"kSwitchLanguage" object:nil];
UIButton *toSwithLanguage = [UIButton buttonWithType:UIButtonTypeInfoLight
primaryAction:[UIAction actionWithHandler:^(__kindof UIAction * _Nonnull action) {
XPMineSwitchLanguageVC*languageVC = [XPMineSwitchLanguageVC new];
[self.navigationController pushViewController:languageVC animated:YES];
}]];
[self.view addSubview:toSwithLanguage];
[toSwithLanguage mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.view);
make.size.mas_equalTo(CGSizeMake(60, 60));
}];
}
UIButton *realBtn = [UIButton new];
[realBtn setTitle:@"调试捉包工具" forState:UIControlStateNormal];
realBtn.titleLabel.font = kFontMedium(16);
[realBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[realBtn addTarget:self action:@selector(showRealTimeView) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:realBtn];
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(30));
make.top.mas_equalTo(kGetScaleWidth(100));
}];
[switchTitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.equalTo(self.titleView);
make.top.equalTo(self.titleView.mas_bottom).mas_offset(kGetScaleWidth(20));
}];
[switchView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.equalTo(switchTitle.mas_trailing).mas_offset(kGetScaleWidth(10));
make.centerY.equalTo(switchTitle);
}];
[realBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.equalTo(self.titleView);
make.top.equalTo(switchTitle.mas_bottom).mas_offset(kGetScaleWidth(30));
}];
}
-(void)switchLanguage:(NSNotification *)not{
#if DEBUG
exit(0);
#endif
}
-(void)showRealTimeView{
[BSNetListenModel initRealTimeView];
UIWindow * window = [UIApplication sharedApplication].keyWindow;
[BSNetListenModel sharedInstance:window];
}
-(void)switchEnvironmentAction:(UISwitch *)sender{
TTAlertConfig *config = [[TTAlertConfig alloc]init];
config.title = @"提示";
config.message = @"确认切换网络环境吗需要重启app";
[TTPopup alertWithConfig:config confirmHandler:^{
if(sender.isOn == YES){
[[NSUserDefaults standardUserDefaults]setValue:@"YES" forKey:@"kIsProductionEnvironment"];
[[NSUserDefaults standardUserDefaults]synchronize];
self.titleView.text = @"当前环境:正式环境";
[self logoutAction];
return;
}
[[NSUserDefaults standardUserDefaults]setValue:@"NO" forKey:@"kIsProductionEnvironment"];
[[NSUserDefaults standardUserDefaults]synchronize];
self.titleView.text = @"当前环境:测试环境";
[self logoutAction];
} cancelHandler:^{
[sender setOn:!sender.isOn];
}];
}
-(void)logoutAction{
#if DEBUG
exit(0);
#endif
}
@end