HJMessageViewController.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. //
  2. // HJMessageViewController.m
  3. // HappyJob
  4. //
  5. // Created by Bob on 2019/3/13.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJMessageViewController.h"
  9. #import "HJMessageTableViewCell.h"
  10. #import "HJMessageDateTableViewCell.h"
  11. #import "UIViewController+HJNavBarRightButtonItems.h"
  12. #import "HJMessageDelPanelViewController.h"
  13. #import "HJMessageBlankView.h"
  14. @interface HJMessageViewController () <UITableViewDelegate, UITableViewDataSource>
  15. @property (nonatomic, strong) HJMessageBlankView *blankView;
  16. @property (nonatomic, strong) UITableView *tableView;
  17. @property (nonatomic, strong) UIButton *delButton;
  18. @end
  19. @implementation HJMessageViewController
  20. #pragma mark - life cycle
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. [self hj_setupNavBarRightButtonItems:@[self.delButton]];
  24. [self.view addSubview:self.blankView];
  25. //[self.view addSubview:self.tableView];
  26. [self makeConstraints];
  27. }
  28. - (void)makeConstraints {
  29. [self.blankView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.center.equalTo(self.view);
  31. }];
  32. // [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. // make.edges.equalTo(self.view);
  34. // }];
  35. }
  36. #pragma mark - UITableViewDelegate
  37. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  38. return 40;
  39. }
  40. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  41. if (indexPath.row == 0 || indexPath.row == 5) {
  42. static NSString *cellIdentifier = @"HJMessageDateTableViewCell";
  43. HJMessageDateTableViewCell *cell = (HJMessageDateTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  44. if (cell == nil) {
  45. cell = [[HJMessageDateTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  46. }
  47. cell.dateText = @"4月2日 早上10:00";
  48. return cell;
  49. } else {
  50. static NSString *cellIdentifier = @"HJMessageTableViewCell";
  51. HJMessageTableViewCell *cell = (HJMessageTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
  52. if (cell == nil) {
  53. cell = [[HJMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
  54. }
  55. return cell;
  56. }
  57. }
  58. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  59. }
  60. #pragma mark - CustomDelegate
  61. #pragma mark - event response
  62. - (void)delButtonClicked:(UIButton *)sender {
  63. HJMessageDelPanelViewController *vc = [[HJMessageDelPanelViewController alloc] init];
  64. vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
  65. vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  66. [self presentViewController:vc animated:YES completion:^{
  67. }];
  68. }
  69. #pragma mark - private methods
  70. #pragma mark - getters and setters
  71. - (UITableView *)tableView {
  72. if (_tableView == nil) {
  73. _tableView = [[UITableView alloc] init];
  74. _tableView.delegate = self;
  75. _tableView.dataSource = self;
  76. // 设置预估行高
  77. _tableView.estimatedRowHeight = 40;
  78. // 设置行高自动计算
  79. _tableView.rowHeight = UITableViewAutomaticDimension;
  80. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  81. }
  82. return _tableView;
  83. }
  84. - (UIButton *)delButton {
  85. if (_delButton == nil) {
  86. _delButton = [UIButton buttonWithType:UIButtonTypeCustom];
  87. [_delButton setImage:[UIImage imageNamed:@"navbar_del"] forState:UIControlStateNormal];
  88. [_delButton addTarget:self action:@selector(delButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
  89. }
  90. return _delButton;
  91. }
  92. - (HJMessageBlankView *)blankView {
  93. if (_blankView == nil) {
  94. _blankView = [[HJMessageBlankView alloc] init];
  95. }
  96. return _blankView;
  97. }
  98. @end