Skip to content

Commit dc49248

Browse files
committed
MRPR_改版
1 parent 6018f14 commit dc49248

23 files changed

Lines changed: 575 additions & 94 deletions

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 47 additions & 29 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// MRDetailViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/10/23.
6+
// Copyright © 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "PRDetailViewController.h"
10+
11+
@interface MRDetailViewController : PRDetailViewController
12+
13+
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// MRDetailViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/10/23.
6+
// Copyright © 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "MRDetailViewController.h"
10+
11+
@implementation MRDetailViewController
12+
13+
@end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// MRListViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/10/23.
6+
// Copyright © 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
#import "Project.h"
11+
12+
@interface MRListViewController : BaseViewController
13+
@property (strong, nonatomic) Project *curProject;
14+
15+
@end
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
//
2+
// MRListViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/10/23.
6+
// Copyright © 2015年 Coding. All rights reserved.
7+
//
8+
9+
#define kMRPRListViewController_BottomViewHeight 49.0
10+
11+
#import "MRListViewController.h"
12+
#import "XTSegmentControl.h"
13+
#import "iCarousel.h"
14+
#import "MRListView.h"
15+
#import "MRDetailViewController.h"
16+
17+
18+
@interface MRListViewController ()<iCarouselDataSource, iCarouselDelegate>
19+
@property (strong, nonatomic) XTSegmentControl *mySegmentControl;
20+
@property (strong, nonatomic) iCarousel *myCarousel;
21+
@property (strong, nonatomic) NSMutableDictionary *myMRsDict;
22+
@property (nonatomic, assign) NSInteger segmentIndex;
23+
24+
@property (strong, nonatomic) UIView *bottomView;
25+
@property (strong, nonatomic) UISegmentedControl *mySegmentedControl;
26+
@end
27+
28+
@implementation MRListViewController
29+
- (void)viewDidLoad
30+
{
31+
[super viewDidLoad];
32+
// Do any additional setup after loading the view.
33+
self.view.backgroundColor = kColorTableBG;
34+
self.title = @"Merge Requests";
35+
_myMRsDict = [[NSMutableDictionary alloc] initWithCapacity:6];
36+
37+
//添加myCarousel
38+
_myCarousel = ({
39+
iCarousel *icarousel = [[iCarousel alloc] init];
40+
icarousel.dataSource = self;
41+
icarousel.delegate = self;
42+
icarousel.decelerationRate = 1.0;
43+
icarousel.scrollSpeed = 1.0;
44+
icarousel.type = iCarouselTypeLinear;
45+
icarousel.pagingEnabled = YES;
46+
icarousel.clipsToBounds = YES;
47+
icarousel.bounceDistance = 0.2;
48+
[self.view addSubview:icarousel];
49+
[icarousel mas_makeConstraints:^(MASConstraintMaker *make) {
50+
make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(kMySegmentControl_Height, 0, 0, 0));
51+
}];
52+
icarousel;
53+
});
54+
55+
//添加滑块
56+
__weak typeof(_myCarousel) weakCarousel = _myCarousel;
57+
_mySegmentControl = [[XTSegmentControl alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kMySegmentControl_Height) Items:@[@"我评审的", @"我发布的", @"其他的"] selectedBlock:^(NSInteger index) {
58+
[weakCarousel scrollToItemAtIndex:index animated:NO];
59+
}];
60+
[self.view addSubview:_mySegmentControl];
61+
[self configBottomView];
62+
self.segmentIndex = 0;
63+
}
64+
65+
- (void)setSegmentIndex:(NSInteger)segmentIndex{
66+
_segmentIndex = segmentIndex;
67+
if (self.mySegmentedControl.selectedSegmentIndex != _segmentIndex) {
68+
[self.mySegmentedControl setSelectedSegmentIndex:_segmentIndex];
69+
}
70+
MRListView *curView = (MRListView *)_myCarousel.currentItemView;
71+
curView.curMRPRS = [self curMRPRS];
72+
[curView refreshToQueryData];
73+
}
74+
75+
- (MRPRS *)curMRPRS{
76+
NSString *curKey = [NSString stringWithFormat:@"%ld_%ld", (long)_myCarousel.currentItemIndex, (long)_segmentIndex];
77+
MRPRS *curMRPRS = _myMRsDict[curKey];
78+
if (!curMRPRS) {
79+
curMRPRS = [[MRPRS alloc] initWithType:MRPRSTypeMRMine + _myCarousel.currentItemIndex
80+
statusIsOpen:_segmentIndex == 0
81+
userGK:_curProject.owner_user_name
82+
projectName:_curProject.name];
83+
_myMRsDict[curKey] = curMRPRS;
84+
}
85+
return curMRPRS;
86+
}
87+
88+
#pragma mark Segment
89+
- (void)configBottomView{
90+
if (!_bottomView) {
91+
_bottomView = [UIView new];
92+
_bottomView.backgroundColor = self.view.backgroundColor;
93+
[_bottomView addLineUp:YES andDown:NO];
94+
[self.view addSubview:_bottomView];
95+
[_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
96+
make.left.right.bottom.equalTo(self.view);
97+
make.height.mas_equalTo(kMRPRListViewController_BottomViewHeight);
98+
}];
99+
}
100+
if (!_mySegmentedControl) {
101+
_mySegmentedControl = ({
102+
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"Open", @"Closed"]];
103+
segmentedControl.tintColor = [UIColor colorWithHexString:@"0x3bbd79"];
104+
[segmentedControl setTitleTextAttributes:@{
105+
NSFontAttributeName: [UIFont boldSystemFontOfSize:16],
106+
NSForegroundColorAttributeName: [UIColor whiteColor]
107+
}
108+
forState:UIControlStateSelected];
109+
[segmentedControl setTitleTextAttributes:@{
110+
NSFontAttributeName: [UIFont boldSystemFontOfSize:16],
111+
NSForegroundColorAttributeName: [UIColor colorWithHexString:@"0x3bbd79"]
112+
} forState:UIControlStateNormal];
113+
[segmentedControl addTarget:self action:@selector(segmentedControlSelected:) forControlEvents:UIControlEventValueChanged];
114+
segmentedControl;
115+
});
116+
_mySegmentedControl.frame = CGRectMake(kPaddingLeftWidth, (kMRPRListViewController_BottomViewHeight - 30)/2, kScreen_Width - 2*kPaddingLeftWidth, 30);
117+
[_bottomView addSubview:_mySegmentedControl];
118+
}
119+
}
120+
121+
- (void)segmentedControlSelected:(id)sender{
122+
UISegmentedControl *segmentedControl = (UISegmentedControl *)sender;
123+
self.segmentIndex = segmentedControl.selectedSegmentIndex;
124+
}
125+
126+
#pragma mark iCarousel M
127+
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel{
128+
return 3;
129+
}
130+
131+
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
132+
133+
MRListView *listView = (MRListView *)view;
134+
if (!listView) {
135+
listView = [[MRListView alloc] initWithFrame:carousel.bounds];
136+
__weak typeof(self) weakSelf = self;
137+
listView.clickedMRBlock = ^(MRPR *clickedMR){
138+
[weakSelf goToMRDetail:clickedMR];
139+
};
140+
}
141+
listView.curMRPRS = [self curMRPRS];
142+
if (index == carousel.currentItemIndex) {
143+
[listView refreshToQueryData];
144+
}
145+
[listView setSubScrollsToTop:(index == carousel.currentItemIndex)];
146+
return listView;
147+
}
148+
149+
- (void)carouselDidScroll:(iCarousel *)carousel{
150+
[self.view endEditing:YES];
151+
if (_mySegmentControl) {
152+
float offset = carousel.scrollOffset;
153+
if (offset > 0) {
154+
[_mySegmentControl moveIndexWithProgress:offset];
155+
}
156+
}
157+
}
158+
159+
- (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel
160+
{
161+
if (_mySegmentControl) {
162+
_mySegmentControl.currentIndex = carousel.currentItemIndex;
163+
}
164+
MRListView *listView = (MRListView *)carousel.currentItemView;
165+
listView.curMRPRS = [self curMRPRS];
166+
[listView refreshToQueryData];
167+
[carousel.visibleItemViews enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
168+
[obj setSubScrollsToTop:(obj == carousel.currentItemView)];
169+
}];
170+
}
171+
172+
#pragma mark goto VC
173+
- (void)goToMRDetail:(MRPR *)curMR{
174+
NSLog(@"%@", curMR.title);
175+
MRDetailViewController *vc = [MRDetailViewController new];
176+
vc.curMRPR = curMR;
177+
vc.curProject = _curProject;
178+
[self.navigationController pushViewController:vc animated:YES];
179+
180+
}
181+
@end

Coding_iOS/Controllers/NProjectViewController/NProjectViewController.m

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
#import "ForkTreeViewController.h"
2828

2929
#import "CodeViewController.h"
30-
#import "MRPRListViewController.h"
30+
#import "PRListViewController.h"
31+
#import "MRListViewController.h"
3132
#import "EaseGitButtonsView.h"
3233

3334
#import "FunctionTipsManager.h"
@@ -309,9 +310,15 @@ - (void)goToReadme{
309310
}
310311

311312
- (void)goTo_MR_PR{
312-
MRPRListViewController *vc = [[MRPRListViewController alloc] init];
313-
vc.curProject = self.myProject;
314-
[self.navigationController pushViewController:vc animated:YES];
313+
if (_myProject.is_public.boolValue) {
314+
PRListViewController *vc = [[PRListViewController alloc] init];
315+
vc.curProject = self.myProject;
316+
[self.navigationController pushViewController:vc animated:YES];
317+
}else{
318+
MRListViewController *vc = [[MRListViewController alloc] init];
319+
vc.curProject = self.myProject;
320+
[self.navigationController pushViewController:vc animated:YES];
321+
}
315322
}
316323

317324
#pragma mark Git_Btn

0 commit comments

Comments
 (0)