Skip to content

Commit dc64309

Browse files
committed
一点点重构 UI
1 parent fd1dbe0 commit dc64309

39 files changed

+633
-91
lines changed

Coding_iOS.xcodeproj/project.pbxproj

+88-20
Large diffs are not rendered by default.

Coding_iOS/.DS_Store

0 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// HelpViewController.h
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 2016/9/8.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "WebViewController.h"
10+
11+
@interface HelpViewController : WebViewController
12+
+ (instancetype)vcWithHelpStr;
13+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// HelpViewController.m
3+
// Coding_iOS
4+
//
5+
// Created by Ease on 2016/9/8.
6+
// Copyright © 2016年 Coding. All rights reserved.
7+
//
8+
9+
#import "HelpViewController.h"
10+
#import "EditTopicViewController.h"
11+
12+
@implementation HelpViewController
13+
14+
+ (instancetype)vcWithHelpStr{
15+
NSString *curUrlStr = @"/help/doc/mobile/index.html";
16+
NSURL *curUrl = [NSURL URLWithString:curUrlStr relativeToURL:[NSURL URLWithString:[NSObject baseURLStr]]];
17+
return [[self alloc] initWithURL:curUrl];
18+
}
19+
20+
- (void)setTitle:(NSString *)title{
21+
[super setTitle:@"帮助中心"];
22+
}
23+
24+
- (void)viewDidLoad{
25+
[super viewDidLoad];
26+
27+
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"反馈" style:UIBarButtonItemStylePlain target:self action:@selector(goToFeedBack)] animated:YES];
28+
}
29+
30+
- (void)goToFeedBack{
31+
EditTopicViewController *vc = [[EditTopicViewController alloc] init];
32+
vc.curProTopic = [ProjectTopic feedbackTopic];
33+
vc.type = TopicEditTypeFeedBack;
34+
vc.topicChangedBlock = nil;
35+
[self.navigationController pushViewController:vc animated:YES];
36+
}
37+
@end

Coding_iOS/Controllers/ProjectListViewController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111

1212
@interface ProjectListViewController : Project_RootViewController
1313
@property (strong, nonatomic) User *curUser;
14-
14+
@property (assign, nonatomic) BOOL isFromMeRoot;
1515
@end

Coding_iOS/Controllers/ProjectListViewController.m

+12-15
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,28 @@ @implementation ProjectListViewController
1212
- (void)viewDidLoad {
1313
[super viewDidLoad];
1414
// Do any additional setup after loading the view.
15-
self.title = _curUser.name;
15+
self.title = _isFromMeRoot? @"我创建的": _curUser.name;
1616
self.icarouselScrollEnabled = YES;
1717
}
1818

1919

20-
-(void)viewWillAppear:(BOOL)animated
21-
{
20+
-(void)viewWillAppear:(BOOL)animated{
2221
[super viewWillAppear:animated];
2322
[self.mySearchBar removeFromSuperview];
2423
//重置titleview
2524
self.navigationItem.titleView=[[[[self.navigationController viewControllers] lastObject] navigationItem] titleView];
2625
}
2726

2827
- (void)setupNavBtn{
28+
self.navigationItem.leftBarButtonItem = nil;
29+
self.navigationItem.rightBarButtonItem = nil;
2930

30-
self.useNewStyle=FALSE;
31-
32-
[self.myCarousel mas_updateConstraints:^(MASConstraintMaker *make) {
33-
make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(kMySegmentControl_Height, 0, 0, 0));
34-
}];
35-
36-
37-
// 添加滑块
31+
self.useNewStyle = _isFromMeRoot;
32+
if (!_isFromMeRoot) {
33+
[self.myCarousel mas_updateConstraints:^(MASConstraintMaker *make) {
34+
make.edges.equalTo(self.view).insets(UIEdgeInsetsMake(kMySegmentControl_Height, 0, 0, 0));
35+
}];
36+
// 添加滑块
3837
__weak typeof(self.myCarousel) weakCarousel = self.myCarousel;
3938
self.mySegmentControl = [[XTSegmentControl alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kMySegmentControl_Height) Items:self.segmentItems selectedBlock:^(NSInteger index) {
4039
if (index == self.oldSelectedIndex) {
@@ -43,9 +42,7 @@ - (void)setupNavBtn{
4342
[weakCarousel scrollToItemAtIndex:index animated:NO];
4443
}];
4544
[self.view addSubview:self.mySegmentControl];
46-
47-
self.navigationItem.leftBarButtonItem = nil;
48-
self.navigationItem.rightBarButtonItem = nil;
45+
}
4946
}
5047

5148
- (void)configSegmentItems{
@@ -57,7 +54,7 @@ - (void)configSegmentItems{
5754
}
5855

5956
- (Projects *)projectsWithIndex:(NSUInteger)index{
60-
return [Projects projectsWithType:(index+ProjectsTypeTaProject) andUser:self.curUser];
57+
return [Projects projectsWithType:_isFromMeRoot? ProjectsTypeCreated:(index + ProjectsTypeTaProject) andUser:self.curUser];
6158
}
6259

6360
@end

Coding_iOS/Controllers/RootControllers/Me_RootViewController.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// Copyright (c) 2014年 Coding. All rights reserved.
77
//
88

9-
#import "UserInfoViewController.h"
9+
#import "BaseViewController.h"
1010

11-
@interface Me_RootViewController : UserInfoViewController
11+
@interface Me_RootViewController : BaseViewController
1212

1313
@end

Coding_iOS/Controllers/RootControllers/Me_RootViewController.m

+215
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,223 @@
77
//
88

99
#import "Me_RootViewController.h"
10+
#import "Coding_NetAPIManager.h"
11+
#import "UsersViewController.h"
12+
#import "AddUserViewController.h"
13+
#import "SettingViewController.h"
14+
#import "SettingMineInfoViewController.h"
15+
#import "UserInfoDetailViewController.h"
16+
#import "ProjectListViewController.h"
17+
#import "LocalFoldersViewController.h"
18+
#import "PointRecordsViewController.h"
19+
#import "AboutViewController.h"
20+
#import "HelpViewController.h"
21+
22+
#import "RDVTabBarController.h"
23+
#import "RDVTabBarItem.h"
24+
#import "ODRefreshControl.h"
25+
26+
#import "UserInfoIconCell.h"
27+
#import "MeRootUserCell.h"
28+
#import "MeRootServiceCell.h"
29+
30+
#import "ServiceInfo.h"
31+
32+
@interface Me_RootViewController ()<UITableViewDataSource, UITableViewDelegate>
33+
@property (strong, nonatomic) UITableView *myTableView;
34+
@property (nonatomic, strong) ODRefreshControl *refreshControl;
35+
36+
@property (strong, nonatomic) User *curUser;
37+
@property (strong, nonatomic) ServiceInfo *curServiceInfo;
38+
@end
1039

1140
@implementation Me_RootViewController
41+
- (void)viewDidLoad{
42+
[super viewDidLoad];
43+
// Do any additional setup after loading the view.
44+
self.title = @"";
45+
_curUser = [Login curLoginUser]? [Login curLoginUser]: [User userWithGlobalKey:@""];
46+
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"addUserBtn_Nav"] style:UIBarButtonItemStylePlain target:self action:@selector(goToAddUser)] animated:NO];
47+
48+
// 添加myTableView
49+
_myTableView = ({
50+
UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
51+
tableView.backgroundColor = kColorTableSectionBg;
52+
tableView.dataSource = self;
53+
tableView.delegate = self;
54+
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
55+
[tableView registerClass:[UserInfoIconCell class] forCellReuseIdentifier:kCellIdentifier_UserInfoIconCell];
56+
[tableView registerClass:[MeRootUserCell class] forCellReuseIdentifier:kCellIdentifier_MeRootUserCell];
57+
[tableView registerClass:[MeRootServiceCell class] forCellReuseIdentifier:kCellIdentifier_MeRootServiceCell];
58+
[self.view addSubview:tableView];
59+
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
60+
make.edges.equalTo(self.view);
61+
}];
62+
UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, CGRectGetHeight(self.rdv_tabBarController.tabBar.frame), 0);
63+
tableView.contentInset = insets;
64+
tableView.scrollIndicatorInsets = insets;
65+
tableView;
66+
});
67+
68+
_refreshControl = [[ODRefreshControl alloc] initInScrollView:self.myTableView];
69+
[_refreshControl addTarget:self action:@selector(refresh) forControlEvents:UIControlEventValueChanged];
70+
}
71+
72+
- (void)viewWillAppear:(BOOL)animated{
73+
[super viewWillAppear:animated];
74+
[self refresh];
75+
}
76+
77+
- (void)refresh{
78+
__weak typeof(self) weakSelf = self;
79+
[[Coding_NetAPIManager sharedManager] request_UserInfo_WithObj:_curUser andBlock:^(id data, NSError *error) {
80+
if (data) {
81+
weakSelf.curUser = data;
82+
[[Coding_NetAPIManager sharedManager] request_ServiceInfoBlock:^(id dataS, NSError *errorS) {
83+
if (dataS) {
84+
weakSelf.curServiceInfo = dataS;
85+
}
86+
[weakSelf.myTableView reloadData];
87+
[weakSelf.refreshControl endRefreshing];
88+
}];
89+
}else{
90+
[weakSelf.refreshControl endRefreshing];
91+
}
92+
}];
93+
}
94+
95+
#pragma mark Table M
96+
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
97+
return 3;
98+
}
99+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
100+
NSInteger row = (section ==0? 2:
101+
section == 1? 1:
102+
4);
103+
return row;
104+
}
105+
106+
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
107+
108+
if (indexPath.section == 0) {
109+
if (indexPath.row == 0) {
110+
MeRootUserCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_MeRootUserCell forIndexPath:indexPath];
111+
cell.curUser = _curUser;
112+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:0];
113+
return cell;
114+
}else{
115+
MeRootServiceCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_MeRootServiceCell forIndexPath:indexPath];
116+
cell.curServiceInfo = _curServiceInfo;
117+
ESWeak(self, weakSelf);
118+
cell.leftBlock = ^(){
119+
[weakSelf goToProjects];
120+
};
121+
cell.rightBlock = ^(){
122+
[weakSelf goToTeams];
123+
};
124+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:0];
125+
return cell;
126+
}
127+
}else{
128+
UserInfoIconCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_UserInfoIconCell forIndexPath:indexPath];
129+
(indexPath.section == 1? [cell setTitle:@"我的码币" icon:@"user_info_point"]:
130+
indexPath.row == 0? [cell setTitle:@"本地文件" icon:@"user_info_file"]:
131+
indexPath.row == 1? [cell setTitle:@"帮助与反馈" icon:@"user_info_help"]:
132+
indexPath.row == 2? [cell setTitle:@"设置" icon:@"user_info_setup"]:
133+
[cell setTitle:@"关于我们" icon:@"user_info_about"]);
134+
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
135+
return cell;
136+
}
137+
}
138+
139+
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
140+
CGFloat cellHeight = 0;
141+
if (indexPath.section == 0) {
142+
cellHeight = indexPath.row == 0? [MeRootUserCell cellHeight]: [MeRootServiceCell cellHeight];
143+
}else{
144+
cellHeight = [UserInfoIconCell cellHeight];
145+
}
146+
return cellHeight;
147+
}
148+
149+
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
150+
return 1.0/[UIScreen mainScreen].scale;
151+
}
152+
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
153+
return 20;
154+
}
155+
156+
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
157+
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, 20)];
158+
headerView.backgroundColor = kColorTableSectionBg;
159+
return headerView;
160+
}
161+
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
162+
[tableView deselectRowAtIndexPath:indexPath animated:YES];
163+
164+
if (indexPath.section == 0) {
165+
if (indexPath.row == 0) {//个人主页
166+
[self goToMeDisplay];
167+
}
168+
}else if (indexPath.section == 1){//我的码币
169+
[self goToPoint];
170+
}else{
171+
if (indexPath.row == 0) {//本地文件
172+
[self goToLocalFolders];
173+
}else if (indexPath.row == 1){//帮助与反馈
174+
[self goToHelp];
175+
}else if (indexPath.row == 2){//设置
176+
[self goToSetting];
177+
}else{//关于我们
178+
[self goToAbout];
179+
}
180+
}
181+
}
182+
183+
#pragma mark GoTo
184+
- (void)goToAddUser{
185+
AddUserViewController *vc = [[AddUserViewController alloc] init];
186+
vc.type = AddUserTypeFollow;
187+
[self.navigationController pushViewController:vc animated:YES];
188+
}
189+
190+
- (void)goToLocalFolders{
191+
LocalFoldersViewController *vc = [LocalFoldersViewController new];
192+
[self.navigationController pushViewController:vc animated:YES];
193+
}
194+
195+
- (void)goToPoint{
196+
PointRecordsViewController *vc = [PointRecordsViewController new];
197+
[self.navigationController pushViewController:vc animated:YES];
198+
}
199+
200+
- (void)goToSetting{
201+
SettingViewController *vc = [[SettingViewController alloc] init];
202+
vc.myUser = self.curUser;
203+
[self.navigationController pushViewController:vc animated:YES];
204+
}
205+
206+
- (void)goToHelp{
207+
[self.navigationController pushViewController:[HelpViewController vcWithHelpStr] animated:YES];
208+
}
209+
210+
- (void)goToAbout{
211+
[self.navigationController pushViewController:[AboutViewController new] animated:YES];
212+
}
213+
214+
- (void)goToProjects{
215+
ProjectListViewController *vc = [[ProjectListViewController alloc] init];
216+
vc.curUser = _curUser;
217+
vc.isFromMeRoot = YES;
218+
[self.navigationController pushViewController:vc animated:YES];
219+
}
220+
221+
- (void)goToTeams{
222+
223+
}
12224

225+
- (void)goToMeDisplay{
226+
227+
}
13228

14229
@end

Coding_iOS/Controllers/RootControllers/Project_RootViewController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
335335
}
336336
};
337337
//使用新系列Cell样式
338-
listView.useNewStyle=_useNewStyle;
338+
listView.useNewStyle = _useNewStyle;
339339
}
340340
[listView setSubScrollsToTop:(index == carousel.currentItemIndex)];
341341
return listView;

Coding_iOS/Controllers/RootControllers/RootTabViewController.m

-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ - (void)setupViewControllers {
9292
UINavigationController *nav_message = [[BaseNavigationController alloc] initWithRootViewController:message];
9393

9494
Me_RootViewController *me = [[Me_RootViewController alloc] init];
95-
me.isRoot = YES;
9695
UINavigationController *nav_me = [[BaseNavigationController alloc] initWithRootViewController:me];
9796

9897
[self setViewControllers:@[nav_project, nav_mytask, nav_tweet, nav_message, nav_me]];

Coding_iOS/Controllers/UserInfoViewController.m

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#import "UserInfoDetailViewController.h"
2020
#import "ProjectListViewController.h"
2121
#import "LocalFoldersViewController.h"
22-
#import "ReviewerListController.h"
2322

2423
#import "RDVTabBarController.h"
2524
#import "RDVTabBarItem.h"
@@ -44,8 +43,7 @@ @interface UserInfoViewController ()<UITableViewDataSource, UITableViewDelegate>
4443
@end
4544

4645
@implementation UserInfoViewController
47-
- (void)viewDidLoad
48-
{
46+
- (void)viewDidLoad{
4947
[super viewDidLoad];
5048
// Do any additional setup after loading the view.
5149
if (_isRoot) {
Loading
Loading
-660 Bytes
Loading
711 Bytes
Loading
1.53 KB
Loading
2.57 KB
Loading
69 Bytes
Loading
Loading
Loading
Loading
Loading
Loading
-119 Bytes
Loading
Loading
-274 Bytes
Loading
Loading

0 commit comments

Comments
 (0)