Skip to content

Commit 89a432d

Browse files
committed
PR_列表
1 parent fd431db commit 89a432d

12 files changed

Lines changed: 518 additions & 9 deletions

File tree

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@
283283
4ECF703C1B171AD8000280FF /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4ECF70341B171AD8000280FF /* [email protected] */; };
284284
4ECF703D1B171AD8000280FF /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4ECF70351B171AD8000280FF /* [email protected] */; };
285285
4ECF70401B180740000280FF /* EaseGitButtonsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ECF703F1B180740000280FF /* EaseGitButtonsView.m */; };
286+
4ECF70431B18514F000280FF /* MRPRListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ECF70421B18514F000280FF /* MRPRListViewController.m */; };
287+
4ECF70461B18557E000280FF /* MRPRS.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ECF70451B18557E000280FF /* MRPRS.m */; };
288+
4ECF70491B185BCC000280FF /* MRPR.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ECF70481B185BCC000280FF /* MRPR.m */; };
289+
4ECF704C1B1876CB000280FF /* MRPRListCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ECF704B1B1876CB000280FF /* MRPRListCell.m */; };
286290
4ED20A781AFC7C8B00C63498 /* EasePageViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ED20A771AFC7C8B00C63498 /* EasePageViewController.m */; };
287291
4ED20A7A1AFCC43600C63498 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4ED20A791AFCC43600C63498 /* [email protected] */; };
288292
4ED6731E1A8DD38C00DF2D1A /* ReportIllegalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4ED6731D1A8DD38C00DF2D1A /* ReportIllegalViewController.m */; };
@@ -1088,6 +1092,14 @@
10881092
4ECF70351B171AD8000280FF /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
10891093
4ECF703E1B180740000280FF /* EaseGitButtonsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EaseGitButtonsView.h; sourceTree = "<group>"; };
10901094
4ECF703F1B180740000280FF /* EaseGitButtonsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EaseGitButtonsView.m; sourceTree = "<group>"; };
1095+
4ECF70411B18514F000280FF /* MRPRListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MRPRListViewController.h; sourceTree = "<group>"; };
1096+
4ECF70421B18514F000280FF /* MRPRListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MRPRListViewController.m; sourceTree = "<group>"; };
1097+
4ECF70441B18557E000280FF /* MRPRS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MRPRS.h; sourceTree = "<group>"; };
1098+
4ECF70451B18557E000280FF /* MRPRS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MRPRS.m; sourceTree = "<group>"; };
1099+
4ECF70471B185BCC000280FF /* MRPR.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MRPR.h; sourceTree = "<group>"; };
1100+
4ECF70481B185BCC000280FF /* MRPR.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MRPR.m; sourceTree = "<group>"; };
1101+
4ECF704A1B1876CB000280FF /* MRPRListCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MRPRListCell.h; sourceTree = "<group>"; };
1102+
4ECF704B1B1876CB000280FF /* MRPRListCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MRPRListCell.m; sourceTree = "<group>"; };
10911103
4ED20A761AFC7C8B00C63498 /* EasePageViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EasePageViewController.h; sourceTree = "<group>"; };
10921104
4ED20A771AFC7C8B00C63498 /* EasePageViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EasePageViewController.m; sourceTree = "<group>"; };
10931105
4ED20A791AFCC43600C63498 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
@@ -2594,6 +2606,8 @@
25942606
4E996BDB1ABA79AB00C704F1 /* UserInfoDetailViewController.m */,
25952607
4E996BE01ABA957B00C704F1 /* ProjectListViewController.h */,
25962608
4E996BE11ABA957B00C704F1 /* ProjectListViewController.m */,
2609+
4ECF70411B18514F000280FF /* MRPRListViewController.h */,
2610+
4ECF70421B18514F000280FF /* MRPRListViewController.m */,
25972611
);
25982612
path = Controllers;
25992613
sourceTree = "<group>";
@@ -2916,6 +2930,10 @@
29162930
4E38CF611A7B7C99005536C0 /* CodeBranchOrTag.m */,
29172931
0A6E6BAB1AB08540004C0107 /* TweetSendLocation.h */,
29182932
0A6E6BAC1AB08540004C0107 /* TweetSendLocation.m */,
2933+
4ECF70441B18557E000280FF /* MRPRS.h */,
2934+
4ECF70451B18557E000280FF /* MRPRS.m */,
2935+
4ECF70471B185BCC000280FF /* MRPR.h */,
2936+
4ECF70481B185BCC000280FF /* MRPR.m */,
29192937
);
29202938
path = Models;
29212939
sourceTree = "<group>";
@@ -3270,6 +3288,8 @@
32703288
4E996BE71ABBCD2D00C704F1 /* TaskDescriptionCell.m */,
32713289
4ECF702A1B1704C5000280FF /* NProjectItemCell.h */,
32723290
4ECF702B1B1704C5000280FF /* NProjectItemCell.m */,
3291+
4ECF704A1B1876CB000280FF /* MRPRListCell.h */,
3292+
4ECF704B1B1876CB000280FF /* MRPRListCell.m */,
32733293
);
32743294
path = Cell;
32753295
sourceTree = "<group>";
@@ -3830,6 +3850,7 @@
38303850
4ECE8B001A3946C10021E29C /* CodingNetAPIClient.m in Sources */,
38313851
8EF643B119FF7E2900F7EEB0 /* ConversationCell.m in Sources */,
38323852
8EF643D019FF7E2900F7EEB0 /* TweetSendImagesCell.m in Sources */,
3853+
4ECF704C1B1876CB000280FF /* MRPRListCell.m in Sources */,
38333854
3A38784F1AE557700078D5DE /* TopicPreviewCell.m in Sources */,
38343855
8ED0D87519FBA6EA00FBA818 /* NSString+Emojize.m in Sources */,
38353856
4E1A228B1AB1844F00CFC14F /* EaseGitButton.m in Sources */,
@@ -3842,6 +3863,7 @@
38423863
4E6D71891A75F00E005AD988 /* YLGIFImage.m in Sources */,
38433864
0A27A05D1AB5A13B00067833 /* TweetSendLocationDetailViewController.m in Sources */,
38443865
0AB591B01AB6D6BE0076C454 /* TweetSendMapAnnotation.m in Sources */,
3866+
4ECF70491B185BCC000280FF /* MRPR.m in Sources */,
38453867
4EA7F1651A6D192B00A046BD /* UIImageView+WebCache.m in Sources */,
38463868
8EF643B819FF7E2900F7EEB0 /* InputOnlyTextPlainCell.m in Sources */,
38473869
4E6BA2DB1A1EE6AF005FD721 /* AFURLSessionManager.m in Sources */,
@@ -3980,6 +4002,7 @@
39804002
4E6BA2D71A1EE6AF005FD721 /* AFHTTPRequestOperation.m in Sources */,
39814003
4EF8181F1B05C9D8005F974B /* ProjectLineNoteActivity.m in Sources */,
39824004
8EF643A919FF7E2900F7EEB0 /* MessageMediaItemCCell.m in Sources */,
4005+
4ECF70461B18557E000280FF /* MRPRS.m in Sources */,
39834006
4ECE8AE41A3943E80021E29C /* UIImage+Common.m in Sources */,
39844007
8EF643D619FF7E9F00F7EEB0 /* ProjectTopicCell.m in Sources */,
39854008
4E6BA2DA1A1EE6AF005FD721 /* AFHTTPSessionManager.m in Sources */,
@@ -4021,6 +4044,7 @@
40214044
4E8765651A22E5B40090CFB9 /* NSMutableArray+SWUtilityButtons.m in Sources */,
40224045
8ECA8BB419FB42CC00C598C6 /* UILongPressMenuImageView.m in Sources */,
40234046
8EA6D1BE19E240C40076D59C /* Register.m in Sources */,
4047+
4ECF70431B18514F000280FF /* MRPRListViewController.m in Sources */,
40244048
4E969CD01AF0EB87005C0CCE /* NSTimer+Common.m in Sources */,
40254049
8EF643B019FF7E2900F7EEB0 /* CodingTipCell.m in Sources */,
40264050
8EA6D1BA19E240C40076D59C /* Projects.m in Sources */,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// MRPRListViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/5/29.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
#import "Project.h"
11+
12+
@interface MRPRListViewController : BaseViewController
13+
@property (strong, nonatomic) Project *curProject;
14+
@end
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
//
2+
// MRPRListViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/5/29.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#define MRPRListViewController_BottomViewHeight 49.0
10+
11+
#import "MRPRListViewController.h"
12+
#import "ODRefreshControl.h"
13+
#import "SVPullToRefresh.h"
14+
#import "MRPRS.h"
15+
#import "Coding_NetAPIManager.h"
16+
#import "MRPRListCell.h"
17+
18+
@interface MRPRListViewController ()<UITableViewDataSource, UITableViewDelegate>
19+
@property (strong, nonatomic) NSMutableDictionary *dataDict;
20+
@property (strong, nonatomic) UITableView *myTableView;
21+
@property (nonatomic, strong) ODRefreshControl *myRefreshControl;
22+
@property (nonatomic, assign) NSInteger selectedIndex;
23+
24+
@property (strong, nonatomic) UIView *bottomView;
25+
@property (strong, nonatomic) UISegmentedControl *mySegmentedControl;
26+
@end
27+
28+
@implementation MRPRListViewController
29+
- (void)viewDidLoad{
30+
[super viewDidLoad];
31+
self.title = _curProject.is_public.boolValue? @"Pull Requests": @"Merge Requests";
32+
_dataDict = [NSMutableDictionary new];
33+
34+
_myTableView = ({
35+
UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
36+
tableView.dataSource = self;
37+
tableView.delegate = self;
38+
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
39+
[tableView registerClass:[MRPRListCell class] forCellReuseIdentifier:kCellIdentifier_MRPRListCell];
40+
[self.view addSubview:tableView];
41+
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
42+
make.edges.equalTo(self.view);
43+
}];
44+
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, MRPRListViewController_BottomViewHeight, 0);
45+
tableView.contentInset = insets;
46+
tableView.scrollIndicatorInsets = insets;
47+
tableView;
48+
});
49+
_myRefreshControl = [[ODRefreshControl alloc] initInScrollView:self.myTableView];
50+
[_myRefreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];
51+
52+
__weak typeof(self) weakSelf = self;
53+
[_myTableView addInfiniteScrollingWithActionHandler:^{
54+
[weakSelf refreshMore:YES];
55+
}];
56+
[self configBottomView];
57+
58+
self.selectedIndex = 0;
59+
}
60+
61+
- (void)setSelectedIndex:(NSInteger)selectedIndex{
62+
_selectedIndex = selectedIndex;
63+
if (self.mySegmentedControl.selectedSegmentIndex != _selectedIndex) {
64+
[self.mySegmentedControl setSelectedSegmentIndex:_selectedIndex];
65+
}
66+
[self.myTableView reloadData];
67+
68+
__weak typeof(self) weakSelf = self;
69+
[self.view configBlankPage:EaseBlankPageTypeView hasData:YES hasError:NO reloadButtonBlock:^(id sender) {
70+
[weakSelf refreshMore:NO];
71+
}];
72+
73+
if ([self curMRPRS].list.count <= 0) {
74+
[self refresh];
75+
}else{
76+
self.myTableView.showsInfiniteScrolling = [self curMRPRS].canLoadMore;
77+
}
78+
}
79+
80+
- (MRPRS *)curMRPRS{
81+
MRPRS *curMRPRS = [_dataDict objectForKey:@(_selectedIndex)];
82+
if (!curMRPRS) {
83+
MRPRSType type = _curProject.is_public.boolValue? _selectedIndex +4: _selectedIndex +1;
84+
curMRPRS = [MRPRS MRPRSWithType:type userGK:_curProject.owner_user_name projectName:_curProject.name];
85+
[_dataDict setObject:curMRPRS forKey:@(_selectedIndex)];
86+
}
87+
return curMRPRS;
88+
}
89+
90+
- (void)refresh{
91+
[self refreshMore:NO];
92+
}
93+
- (void)refreshMore:(BOOL)willLoadMore{
94+
MRPRS *curMRPRS = [self curMRPRS];
95+
if (curMRPRS.isLoading) {
96+
return;
97+
}
98+
if (willLoadMore && !curMRPRS.canLoadMore) {
99+
[_myTableView.infiniteScrollingView stopAnimating];
100+
return;
101+
}
102+
curMRPRS.willLoadMore = willLoadMore;
103+
[self sendRequest:curMRPRS];
104+
}
105+
106+
- (void)sendRequest:(MRPRS *)curMRPRS{
107+
if (curMRPRS.list.count <= 0) {
108+
[self.view beginLoading];
109+
}
110+
__weak typeof(self) weakSelf = self;
111+
__weak typeof(curMRPRS) weakMRPRS = curMRPRS;
112+
[[Coding_NetAPIManager sharedManager] request_MRPRS_WithObj:curMRPRS andBlock:^(MRPRS *data, NSError *error) {
113+
[weakSelf.view endLoading];
114+
[weakSelf.myRefreshControl endRefreshing];
115+
[weakSelf.myTableView.infiniteScrollingView stopAnimating];
116+
if (data) {
117+
[weakMRPRS configWithMRPRS:data];
118+
[weakSelf.myTableView reloadData];
119+
weakSelf.myTableView.showsInfiniteScrolling = [weakSelf curMRPRS].canLoadMore;
120+
}
121+
[weakSelf.view configBlankPage:EaseBlankPageTypeView hasData:([weakSelf curMRPRS].list.count > 0) hasError:(error != nil) reloadButtonBlock:^(id sender) {
122+
[weakSelf refreshMore:NO];
123+
}];
124+
}];
125+
}
126+
127+
#pragma mark Segment
128+
- (void)configBottomView{
129+
if (!_bottomView) {
130+
_bottomView = [UIView new];
131+
_bottomView.backgroundColor = self.view.backgroundColor;
132+
[_bottomView addLineUp:YES andDown:NO];
133+
[self.view addSubview:_bottomView];
134+
[_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
135+
make.left.right.bottom.equalTo(self.view);
136+
make.height.mas_equalTo(MRPRListViewController_BottomViewHeight);
137+
}];
138+
}
139+
if (!_mySegmentedControl) {
140+
_mySegmentedControl = ({
141+
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"Open", @"Closed"]];
142+
segmentedControl.tintColor = [UIColor colorWithHexString:@"0x3bbd79"];
143+
[segmentedControl setTitleTextAttributes:@{
144+
NSFontAttributeName: [UIFont boldSystemFontOfSize:16],
145+
NSForegroundColorAttributeName: [UIColor whiteColor]
146+
}
147+
forState:UIControlStateSelected];
148+
[segmentedControl setTitleTextAttributes:@{
149+
NSFontAttributeName: [UIFont boldSystemFontOfSize:16],
150+
NSForegroundColorAttributeName: [UIColor colorWithHexString:@"0x3bbd79"]
151+
} forState:UIControlStateNormal];
152+
[segmentedControl addTarget:self action:@selector(segmentedControlSelected:) forControlEvents:UIControlEventValueChanged];
153+
segmentedControl;
154+
});
155+
_mySegmentedControl.frame = CGRectMake(kPaddingLeftWidth, (MRPRListViewController_BottomViewHeight - 30)/2, kScreen_Width - 2*kPaddingLeftWidth, 30);
156+
[_bottomView addSubview:_mySegmentedControl];
157+
}
158+
}
159+
160+
- (void)segmentedControlSelected:(id)sender{
161+
UISegmentedControl *segmentedControl = (UISegmentedControl *)sender;
162+
self.selectedIndex = segmentedControl.selectedSegmentIndex;
163+
}
164+
165+
#pragma mark TableM
166+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
167+
return [self curMRPRS].list.count;
168+
}
169+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
170+
MRPR *curMRPR = [[self curMRPRS].list objectAtIndex:indexPath.row];
171+
MRPRListCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_MRPRListCell forIndexPath:indexPath];
172+
[cell configWithMRPR:curMRPR];
173+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:60];
174+
return cell;
175+
}
176+
177+
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
178+
return [MRPRListCell cellHeight];
179+
}
180+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
181+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
182+
MRPR *curMRPR = [[self curMRPRS].list objectAtIndex:indexPath.row];
183+
NSLog(@"%@", curMRPR.title);
184+
}
185+
186+
187+
188+
@end

Coding_iOS/Controllers/NProjectViewController/NProjectViewController.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
//#import "FileViewController.h"
2626

2727
#import "CodeViewController.h"
28+
#import "MRPRListViewController.h"
2829
#import "EaseGitButtonsView.h"
2930

3031
@interface NProjectViewController ()<UITableViewDataSource, UITableViewDelegate>
@@ -262,7 +263,9 @@ - (void)goToReadme{
262263
}
263264

264265
- (void)goTo_MR_PR{
265-
266+
MRPRListViewController *vc = [[MRPRListViewController alloc] init];
267+
vc.curProject = self.myProject;
268+
[self.navigationController pushViewController:vc animated:YES];
266269
}
267270

268271
#pragma mark Git_Btn

Coding_iOS/Models/MRPR.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// MRPR.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/5/29.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface MRPR : NSObject
12+
@property (strong, nonatomic) NSNumber *id, *iid;
13+
@property (strong, nonatomic) NSString *title, *path;
14+
@property (strong, nonatomic) User *author;
15+
@property (strong, nonatomic) NSDate *created_at;
16+
@property (strong, nonatomic) NSAttributedString *attributeTitle, *attributeTail;
17+
18+
@end

Coding_iOS/Models/MRPR.m

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// MRPR.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/5/29.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "MRPR.h"
10+
11+
@implementation MRPR
12+
- (NSAttributedString *)attributeTitle{
13+
NSString *iidStr = [NSString stringWithFormat:@"#%@", _iid.stringValue? _iid.stringValue: @""];
14+
NSString *titleStr = _title? _title: @"";
15+
NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", iidStr, titleStr]];
16+
[attriString addAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:14],
17+
NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0x4E90BF"]}
18+
range:NSMakeRange(0, iidStr.length)];
19+
[attriString addAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:14],
20+
NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0x333333"]}
21+
range:NSMakeRange(iidStr.length + 1, titleStr.length)];
22+
return attriString;
23+
24+
}
25+
- (NSAttributedString *)attributeTail{
26+
NSString *nameStr = _author.name? _author.name: @"";
27+
NSString *timeStr = _created_at? [_created_at stringTimesAgo]: @"";
28+
NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", nameStr, timeStr]];
29+
[attriString addAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:12],
30+
NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0x333333"]}
31+
range:NSMakeRange(0, nameStr.length)];
32+
[attriString addAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:12],
33+
NSForegroundColorAttributeName : [UIColor colorWithHexString:@"0xA9A9A9"]}
34+
range:NSMakeRange(nameStr.length + 1, timeStr.length)];
35+
return attriString;
36+
}
37+
38+
@end

0 commit comments

Comments
 (0)