添加注销账号
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#import "KBGenderPickerPopView.h"
|
||||
#import "KBMyVM.h"
|
||||
#import "KBAlert.h"
|
||||
#import "KBCancelAccountVC.h"
|
||||
@interface KBPersonInfoVC () <UITableViewDelegate, UITableViewDataSource, PHPickerViewControllerDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate>
|
||||
|
||||
// 列表
|
||||
@@ -28,8 +29,6 @@
|
||||
|
||||
// 底部退出登录按钮
|
||||
@property (nonatomic, strong) UIButton *logoutBtn;
|
||||
// 底部注销账户按钮
|
||||
@property (nonatomic, strong) UIButton *cancelBtn;
|
||||
|
||||
// 数据
|
||||
@property (nonatomic, copy) NSArray<NSDictionary *> *items; // {title,value,arrow,copy}
|
||||
@@ -70,15 +69,6 @@
|
||||
// 底部退出登录按钮
|
||||
[self.view addSubview:self.logoutBtn];
|
||||
[self.logoutBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.view).offset(16);
|
||||
make.right.equalTo(self.view).offset(-16);
|
||||
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-(12 + 56 + 10));
|
||||
make.height.mas_equalTo(56);
|
||||
}];
|
||||
|
||||
// 底部注销账户按钮
|
||||
[self.view addSubview:self.cancelBtn];
|
||||
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.view).offset(16);
|
||||
make.right.equalTo(self.view).offset(-16);
|
||||
make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-12);
|
||||
@@ -87,7 +77,7 @@
|
||||
|
||||
// 列表底部腾出空间,避免被按钮挡住
|
||||
UIEdgeInsets inset = self.tableView.contentInset;
|
||||
inset.bottom = 56 + 10 + 56 + 24; // 两个按钮高度 + 间距 + 额外间距
|
||||
inset.bottom = 56 + 24; // 按钮高度 + 额外间距
|
||||
self.tableView.contentInset = inset;
|
||||
self.viewModel = [[KBMyVM alloc] init];
|
||||
__weak typeof(self) weakSelf = self;
|
||||
@@ -128,14 +118,18 @@
|
||||
|
||||
#pragma mark - UITableView
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; }
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.items.count; }
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; }
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
return section == 0 ? self.items.count : 1;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return 56.0;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 12.0; }
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
|
||||
return section == 0 ? 12.0 : 15.0;
|
||||
}
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return [UIView new]; }
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 0.01; }
|
||||
|
||||
@@ -143,19 +137,34 @@
|
||||
static NSString *cid = @"KBPersonInfoItemCell";
|
||||
KBPersonInfoItemCell *cell = [tableView dequeueReusableCellWithIdentifier:cid];
|
||||
if (!cell) { cell = [[KBPersonInfoItemCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cid]; }
|
||||
NSDictionary *it = self.items[indexPath.row];
|
||||
BOOL isTop = (indexPath.row == 0);
|
||||
BOOL isBottom = (indexPath.row == self.items.count - 1);
|
||||
[cell configWithTitle:it[@"title"]
|
||||
value:it[@"value"]
|
||||
showArrow:[it[@"arrow"] boolValue]
|
||||
showCopy:[it[@"copy"] boolValue]
|
||||
isTop:isTop
|
||||
isBottom:isBottom];
|
||||
|
||||
if (indexPath.section == 0) {
|
||||
NSDictionary *it = self.items[indexPath.row];
|
||||
BOOL isTop = (indexPath.row == 0);
|
||||
BOOL isBottom = (indexPath.row == self.items.count - 1);
|
||||
[cell configWithTitle:it[@"title"]
|
||||
value:it[@"value"]
|
||||
showArrow:[it[@"arrow"] boolValue]
|
||||
showCopy:[it[@"copy"] boolValue]
|
||||
isTop:isTop
|
||||
isBottom:isBottom];
|
||||
} else {
|
||||
[cell configWithTitle:KBLocalized(@"Cancel Account")
|
||||
value:@""
|
||||
showArrow:YES
|
||||
showCopy:NO
|
||||
isTop:YES
|
||||
isBottom:YES];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (indexPath.section == 1) {
|
||||
KBCancelAccountVC *vc = [[KBCancelAccountVC alloc] init];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
return;
|
||||
}
|
||||
if (indexPath.row == 0) {
|
||||
// 昵称编辑 -> 弹窗
|
||||
CGFloat width = KB_SCREEN_WIDTH;
|
||||
@@ -287,25 +296,6 @@
|
||||
[self.myVM logout];
|
||||
}
|
||||
|
||||
- (void)onTapCancelAccount {
|
||||
[[KBMaiPointReporter sharedReporter] reportClickWithEventName:@"click_person_cancel_account_btn"
|
||||
pageId:@"person_info"
|
||||
elementId:@"cancel_account_btn"
|
||||
extra:nil
|
||||
completion:nil];
|
||||
KBWeakSelf;
|
||||
[KBAlert confirmTitle:KBLocalized(@"Cancel Account")
|
||||
message:KBLocalized(@"After cancellation, your account will be deactivated and local login data will be cleared. Continue?")
|
||||
ok:KBLocalized(@"Confirm")
|
||||
cancel:KBLocalized(@"Cancel")
|
||||
okColor:[UIColor colorWithHex:0xFF0000]
|
||||
cancelColor:nil
|
||||
completion:^(BOOL ok) {
|
||||
if (!ok) { return; }
|
||||
[weakSelf.myVM cancelAccountWithCompletion:nil];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Lazy UI(懒加载)
|
||||
|
||||
- (UITableView *)tableView {
|
||||
@@ -409,19 +399,6 @@
|
||||
return _logoutBtn;
|
||||
}
|
||||
|
||||
- (UIButton *)cancelBtn {
|
||||
if (!_cancelBtn) {
|
||||
_cancelBtn = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
[_cancelBtn setTitle:KBLocalized(@"Cancel Account") forState:UIControlStateNormal];
|
||||
[_cancelBtn setTitleColor:[UIColor colorWithHex:0xFF0000] forState:UIControlStateNormal];
|
||||
_cancelBtn.titleLabel.font = [KBFont medium:16];
|
||||
_cancelBtn.backgroundColor = UIColor.whiteColor;
|
||||
_cancelBtn.layer.cornerRadius = 12; _cancelBtn.layer.masksToBounds = YES;
|
||||
[_cancelBtn addTarget:self action:@selector(onTapCancelAccount) forControlEvents:UIControlEventTouchUpInside];
|
||||
}
|
||||
return _cancelBtn;
|
||||
}
|
||||
|
||||
#pragma mark - Image Picker
|
||||
|
||||
- (void)presentImagePicker {
|
||||
|
||||
Reference in New Issue
Block a user