Skip to content

Commit 3602c7a

Browse files
committed
优化UI + 重构代码
1 parent 4dc3931 commit 3602c7a

11 files changed

Lines changed: 336 additions & 424 deletions

File tree

Coding_iOS.xcodeproj/project.pbxproj

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
4E6D71891A75F00E005AD988 /* YLGIFImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E6D71861A75F00E005AD988 /* YLGIFImage.m */; };
195195
4E6D718A1A75F00E005AD988 /* YLImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E6D71881A75F00E005AD988 /* YLImageView.m */; };
196196
4E6FB0551B5799B100B0A17B /* ProjectTag.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E6FB0541B5799B100B0A17B /* ProjectTag.m */; };
197+
4E6FB0581B58DB0A00B0A17B /* ProjectTagsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E6FB0571B58DB0A00B0A17B /* ProjectTagsView.m */; };
197198
4E72F82D1B144778001B6CE6 /* NSMutableString+Common.m in Sources */ = {isa = PBXBuildFile; fileRef = 4E72F82C1B144778001B6CE6 /* NSMutableString+Common.m */; };
198199
4E72F82F1B159997001B6CE6 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E72F82E1B159997001B6CE6 /* [email protected] */; };
199200
4E72F8331B15B811001B6CE6 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 4E72F8321B15B811001B6CE6 /* [email protected] */; };
@@ -761,8 +762,6 @@
761762
B9A00D821ACA3A17008BA008 /* ProjectSettingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B9A00D811ACA3A17008BA008 /* ProjectSettingViewController.m */; };
762763
B9A00D851ACA3A55008BA008 /* ProjectAdvancedSettingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B9A00D841ACA3A55008BA008 /* ProjectAdvancedSettingViewController.m */; };
763764
E7A046A01A47279E00528C12 /* Helper.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A0469F1A47279E00528C12 /* Helper.m */; };
764-
EBDD2E411AE7B88C0024B952 /* WMDelLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = EBDD2E401AE7B88C0024B952 /* WMDelLabel.m */; };
765-
EBDD2E4E1AEA159D0024B952 /* ProjectTopicLabelView.m in Sources */ = {isa = PBXBuildFile; fileRef = EBDD2E4D1AEA159D0024B952 /* ProjectTopicLabelView.m */; };
766765
/* End PBXBuildFile section */
767766

768767
/* Begin PBXFileReference section */
@@ -1055,6 +1054,8 @@
10551054
4E6D71881A75F00E005AD988 /* YLImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YLImageView.m; sourceTree = "<group>"; };
10561055
4E6FB0531B5799B100B0A17B /* ProjectTag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectTag.h; sourceTree = "<group>"; };
10571056
4E6FB0541B5799B100B0A17B /* ProjectTag.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectTag.m; sourceTree = "<group>"; };
1057+
4E6FB0561B58DB0A00B0A17B /* ProjectTagsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectTagsView.h; sourceTree = "<group>"; };
1058+
4E6FB0571B58DB0A00B0A17B /* ProjectTagsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectTagsView.m; sourceTree = "<group>"; };
10581059
4E72F82B1B144778001B6CE6 /* NSMutableString+Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableString+Common.h"; sourceTree = "<group>"; };
10591060
4E72F82C1B144778001B6CE6 /* NSMutableString+Common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSMutableString+Common.m"; sourceTree = "<group>"; };
10601061
4E72F82E1B159997001B6CE6 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
@@ -1929,10 +1930,6 @@
19291930
C613B8719C3D38FED828A1E2 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
19301931
E7A0469E1A47279E00528C12 /* Helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Helper.h; sourceTree = "<group>"; };
19311932
E7A0469F1A47279E00528C12 /* Helper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Helper.m; sourceTree = "<group>"; };
1932-
EBDD2E3F1AE7B88C0024B952 /* WMDelLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMDelLabel.h; sourceTree = "<group>"; };
1933-
EBDD2E401AE7B88C0024B952 /* WMDelLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMDelLabel.m; sourceTree = "<group>"; };
1934-
EBDD2E4C1AEA159D0024B952 /* ProjectTopicLabelView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProjectTopicLabelView.h; sourceTree = "<group>"; };
1935-
EBDD2E4D1AEA159D0024B952 /* ProjectTopicLabelView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProjectTopicLabelView.m; sourceTree = "<group>"; };
19361933
/* End PBXFileReference section */
19371934

19381935
/* Begin PBXFrameworksBuildPhase section */
@@ -3549,7 +3546,6 @@
35493546
4E94C50F1B4E0C0300EB668A /* XHRealTimeBlur */,
35503547
4E94C4F51B4D2B9300EB668A /* PopMenu */,
35513548
4E53EB4C1AF9CC520034FE1C /* RKSwipeBetweenViewControllers */,
3552-
EBDD2E3E1AE7B84D0024B952 /* WMDelLabel */,
35533549
4E996BC11ABA754600C704F1 /* JDStatusBarNotification */,
35543550
4E6C411A1A846AC30098DC17 /* RFKeyboardToolbar */,
35553551
4E6D71841A75F00E005AD988 /* YLGIFImage */,
@@ -3649,8 +3645,8 @@
36493645
8EA6D0FA19E240C40076D59C /* ProjectTopicsView.m */,
36503646
8EA6D0F719E240C40076D59C /* ProjectTopicListView.h */,
36513647
8EA6D0F819E240C40076D59C /* ProjectTopicListView.m */,
3652-
EBDD2E4C1AEA159D0024B952 /* ProjectTopicLabelView.h */,
3653-
EBDD2E4D1AEA159D0024B952 /* ProjectTopicLabelView.m */,
3648+
4E6FB0561B58DB0A00B0A17B /* ProjectTagsView.h */,
3649+
4E6FB0571B58DB0A00B0A17B /* ProjectTagsView.m */,
36543650
8E59F0EC1A00F34E009A905F /* ProjectCodeListView.h */,
36553651
8E59F0ED1A00F34E009A905F /* ProjectCodeListView.m */,
36563652
8E59F0EF1A00F38A009A905F /* ProjectFolderListView.h */,
@@ -3891,15 +3887,6 @@
38913887
path = ProjectSetting;
38923888
sourceTree = "<group>";
38933889
};
3894-
EBDD2E3E1AE7B84D0024B952 /* WMDelLabel */ = {
3895-
isa = PBXGroup;
3896-
children = (
3897-
EBDD2E3F1AE7B88C0024B952 /* WMDelLabel.h */,
3898-
EBDD2E401AE7B88C0024B952 /* WMDelLabel.m */,
3899-
);
3900-
path = WMDelLabel;
3901-
sourceTree = "<group>";
3902-
};
39033890
/* End PBXGroup section */
39043891

39053892
/* Begin PBXNativeTarget section */
@@ -4370,7 +4357,6 @@
43704357
4E4D6A581B1C5DC000FD2E49 /* MRPRCommentCell.m in Sources */,
43714358
B94C1B6E1AC98CCE0000C271 /* NewProjectTypeViewController.m in Sources */,
43724359
4E96E7BB1A1B25D40037C098 /* DirectoryWatcher.m in Sources */,
4373-
EBDD2E4E1AEA159D0024B952 /* ProjectTopicLabelView.m in Sources */,
43744360
4ED673221A8E0ECC00DF2D1A /* SVWebViewControllerActivityReport.m in Sources */,
43754361
4E6BA2E41A1EE6AF005FD721 /* UIButton+AFNetworking.m in Sources */,
43764362
8EF643C919FF7E2900F7EEB0 /* TopicCommentCell.m in Sources */,
@@ -4620,7 +4606,6 @@
46204606
3A38783A1AE2949E0078D5DE /* ResetLabelViewController.m in Sources */,
46214607
8EA6D13C19E240C40076D59C /* Tweet_RootViewController.m in Sources */,
46224608
B93D904B1ACBA3110057A6EE /* ProjectDeleteAlertControllerVisualStyle.m in Sources */,
4623-
EBDD2E411AE7B88C0024B952 /* WMDelLabel.m in Sources */,
46244609
4E1A22851AB172C400CFC14F /* ProjectItemsCell.m in Sources */,
46254610
4ECE8B051A3946C10021E29C /* WebContentManager.m in Sources */,
46264611
4E94C4F41B4D007600EB668A /* Login2FATipCell.m in Sources */,
@@ -4735,6 +4720,7 @@
47354720
4ECF70431B18514F000280FF /* MRPRListViewController.m in Sources */,
47364721
4E969CD01AF0EB87005C0CCE /* NSTimer+Common.m in Sources */,
47374722
8EF643B019FF7E2900F7EEB0 /* CodingTipCell.m in Sources */,
4723+
4E6FB0581B58DB0A00B0A17B /* ProjectTagsView.m in Sources */,
47384724
8EA6D1BA19E240C40076D59C /* Projects.m in Sources */,
47394725
4E996BDF1ABA7CE100C704F1 /* UserInfoDetailUserCell.m in Sources */,
47404726
4EACB4461A2C60110097ABB3 /* ProjectActivities.m in Sources */,

Coding_iOS/Controllers/EditTopicViewController.m

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#import "EditLabelViewController.h"
1515
#import "TopicPreviewCell.h"
1616
#import "ProjectTag.h"
17-
#import "ProjectTopicLabelView.h"
17+
#import "ProjectTagsView.h"
1818

1919
@interface EditTopicViewController ()<UIWebViewDelegate, UITableViewDataSource, UITableViewDelegate>
2020

@@ -29,8 +29,7 @@ @interface EditTopicViewController ()<UIWebViewDelegate, UITableViewDataSource,
2929

3030
@property (strong, nonatomic) UIView *lineView;
3131

32-
@property (strong, nonatomic) ProjectTopicLabelView *labelView;
33-
@property (strong, nonatomic) UIButton *labelAddBtn;
32+
@property (strong, nonatomic) ProjectTagsView *tagsView;
3433

3534
@end
3635

@@ -127,17 +126,21 @@ - (void)setCurIndex:(NSInteger)curIndex
127126

128127
- (void)loadLabelView
129128
{
130-
if (_labelView) {
131-
[_labelView removeFromSuperview];
129+
if (!_tagsView) {
130+
_tagsView = [ProjectTagsView viewWithTags:_curProTopic.mdLabels];
131+
[self.editView addSubview:_tagsView];
132+
}else{
133+
_tagsView.tags = _curProTopic.mdLabels;
132134
}
133-
_labelView = [[ProjectTopicLabelView alloc] initWithFrame:CGRectZero projectTopic:_curProTopic md:YES];
134135
__weak typeof(self) weakSelf = self;
135-
_labelView.delLabelBlock = ^(NSInteger index){
136-
[weakSelf.curProTopic.mdLabels removeObjectAtIndex:index];
136+
_tagsView.deleteTagBlock = ^(ProjectTag *curTag){
137+
[weakSelf.curProTopic.mdLabels removeObject:curTag];
137138
[weakSelf loadEditView];
138139
weakSelf.navigationItem.rightBarButtonItem.enabled = YES;
139140
};
140-
[_editView insertSubview:_labelView belowSubview:_labelAddBtn];
141+
_tagsView.addTagBlock = ^(){
142+
[weakSelf addtitleBtnClick];
143+
};
141144
}
142145

143146
- (void)loadEditView
@@ -152,14 +155,6 @@ - (void)loadEditView
152155
_inputTitleView.attributedPlaceholder = [[NSAttributedString alloc] initWithString:(self.type == TopicEditTypeFeedBack ? @"反馈标题" : @"讨论标题") attributes:@{NSForegroundColorAttributeName : [UIColor lightGrayColor]}];
153156
[_editView addSubview:_inputTitleView];
154157

155-
if (self.type != TopicEditTypeFeedBack) {
156-
_labelAddBtn = [[UIButton alloc] initWithFrame:CGRectZero];
157-
[_labelAddBtn setImage:[UIImage imageNamed:@"tag_add"] forState:UIControlStateNormal];
158-
[_labelAddBtn setImageEdgeInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
159-
[_labelAddBtn addTarget:self action:@selector(addtitleBtnClick) forControlEvents:UIControlEventTouchUpInside];
160-
[_editView addSubview:_labelAddBtn];
161-
}
162-
163158
_lineView = [[UIView alloc] initWithFrame:CGRectZero];
164159
_lineView.backgroundColor = kColorTableSectionBg;
165160
[_editView addSubview:_lineView];
@@ -212,24 +207,16 @@ - (void)loadEditView
212207

213208
if (self.type != TopicEditTypeFeedBack) {
214209
// 标签
215-
[_labelView mas_makeConstraints:^(MASConstraintMaker *make) {
210+
CGFloat tagsViewHeight = [ProjectTagsView heghtForTags:_curProTopic.mdLabels];
211+
[_tagsView mas_makeConstraints:^(MASConstraintMaker *make) {
216212
make.top.equalTo(_inputTitleView.mas_bottom).offset(16.0);
217-
make.height.mas_equalTo(_labelView.labelH);
218-
219-
make.left.equalTo(_editView).offset(kPaddingLeftWidth);
220-
make.right.equalTo(_editView).offset(-kPaddingLeftWidth);
221-
}];
222-
223-
[_labelAddBtn mas_makeConstraints:^(MASConstraintMaker *make) {
224-
make.top.equalTo(_labelView.mas_top).offset(-10);
225-
make.right.equalTo(_editView);
213+
make.height.mas_equalTo(tagsViewHeight);
226214

227-
make.width.mas_equalTo(44);
228-
make.height.mas_equalTo(44);
215+
make.left.right.equalTo(_editView);
229216
}];
230217

231218
[_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
232-
make.top.equalTo(_labelView.mas_bottom).offset(12.0);
219+
make.top.equalTo(_tagsView.mas_bottom).offset(9.0);
233220
make.left.equalTo(_editView).offset(kPaddingLeftWidth);
234221
make.height.mas_equalTo(1.0);
235222
make.right.equalTo(_editView);

Coding_iOS/Util/OC_Category/UIView+PressMenu.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ @implementation UIView (PressMenu)
1717

1818
#pragma mark M
1919
- (void)addPressMenuTitles:(NSArray *)menuTitles menuClickedBlock:(void(^)(NSInteger index, NSString *title))block{
20+
self.userInteractionEnabled = YES;
2021
self.menuClickedBlock = block;
2122
self.menuTitles = menuTitles;
2223
if (self.pressGR == nil) {

Coding_iOS/Vendor/WMDelLabel/WMDelLabel.h

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

Coding_iOS/Vendor/WMDelLabel/WMDelLabel.m

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

0 commit comments

Comments
 (0)