Skip to content

Commit 4a442c3

Browse files
committed
提示 & 跳转
1 parent f6f490f commit 4a442c3

7 files changed

Lines changed: 50 additions & 10 deletions

File tree

Coding_iOS/Controllers/MRPRDetailViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@
1414
@property (strong, nonatomic) MRPR *curMRPR;
1515
@property (strong, nonatomic) Project *curProject;
1616
+ (MRPRDetailViewController *)vcWithPath:(NSString *)path;
17+
- (void)refresh;
1718
@end

Coding_iOS/Controllers/NProjectViewController/NProjectViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111

1212
@interface NProjectViewController : BaseViewController
1313
@property (nonatomic, strong) Project *myProject;
14-
14+
@property (nonatomic, assign) BOOL needUpdateVisit;
1515
@end

Coding_iOS/Controllers/NProjectViewController/NProjectViewController.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
166166
switch (indexPath.row) {
167167
case 0:
168168
[cell setImageStr:@"project_item_activity" andTitle:@"动态"];
169+
if (_myProject.un_read_activities_count.integerValue > 0) {
170+
[cell addTip:_myProject.un_read_activities_count.stringValue];
171+
}
169172
break;
170173
case 1:
171174
if (_myProject.is_public.boolValue) {
@@ -245,6 +248,14 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
245248

246249
#pragma mark goTo VC
247250
- (void)goToIndex:(NSInteger)index{
251+
if (index == 0) {
252+
__weak typeof(self) weakSelf = self;
253+
[[Coding_NetAPIManager sharedManager] request_Project_UpdateVisit_WithObj:_myProject andBlock:^(id data, NSError *error) {
254+
if (data) {
255+
weakSelf.myProject.un_read_activities_count = [NSNumber numberWithInteger:0];
256+
}
257+
}];
258+
}
248259
ProjectViewController *vc = [[ProjectViewController alloc] init];
249260
vc.myProject = self.myProject;
250261
vc.curIndex = index;

Coding_iOS/Controllers/RootControllers/BaseViewController.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#import "RootTabViewController.h"
2525
#import "Message_RootViewController.h"
2626

27+
#import "ProjectCommitsViewController.h"
28+
#import "MRPRDetailViewController.h"
29+
2730
#import "UnReadManager.h"
2831

2932
typedef NS_ENUM(NSInteger, AnalyseMethodType) {
@@ -152,6 +155,7 @@ + (UIViewController *)analyseVCFromLinkStr:(NSString *)linkStr analyseMethod:(An
152155
NSString *ppRegexStr = @"/u/([^/]+)/pp/([0-9]+)$";
153156
NSString *topicRegexStr = @"/u/([^/]+)/p/([^/]+)/topic/(\\d+)";
154157
NSString *taskRegexStr = @"/u/([^/]+)/p/([^/]+)/task/(\\d+)";
158+
NSString *mergeRegexStr = @"/u/([^/]+)/p/([^/]+)/git/merge/(\\d+)";
155159
NSString *conversionRegexStr = @"/user/messages/history/([^/]+)$";
156160
NSString *projectRegexStr = @"/u/([^/]+)/p/([^/]+)";
157161
NSArray *matchedCaptures = nil;
@@ -174,6 +178,21 @@ + (UIViewController *)analyseVCFromLinkStr:(NSString *)linkStr analyseMethod:(An
174178
vc.curTweet = [Tweet tweetWithGlobalKey:user_global_key andPPID:pp_id];
175179
analyseVC = vc;
176180
}
181+
}else if ((matchedCaptures = [linkStr captureComponentsMatchedByRegex:mergeRegexStr]).count > 0){
182+
//MR
183+
NSString *path = [linkStr stringByReplacingOccurrencesOfString:@"https://coding.net" withString:@""];
184+
185+
if ([presentingVC isKindOfClass:[MRPRDetailViewController class]]) {
186+
MRPRDetailViewController *vc = (MRPRDetailViewController *)presentingVC;
187+
if ([vc.curMRPR.path isEqualToString:path]) {
188+
[vc refresh];
189+
analyseVCIsNew = NO;
190+
analyseVC = vc;
191+
}
192+
}
193+
if (!analyseVC) {
194+
analyseVC = [MRPRDetailViewController vcWithPath:path];
195+
}
177196
}else if ((matchedCaptures = [linkStr captureComponentsMatchedByRegex:topicRegexStr]).count > 0){
178197
//讨论
179198
NSString *topic_id = matchedCaptures[3];

Coding_iOS/Controllers/RootControllers/Project_RootViewController.m

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,8 @@ -(void)gotoNewProject{
191191

192192
- (void)goToProject:(Project *)project{
193193
Projects *curPros = [_myProjectsDict objectForKey:[NSNumber numberWithUnsignedInteger:_myCarousel.currentItemIndex]];
194-
ProjectListView *listView = (ProjectListView *)self.myCarousel.currentItemView;
195-
if (curPros.type < ProjectsTypeTaProject) {
196-
[[Coding_NetAPIManager sharedManager] request_Project_UpdateVisit_WithObj:project andBlock:^(id data, NSError *error) {
197-
if (data) {
198-
project.un_read_activities_count = [NSNumber numberWithInteger:0];
199-
[listView refreshUI];
200-
}
201-
}];
202-
}
203194
NProjectViewController *vc = [[NProjectViewController alloc] init];
195+
vc.needUpdateVisit = (curPros.type < ProjectsTypeTaProject);
204196
vc.myProject = project;
205197
[self.navigationController pushViewController:vc animated:YES];
206198
}

Coding_iOS/Views/Cell/NProjectItemCell.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212

1313
@interface NProjectItemCell : UITableViewCell
1414
- (void)setImageStr:(NSString *)imgStr andTitle:(NSString *)title;
15+
- (void)addTip:(NSString *)countStr;
16+
- (void)removeTip;
1517
+ (CGFloat)cellHeight;
1618
@end

Coding_iOS/Views/Cell/NProjectItemCell.m

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
4444
}
4545
return self;
4646
}
47+
48+
- (void)prepareForReuse{
49+
[self removeTip];
50+
}
51+
52+
- (void)addTip:(NSString *)countStr{
53+
CGFloat pointX = kScreen_Width - 25;
54+
CGFloat pointY = [[self class] cellHeight]/2;
55+
[self addBadgeTip:countStr withCenterPosition:CGPointMake(pointX, pointY)];
56+
}
57+
58+
- (void)removeTip{
59+
[self removeBadgeTips];
60+
}
61+
4762
- (void)setImageStr:(NSString *)imgStr andTitle:(NSString *)title{
4863
self.imgView.image = [UIImage imageNamed:imgStr];
4964
self.titleLabel.text = title;

0 commit comments

Comments
 (0)