Skip to content

Commit aad81bc

Browse files
committed
增加分享中的文件夹
1 parent b6d3266 commit aad81bc

6 files changed

Lines changed: 50 additions & 8 deletions

File tree

Coding_iOS/Models/ProjectFile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ typedef NS_ENUM(NSInteger, DownloadState){
3131
@property (strong, nonatomic) NSString *project_name, *project_owner_name;
3232

3333
+ (ProjectFile *)fileWithFileId:(NSNumber *)fileId andProjectId:(NSNumber *)project_id;
34+
+ (instancetype)sharedFolderInProject:(NSString *)project_name ofUser:(NSString *)project_owner_name;
3435
- (instancetype)initWithFileId:(NSNumber *)fileId inProject:(NSString *)project_name ofUser:(NSString *)project_owner_name;
3536

37+
- (BOOL)isDefaultFolder;
38+
- (BOOL)isSharedFolder;
3639
- (BOOL)isEmpty;
3740

3841
- (DownloadState)downloadState;

Coding_iOS/Models/ProjectFile.m

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ +(ProjectFile *)fileWithFileId:(NSNumber *)fileId andProjectId:(NSNumber *)proje
5151
return file;
5252
}
5353

54+
+ (instancetype)sharedFolderInProject:(NSString *)project_name ofUser:(NSString *)project_owner_name{
55+
ProjectFile *file = [[self alloc] initWithFileId:@(-1) inProject:project_name ofUser:project_owner_name];
56+
file.type = @0;//文件夹类型
57+
return file;
58+
}
59+
5460
- (instancetype)initWithFileId:(NSNumber *)fileId inProject:(NSString *)project_name ofUser:(NSString *)project_owner_name{
5561
self = [super init];
5662
if (self) {
@@ -79,6 +85,14 @@ - (void)setCount:(NSNumber *)count{
7985
_count = @(MAX(0, count.integerValue));
8086
}
8187

88+
- (BOOL)isDefaultFolder{
89+
return _file_id && _file_id.integerValue == 0;
90+
}
91+
92+
- (BOOL)isSharedFolder{
93+
return _file_id && _file_id.integerValue == -1;
94+
}
95+
8296
- (BOOL)isEmpty{
8397
return !(self.storage_key && self.storage_key.length > 0);
8498
}
@@ -176,7 +190,11 @@ - (NSDictionary *)toShareParams{
176190

177191

178192
- (NSString *)toFolderFilesPath{
179-
return [NSString stringWithFormat:@"api/user/%@/project/%@/folder/%@/all", _project_owner_name, _project_name, self.file_id];
193+
if (self.isSharedFolder) {
194+
return [NSString stringWithFormat:@"api/user/%@/project/%@/folder/shared_files", _project_owner_name, _project_name];
195+
}else{
196+
return [NSString stringWithFormat:@"api/user/%@/project/%@/folder/%@/all", _project_owner_name, _project_name, self.file_id];
197+
}
180198
}
181199
- (NSDictionary *)toFolderFilesParams{
182200
return @{@"height": @"90",

Coding_iOS/Models/ProjectFiles.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
@property (assign, nonatomic) BOOL isLoading;
1818

1919
@property (readonly, nonatomic, strong) NSMutableArray *fileList, *folderList;
20+
- (void)addSharedFolder;
2021
@end

Coding_iOS/Models/ProjectFiles.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@ - (void)setList:(NSMutableArray *)list{
2727
_fileList = [list filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:[NSString stringWithFormat:@"type != 0"]]].mutableCopy ?: @[].mutableCopy;
2828

2929
}
30+
31+
- (void)addSharedFolder{
32+
ProjectFile *tempF = _list.firstObject;
33+
ProjectFile *sharedF = [ProjectFile sharedFolderInProject:tempF.project_name ofUser:tempF.project_owner_name];
34+
[_list insertObject:sharedF atIndex:0];
35+
[_folderList insertObject:sharedF atIndex:0];
36+
}
37+
3038
@end

Coding_iOS/Views/Cell/FileListFolderCell.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ - (void)layoutSubviews{
5151
if (!_folder) {
5252
return;
5353
}
54-
_iconView.image = [UIImage imageNamed:@"icon_file_folder_normal"];
54+
_iconView.image = [UIImage imageNamed:_folder.isSharedFolder? @"icon_file_folder_share": @"icon_file_folder_normal"];
5555
// _nameLabel.text = [NSString stringWithFormat:@"%@(%ld)", _folder.name, (long)(_folder.count.integerValue)];
56-
_nameLabel.text = _folder.name;//count 字段 api 里去掉了
57-
_infoLabel.text = [NSString stringWithFormat:@"%@ 创建于 %@", _folder.owner_name, [_folder.updated_at stringDisplay_HHmm]];
56+
_nameLabel.text = _folder.isSharedFolder? @"分享中": _folder.name;//count 字段 api 里去掉了
57+
_infoLabel.text = _folder.isSharedFolder? @"": [NSString stringWithFormat:@"%@ 创建于 %@", _folder.owner_name, [_folder.updated_at stringDisplay_HHmm]];
58+
_nameLabel.y = _folder.isSharedFolder? (75 - 25)/ 2: kFileListFolderCell_TopPading;
5859
}
5960

6061
+ (CGFloat)cellHeight{

Coding_iOS/Views/TableListView/NProjectFileListView.m

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ - (void)refresh{
213213
[weakSelf endLoading];
214214
if (data) {
215215
weakSelf.myFiles = data;
216+
if (weakSelf.curFolder.isDefaultFolder && weakSelf.myFiles.list.count > 0) {
217+
[weakSelf.myFiles addSharedFolder];
218+
}
216219
[weakSelf updateDataWithSearchStr];
217220
}
218221
[weakSelf configBlankPage:EaseBlankPageTypeFile hasData:([weakSelf totalDataRow] > 0) hasError:(error != nil) reloadButtonBlock:^(id sender) {
@@ -490,13 +493,19 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
490493
if (indexPath.row < _uploadFiles.count) {
491494
[NSObject showHudTipStr:@"正在上传的不能批处理"];
492495
[tableView deselectRowAtIndexPath:indexPath animated:YES];
496+
}else if (indexPath.row < _folderList.count + _uploadFiles.count) {
497+
ProjectFile *clickedFolder = [_folderList objectAtIndex:indexPath.row - _uploadFiles.count];
498+
if (clickedFolder.isSharedFolder) {
499+
[NSObject showHudTipStr:@"分享中文件夹不支持编辑"];
500+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
501+
}
493502
}
494503
}else{
495504
[tableView deselectRowAtIndexPath:indexPath animated:YES];
496505
if (indexPath.row < _uploadFiles.count) {
497506

498507
}else if (indexPath.row < _folderList.count + _uploadFiles.count) {
499-
ProjectFile *clickedFolder = [_folderList objectAtIndex:indexPath.row - _uploadFiles.count];;
508+
ProjectFile *clickedFolder = [_folderList objectAtIndex:indexPath.row - _uploadFiles.count];
500509
[self goToVCWithFolder:clickedFolder inProject:self.curProject];
501510
}else{
502511
ProjectFile *file = [_fileList objectAtIndex:(indexPath.row - _folderList.count - _uploadFiles.count)];
@@ -508,9 +517,11 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
508517
#pragma mark Edit Table
509518
- (NSArray *)rightButtonsWithObj:(ProjectFile *)obj{
510519
NSMutableArray *rightUtilityButtons = [NSMutableArray new];
511-
[rightUtilityButtons sw_addUtilityButtonWithColor:kColorD8DDE4 icon:[UIImage imageNamed:@"icon_file_cell_move"]];
512-
[rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithHexString:@"0xF2F4F6"] icon:[UIImage imageNamed:@"icon_file_cell_rename"]];
513-
[rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithHexString:@"0xF66262"] icon:[UIImage imageNamed:@"icon_file_cell_delete"]];
520+
if (!obj.isSharedFolder) {
521+
[rightUtilityButtons sw_addUtilityButtonWithColor:kColorD8DDE4 icon:[UIImage imageNamed:@"icon_file_cell_move"]];
522+
[rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithHexString:@"0xF2F4F6"] icon:[UIImage imageNamed:@"icon_file_cell_rename"]];
523+
[rightUtilityButtons sw_addUtilityButtonWithColor:[UIColor colorWithHexString:@"0xF66262"] icon:[UIImage imageNamed:@"icon_file_cell_delete"]];
524+
}
514525
return rightUtilityButtons;
515526
}
516527

0 commit comments

Comments
 (0)