| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- //
- // MOMineSetUpVC.m
- // MiMoLive
- //
- // Created by SuperC on 2023/10/23.
- //
- #import "MOMineSetUpVC.h"
- #import "MOMineSetUpCell.h"
- #import "MOSetUpPlayBackCell.h"
- #import "MOBlackListVC.h"
- #import "MOChangeLanguageVC.h"
- #import "MOLoginChooseVC.h"
- #import "MOBingMobileVC.h"
- #import "MOSetPasswordSMS.h"
- #import "MOAboutUsVC.h"
- #import "NSDate+K1Util.h"
- #import "MODeleteAccountAlertView.h"
- #import "MOPhoneBindVC.h"
- #import "MONewVersionView.h"
- #import "MOAccountSecurityVC.h"
- #import "MOMinimizeManager.h"
- #import "MOThreeOptionAlertView.h"
- #if DEBUG
- #import "DoraemonKit.h"
- #endif
- @interface MOMineSetUpVC ()
- @property (weak, nonatomic) IBOutlet UITableView *tableView;
- @property (weak, nonatomic) IBOutlet UISwitch *theTestSwitch;
- @property (nonatomic, strong) MOSecurityData *baseData;
- @property (nonatomic, strong) UIView *footerView;
- @property (weak, nonatomic) IBOutlet UIView *dokitView;
- @property (weak, nonatomic) IBOutlet UISwitch *dokitSwitch;
- @end
- @implementation MOMineSetUpVC
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:NO animated:animated];
-
- [self mo_v2_setNavLeftItemWithImage:[UIImage imageNamed:@"v_2_icon_new_back_black"] andBackgroundImg:nil AndBgColor:nil];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.navigationItem.title = NSLocalString(@"mimo_setting_titler");
-
- [self setupUI];
-
- [self toGetTheSecurityInfo];
- }
- - (void)toGetTheSecurityInfo{
- WEAKSELF
- [kHttpManager toGetTheUserSecurityInfoWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- weakSelf.baseData = [MOSecurityData modelObjectWithDictionary:data[@"data"]];
- [weakSelf.tableView reloadData];
- }
- else{
- MOLogV(@"toGetTheUserSecurityInfoWithParams 接口报错了");
- kShowNetError(data)
- }
- }];
- }
- - (void)setupUI{
-
- self.view.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA"];
-
- self.tableView.estimatedRowHeight = 0;
- self.tableView.estimatedSectionHeaderHeight = 0;
- self.tableView.estimatedSectionFooterHeight = 0;
-
- //iOS15适配
- if (@available(iOS 15.0, *))
- {
- self.tableView.sectionHeaderTopPadding = 0;
- }
-
- [self.tableView registerClass:MOMineSetUpCell.class forCellReuseIdentifier:NSStringFromClass(MOMineSetUpCell.class)];
- [self.tableView registerClass:MOSetUpPlayBackCell.class forCellReuseIdentifier:NSStringFromClass(MOSetUpPlayBackCell.class)];
- self.tableView.tableFooterView = self.footerView;
-
-
- #if DEBUG
- self.theTestSwitch.hidden = NO;
-
- BOOL isTest = GetIsTest;
- self.theTestSwitch.on = isTest;
-
- self.dokitView.hidden = NO;
- self.dokitView.layer.cornerRadius = 16;
- [self.dokitSwitch setOn:[[DoraemonManager shareInstance] isShowDoraemon]];
-
- #endif
-
- //#if kAPP_Environment == 2
- // UIButton *copyIDFVBtn = [[UIButton alloc] init];
- // copyIDFVBtn.backgroundColor = [UIColor cyanColor];
- // [copyIDFVBtn setTitle:@"idfv" forState:UIControlStateNormal];
- // [copyIDFVBtn addTarget:self action:@selector(copyIDFVBtnAction) forControlEvents:UIControlEventTouchUpInside];
- // [self.view addSubview:copyIDFVBtn];
- // [copyIDFVBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.bottom.equalTo(self.quitBtn.mas_top).offset(-10);
- // make.right.equalTo(self.quitBtn);
- // make.size.mas_equalTo(CGSizeMake(50, 30));
- // }];
- //
- //#endif
- }
- //#if kAPP_Environment == 2
- //- (void)copyIDFVBtnAction {
- // [Adjust idfvWithCompletionHandler:^(NSString * _Nullable idfv) {
- // UIPasteboard *pab = [UIPasteboard generalPasteboard];
- // [pab setString:idfv];
- // if (pab == nil) {
- // [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_money_Failed")];
- // } else {
- // [MBProgressHUD showTipMessageInWindow:idfv];
- // }
- // }];
- //}
- //#endif
- #pragma mark - UITableViewDelegate,UITableViewDataSource
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 5;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- return 1;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- if (indexPath.section == 4) {//播放设置
- CGFloat contentHeight = [MOTools getSizeFrom:NSLocalString(@"mimo_setting_play_desc") font:[MOTextTools regularFont:12] maxSize:CGSizeMake(SCREENWIDTH - 153, MAXFLOAT)].height;
- return contentHeight + 60;
- }
- return 56.0;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- if (indexPath.section == 4) {//播放设置
- MOSetUpPlayBackCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(MOSetUpPlayBackCell.class)];
- cell.titleLabel.text = NSLocalString(@"mimo_setting_play");
- [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_play"]];
- cell.contentLabel.text = NSLocalString(@"mimo_setting_play_desc");
- return cell;
- } else {
- MOMineSetUpCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass(MOMineSetUpCell.class)];
- cell.titleLabel.text = @"";
- [cell hideStartImgView];
-
- if(indexPath.section == 0){
- cell.titleLabel.text = NSLocalString(@"mimo_mine_setting_account_security");
- [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_account"]];
-
- if(self.baseData){
- if(self.baseData.level == 2){
- //High
- [cell setupStartImageWithHight:YES];
- }
- else{
- //Low
- [cell setupStartImageWithHight:NO];
- }
- }
- }
- else if (indexPath.section == 1){
- cell.titleLabel.text = NSLocalString(@"mimo_setting_language");
- [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_language"]];
- }
- else if (indexPath.section == 2){
- cell.titleLabel.text = NSLocalString(@"mimo_setting_blacklist");
- [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_black"]];
- }
- else if (indexPath.section == 3){
- cell.titleLabel.text = NSLocalString(@"mimo_setting_about_us");
- [cell.iconImgView setImage:[UIImage imageNamed:@"icon_setting_about_us"]];
- }
-
- return cell;
- }
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
-
- WEAKSELF
- if(indexPath.section == 0){
-
- MOAccountSecurityVC *securityVc = [[MOAccountSecurityVC alloc] init];
- securityVc.baseModel = weakSelf.baseModel;
- securityVc.toRefreshTheData = ^(MOSecurityData * _Nonnull theBaseData) {
- weakSelf.baseData = theBaseData;
- [weakSelf.tableView reloadData];
- };
- [self.navigationController pushViewController:securityVc animated:YES];
- }
- else if (indexPath.section == 1){
- //Language
- MOChangeLanguageVC *vc = [[MOChangeLanguageVC alloc] init];
- [self.navigationController pushViewController:vc animated:YES];
- }
- else if (indexPath.section == 2){
- //Blacklist
- MOBlackListVC *vc = [[MOBlackListVC alloc] init];
- [self.navigationController pushViewController:vc animated:YES];
- }
- else if (indexPath.section == 3){
- //About Us
- MOAboutUsVC *vc = [[MOAboutUsVC alloc] init];
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
-
- return 0.01;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- return 8;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
- UIView *view = [[UIView alloc] init];
- view.backgroundColor = [UIColor clearColor];
- return view;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
- UIView *view = [[UIView alloc] init];
- view.backgroundColor = [UIColor clearColor];
- return view;
- }
- - (IBAction)switchChanged:(UISwitch *)sender {
- if(sender.isOn){
- [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"k_MiMo_Test"];
- }
- else{
- [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"k_MiMo_Test"];
- }
- }
- - (void)logoutButtonAction {
- //TODO: 退出登录
- //关闭最小化小窗口
- [[MOMinimizeManager shareManager] closeAll];
-
- WEAKSELF
- UIAlertController *sheetC = [UIAlertController alertControllerWithTitle:nil message:NSLocalString(@"mimo_setting_revoked_alert_title") preferredStyle:UIAlertControllerStyleActionSheet];
-
- [sheetC addAction:[UIAlertAction actionWithTitle:NSLocalString(@"mimo_common_cancel") style:UIAlertActionStyleCancel handler:nil]];
-
- [sheetC addAction:[UIAlertAction actionWithTitle:NSLocalString(@"mimo_common_confirm") style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action)
- {
- [MOMineSetUpVC toLoginVCAndShowTip:NO];
- }]];
-
- [self presentViewController:sheetC animated:YES completion:nil];
- }
- + (void)toLoginVCAndShowTip:(BOOL)showTip{
- //通知服务器
- [kHttpManager toLogoutWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- MOLogV(@"退出服务器回调");
- }];
-
- //RTM 退出登录
- [[MOAgoraRTMManager shareManager] toLogoutRtm];
-
- //删除关键信息
- [MODataManager deleteUserDefaultsExceptApp];
-
- MOMainTabController *mainTabbar = [MOMainTabController sharedSingleton];
- mainTabbar.isNormalOpen = NO;
-
- MOLoginChooseVC *vc = [[MOLoginChooseVC alloc] init];
- UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
- [nav.navigationBar setHidden:YES];
- UIWindow *window = [UIApplication sharedApplication].keyWindow;
- window.rootViewController = nav;
-
- if(showTip){
- UIAlertAction *noAction = [UIAlertAction actionWithTitle:NSLocalString(@"mimo_boot_action_no_location_tip_Sure") style:UIAlertActionStyleDefault handler:nil];
- NSString *tipStr = NSLocalString(@"mimo_login_tip_status_other_device");
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:tipStr message:nil preferredStyle:UIAlertControllerStyleAlert];
- [alertController addAction:noAction];
- [nav presentViewController:alertController animated:YES completion:nil];
- }
-
- [MOEventDeliver notifyUserLogout];
- }
- - (UIView *)footerView {
- if (!_footerView) {
- _footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, 80)];
- _footerView.backgroundColor = [UIColor clearColor];
-
- UIButton *logoutButton = [[UIButton alloc] init];
- [logoutButton setTitle:NSLocalString(@"mimo_setting_revoked") forState:UIControlStateNormal];
- [logoutButton setTitleColor:[MOTools colorWithHexString:@"#F23051"] forState:UIControlStateNormal];
- logoutButton.titleLabel.font = [MOTextTools mediumFont:16];
- logoutButton.layer.masksToBounds = YES;
- logoutButton.layer.cornerRadius = 16;
- logoutButton.layer.borderWidth = 1;
- logoutButton.layer.borderColor = [MOTools colorWithHexString:@"#DADCE6"].CGColor;
- [logoutButton setBackgroundImage:[MOTools createImageWithColor:[MOTools colorWithHexString:@"#FFFFFF"]] forState:UIControlStateNormal];
- [logoutButton setBackgroundImage:[MOTools createImageWithColor:[MOTools colorWithHexString:@"#DADCE6"]] forState:UIControlStateHighlighted];
- [logoutButton addTarget:self action:@selector(logoutButtonAction) forControlEvents:UIControlEventTouchUpInside];
- [_footerView addSubview:logoutButton];
- [logoutButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(12);
- make.right.mas_equalTo(-12);
- make.center.mas_equalTo(0);
- make.height.mas_equalTo(48);
- }];
- }
- return _footerView;
- }
- - (IBAction)handleDokitSwitch:(id)sender {
- #if DEBUG
- if (self.dokitSwitch.isOn) {
- [[DoraemonManager shareInstance] showDoraemon];
- } else {
- [[DoraemonManager shareInstance] hiddenDoraemon];
- }
- #endif
- }
- @end
|