123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- //
- // shareRecordViewController.m
- // 双子星云手机
- //
- // Created by xd h on 2024/5/14.
- //
- #import "shareRecordViewController.h"
- #import "shareRecordTableViewCell.h"
- #import "shareRecordDetailsHWViewController.h"
- @interface shareRecordViewController ()<UITableViewDelegate,UITableViewDataSource,DZNEmptyDataSetSource, DZNEmptyDataSetDelegate>
- {
- BOOL isEditType;
- }
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) UIButton *ruleBottomButton;
- @property (nonatomic, strong) UIButton *delRuleButton;
- @property (nonatomic, strong) UIButton *cancelShareButton;
- @property (nonatomic, strong) UIButton *rightEditButton;
- @property (nonatomic, strong) UIButton *leftCancleButton;
- @property (nonatomic, strong) UIButton *rightSelectAllButton;
- @end
- @implementation shareRecordViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self.toolBar setHidden:YES];
- [self.navigationBar setHidden:YES];
- [self.navBarBGView setHidden:NO];
- self.navBarBGView.backgroundColor = [UIColor whiteColor];
- [self.view setBackgroundColor:[UIColor hwColor:@"#F5F7FA"]];
- self.titleLabel.text = NSLocalizedString(@"my_set_no_share",nil);
-
- [self drawAnyView];
- }
- - (void)drawAnyView{
-
- [self initNavHeadUIFun];
-
- [self.view addSubview:self.tableView];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(-(60 + safeArea));
- make.top.equalTo(self.navBarBGView.mas_bottom).offset(10.f);
- }];
-
- _ruleBottomButton = [[UIButton alloc] init];
- [_ruleBottomButton setTitle:NSLocalizedString(@"share_rule_but_title",nil) forState:UIControlStateNormal];
- [_ruleBottomButton setTitleColor:HW0A132BColor forState:UIControlStateNormal];
- _ruleBottomButton.titleLabel.font = [UIFont boldSystemFontOfSize:14.0];
- [_ruleBottomButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- _ruleBottomButton.tag = 1;
- [self.view addSubview:_ruleBottomButton];
- _ruleBottomButton.layer.cornerRadius = 8;
- _ruleBottomButton.layer.masksToBounds = YES;
- _ruleBottomButton.backgroundColor = [UIColor whiteColor];
-
- [_ruleBottomButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.bottom.mas_equalTo(-(safeArea));
- make.height.mas_equalTo(48);
- }];
-
-
- _delRuleButton = [[UIButton alloc] init];
- [_delRuleButton setTitle:NSLocalizedString(@"share_del_record",nil) forState:UIControlStateNormal];
- [_delRuleButton setTitleColor:HW0A132BColor forState:UIControlStateNormal];
- _delRuleButton.titleLabel.font = [UIFont boldSystemFontOfSize:14.0];
- [_delRuleButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- _delRuleButton.tag = 10;
- [self.view addSubview:_delRuleButton];
- _delRuleButton.layer.cornerRadius = 8;
- _delRuleButton.layer.masksToBounds = YES;
- _delRuleButton.backgroundColor = [UIColor hwColor:@"#E3E8F1"];
- _delRuleButton.hidden = YES;
-
- [_delRuleButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.equalTo(self.view.mas_centerX).offset(-10);
- make.bottom.mas_equalTo(-(safeArea));
- make.height.mas_equalTo(48);
- }];
-
-
- _cancelShareButton = [[UIButton alloc] init];
- CGFloat w_btn = SCREEN_W/2.0 -15 -10;
-
- // gradient
- CAGradientLayer *gl = [CAGradientLayer layer];
- gl.frame = CGRectMake(0,0,w_btn,48.f);
- gl.startPoint = CGPointMake(0, 0.5);
- gl.endPoint = CGPointMake(1, 0.5);
- gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
- gl.locations = @[@(0), @(1.0f)];
-
- [_cancelShareButton.layer addSublayer:gl];
- [_cancelShareButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
- [_cancelShareButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:(UIControlEventTouchUpInside)];
- [_cancelShareButton setTitle:NSLocalizedString(@"cancel_share_title",nil) forState:(UIControlStateNormal)];
- [_cancelShareButton.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
- [_cancelShareButton.layer setCornerRadius:8.f];
- _cancelShareButton.clipsToBounds = YES;
- _cancelShareButton.tag = 11;
-
- [self.view addSubview:_cancelShareButton];
- _cancelShareButton.hidden = YES;
- [_cancelShareButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-15);
- make.left.equalTo(self.view.mas_centerX).offset(10);
- make.bottom.mas_equalTo(-(safeArea));
- make.height.mas_equalTo(48);
- }];
-
-
-
- }
- - (void)initNavHeadUIFun
- {
- _rightEditButton = [[UIButton alloc] init];
- [_rightEditButton setTitle:NSLocalizedString(@"edit_common",nil) forState:UIControlStateNormal];
- _rightEditButton.tag = 2;
- [_rightEditButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
- _rightEditButton.titleLabel.font = [UIFont systemFontOfSize:16.0];
- _rightEditButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- [_rightEditButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- [self.navBarBGView addSubview:_rightEditButton];
-
- [_rightEditButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(80);
- make.height.mas_equalTo(40);
- make.right.mas_equalTo(-15);
- make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
- }];
-
-
- _leftCancleButton = [[UIButton alloc] init];
- [_leftCancleButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
- _leftCancleButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
- _leftCancleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- [_leftCancleButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- _leftCancleButton.tag = 3;
- [_leftCancleButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
- [self.navBarBGView addSubview:_leftCancleButton];
- _leftCancleButton.hidden = YES;
-
- [_leftCancleButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(80);
- make.left.mas_equalTo(15);
- make.height.mas_equalTo(30);
- make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
- }];
-
- _rightSelectAllButton = [[UIButton alloc] init];
- [_rightSelectAllButton setImage:[UIImage imageNamed:@"edit_select_all_h"] forState:UIControlStateSelected];
- [_rightSelectAllButton setImage:[UIImage imageNamed:@"edit_select_all_n"] forState:UIControlStateNormal];
- [_rightSelectAllButton addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
- _rightSelectAllButton.tag = 4;
- [self.navBarBGView addSubview:_rightSelectAllButton];
- _rightSelectAllButton.hidden = YES;
-
- [_rightSelectAllButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(80);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(30);
- make.centerY.mas_equalTo(self.titleLabel.mas_centerY);
- }];
- }
- #pragma mark - 懒加载
- - (UITableView *)tableView{
- if (!_tableView) {
- _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.showsVerticalScrollIndicator = NO;
- _tableView.showsHorizontalScrollIndicator = NO;
- // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
- [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
- [_tableView setSeparatorColor:[UIColor clearColor]];
- [_tableView setBackgroundColor:[UIColor clearColor]];
- [_tableView setTableFooterView:[UIView new]];
- [_tableView setBounces:YES];
-
- if (@available(iOS 15.0, *)) {
- _tableView.sectionHeaderTopPadding = 0;
- }
-
- //空数据引入第三方开源处理
- _tableView.emptyDataSetSource = self;
- _tableView.emptyDataSetDelegate = self;
- }
-
- return _tableView;
- }
- #pragma mark - 列表委托
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 2;
- }
- - (shareRecordTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- __block NSInteger row = indexPath.row;
- static NSString *identifier = @"shareRecordTableViewCell";
-
- shareRecordTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- if (!cell){
- cell = [[shareRecordTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- [cell setBackgroundColor:[UIColor clearColor]];
- [cell setAccessoryType:(UITableViewCellAccessoryNone)];
-
-
- }
-
- cell.isEditType = isEditType;
-
- // if(row < _curCouldPhoneFileListMod.data.list.count){
- // couldPhoneFileModel* fileModel = _curCouldPhoneFileListMod.data.list[row];
- // cell.curFileModel = fileModel;
- //
- // KWeakSelf
- // cell.didClickSwitch = ^(BOOL SwitchOn) {
- // if([weakSelf userCheckFileModel:fileModel withShowTip:YES]){
- // [weakSelf userCheckFilePreviewByRow:row];
- // }
- // };
- // }
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 70;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- NSInteger row = indexPath.row;
- if(isEditType){
- return;
- }
-
- shareRecordDetailsHWViewController *vc = [shareRecordDetailsHWViewController new];
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark 空数据
- - (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
-
- NSString *imageName = @"uploadFile_noData";
-
- return [UIImage imageNamed:imageName];
- }
- - (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
- NSString *text = NSLocalizedString(@"common_no_data_pic",nil);
-
- NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:16.0f],
- NSForegroundColorAttributeName: HW999999Color};
-
- return [[NSAttributedString alloc] initWithString:text attributes:attributes];
- }
- //调整图片位置
- - (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
- return -150;
- }
- - (void)didClickButtonFun:(UIButton*)but
- {
- NSInteger tag = but.tag;
-
- if(tag == 1){
- [[iToast makeText:@"分享规则"] show];
- }
- else if(tag == 2){
- [self setEditTypeFun];
- }
- else if(tag == 3){
- [self cancelEditTypeFun];
- }
- else if(tag == 4){
- but.selected = !but.selected;
- }
-
- }
- #pragma mark 进入编辑
- - (void)setEditTypeFun
- {
- isEditType = YES;
- _rightEditButton.hidden = YES;
- _ruleBottomButton.hidden = YES;
- self.backBtn.hidden = YES;
-
- _leftCancleButton.hidden = NO;
- _rightSelectAllButton.hidden = NO;
-
- _delRuleButton.hidden = NO;
- _delRuleButton.userInteractionEnabled = NO;
- // [_delRuleButton setTitleColor:[UIColor hwColor:@"#0A132B" alpha:0.5] forState:UIControlStateNormal];
- // _delRuleButton.backgroundColor = [UIColor hwColor:@"#E3E8F1" alpha:0.5];
- _delRuleButton.alpha = 0.5;
-
- _cancelShareButton.hidden = NO;
- _cancelShareButton.userInteractionEnabled = NO;
- _cancelShareButton.alpha = 0.5;
-
- [self.tableView reloadData];
- }
- #pragma mark 取消编辑
- - (void)cancelEditTypeFun
- {
- isEditType = NO;
- _rightEditButton.hidden = NO;
- _ruleBottomButton.hidden = NO;
- self.backBtn.hidden = NO;
-
- _leftCancleButton.hidden = YES;
- _rightSelectAllButton.hidden = YES;
- _delRuleButton.hidden = YES;
- _cancelShareButton.hidden = YES;
- [self.tableView reloadData];
- }
- @end
|