Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 39b5d48

Browse files
带代码和公式的评论,加详情页面
1 parent 83d2d7b commit 39b5d48

18 files changed

+198
-14
lines changed

‎Coding_iOS.xcodeproj/project.pbxproj‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@
493493
4E996C051ABBF56A00C704F1 /* n_sex_man_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E996BFD1ABBF56A00C704F1 /* n_sex_man_icon@2x.png */; };
494494
4E996C061ABBF56A00C704F1 /* n_sex_woman_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E996BFE1ABBF56A00C704F1 /* n_sex_woman_icon@2x.png */; };
495495
4E996C071ABBF56A00C704F1 /* user_info_detail@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E996BFF1ABBF56A00C704F1 /* user_info_detail@2x.png */; };
496+
4E9E3B751DCC2DB10005FD79 /* HtmlMediaViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E9E3B741DCC2DB10005FD79 /* HtmlMediaViewController.m */; };
496497
4E9F5D201C03051D007CCDCC /* tipIcon_tweetReward@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 4E9F5D1F1C03051D007CCDCC /* tipIcon_tweetReward@2x.png */; };
497498
4EA6790A1A1461C3001A0324 /* ProjectFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EA679091A1461C3001A0324 /* ProjectFile.m */; };
498499
4EA6790D1A1461DC001A0324 /* ProjectFolder.m in Sources */ = {isa = PBXBuildFile; fileRef = 4EA6790C1A1461DC001A0324 /* ProjectFolder.m */; };
@@ -1901,6 +1902,8 @@
19011902
4E996BFD1ABBF56A00C704F1 /* n_sex_man_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "n_sex_man_icon@2x.png"; sourceTree = "<group>"; };
19021903
4E996BFE1ABBF56A00C704F1 /* n_sex_woman_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "n_sex_woman_icon@2x.png"; sourceTree = "<group>"; };
19031904
4E996BFF1ABBF56A00C704F1 /* user_info_detail@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "user_info_detail@2x.png"; sourceTree = "<group>"; };
1905+
4E9E3B731DCC2DB10005FD79 /* HtmlMediaViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HtmlMediaViewController.h; sourceTree = "<group>"; };
1906+
4E9E3B741DCC2DB10005FD79 /* HtmlMediaViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HtmlMediaViewController.m; sourceTree = "<group>"; };
19041907
4E9F5D1F1C03051D007CCDCC /* tipIcon_tweetReward@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tipIcon_tweetReward@2x.png"; sourceTree = "<group>"; };
19051908
4EA679081A1461C3001A0324 /* ProjectFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectFile.h; sourceTree = "<group>"; };
19061909
4EA679091A1461C3001A0324 /* ProjectFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectFile.m; sourceTree = "<group>"; };
@@ -4823,6 +4826,8 @@
48234826
4E2247FB1D82C98800551EA4 /* MeDisplayViewController.m */,
48244827
4E6CBE4F1D8E962300644086 /* TopicAnswerDetailViewController.h */,
48254828
4E6CBE501D8E962300644086 /* TopicAnswerDetailViewController.m */,
4829+
4E9E3B731DCC2DB10005FD79 /* HtmlMediaViewController.h */,
4830+
4E9E3B741DCC2DB10005FD79 /* HtmlMediaViewController.m */,
48264831
);
48274832
path = Controllers;
48284833
sourceTree = "<group>";
@@ -7057,6 +7062,7 @@
70577062
4ED618181C3A6CA50017946C /* LocationCell.m in Sources */,
70587063
8EA6D1B019E240C40076D59C /* Comment.m in Sources */,
70597064
0A6E6BA71AAF4162004C0107 /* TweetSendLocationCell.m in Sources */,
7065+
4E9E3B751DCC2DB10005FD79 /* HtmlMediaViewController.m in Sources */,
70607066
4E0BD86E1B6C7E3D0061CAA6 /* CSTopicCreateVC.m in Sources */,
70617067
4E8765651A22E5B40090CFB9 /* NSMutableArray+SWUtilityButtons.m in Sources */,
70627068
13972E2F1CA6D5C600489EBA /* MActivityInfo.m in Sources */,

‎Coding_iOS/Controllers/CodeViewController.m‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ - (void)viewDidLoad {
3434
self.view.backgroundColor = kColorTableBG;
3535
self.title = self.isReadMe? @"README": [[_myCodeFile.path componentsSeparatedByString:@"/"] lastObject];
3636

37-
{
38-
//用webView显示内容
37+
{//用webView显示内容
3938
_webContentView = [[UIWebView alloc] initWithFrame:self.view.bounds];
4039
_webContentView.delegate = self;
4140
_webContentView.backgroundColor = [UIColor clearColor];

‎Coding_iOS/Controllers/DynamicCommentCell.m‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818

1919
#import "MJPhotoBrowser.h"
2020
#import "FileComment.h"
21+
#import "HtmlMediaViewController.h"
2122

2223
@interface DynamicCommentCell ()<UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>
2324
@property (strong, nonatomic) UIImageView *ownerIconView, *timeLineView, *contentBGView;
2425
@property (strong, nonatomic) UILabel *timeLabel;
2526
@property (strong, nonatomic) UICustomCollectionView *imageCollectionView;
27+
@property (strong, nonatomic) UIButton *detailBtn;
2628

2729
@end
2830

@@ -92,15 +94,33 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus
9294
[_contentBGView mas_makeConstraints:^(MASConstraintMaker *make) {
9395
make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(5, 60- 7, 5, 20));
9496
}];
97+
if (!_detailBtn) {
98+
_detailBtn = [UIButton buttonWithTitle:@"查看详情" titleColor:kColorBrandGreen];
99+
_detailBtn.titleLabel.font = [UIFont systemFontOfSize:12];
100+
[_detailBtn addTarget:self action:@selector(goToDetail) forControlEvents:UIControlEventTouchUpInside];
101+
[self.contentView addSubview:_detailBtn];
102+
[_detailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
103+
make.size.mas_equalTo(CGSizeMake(60, 30));
104+
make.right.equalTo(_contentBGView).offset(-10);
105+
make.bottom.equalTo(_contentBGView).offset(-5);
106+
}];
107+
}
108+
95109
}
96110
return self;
97111
}
98112

113+
- (void)goToDetail{
114+
HtmlMediaViewController *vc = [HtmlMediaViewController instanceWithHtmlMedia:self.curComment.htmlMedia title:[NSString stringWithFormat:@"%@ 的评论", self.curComment.author.name]];
115+
[BaseViewController goToVC:vc];
116+
}
117+
99118
- (void)setCurComment:(ProjectLineNote *)curComment{
100119
_curComment = curComment;
101120
if (!_curComment) {
102121
return;
103122
}
123+
_detailBtn.hidden = ![self.curComment.htmlMedia needToShowDetail];
104124
CGFloat curBottomY = 15;
105125
[_ownerIconView sd_setImageWithURL:[_curComment.author.avatar urlImageWithCodePathResizeToView:_ownerIconView] placeholderImage:kPlaceholderMonkeyRoundWidth(33.0)];
106126
NSString *contentStr = _curComment.content;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//
2+
// HtmlMediaViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 2016年11月4日.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
#import "HtmlMedia.h"
11+
12+
@interface HtmlMediaViewController : BaseViewController
13+
+ (instancetype)instanceWithHtmlMedia:(HtmlMedia *)htmlMedia title:(NSString *)title;
14+
@end
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//
2+
// HtmlMediaViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 2016年11月4日.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "HtmlMediaViewController.h"
10+
#import "WebContentManager.h"
11+
12+
@interface HtmlMediaViewController ()<UIWebViewDelegate>
13+
@property (strong, nonatomic) UIWebView *webContentView;
14+
@property (strong, nonatomic) UIActivityIndicatorView *activityIndicator;
15+
16+
@property (strong, nonatomic) HtmlMedia *htmlMedia;
17+
@end
18+
19+
@implementation HtmlMediaViewController
20+
+ (instancetype)instanceWithHtmlMedia:(HtmlMedia *)htmlMedia title:(NSString *)title{
21+
HtmlMediaViewController *vc = [self new];
22+
vc.htmlMedia = htmlMedia;
23+
vc.title = title ?: @"评论详情";
24+
return vc;
25+
}
26+
27+
- (void)viewDidLoad {
28+
[super viewDidLoad];
29+
// Do any additional setup after loading the view.
30+
self.view.backgroundColor = kColorTableBG;
31+
{//用webView显示内容
32+
_webContentView = [[UIWebView alloc] initWithFrame:self.view.bounds];
33+
_webContentView.delegate = self;
34+
_webContentView.backgroundColor = [UIColor clearColor];
35+
_webContentView.opaque = NO;
36+
_webContentView.scalesPageToFit = YES;
37+
[self.view addSubview:_webContentView];
38+
//webview加载指示
39+
_activityIndicator = [[UIActivityIndicatorView alloc]
40+
initWithActivityIndicatorStyle:
41+
UIActivityIndicatorViewStyleGray];
42+
_activityIndicator.hidesWhenStopped = YES;
43+
[_activityIndicator setCenter:CGPointMake(CGRectGetWidth(_webContentView.frame)/2, CGRectGetHeight(_webContentView.frame)/2)];
44+
[_webContentView addSubview:_activityIndicator];
45+
[_webContentView mas_makeConstraints:^(MASConstraintMaker *make) {
46+
make.edges.equalTo(self.view);
47+
}];
48+
}
49+
NSString *contentStr = [WebContentManager markdownPatternedWithContent:_htmlMedia.contentOrigional];
50+
[self.webContentView loadHTMLString:contentStr baseURL:nil];
51+
}
52+
53+
#pragma mark UIWebViewDelegate
54+
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
55+
DebugLog(@"strLink=[%@]",request.URL.absoluteString);
56+
UIViewController *vc = [BaseViewController analyseVCFromLinkStr:request.URL.absoluteString];
57+
if (vc) {
58+
[self.navigationController pushViewController:vc animated:YES];
59+
return NO;
60+
}
61+
return YES;
62+
}
63+
- (void)webViewDidStartLoad:(UIWebView *)webView{
64+
[_activityIndicator startAnimating];
65+
}
66+
- (void)webViewDidFinishLoad:(UIWebView *)webView{
67+
[_activityIndicator stopAnimating];
68+
}
69+
70+
@end

‎Coding_iOS/Controllers/RootControllers/BaseViewController.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
+ (void)presentLinkStr:(NSString *)linkStr;
1919
+ (UIViewController *)presentingVC;
2020
+ (void)presentVC:(UIViewController *)viewController;
21+
+ (void)goToVC:(UIViewController *)viewController;
2122
@end

‎Coding_iOS/Controllers/RootControllers/BaseViewController.m‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,15 @@ + (void)presentVC:(UIViewController *)viewController{
421421
}
422422
[[self presentingVC] presentViewController:nav animated:YES completion:nil];
423423
}
424+
+ (void)goToVC:(UIViewController *)viewController{
425+
if (!viewController) {
426+
return;
427+
}
428+
UINavigationController *nav = [self presentingVC].navigationController;
429+
if (nav) {
430+
[nav pushViewController:viewController animated:YES];
431+
}
432+
}
424433

425434
#pragma mark Login
426435
- (void)loginOutToLoginVC{

‎Coding_iOS/Models/Commit.m‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ - (void)setShort_message:(NSString *)short_message{
2222
_short_message = short_message;
2323
return;
2424
}
25-
HtmlMedia *htmlHedia = [HtmlMedia htmlMediaWithString:short_message showType:MediaShowTypeCode];
25+
HtmlMedia *htmlHedia = [HtmlMedia htmlMediaWithString:short_message showType:MediaShowTypeNone];
2626
_short_message = htmlHedia.contentDisplay;
2727
}
2828

2929
@end
3030

3131
@implementation Committer
3232

33-
@end
33+
@end

‎Coding_iOS/Models/FileComment.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@implementation FileComment
1212
- (void)setContent:(NSString *)content{
1313
if (_content != content) {
14-
_htmlMedia = [HtmlMedia htmlMediaWithString:content showType:MediaShowTypeCode];
14+
_htmlMedia = [HtmlMedia htmlMediaWithString:content showType:MediaShowTypeNone];
1515
_content = _htmlMedia.contentDisplay;
1616
}
1717
}

‎Coding_iOS/Models/HtmlMedia.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef NS_ENUM(NSInteger, MediaShowType) {
3838
@property (readwrite, nonatomic, strong) NSMutableArray *mediaItems;
3939
@property (strong, nonatomic) NSArray *imageItems;
4040
- (void)removeItem:(HtmlMediaItem *)item;
41-
41+
- (BOOL)needToShowDetail;
4242
+ (instancetype)htmlMediaWithString:(NSString *)htmlString showType:(MediaShowType)showType;
4343
- (instancetype)initWithString:(NSString *)htmlString showType:(MediaShowType)showType;
4444

@@ -63,4 +63,4 @@ typedef NS_ENUM(NSInteger, MediaShowType) {
6363

6464
- (NSString *)displayStr;
6565
- (BOOL)isGif;
66-
@end
66+
@end

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /