-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathFileActivityCell.m
50 lines (40 loc) · 2.04 KB
/
FileActivityCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// FileActivityCell.m
// Coding_iOS
//
// Created by Ease on 15/8/12.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#import "FileActivityCell.h"
@implementation FileActivityCell
+ (NSAttributedString *)attrContentWithObj:(ProjectActivity *)curActivity{
if (![curActivity.target_type isEqualToString:@"ProjectFile"]) {
return nil;
}
NSString *userName, *contentStr;
userName = curActivity.user.name? curActivity.user.name: @"";
NSMutableAttributedString *attrContent;
if ([curActivity.action isEqualToString:@"delete_history"]) {
contentStr = [NSString stringWithFormat:@"%@ 历史版本 V%@ - %@", curActivity.action_msg, curActivity.version, [curActivity.created_at stringDisplay_HHmm]];
}else{
if ([curActivity.action isEqualToString:@"rename"]) {
contentStr = [NSString stringWithFormat:@"修改了文件名称 - %@", [curActivity.created_at stringDisplay_HHmm]];
}else{
contentStr = [NSString stringWithFormat:@"%@ 文件 - %@", curActivity.action_msg, [curActivity.created_at stringDisplay_HHmm]];
}
}
attrContent = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", userName, contentStr]];
[attrContent addAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:13],
NSForegroundColorAttributeName : kColorDark3}
range:NSMakeRange(0, userName.length)];
[attrContent addAttributes:@{NSFontAttributeName : [UIFont systemFontOfSize:13],
NSForegroundColorAttributeName : kColorDark7}
range:NSMakeRange(userName.length + 1, contentStr.length)];
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.minimumLineHeight = 18;
[attrContent addAttribute:NSParagraphStyleAttributeName
value:paragraphStyle
range:NSMakeRange(0, [attrContent length])];
return attrContent;
}
@end