Skip to content

Commit cdc3fa6

Browse files
committed
修改代码 - 对 readme 特殊处理一下
1 parent 9a443e7 commit cdc3fa6

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

Coding_iOS/Controllers/CodeViewController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
@interface CodeViewController : BaseViewController<UIWebViewDelegate>
1414
@property (strong, nonatomic) Project *myProject;
1515
@property (strong, nonatomic) CodeFile *myCodeFile;
16+
@property (assign, nonatomic) BOOL isReadMe;
1617
+ (CodeViewController *)codeVCWithProject:(Project *)project andCodeFile:(CodeFile *)codeFile;
1718
@end

Coding_iOS/Controllers/CodeViewController.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ + (CodeViewController *)codeVCWithProject:(Project *)project andCodeFile:(CodeFi
3131
- (void)viewDidLoad {
3232
[super viewDidLoad];
3333
// Do any additional setup after loading the view.
34-
self.title = [[_myCodeFile.path componentsSeparatedByString:@"/"] lastObject];
34+
self.title = self.isReadMe? @"README": [[_myCodeFile.path componentsSeparatedByString:@"/"] lastObject];
3535

3636
{
3737
//用webView显示内容
@@ -74,14 +74,13 @@ - (UIInterfaceOrientationMask)supportedInterfaceOrientations{
7474
- (void)sendRequest{
7575
[self.view beginLoading];
7676
__weak typeof(self) weakSelf = self;
77-
if (_myCodeFile.ref.length <= 0 && [_myCodeFile.path isEqualToString:@"README"]) {
77+
if (_isReadMe) {
7878
[[Coding_NetAPIManager sharedManager] request_ReadMeOFProject:_myProject andBlock:^(id data, NSError *error) {
7979
[weakSelf doSomethingWithResponse:data andError:error];
8080
}];
8181
}else{
8282
[[Coding_NetAPIManager sharedManager] request_CodeFile:_myCodeFile withPro:_myProject andBlock:^(id data, NSError *error) {
8383
[weakSelf doSomethingWithResponse:data andError:error];
84-
[weakSelf configRightNavBtn];
8584
}];
8685
}
8786
}
@@ -98,6 +97,7 @@ - (void)doSomethingWithResponse:(id)data andError:(NSError *)error{
9897
[self.view configBlankPage:EaseBlankPageTypeView hasData:(data != nil) hasError:(error != nil) reloadButtonBlock:^(id sender) {
9998
[self sendRequest];
10099
}];
100+
[self configRightNavBtn];
101101
}
102102

103103
- (void)refreshCodeViewData{
@@ -146,7 +146,11 @@ - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
146146
#pragma mark Nav
147147
- (void)configRightNavBtn{
148148
if (!self.navigationItem.rightBarButtonItem) {
149-
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"moreBtn_Nav"] style:UIBarButtonItemStylePlain target:self action:@selector(rightNavBtnClicked)] animated:NO];
149+
if (_isReadMe) {
150+
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"tweetBtn_Nav"] style:UIBarButtonItemStylePlain target:self action:@selector(goToEditVC)] animated:NO];
151+
}else{
152+
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"moreBtn_Nav"] style:UIBarButtonItemStylePlain target:self action:@selector(rightNavBtnClicked)] animated:NO];
153+
}
150154
}
151155
}
152156

Coding_iOS/Controllers/NProjectViewController/NProjectViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ - (void)gotoPro:(Project *)project{
304304
}
305305

306306
- (void)goToReadme{
307-
CodeFile *nextCodeFile = [CodeFile codeFileWithRef:@"" andPath:@"README"];
308-
CodeViewController *vc = [CodeViewController codeVCWithProject:_myProject andCodeFile:nextCodeFile];
307+
CodeViewController *vc = [CodeViewController codeVCWithProject:_myProject andCodeFile:nil];
308+
vc.isReadMe = YES;
309309
[self.navigationController pushViewController:vc animated:YES];
310310
}
311311

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,10 +2272,11 @@ - (void)request_ReadMeOFProject:(Project *)project andBlock:(void (^)(id data, N
22722272
if (data) {
22732273
[MobClick event:kUmeng_Event_Request_Get label:@"项目_README"];
22742274

2275-
id resultData = [[data valueForKey:@"data"] valueForKey:@"readme"];
2275+
id resultData = data[@"data"][@"readme"];
22762276
if (resultData) {
2277+
CodeFile *rCodeFile = [NSObject objectOfClass:@"CodeFile" fromJSON:data[@"data"]];
22772278
CodeFile_RealFile *realFile = [NSObject objectOfClass:@"CodeFile_RealFile" fromJSON:resultData];
2278-
CodeFile *rCodeFile = [CodeFile codeFileWithRef:defultBranch andPath:realFile.path];
2279+
rCodeFile.path = realFile.path;
22792280
rCodeFile.file = realFile;
22802281
block(rCodeFile, nil);
22812282
}else{

0 commit comments

Comments
 (0)