161 lines
5.1 KiB
Objective-C
161 lines
5.1 KiB
Objective-C
//
|
||
// AIReportVC.m
|
||
// keyBoard
|
||
//
|
||
// Created by Mac on 2026/1/29.
|
||
//
|
||
|
||
#import "AIReportVC.h"
|
||
|
||
@interface AIReportVC ()
|
||
|
||
/// 举报原因列表
|
||
@property (nonatomic, strong) NSArray<NSString *> *reportReasons;
|
||
/// 当前选中的索引
|
||
@property (nonatomic, assign) NSInteger selectedIndex;
|
||
/// 举报原因 TableView
|
||
@property (nonatomic, strong) UITableView *tableView;
|
||
/// 提交按钮
|
||
@property (nonatomic, strong) UIButton *submitButton;
|
||
|
||
@end
|
||
|
||
@implementation AIReportVC
|
||
|
||
#pragma mark - Lifecycle
|
||
|
||
- (void)viewDidLoad {
|
||
[super viewDidLoad];
|
||
|
||
self.view.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1.0];
|
||
self.kb_titleLabel.text = KBLocalized(@"Report");
|
||
self.selectedIndex = -1;
|
||
|
||
/// 1:初始化数据
|
||
[self initData];
|
||
/// 2:控件初始化
|
||
[self setupUI];
|
||
}
|
||
|
||
#pragma mark - 1:初始化数据
|
||
|
||
- (void)initData {
|
||
self.reportReasons = @[
|
||
KBLocalized(@"Inappropriate content"),
|
||
KBLocalized(@"Spam or advertising"),
|
||
KBLocalized(@"Harassment or bullying"),
|
||
KBLocalized(@"False information"),
|
||
KBLocalized(@"Intellectual property violation"),
|
||
KBLocalized(@"Other")
|
||
];
|
||
}
|
||
|
||
#pragma mark - 2:控件初始化
|
||
|
||
- (void)setupUI {
|
||
[self.view addSubview:self.tableView];
|
||
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.top.equalTo(self.kb_navView.mas_bottom).offset(20);
|
||
make.left.right.equalTo(self.view);
|
||
make.bottom.equalTo(self.submitButton.mas_top).offset(-20);
|
||
}];
|
||
|
||
[self.view addSubview:self.submitButton];
|
||
[self.submitButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.view).offset(40);
|
||
make.right.equalTo(self.view).offset(-40);
|
||
make.bottom.equalTo(self.view).offset(-KB_SAFE_BOTTOM - 30);
|
||
make.height.mas_equalTo(50);
|
||
}];
|
||
}
|
||
|
||
#pragma mark - UITableViewDataSource
|
||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||
return self.reportReasons.count;
|
||
}
|
||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReportCell" forIndexPath:indexPath];
|
||
cell.backgroundColor = [UIColor clearColor];
|
||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
cell.textLabel.text = self.reportReasons[indexPath.row];
|
||
cell.textLabel.textColor = [UIColor whiteColor];
|
||
cell.textLabel.font = [UIFont systemFontOfSize:16];
|
||
|
||
// 选中状态
|
||
if (indexPath.row == self.selectedIndex) {
|
||
cell.accessoryType = UITableViewCellAccessoryCheckmark;
|
||
cell.tintColor = [UIColor colorWithRed:0.8 green:1.0 blue:0.6 alpha:1.0];
|
||
} else {
|
||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||
}
|
||
|
||
return cell;
|
||
}
|
||
|
||
#pragma mark - UITableViewDelegate
|
||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
self.selectedIndex = indexPath.row;
|
||
[tableView reloadData];
|
||
|
||
// 更新提交按钮状态
|
||
self.submitButton.enabled = YES;
|
||
self.submitButton.alpha = 1.0;
|
||
}
|
||
|
||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
return 56;
|
||
}
|
||
|
||
#pragma mark - Actions
|
||
|
||
- (void)submitButtonTapped {
|
||
if (self.selectedIndex < 0) {
|
||
[KBHUD showError:KBLocalized(@"Please select a reason")];
|
||
return;
|
||
}
|
||
|
||
NSString *reason = self.reportReasons[self.selectedIndex];
|
||
NSLog(@"[AIReportVC] 举报人设 ID: %ld, 原因: %@", (long)self.personaId, reason);
|
||
|
||
// TODO: 调用举报接口
|
||
[KBHUD showSuccess:KBLocalized(@"Report submitted")];
|
||
|
||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
});
|
||
}
|
||
|
||
#pragma mark - Lazy Load
|
||
|
||
- (UITableView *)tableView {
|
||
if (!_tableView) {
|
||
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||
_tableView.backgroundColor = [UIColor clearColor];
|
||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||
_tableView.delegate = self;
|
||
_tableView.dataSource = self;
|
||
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"ReportCell"];
|
||
}
|
||
return _tableView;
|
||
}
|
||
|
||
- (UIButton *)submitButton {
|
||
if (!_submitButton) {
|
||
_submitButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||
_submitButton.backgroundColor = [UIColor colorWithRed:0.8 green:1.0 blue:0.6 alpha:1.0];
|
||
_submitButton.layer.cornerRadius = 25;
|
||
[_submitButton setTitle:KBLocalized(@"Submit") forState:UIControlStateNormal];
|
||
[_submitButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
||
_submitButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
|
||
_submitButton.enabled = NO;
|
||
_submitButton.alpha = 0.5;
|
||
[_submitButton addTarget:self action:@selector(submitButtonTapped) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
return _submitButton;
|
||
}
|
||
|
||
@end
|