123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- //
- // uoloadFileRecordViewController.m
- // 隐私保护
- //
- // Created by xd h on 2023/11/13.
- //
- #import "uploadFileRecordViewController.h"
- #import "uploadFileManager.h"
- #import "uploadFileDataModel.h"
- #import "uploadFileRecordheadView.h"
- #import "uploadFileRecordBodyView.h"
- #import "uploadFileRecordEditBottomView.h"
- @interface uploadFileRecordViewController ()
- //选中的项
- @property (nonatomic, strong) NSMutableArray *indexPathsForSelectedItems;
- @property (nonatomic, strong) uploadFileRecordheadView *uploadFileRecordheadV;
- @property (nonatomic, strong) uploadFileRecordBodyView *uploadFileRecordBodyV;
- @property (nonatomic, strong) NSMutableArray *allDataArr;
- @property (nonatomic, strong) UIButton *leftButton;
- @property (nonatomic, strong) UIButton *rightButton;
- @property (nonatomic, strong) uploadFileRecordEditBottomView *uploadFileRecordEditBottomV;
- @property (nonatomic,assign) BOOL isEditType;
- @end
- @implementation uploadFileRecordViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- //[self.view setBackgroundColor:HWF5F7FAColor];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileRefreshFun:) name:uploadFileRefreshNotification object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(uploadFileDeteleFun:) name:uploadFileDeteleNotification object:nil];
-
- [self.view setBackgroundColor:[UIColor whiteColor]];
-
- self.titleLabel.text = NSLocalizedString(@"my_set_no_File_upload_record",nil) ;
-
- [self.toolBar setHidden:YES];
- [self.navigationBar setHidden:YES];
- [self.navBarBGView setHidden:NO];
- self.navBarBGView.backgroundColor = [UIColor whiteColor];
-
- [self initbaseUIFun];
- [self getDataInDatabaseFun];
- }
- #pragma mark UI
- - (void)initbaseUIFun
- {
- _uploadFileRecordheadV = [[uploadFileRecordheadView alloc] init];
- [self.view addSubview:_uploadFileRecordheadV];
-
- [_uploadFileRecordheadV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(15);
- make.right.mas_equalTo(-15);
- make.top.mas_equalTo(self.navBarBGView.mas_bottom).offset(15.0);
- make.height.mas_equalTo(50);
- }];
-
- KWeakSelf
- #pragma mark 头部点击事件
- _uploadFileRecordheadV.didClickButFun = ^(NSInteger index) {
- [weakSelf didClickHeadFun: index];
- };
-
- _uploadFileRecordBodyV = [[uploadFileRecordBodyView alloc] init];
- _uploadFileRecordBodyV.curVC = self;
- [self.view addSubview:_uploadFileRecordBodyV];
-
- [_uploadFileRecordBodyV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
- make.bottom.mas_equalTo(0);
- }];
-
-
- _uploadFileRecordBodyV.didScrollFun = ^(NSInteger index) {
- [weakSelf didScorllBodyFun:index];
- };
-
- _uploadFileRecordBodyV.didLongPressClick = ^{
- weakSelf.isEditType = YES;
- };
-
- _leftButton = [[UIButton alloc] init];
- [_leftButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
- _leftButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
- _leftButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
- [_leftButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- _leftButton.tag = 1;
- [_leftButton setTitle:NSLocalizedString(@"other_cancel",nil) forState:UIControlStateNormal];
- _leftButton.hidden = YES;
- [self.navBarBGView addSubview:_leftButton];
-
- [_leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(80);
- make.left.mas_equalTo(15);
- make.height.mas_equalTo(self.backBtn.mas_height);
- make.centerY.mas_equalTo(self.backBtn.mas_centerY);
- }];
-
- _rightButton = [[UIButton alloc] init];
- [_rightButton setTitleColor:[UIColor hwColor:@"#01B7EA" alpha:1.0] forState:UIControlStateNormal];
- _rightButton.titleLabel.font = [UIFont systemFontOfSize:18.0];
- _rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- [_rightButton addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
- _rightButton.tag = 2;
- [_rightButton setTitle:NSLocalizedString(@"File_upload_Record_select_all",nil) forState:UIControlStateNormal];
- _rightButton.hidden = YES;
- [self.navBarBGView addSubview:_rightButton];
-
- [_rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(80);
- make.right.mas_equalTo(-15);
- make.height.mas_equalTo(self.backBtn.mas_height);
- make.centerY.mas_equalTo(self.backBtn.mas_centerY);
- }];
-
- _uploadFileRecordEditBottomV = [[uploadFileRecordEditBottomView alloc] init];
- _uploadFileRecordEditBottomV.hidden = YES;
- [self.view addSubview:_uploadFileRecordEditBottomV];
-
- [_uploadFileRecordEditBottomV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(60 + safeArea);
- make.bottom.mas_equalTo(0);
- }];
-
- _uploadFileRecordEditBottomV.didClickButFun = ^{
- [weakSelf.uploadFileRecordBodyV deleteModelOneByOneFun];
- };
- }
- #pragma mark 头部点击 背景滚动
- - (void)didClickHeadFun:(NSInteger)index
- {
- _uploadFileRecordBodyV.selectIndex = index;
- }
- - (void)didScorllBodyFun:(NSInteger)index
- {
- _uploadFileRecordheadV.selectIndex = index;
- }
- -(void)gotoUploadFile:(NSMutableArray*)indexPathsForSelectedItems
- {
-
- _indexPathsForSelectedItems = [[uploadFileManager shareInstance] handlTZAssetModelToUploadFileDataFunBy:indexPathsForSelectedItems];
- HLog(@"11");
- }
- #pragma mark 读取数据库数据
- - (void)getDataInDatabaseFun
- {
- _allDataArr = [NSMutableArray new];
-
- KWeakSelf
- [uploadFileDataModel bg_findAllAsync:upLoadFile_image_tableName complete:^(NSArray * _Nullable array) {
- NSMutableArray *failArr = [NSMutableArray new];
- NSMutableArray *doneArr = [NSMutableArray new];
- NSMutableArray *otherArr = [NSMutableArray new];
-
- for (uploadFileDataModel * curModel in array) {
- if(curModel.curUploadStateType == uploadStateFail){
- [failArr addObject:curModel];
- }
- else if(curModel.curUploadStateType == uploadStateDone){
- [doneArr addObject:curModel];
- }
- else{
- [otherArr addObject:curModel];
- }
- }
-
- [self->_allDataArr addObject:otherArr];
- [self->_allDataArr addObject:doneArr];
- [self->_allDataArr addObject:failArr];
-
- weakSelf.uploadFileRecordBodyV.allDataArr = self->_allDataArr;
- }];
- }
- - (void)uploadFileRefreshFun:(NSNotification*)not
- {
- uploadFileDataModel *uploadFileDataMod = [not object];
- HLog(@"%@",uploadFileDataMod);
-
- if(_allDataArr.count == 3 && [uploadFileDataMod isKindOfClass:[uploadFileDataModel class]] ){
-
- NSMutableArray *curArr = _allDataArr[0];
-
- NSInteger index = 0;
- for (uploadFileDataModel*mod in curArr) {
- HLog(@"bg_id:%@ ?=? %@",mod.bg_id,uploadFileDataMod.bg_id);
-
- if(mod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
-
- if(uploadFileDataMod.curUploadStateType == uploadStateDone){
- [curArr removeObject:mod];
-
- NSMutableArray *doneArr = _allDataArr[1];
- [doneArr insertObject:uploadFileDataMod atIndex:0];
-
- //全部上传了
- if(curArr.count == 0){
-
- }
- }
- else if(uploadFileDataMod.curUploadStateType == uploadStateFail){
- [curArr removeObject:mod];
-
- NSMutableArray *failArr = _allDataArr[2];
- [failArr insertObject:uploadFileDataMod atIndex:0];
- }
- else{
- [curArr replaceObjectAtIndex:index withObject:uploadFileDataMod];
- }
-
- break;
- }
-
- index++;
- }
-
- //精准刷新
- if(uploadFileDataMod.curUploadStateType == uploadStateDone){
- [self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:_allDataArr[1] withfailArr:nil];
- }
- else if(uploadFileDataMod.curUploadStateType == uploadStateFail){
- [self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:_allDataArr[2]];
- }
- else{
- [self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:nil];
- }
- }
-
- //self.uploadFileRecordBodyV.allDataArr = _allDataArr;
-
- }
- - (void)uploadFileDeteleFun:(NSNotification*)not
- {
- uploadFileDataModel *uploadFileDataMod = [not object];
- HLog(@"%@",uploadFileDataMod);
-
- if(_allDataArr.count == 3 && [uploadFileDataMod isKindOfClass:[uploadFileDataModel class]] ){
-
- NSMutableArray *curArr = _allDataArr[0];
-
- NSInteger index = 0;
- for (uploadFileDataModel*mod in curArr) {
- HLog(@"bg_id:%@ ?=? %@",mod.bg_id,uploadFileDataMod.bg_id);
-
- if(mod.bg_id.integerValue == uploadFileDataMod.bg_id.integerValue){
- [curArr removeObject:mod];
- break;
- }
-
- index++;
- }
-
- //精准刷新
- [self.uploadFileRecordBodyV RefreshDataWithUploadingArr:_allDataArr[0] withDoneArr:nil withfailArr:nil];
- }
-
- }
- #pragma mark 按钮点击
- - (void)didClickButFun:(UIButton*)but
- {
- NSInteger tag = but.tag;
- if(tag == 1){
- self.isEditType = NO;
- self.uploadFileRecordBodyV.isEditType = NO;
- }
- else{
- self.uploadFileRecordBodyV.isSelectAllType = YES;
- }
- }
- -(void)setIsEditType:(BOOL)isEditType
- {
- _isEditType = isEditType;
-
- if(_isEditType){
- _leftButton.hidden = NO;
- _rightButton.hidden = NO;
- self.backBtn.hidden = YES;
- _uploadFileRecordEditBottomV.hidden = NO;
- _uploadFileRecordheadV.userInteractionEnabled = NO;
-
- [_uploadFileRecordBodyV mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(_uploadFileRecordEditBottomV.mas_top).offset(0.0);
- make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
- }];
-
- //dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.15 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // UITableView *curTabview = [_uploadFileRecordBodyV.bgScrollV viewWithTag:(10+_uploadFileRecordBodyV.selectIndex -1)];
- //
- // CGRect frame = curTabview.frame;
- // frame.size.height = SCREEN_H - CGRectGetMaxY(_uploadFileRecordheadV.frame) - (60 + safeArea);
- //
- // CGSize curSize = _uploadFileRecordBodyV.bgScrollV.contentSize;
- // curSize.height = frame.size.height;
- // _uploadFileRecordBodyV.bgScrollV.contentSize = curSize;
-
- //curTabview.frame = frame;
-
- //});
-
- }
- else{
- _leftButton.hidden = YES;
- _rightButton.hidden = YES;
- self.backBtn.hidden = NO;
-
- _uploadFileRecordEditBottomV.hidden = YES;
- _uploadFileRecordheadV.userInteractionEnabled = YES;
-
- [_uploadFileRecordBodyV mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(_uploadFileRecordheadV.mas_bottom).offset(0.0);
- make.bottom.mas_equalTo(0);
- }];
-
-
- // UITableView *curTabview = [_uploadFileRecordBodyV.bgScrollV viewWithTag:(10+_uploadFileRecordBodyV.selectIndex -1)];
- //
- // CGRect frame = curTabview.frame;
- // frame.size.height = SCREEN_W - CGRectGetHeight(_uploadFileRecordBodyV.frame);
- // curTabview.frame = frame;
-
- }
- }
- @end
|