2
0

WFCSecurityTableViewController.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // SettingTableViewController.m
  3. // WFChat UIKit
  4. //
  5. // Created by WF Chat on 2017/10/6.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCSecurityTableViewController.h"
  9. #import <WFChatClient/WFCChatClient.h>
  10. #import "WFCChangePasswordViewController.h"
  11. #import "WFCResetPasswordViewController.h"
  12. @interface WFCSecurityTableViewController () <UITableViewDataSource, UITableViewDelegate>
  13. @property (nonatomic, strong)UITableView *tableView;
  14. @end
  15. @implementation WFCSecurityTableViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.title = LocalizedString(@"AccountSafety");
  19. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
  20. if (@available(iOS 15, *)) {
  21. self.tableView.sectionHeaderTopPadding = 0;
  22. }
  23. self.tableView.delegate = self;
  24. self.tableView.dataSource = self;
  25. self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  26. [self.tableView reloadData];
  27. [self.view addSubview:self.tableView];
  28. }
  29. - (void)didReceiveMemoryWarning {
  30. [super didReceiveMemoryWarning];
  31. // Dispose of any resources that can be recreated.
  32. }
  33. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  34. return 48;
  35. }
  36. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  37. return [[UIView alloc] initWithFrame:CGRectZero];
  38. }
  39. //#pragma mark - Table view data source
  40. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  41. return 1;
  42. }
  43. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  44. if (section == 0) {
  45. return 1;
  46. }
  47. return 0;
  48. }
  49. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  50. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"style1Cell"];
  51. if (cell == nil) {
  52. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"style1Cell"];
  53. }
  54. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  55. cell.accessoryView = nil;
  56. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  57. if (indexPath.section == 0) {
  58. cell.textLabel.text = LocalizedString(@"ChangePassword");
  59. }
  60. return cell;
  61. }
  62. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  63. UIAlertController* actionSheet = [UIAlertController alertControllerWithTitle:nil message:@"修改密码" preferredStyle:UIAlertControllerStyleActionSheet];
  64. __weak typeof(self)ws = self;
  65. UIAlertAction *actionCode = [UIAlertAction actionWithTitle:@"短信验证码验证" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  66. WFCResetPasswordViewController *vc = [[WFCResetPasswordViewController alloc] init];
  67. [ws.navigationController pushViewController:vc animated:YES];
  68. }];
  69. UIAlertAction *actionPwd = [UIAlertAction actionWithTitle:@"使用密码验证" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  70. WFCChangePasswordViewController *vc = [[WFCChangePasswordViewController alloc] init];
  71. [ws.navigationController pushViewController:vc animated:YES];
  72. }];
  73. UIAlertAction *actionCancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  74. }];
  75. [actionSheet addAction:actionCode];
  76. [actionSheet addAction:actionPwd];
  77. [actionSheet addAction:actionCancel];
  78. [self presentViewController:actionSheet animated:YES completion:nil];
  79. }
  80. @end