WFCUFilesEntryViewController.m 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // WFCUFilesEntryViewController.m
  3. // WFChatUIKit
  4. //
  5. // Created by dali on 2020/11/12.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUFilesEntryViewController.h"
  9. #import "WFCUFilesViewController.h"
  10. #import "WFCUConversationFilesViewController.h"
  11. #import "WFCUContactListViewController.h"
  12. @interface WFCUFilesEntryViewController () <UITableViewDelegate, UITableViewDataSource>
  13. @property(nonatomic, strong)UITableView *tableView;
  14. @end
  15. @implementation WFCUFilesEntryViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.title = WFCString(@"Files");
  19. self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
  20. if (@available(iOS 15, *)) {
  21. self.tableView.sectionHeaderTopPadding = 0;
  22. }
  23. self.tableView.dataSource = self;
  24. self.tableView.delegate = self;
  25. self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  26. [self.view addSubview:self.tableView];
  27. }
  28. #pragma mark - UITableViewDataSource
  29. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  30. return 4;
  31. //所有,我发的,群文件,用户文件
  32. }
  33. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  34. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
  35. if (!cell) {
  36. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
  37. }
  38. if (indexPath.row == 0) {
  39. cell.textLabel.text = WFCString(@"AllFiles");
  40. } else if (indexPath.row == 1) {
  41. cell.textLabel.text = WFCString(@"MyFiles");
  42. } else if (indexPath.row == 2) {
  43. cell.textLabel.text = WFCString(@"ConversationFiles");
  44. } else if (indexPath.row == 3) {
  45. cell.textLabel.text = WFCString(@"UserFiles");
  46. }
  47. return cell;
  48. }
  49. #pragma mark - UITableViewDelegate
  50. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  51. if (indexPath.row == 0) {
  52. WFCUFilesViewController *vc = [[WFCUFilesViewController alloc] init];
  53. [self.navigationController pushViewController:vc animated:YES];
  54. } else if(indexPath.row == 1) {
  55. WFCUFilesViewController *vc = [[WFCUFilesViewController alloc] init];
  56. vc.myFiles = YES;
  57. [self.navigationController pushViewController:vc animated:YES];
  58. } else if(indexPath.row == 2) {
  59. WFCUConversationFilesViewController *vc = [[WFCUConversationFilesViewController alloc] init];
  60. [self.navigationController pushViewController:vc animated:YES];
  61. } else if(indexPath.row == 3) {
  62. WFCUContactListViewController *pvc = [[WFCUContactListViewController alloc] init];
  63. pvc.selectContact = YES;
  64. pvc.multiSelect = NO;
  65. pvc.withoutCheckBox = YES;
  66. __weak typeof(self)ws = self;
  67. pvc.selectResult = ^(NSArray<NSString *> *contacts) {
  68. if (contacts.count == 1) {
  69. dispatch_async(dispatch_get_main_queue(), ^{
  70. WFCUFilesViewController *vc = [[WFCUFilesViewController alloc] init];
  71. vc.userFiles = YES;
  72. vc.userId = contacts[0];
  73. [ws.navigationController pushViewController:vc animated:YES];
  74. });
  75. } else {
  76. }
  77. };
  78. pvc.disableUsersSelected = YES;
  79. UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:pvc];
  80. [self.navigationController presentViewController:navi animated:YES completion:nil];
  81. }
  82. }
  83. @end