shareRecordViewController.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. //
  2. // shareRecordViewController.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/5/14.
  6. //
  7. #import "shareRecordViewController.h"
  8. #import "shareRecordTableViewCell.h"
  9. #import "shareRecordDetailsHWViewController.h"
  10. @interface shareRecordViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
  11. {
  12. BOOL isEditType;
  13. }
  14. @property (nonatomic, strong) UITableView *tableView;
  15. @property (nonatomic, strong) UIButton *ruleBottomButton;
  16. @property (nonatomic, strong) UIButton *delRuleButton;
  17. @property (nonatomic, strong) UIButton *cancelShareButton;
  18. @property (nonatomic, strong) UIButton *rightEditButton;
  19. @property (nonatomic, strong) UIButton *leftCancleButton;
  20. @property (nonatomic, strong) UIButton *rightSelectAllButton;
  21. @end
  22. @implementation shareRecordViewController
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. // Do any additional setup after loading the view.
  26. [self.toolBar setHidden:YES];
  27. [self.navigationBar setHidden:YES];
  28. [self.navBarBGView setHidden:NO];
  29. self.navBarBGView.backgroundColor = [UIColor whiteColor];
  30. [self.view setBackgroundColor:[UIColor hwColor:@"#F5F7FA"]];
  31. self.titleLabel.text = NSLocalizedString(@"my_set_no_share",nil);
  32. [self drawAnyView];
  33. }
  34. - (void)drawAnyView{
  35. [self initNavHeadUIFun];
  36. [self.view addSubview:self.tableView];
  37. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.mas_equalTo(0);
  39. make.right.mas_equalTo(0);
  40. make.bottom.mas_equalTo(-(60 + safeArea));
  41. make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
  42. }];
  43. _ruleBottomButton = [[UIButton alloc] init];
  44. [_ruleBottomButton setTitle:NSLocalizedString(@"share_rule_but_title",nil) forState:UIControlStateNormal];
  45. [_ruleBottomButton setTitleColor:HW0A132BColor forState:UIControlStateNormal];
  46. _ruleBottomButton.titleLabel.font = [UIFont boldSystemFontOfSize:14.0];
  47. [_ruleBottomButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  48. _ruleBottomButton.tag = 1;
  49. [self.view addSubview:_ruleBottomButton];
  50. _ruleBottomButton.layer.cornerRadius = 8;
  51. _ruleBottomButton.layer.masksToBounds = YES;
  52. _ruleBottomButton.backgroundColor = [UIColor whiteColor];
  53. [_ruleBottomButton mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.mas_equalTo(15);
  55. make.right.mas_equalTo(-15);
  56. make.bottom.mas_equalTo(-(safeArea));
  57. make.height.mas_equalTo(48);
  58. }];
  59. _delRuleButton = [[UIButton alloc] init];
  60. [_delRuleButton setTitle:NSLocalizedString(@"share_del_record",nil) forState:UIControlStateNormal];
  61. [_delRuleButton setTitleColor:HW0A132BColor forState:UIControlStateNormal];
  62. _delRuleButton.titleLabel.font = [UIFont boldSystemFontOfSize:14.0];
  63. [_delRuleButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  64. _delRuleButton.tag = 10;
  65. [self.view addSubview:_delRuleButton];
  66. _delRuleButton.layer.cornerRadius = 8;
  67. _delRuleButton.layer.masksToBounds = YES;
  68. _delRuleButton.backgroundColor = [UIColor hwColor:@"#E3E8F1"];
  69. _delRuleButton.hidden = YES;
  70. [_delRuleButton mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.left.mas_equalTo(15);
  72. make.right.equalTo(self.view.mas_centerX).offset(-10);
  73. make.bottom.mas_equalTo(-(safeArea));
  74. make.height.mas_equalTo(48);
  75. }];
  76. _cancelShareButton = [[UIButton alloc] init];
  77. CGFloat w_btn = SCREEN_W/2.0 -15 -10;
  78. // gradient
  79. CAGradientLayer *gl = [CAGradientLayer layer];
  80. gl.frame = CGRectMake(0,0,w_btn,48.f);
  81. gl.startPoint = CGPointMake(0, 0.5);
  82. gl.endPoint = CGPointMake(1, 0.5);
  83. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  84. gl.locations = @[@(0), @(1.0f)];
  85. [_cancelShareButton.layer addSublayer:gl];
  86. [_cancelShareButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  87. [_cancelShareButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
  88. [_cancelShareButton setTitle:NSLocalizedString(@"cancel_share_title",nil) forState:(UIControlStateNormal)];
  89. [_cancelShareButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  90. [_cancelShareButton.layer setCornerRadius:8.f];
  91. _cancelShareButton.clipsToBounds = YES;
  92. _cancelShareButton.tag = 11;
  93. [self.view addSubview:_cancelShareButton];
  94. _cancelShareButton.hidden = YES;
  95. [_cancelShareButton mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.right.mas_equalTo(-15);
  97. make.left.equalTo(self.view.mas_centerX).offset(10);
  98. make.bottom.mas_equalTo(-(safeArea));
  99. make.height.mas_equalTo(48);
  100. }];
  101. }
  102. - (void)initNavHeadUIFun
  103. {
  104. _rightEditButton = [[UIButton alloc] init];
  105. [_rightEditButton setTitle:NSLocalizedString(@"edit_common",nil) forState:UIControlStateNormal];
  106. _rightEditButton.tag = 2;
  107. [_rightEditButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  108. _rightEditButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
  109. _rightEditButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  110. [_rightEditButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  111. [self.navBarBGView addSubview:_rightEditButton];
  112. [_rightEditButton mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.width.mas_equalTo(80);
  114. make.height.mas_equalTo(40);
  115. make.right.mas_equalTo(-15);
  116. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  117. }];
  118. _leftCancleButton = [[UIButton alloc] init];
  119. [_leftCancleButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
  120. _leftCancleButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
  121. _leftCancleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  122. [_leftCancleButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  123. _leftCancleButton.tag = 3;
  124. [_leftCancleButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
  125. [self.navBarBGView addSubview:_leftCancleButton];
  126. _leftCancleButton.hidden = YES;
  127. [_leftCancleButton mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.width.mas_equalTo(80);
  129. make.left.mas_equalTo(15);
  130. make.height.mas_equalTo(30);
  131. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  132. }];
  133. _rightSelectAllButton = [[UIButton alloc] init];
  134. [_rightSelectAllButton setImage:[UIImage imageNamed:@"edit_select_all_h"] forState:UIControlStateSelected];
  135. [_rightSelectAllButton setImage:[UIImage imageNamed:@"edit_select_all_n"] forState:UIControlStateNormal];
  136. [_rightSelectAllButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  137. _rightSelectAllButton.tag = 4;
  138. [self.navBarBGView addSubview:_rightSelectAllButton];
  139. _rightSelectAllButton.hidden = YES;
  140. [_rightSelectAllButton mas_makeConstraints:^(MASConstraintMaker *make) {
  141. make.width.mas_equalTo(80);
  142. make.right.mas_equalTo(0);
  143. make.height.mas_equalTo(30);
  144. make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
  145. }];
  146. }
  147. #pragma mark - 懒加载
  148. - (UITableView *)tableView{
  149. if (!_tableView) {
  150. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  151. _tableView.delegate = self;
  152. _tableView.dataSource = self;
  153. _tableView.showsVerticalScrollIndicator = NO;
  154. _tableView.showsHorizontalScrollIndicator = NO;
  155. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  156. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  157. [_tableView setSeparatorColor:[UIColor clearColor]];
  158. [_tableView setBackgroundColor:[UIColor clearColor]];
  159. [_tableView setTableFooterView:[UIView new]];
  160. [_tableView setBounces:YES];
  161. if (@available(iOS 15.0, *)) {
  162. _tableView.sectionHeaderTopPadding = 0;
  163. }
  164. //空数据引入第三方开源处理
  165. _tableView.emptyDataSetSource = self;
  166. _tableView.emptyDataSetDelegate = self;
  167. }
  168. return _tableView;
  169. }
  170. #pragma mark - 列表委托
  171. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  172. return 1;
  173. }
  174. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  175. return 2;
  176. }
  177. - (shareRecordTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  178. __block NSInteger row = indexPath.row;
  179. static NSString *identifier = @"shareRecordTableViewCell";
  180. shareRecordTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  181. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  182. if (!cell){
  183. cell = [[shareRecordTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  184. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  185. [cell setBackgroundColor:[UIColor clearColor]];
  186. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  187. }
  188. cell.isEditType = isEditType;
  189. // if(row < _curCouldPhoneFileListMod.data.list.count){
  190. // couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
  191. // cell.curFileModel = fileModel;
  192. //
  193. // KWeakSelf
  194. // cell.didClickSwitch = ^(BOOL SwitchOn) {
  195. // if([weakSelf userCheckFileModel:fileModel withShowTip:YES]){
  196. // [weakSelf userCheckFilePreviewByRow:row];
  197. // }
  198. // };
  199. // }
  200. return cell;
  201. }
  202. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  203. return 70;
  204. }
  205. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  206. NSInteger row = indexPath.row;
  207. if(isEditType){
  208. return;
  209. }
  210. shareRecordDetailsHWViewController *vc = [shareRecordDetailsHWViewController new];
  211. [self.navigationController pushViewController:vc animated:YES];
  212. }
  213. #pragma mark 空数据
  214. - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
  215. NSString *imageName = @"uploadFile_noData";
  216. return [UIImage imageNamed:imageName];
  217. }
  218. - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
  219. NSString *text = NSLocalizedString(@"common_no_data_pic",nil);
  220. NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
  221. NSForegroundColorAttributeName: HW999999Color};
  222. return [[NSAttributedString alloc] initWithString:text attributes:attributes];
  223. }
  224. //调整图片位置
  225. - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
  226. return -150;
  227. }
  228. - (void)didClickButtonFun:(UIButton*)but
  229. {
  230. NSInteger tag = but.tag;
  231. if(tag == 1){
  232. [[iToast makeText:@"分享规则"] show];
  233. }
  234. else if(tag == 2){
  235. [self setEditTypeFun];
  236. }
  237. else if(tag == 3){
  238. [self cancelEditTypeFun];
  239. }
  240. else if(tag == 4){
  241. but.selected = !but.selected;
  242. }
  243. }
  244. #pragma mark 进入编辑
  245. - (void)setEditTypeFun
  246. {
  247. isEditType = YES;
  248. _rightEditButton.hidden = YES;
  249. _ruleBottomButton.hidden = YES;
  250. self.backBtn.hidden = YES;
  251. _leftCancleButton.hidden = NO;
  252. _rightSelectAllButton.hidden = NO;
  253. _delRuleButton.hidden = NO;
  254. _delRuleButton.userInteractionEnabled = NO;
  255. // [_delRuleButton setTitleColor:[UIColor hwColor:@"#0A132B" alpha:0.5] forState:UIControlStateNormal];
  256. // _delRuleButton.backgroundColor = [UIColor hwColor:@"#E3E8F1" alpha:0.5];
  257. _delRuleButton.alpha = 0.5;
  258. _cancelShareButton.hidden = NO;
  259. _cancelShareButton.userInteractionEnabled = NO;
  260. _cancelShareButton.alpha = 0.5;
  261. [self.tableView reloadData];
  262. }
  263. #pragma mark 取消编辑
  264. - (void)cancelEditTypeFun
  265. {
  266. isEditType = NO;
  267. _rightEditButton.hidden = NO;
  268. _ruleBottomButton.hidden = NO;
  269. self.backBtn.hidden = NO;
  270. _leftCancleButton.hidden = YES;
  271. _rightSelectAllButton.hidden = YES;
  272. _delRuleButton.hidden = YES;
  273. _cancelShareButton.hidden = YES;
  274. [self.tableView reloadData];
  275. }
  276. @end