Skip to content

Commit f4f05cb

Browse files
committed
Beta
1 parent 2277da2 commit f4f05cb

26 files changed

+984
-65
lines changed

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 76 additions & 0 deletions
Large diffs are not rendered by default.

Coding_iOS/Coding_iOS-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</dict>
3333
</array>
3434
<key>CFBundleVersion</key>
35-
<string>2.4.2015031116</string>
35+
<string>2.4.2015031318</string>
3636
<key>LSRequiresIPhoneOS</key>
3737
<true/>
3838
<key>UIAppFonts</key>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// NProjectViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/3/11.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
#import "Projects.h"
11+
12+
@interface NProjectViewController : BaseViewController
13+
@property (nonatomic, strong) Project *myProject;
14+
15+
@end
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
//
2+
// NProjectViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 15/3/11.
6+
// Copyright (c) 2015年 Coding. All rights reserved.
7+
//
8+
9+
#import "NProjectViewController.h"
10+
#import "ProjectInfoCell.h"
11+
#import "ProjectItemsCell.h"
12+
#import "ProjectDescriptionCell.h"
13+
#import "ProjectViewController.h"
14+
#import "Coding_NetAPIManager.h"
15+
#import "ODRefreshControl.h"
16+
17+
@interface NProjectViewController ()<UITableViewDataSource, UITableViewDelegate>
18+
@property (nonatomic, strong) UITableView *myTableView;
19+
@property (nonatomic, strong) ODRefreshControl *refreshControl;
20+
21+
@end
22+
23+
@implementation NProjectViewController
24+
- (void)viewDidLoad{
25+
[super viewDidLoad];
26+
27+
self.title = @"项目首页";
28+
// 添加myTableView
29+
_myTableView = ({
30+
UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
31+
tableView.backgroundColor = [UIColor clearColor];
32+
tableView.dataSource = self;
33+
tableView.delegate = self;
34+
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
35+
[tableView registerClass:[ProjectInfoCell class] forCellReuseIdentifier:kCellIdentifier_ProjectInfoCell];
36+
[tableView registerClass:[ProjectItemsCell class] forCellReuseIdentifier:kCellIdentifier_ProjectItemsCell_Private];
37+
[tableView registerClass:[ProjectItemsCell class] forCellReuseIdentifier:kCellIdentifier_ProjectItemsCell_Public];
38+
[tableView registerClass:[ProjectDescriptionCell class] forCellReuseIdentifier:kCellIdentifier_ProjectDescriptionCell];
39+
[self.view addSubview:tableView];
40+
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
41+
make.edges.equalTo(self.view);
42+
}];
43+
tableView;
44+
});
45+
46+
_refreshControl = [[ODRefreshControl alloc] initInScrollView:self.myTableView];
47+
[_refreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];
48+
49+
[self refresh];
50+
}
51+
52+
53+
- (void)refresh{
54+
if (_myProject.isLoadingDetail) {
55+
return;
56+
}
57+
58+
__weak typeof(self) weakSelf = self;
59+
[[Coding_NetAPIManager sharedManager] request_ProjectDetail_WithObj:_myProject andBlock:^(id data, NSError *error) {
60+
[weakSelf.refreshControl endRefreshing];
61+
if (data) {
62+
weakSelf.myProject = data;
63+
[weakSelf.myTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
64+
}
65+
}];
66+
}
67+
68+
#pragma mark Table M
69+
70+
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
71+
NSInteger section = 0;
72+
if (_myProject.is_public) {
73+
section = _myProject.is_public.boolValue? 2: 1;
74+
}
75+
return section;
76+
}
77+
78+
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
79+
UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 20)];
80+
footerView.backgroundColor = [UIColor colorWithHexString:@"0xe5e5e5"];
81+
[footerView addLineUp:YES andDown:NO andColor:tableView.separatorColor];
82+
return footerView;
83+
}
84+
85+
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
86+
if (section == _myProject.is_public.boolValue? 1: 0) {
87+
return 0;
88+
}
89+
return 20;
90+
}
91+
92+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
93+
NSInteger row = 0;
94+
if (_myProject.is_public) {
95+
switch (section) {
96+
case 0:
97+
row = 2;
98+
break;
99+
case 1:
100+
default:
101+
row = _myProject.is_public.boolValue? 1: 0;
102+
break;
103+
}
104+
}
105+
return row;
106+
}
107+
108+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
109+
if (_myProject.is_public.boolValue) {
110+
if (indexPath.section == 0) {
111+
if (indexPath.row == 0) {
112+
ProjectInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_ProjectInfoCell forIndexPath:indexPath];
113+
cell.curProject = _myProject;
114+
return cell;
115+
}else{
116+
ProjectDescriptionCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_ProjectDescriptionCell forIndexPath:indexPath];
117+
cell.curProject = _myProject;
118+
cell.gitButtonClickedBlock = ^(NSInteger index){
119+
[self gitButtonClicked:index];
120+
};
121+
return cell;
122+
}
123+
}else{
124+
ProjectItemsCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_ProjectItemsCell_Public forIndexPath:indexPath];
125+
cell.curProject = _myProject;
126+
cell.itemClickedBlock = ^(NSInteger index){
127+
[self goToIndex:index];
128+
};
129+
return cell;
130+
}
131+
}else{
132+
if (indexPath.row == 0) {
133+
ProjectInfoCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_ProjectInfoCell forIndexPath:indexPath];
134+
cell.curProject = _myProject;
135+
return cell;
136+
}else{
137+
ProjectItemsCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_ProjectItemsCell_Private forIndexPath:indexPath];
138+
cell.curProject = _myProject;
139+
cell.itemClickedBlock = ^(NSInteger index){
140+
[self goToIndex:index];
141+
};
142+
return cell;
143+
}
144+
}
145+
}
146+
147+
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
148+
CGFloat cellHeight = 0;
149+
if (_myProject.is_public.boolValue) {
150+
if (indexPath.section == 0) {
151+
cellHeight = indexPath.row == 0? [ProjectInfoCell cellHeight]: [ProjectDescriptionCell cellHeightWithObj:_myProject];
152+
}else{
153+
cellHeight = [ProjectItemsCell cellHeightWithObj:_myProject];
154+
}
155+
}else{
156+
cellHeight = indexPath.row == 0? [ProjectInfoCell cellHeight]: [ProjectItemsCell cellHeightWithObj:_myProject];
157+
}
158+
return cellHeight;
159+
}
160+
161+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
162+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
163+
}
164+
165+
#pragma mark goTo VC
166+
- (void)goToIndex:(NSInteger)index{
167+
ProjectViewController *vc = [[ProjectViewController alloc] init];
168+
vc.myProject = self.myProject;
169+
vc.curIndex = index;
170+
[self.navigationController pushViewController:vc animated:YES];
171+
}
172+
173+
#pragma mark Git_Btn
174+
- (void)gitButtonClicked:(NSInteger)index{
175+
__weak typeof(self) weakSelf = self;
176+
switch (index) {
177+
case 0://Star
178+
{
179+
if (!_myProject.isStaring) {
180+
[[Coding_NetAPIManager sharedManager] request_StarProject:_myProject andBlock:^(id data, NSError *error) {
181+
[weakSelf.myTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
182+
}];
183+
}
184+
}
185+
break;
186+
case 1://Watch
187+
{
188+
if (!_myProject.isWatching) {
189+
[[Coding_NetAPIManager sharedManager] request_WatchProject:_myProject andBlock:^(id data, NSError *error) {
190+
[weakSelf.myTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
191+
}];
192+
}
193+
}
194+
break;
195+
default://Fork
196+
{
197+
if (_myProject.forked.boolValue
198+
|| [_myProject.owner_user_name isEqualToString:[Login curLoginUser].global_key]) {
199+
return;
200+
}else{
201+
202+
[[Coding_NetAPIManager sharedManager] request_ForkProject:_myProject andBlock:^(id data, NSError *error) {
203+
[weakSelf.myTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationNone];
204+
if (data) {
205+
NProjectViewController *vc = [[NProjectViewController alloc] init];
206+
vc.myProject = data;
207+
[weakSelf.navigationController pushViewController:vc animated:YES];
208+
}
209+
}];
210+
}
211+
}
212+
break;
213+
}
214+
}
215+
216+
@end

Coding_iOS/Controllers/ProjectMemberListViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ - (void)setFrame:(CGRect)frame project:(Project *)project type:(ProMemType)type
123123
}
124124

125125
- (void)refresh{
126-
if (_myProject.isLoading) {
126+
if (_myProject.isLoadingMember) {
127127
return;
128128
}
129129
if (!_myMemberArray || _myMemberArray.count <= 0) {

Coding_iOS/Controllers/ProjectViewController.m

Lines changed: 45 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ - (void)viewDidLoad
7474
_projectContentDict = [[NSMutableDictionary alloc] initWithCapacity:5];
7575

7676
if (_myProject) {
77-
if (!_myProject.owner_id) {
77+
if (!_myProject.is_public) {
7878
[self requestForMyProject];
7979
}else{
8080
[self configNavBtnWithMyProject];
81-
[self refreshWithViewType:_curIndex];
81+
[self refreshWithNewIndex:_curIndex];
8282
}
8383
}
8484
}
@@ -118,54 +118,13 @@ - (void)requestForMyProject{
118118
if (data) {
119119
weakSelf.myProject = data;
120120
[weakSelf configNavBtnWithMyProject];
121-
[weakSelf refreshWithViewType:_curIndex];
121+
[weakSelf refreshWithNewIndex:_curIndex];
122122
}
123123
}];
124124
}
125125

126126
- (void)configNavBtnWithMyProject{
127-
__weak typeof(self) weakSelf = self;
128-
if (_myProject.is_public.boolValue) {
129-
[self customDownMenuWithTitles:@[[DownMenuTitle title:@"项目动态" image:@"nav_project_activity" badge:nil],
130-
[DownMenuTitle title:@"项目讨论" image:@"nav_project_topic" badge:nil],
131-
[DownMenuTitle title:@"项目代码" image:@"nav_project_code" badge:nil],
132-
[DownMenuTitle title:@"项目成员" image:@"nav_project_member" badge:nil]]
133-
andDefaultIndex:_curIndex
134-
andBlock:^(id titleObj, NSInteger index) {
135-
[(DownMenuTitle *)titleObj setBadgeValue:nil];
136-
ProjectViewType type;
137-
switch (index) {
138-
case 0:
139-
type = ProjectViewTypeActivities;
140-
break;
141-
case 1:
142-
type = ProjectViewTypeTopics;
143-
break;
144-
case 2:
145-
type = ProjectViewTypeCodes;
146-
break;
147-
case 3:
148-
type = ProjectViewTypeMembers;
149-
break;
150-
default:
151-
type = ProjectViewTypeActivities;
152-
break;
153-
}
154-
[weakSelf refreshWithViewType:type];
155-
}];
156-
}else{
157-
[self customDownMenuWithTitles:@[[DownMenuTitle title:@"项目动态" image:@"nav_project_activity" badge:nil],
158-
[DownMenuTitle title:@"项目任务" image:@"nav_project_task" badge:nil],
159-
[DownMenuTitle title:@"项目讨论" image:@"nav_project_topic" badge:nil],
160-
[DownMenuTitle title:@"项目文档" image:@"nav_project_file" badge:nil],
161-
[DownMenuTitle title:@"项目代码" image:@"nav_project_code" badge:nil],
162-
[DownMenuTitle title:@"项目成员" image:@"nav_project_member" badge:nil]]
163-
andDefaultIndex:_curIndex
164-
andBlock:^(id titleObj, NSInteger index) {
165-
[(DownMenuTitle *)titleObj setBadgeValue:nil];
166-
[weakSelf refreshWithViewType:index];
167-
}];
168-
}
127+
self.title = _myProject.name;
169128
}
170129

171130
- (void)configRightBarButtonItemWithViewType:(ProjectViewType)viewType{
@@ -183,20 +142,53 @@ - (void)configRightBarButtonItemWithViewType:(ProjectViewType)viewType{
183142
[self.navigationItem setRightBarButtonItem:shouldBeItem animated:YES];
184143
}
185144

186-
- (void)refreshWithViewType:(ProjectViewType)viewType{
187-
[self configRightBarButtonItemWithViewType:viewType];
145+
- (ProjectViewType)viewTypeFromIndex:(NSInteger)index{
146+
ProjectViewType type = 0;
147+
if (_myProject.is_public) {
148+
if (_myProject.is_public.boolValue) {
149+
switch (index) {
150+
case 0:
151+
type = ProjectViewTypeActivities;
152+
break;
153+
case 1:
154+
type = ProjectViewTypeTopics;
155+
break;
156+
case 2:
157+
type = ProjectViewTypeCodes;
158+
break;
159+
case 3:
160+
type = ProjectViewTypeMembers;
161+
break;
162+
default:
163+
type = ProjectViewTypeActivities;
164+
break;
165+
}
166+
}else{
167+
type = index;
168+
}
169+
}
170+
return type;
171+
}
172+
173+
174+
- (void)refreshWithNewIndex:(NSInteger)newIndex{
175+
ProjectViewType curViewType = [self viewTypeFromIndex:_curIndex];
176+
ProjectViewType newViewType = [self viewTypeFromIndex:newIndex];
177+
178+
// 配置navBtn
179+
[self configRightBarButtonItemWithViewType:newViewType];
188180

189181
// 隐藏上一个视图
190182
UIView *curView = [self getCurContentView];
191-
if (_curIndex!= viewType && curView) {
183+
if (curViewType != newViewType && curView) {
192184
curView.hidden = YES;
193185
}
194186
// 配置将要显示的视图
195-
_curIndex = viewType;
187+
_curIndex = newIndex;
196188
curView = [self getCurContentView];
197189
__weak typeof(self) weakSelf = self;
198190
if (curView == nil) {
199-
switch (_curIndex) {
191+
switch (newViewType) {
200192
case ProjectViewTypeActivities:{
201193
curView = ({
202194
ProjectActivitiesView *activitiesView = [[ProjectActivitiesView alloc] initWithFrame:self.view.bounds project:_myProject block:^(ProjectActivity *proActivity) {
@@ -286,7 +278,7 @@ - (void)refreshWithViewType:(ProjectViewType)viewType{
286278
make.edges.equalTo(self.view);
287279
}];
288280
}
289-
if (_curIndex != ProjectViewTypeMembers && _proMemberVC) {
281+
if (newViewType != ProjectViewTypeMembers && _proMemberVC) {
290282
[_proMemberVC willHiden];
291283
}
292284
curView.hidden = NO;
@@ -424,7 +416,8 @@ - (void)goToVCWithItem:(HtmlMediaItem *)clickedItem activity:(ProjectActivity *)
424416

425417
#pragma mark Mine M
426418
- (void)navAddBtnClicked{
427-
switch (_curIndex) {
419+
ProjectViewType curViewType = [self viewTypeFromIndex:_curIndex];
420+
switch (curViewType) {
428421
case ProjectViewTypeTasks:
429422
{
430423
EditTaskViewController *vc = [[EditTaskViewController alloc] init];

0 commit comments

Comments
 (0)