Skip to content

Commit 527e54c

Browse files
committed
讨论改版-0.1
1 parent 5d42cde commit 527e54c

17 files changed

Lines changed: 149 additions & 89 deletions

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@
332332
8E9866C2198E416C00ABFFA0 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E9866C1198E416C00ABFFA0 /* CoreText.framework */; };
333333
8EA6D12819E240C40076D59C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EA6CF1619E240C40076D59C /* AppDelegate.m */; };
334334
8EA6D12A19E240C40076D59C /* Coding_iOS.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 8EA6CF1919E240C40076D59C /* Coding_iOS.xcdatamodeld */; };
335-
8EA6D12C19E240C40076D59C /* AddTopicViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EA6CF1F19E240C40076D59C /* AddTopicViewController.m */; };
335+
8EA6D12C19E240C40076D59C /* EditTopicViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EA6CF1F19E240C40076D59C /* EditTopicViewController.m */; };
336336
8EA6D12D19E240C40076D59C /* ConversationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EA6CF2119E240C40076D59C /* ConversationViewController.m */; };
337337
8EA6D12E19E240C40076D59C /* EditTaskViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EA6CF2319E240C40076D59C /* EditTaskViewController.m */; };
338338
8EA6D13019E240C40076D59C /* LikersViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EA6CF2719E240C40076D59C /* LikersViewController.m */; };
@@ -1034,8 +1034,8 @@
10341034
8EA6CF1719E240C40076D59C /* Coding_iOS-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Coding_iOS-Info.plist"; sourceTree = "<group>"; };
10351035
8EA6CF1819E240C40076D59C /* Coding_iOS-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Coding_iOS-Prefix.pch"; sourceTree = "<group>"; };
10361036
8EA6CF1A19E240C40076D59C /* Coding_iOS.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Coding_iOS.xcdatamodel; sourceTree = "<group>"; };
1037-
8EA6CF1E19E240C40076D59C /* AddTopicViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AddTopicViewController.h; sourceTree = "<group>"; };
1038-
8EA6CF1F19E240C40076D59C /* AddTopicViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AddTopicViewController.m; sourceTree = "<group>"; };
1037+
8EA6CF1E19E240C40076D59C /* EditTopicViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditTopicViewController.h; sourceTree = "<group>"; };
1038+
8EA6CF1F19E240C40076D59C /* EditTopicViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EditTopicViewController.m; sourceTree = "<group>"; };
10391039
8EA6CF2019E240C40076D59C /* ConversationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConversationViewController.h; sourceTree = "<group>"; };
10401040
8EA6CF2119E240C40076D59C /* ConversationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConversationViewController.m; sourceTree = "<group>"; };
10411041
8EA6CF2219E240C40076D59C /* EditTaskViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditTaskViewController.h; sourceTree = "<group>"; };
@@ -2155,8 +2155,8 @@
21552155
8EA6CF2819E240C40076D59C /* Login */,
21562156
8EA6CF3219E240C40076D59C /* RootControllers */,
21572157
8E1C3DF919E8DFE300EF3032 /* MeSetting */,
2158-
8EA6CF1E19E240C40076D59C /* AddTopicViewController.h */,
2159-
8EA6CF1F19E240C40076D59C /* AddTopicViewController.m */,
2158+
8EA6CF1E19E240C40076D59C /* EditTopicViewController.h */,
2159+
8EA6CF1F19E240C40076D59C /* EditTopicViewController.m */,
21602160
8EA6CF2019E240C40076D59C /* ConversationViewController.h */,
21612161
8EA6CF2119E240C40076D59C /* ConversationViewController.m */,
21622162
8EA6CF2219E240C40076D59C /* EditTaskViewController.h */,
@@ -3264,7 +3264,7 @@
32643264
4E87656A1A22E5B40090CFB9 /* SWUtilityButtonView.m in Sources */,
32653265
8EABE3C819F10D2400A17784 /* TaskComment.m in Sources */,
32663266
8E97CE471A0A2DF8006F9AD7 /* AGEmojiKeyBoardView.m in Sources */,
3267-
8EA6D12C19E240C40076D59C /* AddTopicViewController.m in Sources */,
3267+
8EA6D12C19E240C40076D59C /* EditTopicViewController.m in Sources */,
32683268
4EA7F15B1A6D192B00A046BD /* SDWebImageCompat.m in Sources */,
32693269
8EA6D13A19E240C40076D59C /* Project_RootViewController.m in Sources */,
32703270
4E3AD3D51A273A4A005C749B /* UIButton+PPiAwesome.m in Sources */,

Coding_iOS/Controllers/AddTopicViewController.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

Coding_iOS/Controllers/EditTaskViewController.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
typedef NS_ENUM(NSInteger, TaskEditType) {
1515
TaskEditTypeAdd = 0,
16-
TaskEditTypeChange,
17-
TaskEditTypeDelete
16+
TaskEditTypeModify,
1817
};
1918

2019
@interface EditTaskViewController : BaseViewController<UITableViewDataSource, UITableViewDelegate, UIMessageInputViewDelegate>

Coding_iOS/Controllers/EditTaskViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ - (void)doneBtnClicked{
230230
_myTask.owner = _myCopyTask.owner;
231231
_myTask.status = _myCopyTask.status;
232232
if (_taskChangedBlock) {
233-
_taskChangedBlock(_myTask, TaskEditTypeChange);
233+
_taskChangedBlock(_myTask, TaskEditTypeModify);
234234
}
235235
[self.navigationController popViewControllerAnimated:YES];
236236
}else{
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// EditTopicViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by 王 原闯 on 14-8-27.
6+
// Copyright (c) 2014年 Coding. All rights reserved.
7+
//
8+
9+
#import "BaseViewController.h"
10+
#import "Projects.h"
11+
12+
typedef NS_ENUM(NSInteger, TopicEditType) {
13+
TopicEditTypeAdd = 0,
14+
TopicEditTypeModify,
15+
TopicEditTypeFeedBack
16+
};
17+
18+
@interface EditTopicViewController : BaseViewController
19+
20+
@property (strong, nonatomic) ProjectTopic *myProTopic;
21+
@property (nonatomic, assign) TopicEditType type;
22+
23+
@property (copy, nonatomic) void(^topicChangedBlock)(ProjectTopic *curTopic, TopicEditType type);
24+
25+
@end

Coding_iOS/Controllers/AddTopicViewController.m renamed to Coding_iOS/Controllers/EditTopicViewController.m

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
//
2-
// AddTopicViewController.m
2+
// EditTopicViewController.m
33
// Coding_iOS
44
//
55
// Created by 王 原闯 on 14-8-27.
66
// Copyright (c) 2014年 Coding. All rights reserved.
77
//
88

9-
#import "AddTopicViewController.h"
9+
#import "EditTopicViewController.h"
1010
#import "ProjectTopic.h"
1111
#import "Coding_NetAPIManager.h"
1212
#import "EaseMarkdownTextView.h"
1313
#import "WebContentManager.h"
1414

15-
@interface AddTopicViewController ()<UIWebViewDelegate>
16-
@property (strong, nonatomic) ProjectTopic *myProTopic;
15+
@interface EditTopicViewController ()<UIWebViewDelegate>
1716

1817

1918
@property (strong, nonatomic) UISegmentedControl *segmentedControl;
@@ -29,7 +28,7 @@ @interface AddTopicViewController ()<UIWebViewDelegate>
2928

3029
@end
3130

32-
@implementation AddTopicViewController
31+
@implementation EditTopicViewController
3332

3433
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
3534
{
@@ -45,8 +44,6 @@ - (void)viewDidLoad
4544
[super viewDidLoad];
4645
// Do any additional setup after loading the view.
4746

48-
self.myProTopic = [ProjectTopic topicWithPro:self.curProject];
49-
5047
if (!_segmentedControl) {
5148
_segmentedControl = ({
5249
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:@[@"编辑", @"预览"]];
@@ -68,7 +65,7 @@ - (void)viewDidLoad
6865
self.navigationItem.titleView = _segmentedControl;
6966
}
7067

71-
[self.navigationItem setRightBarButtonItem:[UIBarButtonItem itemWithBtnTitle:@"完成" target:self action:@selector(saveBtnClicked)] animated:YES];
68+
[self.navigationItem setRightBarButtonItem:[UIBarButtonItem itemWithBtnTitle:self.type == TopicEditTypeFeedBack? @"发送": @"完成" target:self action:@selector(saveBtnClicked)] animated:YES];
7269
self.navigationItem.rightBarButtonItem.enabled = NO;
7370

7471

@@ -82,7 +79,6 @@ - (void)viewDidLoad
8279
}];
8380

8481
self.curIndex = 0;
85-
8682
}
8783

8884
- (void)didReceiveMemoryWarning
@@ -145,8 +141,8 @@ - (void)loadEditView{
145141
make.edges.equalTo(self.view);
146142
}];
147143
[_inputTitleView mas_makeConstraints:^(MASConstraintMaker *make) {
148-
make.top.equalTo(_editView.mas_top).offset(20.0);
149-
make.height.mas_equalTo(20);
144+
make.top.equalTo(_editView.mas_top).offset(10.0);
145+
make.height.mas_equalTo(30);
150146

151147
make.left.equalTo(_editView).offset(kPaddingLeftWidth);
152148
make.right.equalTo(_editView).offset(-kPaddingLeftWidth);
@@ -163,14 +159,18 @@ - (void)loadEditView{
163159
}];
164160

165161
//内容
162+
@weakify(self);
166163
RAC(self.navigationItem.rightBarButtonItem, enabled) = [RACSignal combineLatest:@[self.inputTitleView.rac_textSignal, self.inputContentView.rac_textSignal] reduce:^id (NSString *title, NSString *content){
164+
@strongify(self);
167165
BOOL enabled = ([title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length > 0
168-
&& [content stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length > 0);
166+
&& [content stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]].length > 0
167+
&& ![title isEqualToString:self.myProTopic.mdTitle]
168+
&& ![content isEqualToString:self.myProTopic.mdContent]);
169169
return @(enabled);
170170
}];
171-
_inputTitleView.placeholder = @"讨论标题";
171+
_inputTitleView.placeholder = self.type == TopicEditTypeFeedBack? @"反馈标题": @"讨论标题";
172172
[_inputTitleView setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
173-
_inputContentView.placeholder = @"讨论内容";
173+
_inputContentView.placeholder = self.type == TopicEditTypeFeedBack? @"反馈内容": @"讨论内容";
174174
}
175175
_editView.hidden = NO;
176176
_preview.hidden = YES;
@@ -206,7 +206,7 @@ - (void)loadPreview{
206206
}
207207

208208
- (void)previewLoadMDData{
209-
NSString *mdStr = [NSString stringWithFormat:@"# %@\n\n%@", _inputTitleView.text, _inputContentView.text];
209+
NSString *mdStr = [NSString stringWithFormat:@"# %@\n%@", _inputTitleView.text, _inputContentView.text];
210210
[_activityIndicator startAnimating];
211211

212212
@weakify(self);
@@ -221,23 +221,37 @@ - (void)previewLoadMDData{
221221
#pragma mark nav_btn
222222

223223
- (void)saveBtnClicked{
224-
self.myProTopic.title = _inputTitleView.text;
225-
self.myProTopic.content = _inputContentView.text;
226-
227-
if (_myProTopic.title.length <= 0 || _myProTopic.htmlMedia.contentOrigional <= 0) {
228-
kTipAlert(@"至少写点什么吖");
229-
return;
224+
self.myProTopic.mdTitle = _inputTitleView.text;
225+
self.myProTopic.mdContent = _inputContentView.text;
226+
if (self.type == TopicEditTypeModify) {
227+
self.navigationItem.rightBarButtonItem.enabled = NO;
228+
@weakify(self);
229+
[[Coding_NetAPIManager sharedManager] request_ModifyProjectTpoic:self.myProTopic andBlock:^(id data, NSError *error) {
230+
@strongify(self);
231+
self.navigationItem.rightBarButtonItem.enabled = YES;
232+
if (data) {
233+
if (self.topicChangedBlock) {
234+
self.topicChangedBlock(data, self.type);
235+
}
236+
[self.navigationController popViewControllerAnimated:YES];
237+
}
238+
}];
239+
}else{
240+
self.navigationItem.rightBarButtonItem.enabled = NO;
241+
@weakify(self);
242+
[[Coding_NetAPIManager sharedManager] request_AddProjectTpoic:self.myProTopic andBlock:^(id data, NSError *error) {
243+
@strongify(self);
244+
self.navigationItem.rightBarButtonItem.enabled = YES;
245+
if (data) {
246+
if (self.topicChangedBlock) {
247+
self.topicChangedBlock(data, self.type);
248+
}
249+
[self.navigationController popViewControllerAnimated:YES];
250+
}
251+
}];
230252
}
231-
self.navigationItem.rightBarButtonItem.enabled = NO;
232-
[[Coding_NetAPIManager sharedManager] request_AddProjectTpoic:self.myProTopic andBlock:^(id data, NSError *error) {
233-
self.navigationItem.rightBarButtonItem.enabled = YES;
234-
if (data) {
235-
self.myProTopic = data;
236-
[self.navigationController popViewControllerAnimated:YES];
237-
}
238-
}];
239-
}
240253

254+
}
241255

242256
#pragma mark UIWebViewDelegate
243257
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{

Coding_iOS/Controllers/MeSetting/FeedbackViewController.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ - (void)didReceiveMemoryWarning
8080
}
8181

8282
- (void)feedbackBtnClicked:(id)sender{
83-
self.myProTopic.title = _inputTitleView.text;
84-
self.myProTopic.content = _inputContentView.text;
83+
self.myProTopic.mdTitle = _inputTitleView.text;
84+
self.myProTopic.mdContent = _inputContentView.text;
8585

86-
if (_myProTopic.title.length <= 0 || _myProTopic.htmlMedia.contentOrigional <= 0) {
86+
if (_myProTopic.mdTitle.length <= 0 || _myProTopic.mdContent <= 0) {
8787
kTipAlert(@"至少写点什么吖");
8888
return;
8989
}

Coding_iOS/Controllers/ProjectViewController.m

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#import "EditTaskViewController.h"
1414
#import "ProjectTopicsView.h"
1515
#import "ProjectMemberListViewController.h"
16-
#import "AddTopicViewController.h"
16+
#import "EditTopicViewController.h"
1717
#import "TopicDetailViewController.h"
1818
#import "ConversationViewController.h"
1919
#import "Coding_NetAPIManager.h"
@@ -89,7 +89,16 @@ - (void)didReceiveMemoryWarning
8989
}
9090
- (void)viewWillAppear:(BOOL)animated{
9191
[super viewWillAppear:animated];
92+
[self refreshToQueryData];
93+
}
94+
95+
- (void)refreshToQueryData{
9296
UIView *curView = [self getCurContentView];
97+
if (curView && [curView respondsToSelector:@selector(refreshToQueryData)]) {
98+
[curView performSelector:@selector(refreshToQueryData)];
99+
}
100+
101+
93102
if ([curView isKindOfClass:[ProjectTasksView class]]) {
94103
ProjectTasksView *tasksView = (ProjectTasksView *)curView;
95104
[tasksView refreshToQueryData];
@@ -100,6 +109,7 @@ - (void)viewWillAppear:(BOOL)animated{
100109
}
101110
}
102111

112+
103113
- (void)requestForMyProject{
104114
[self.view beginLoading];
105115
__weak typeof(self) weakSelf = self;
@@ -221,9 +231,6 @@ - (void)refreshWithViewType:(ProjectViewType)viewType{
221231
DebugLog(@"%@--\nProjectTopic:%@", projectTopicListView, projectTopic.title);
222232
TopicDetailViewController *vc = [[TopicDetailViewController alloc] init];
223233
vc.curTopic = projectTopic;
224-
vc.deleteTopicBlock = ^(ProjectTopic *curTopic){
225-
[projectTopicListView reloadQueryData];
226-
};
227234
[weakSelf.navigationController pushViewController:vc animated:YES];
228235
} defaultIndex:0];
229236
}
@@ -427,8 +434,12 @@ - (void)navAddBtnClicked{
427434
break;
428435
case ProjectViewTypeTopics:
429436
{
430-
AddTopicViewController *vc = [[AddTopicViewController alloc] init];
431-
vc.curProject = self.myProject;
437+
EditTopicViewController *vc = [[EditTopicViewController alloc] init];
438+
vc.myProTopic = [ProjectTopic topicWithPro:self.myProject];
439+
vc.type = TopicEditTypeAdd;
440+
vc.topicChangedBlock = ^(ProjectTopic *topic, TopicEditType type){
441+
442+
};
432443
[self.navigationController pushViewController:vc animated:YES];
433444
}
434445
break;

Coding_iOS/Models/ProjectTopic.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@
2727
@property (readwrite, nonatomic, strong) HtmlMedia *htmlMedia;
2828
@property (assign, nonatomic) CGFloat contentHeight;
2929

30+
@property (strong, nonatomic) NSString *mdTitle, *mdContent;
31+
3032
@property (readwrite, nonatomic, strong) NSNumber *page, *pageSize, *totalPage, *totalRow;
3133
@property (assign, nonatomic) BOOL canLoadMore, willLoadMore, isLoading, isTopicLoading, isTopicEditLoading;
3234

35+
+ (ProjectTopic *)feedbackTopic;
3336
+ (ProjectTopic *)topicWithPro:(Project *)pro;
3437
+ (ProjectTopic *)topicWithId:(NSNumber *)topicId;
3538
- (NSString *)toTopicPath;
36-
- (NSDictionary *)toTopicParams;
37-
- (NSDictionary *)toTopicEditParams;
39+
40+
- (NSDictionary *)toEditParams;
3841

3942
- (NSString *)toAddTopicPath;
4043
- (NSDictionary *)toAddTopicParams;

0 commit comments

Comments
 (0)