2727
2828#import " UserInfoTextCell.h"
2929#import " UserInfoIconCell.h"
30+ #import " TitleDisclosureCell.h"
3031
3132#import " StartImagesManager.h"
3233#import " EaseUserHeaderView.h"
@@ -45,18 +46,7 @@ @interface UserInfoViewController ()<UITableViewDataSource, UITableViewDelegate>
4546@implementation UserInfoViewController
4647- (void )viewDidLoad {
4748 [super viewDidLoad ];
48- // Do any additional setup after loading the view.
49- if (_isRoot) {
50- self.title = @" 我" ;
51- _curUser = [Login curLoginUser ]? [Login curLoginUser ]: [User userWithGlobalKey: @" " ];
52-
53- [self .navigationItem setRightBarButtonItem: [[UIBarButtonItem alloc ] initWithImage: [UIImage imageNamed: @" settingBtn_Nav" ] style: UIBarButtonItemStylePlain target: self action: @selector (settingBtnClicked: )] animated: NO ];
54- [self .navigationItem setLeftBarButtonItem: [[UIBarButtonItem alloc ] initWithImage: [UIImage imageNamed: @" addUserBtn_Nav" ] style: UIBarButtonItemStylePlain target: self action: @selector (addUserBtnClicked: )] animated: NO ];
55-
56- }else {
57- self.title = _curUser.name ;
58- }
59-
49+ self.title = _curUser.name ;
6050 // 添加myTableView
6151 _myTableView = ({
6252 UITableView *tableView = [[UITableView alloc ] initWithFrame: self .view.bounds style: UITableViewStyleGrouped];
@@ -66,15 +56,11 @@ - (void)viewDidLoad{
6656 tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
6757 [tableView registerClass: [UserInfoTextCell class ] forCellReuseIdentifier: kCellIdentifier_UserInfoTextCell ];
6858 [tableView registerClass: [UserInfoIconCell class ] forCellReuseIdentifier: kCellIdentifier_UserInfoIconCell ];
59+ [tableView registerClass: [TitleDisclosureCell class ] forCellReuseIdentifier: kCellIdentifier_TitleDisclosure ];
6960 [self .view addSubview: tableView];
7061 [tableView mas_makeConstraints: ^(MASConstraintMaker *make) {
7162 make.edges .equalTo (self.view );
7263 }];
73- if (_isRoot) {
74- UIEdgeInsets insets = UIEdgeInsetsMake (0 , 0 , CGRectGetHeight (self.rdv_tabBarController .tabBar .frame ), 0 );
75- tableView.contentInset = insets;
76- tableView.scrollIndicatorInsets = insets;
77- }
7864 tableView;
7965 });
8066 __weak typeof (self) weakSelf = self;
@@ -92,38 +78,25 @@ - (void)viewDidLoad{
9278 [weakSelf followBtnClicked ];
9379 };
9480 [_myTableView addParallaxWithView: _headerView andHeight: CGRectGetHeight (_headerView.frame)];
95- if (![self isMe ]) {
96- _myTableView.tableFooterView = [self footerV ];
97- }
81+ _myTableView.tableFooterView = [self footerV ];
9882
9983 _refreshControl = [[ODRefreshControl alloc ] initInScrollView: self .myTableView];
10084 [_refreshControl addTarget: self action: @selector (refresh ) forControlEvents: UIControlEventValueChanged];
10185}
10286
103- - (BOOL )isMe {
104- return (_isRoot || [_curUser.global_key isEqualToString: [Login curLoginUser ].global_key]);
105- }
106-
10787- (void )viewWillAppear : (BOOL )animated {
10888 [super viewWillAppear: animated];
10989 [self refresh ];
11090}
11191
112- - (void )dealloc
113- {
114- _myTableView.delegate = nil ;
115- _myTableView.dataSource = nil ;
116- }
117-
118-
11992- (void )refresh {
12093 __weak typeof (self) weakSelf = self;
12194 [[Coding_NetAPIManager sharedManager ] request_UserInfo_WithObj: _curUser andBlock: ^(id data, NSError *error) {
12295 [weakSelf.refreshControl endRefreshing ];
12396 if (data) {
12497 weakSelf.curUser = data;
12598 weakSelf.headerView .curUser = data;
126- weakSelf.title = _isRoot? @" 我 " : weakSelf.curUser .name ;
99+ weakSelf.title = weakSelf.curUser .name ;
127100 [weakSelf.myTableView reloadData ];
128101 }
129102 }];
@@ -132,87 +105,64 @@ - (void)refresh{
132105#pragma mark footerV
133106- (UIView *)footerV {
134107 UIView *footerV = [[UIView alloc ] initWithFrame: CGRectMake (0 , 0 , kScreen_Width , 72 )];
135-
136108 UIButton *footerBtn = [UIButton buttonWithStyle: StrapSuccessStyle andTitle: @" 发消息" andFrame: CGRectMake (kPaddingLeftWidth , (CGRectGetHeight (footerV.frame)-44 )/2 , kScreen_Width - 2 *kPaddingLeftWidth , 44 ) target: self action: @selector (messageBtnClicked )];
137109 [footerV addSubview: footerBtn];
138110 return footerV;
139111}
140112
141113#pragma mark Table M
142114- (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView {
143- return [ self .curUser.global_key isEqualToString: [Login curLoginUser ].global_key]? 4 : 3 ;
115+ return 2 ;
144116}
145117- (NSInteger )tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger )section {
146- NSInteger row = 0 ;
147- if (section == 0 ) {
148- row = [self isMe ]? 0 : 3 ;
149- }else if (section == 1 ){
150- row = 1 ;
151- }else if (section == 2 ){
152- row = [self isMe ]? 4 : 3 ;
153- }else if (section == 3 ){
154- row = 1 ;
155- }
156- return row;
118+ return section == 0 ? 4 : 3 ;
157119}
158120
159121- (UITableViewCell *)tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath {
160122
161123 if (indexPath.section == 0 ) {
162- UserInfoTextCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_UserInfoTextCell forIndexPath: indexPath];
163- switch (indexPath.row ) {
164- case 0 :
165- [cell setTitle: @" 所在地" value: _curUser.location];
166- break ;
167- case 1 :
168- [cell setTitle: @" 座右铭" value: _curUser.slogan];
169- break ;
170- default :
171- [cell setTitle: @" 个性标签" value: _curUser.tags_str];
172- break ;
124+ if (indexPath.row < 3 ) {
125+ UserInfoTextCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_UserInfoTextCell forIndexPath: indexPath];
126+ switch (indexPath.row ) {
127+ case 0 :
128+ [cell setTitle: @" 所在地" value: _curUser.location];
129+ break ;
130+ case 1 :
131+ [cell setTitle: @" 座右铭" value: _curUser.slogan];
132+ break ;
133+ default :
134+ [cell setTitle: @" 个性标签" value: _curUser.tags_str];
135+ break ;
136+ }
137+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
138+ return cell;
139+ }else {
140+ TitleDisclosureCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_TitleDisclosure forIndexPath: indexPath];
141+ cell.titleLabel .font = [UIFont systemFontOfSize: 15 ];
142+ cell.backgroundColor = [UIColor whiteColor ];
143+ [cell setTitleStr: @" 详细信息" ];
144+ [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
145+ return cell;
173146 }
174- [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
175- return cell;
176147 }else {
177148 UserInfoIconCell *cell = [tableView dequeueReusableCellWithIdentifier: kCellIdentifier_UserInfoIconCell forIndexPath: indexPath];
178- if (indexPath.section == 1 ) {
179- [cell setTitle: @" 详细信息" icon: @" user_info_detail" ];
180- }else if (indexPath.section == 2 ){
181- if (indexPath.row == 0 ) {
182- [cell setTitle: [self isMe ]? @" 我的项目" : @" Ta的项目" icon: @" user_info_project" ];
183- }else if (indexPath.row == 1 ){
184- [cell setTitle: [self isMe ]? @" 我的冒泡" : @" Ta的冒泡" icon: @" user_info_tweet" ];
185- }else if (indexPath.row == 2 ){
186- [cell setTitle: [self isMe ]? @" 我的话题" : @" Ta的话题" icon: @" user_info_topic" ];
187- }else {
188- [cell setTitle: @" 本地文件" icon: @" user_info_file" ];
189- }
190- }else {
191- [cell setTitle: @" 我的码币" icon: @" user_info_point" ];
192- if ([[FunctionTipsManager shareManager ] needToTip: kFunctionTipStr_Me_Points ]) {
193- [cell addTipIcon ];
194- }
149+ if (indexPath.row == 0 ) {
150+ [cell setTitle: @" Ta的项目" icon: @" user_info_project" ];
151+ }else if (indexPath.row == 1 ){
152+ [cell setTitle: @" Ta的冒泡" icon: @" user_info_tweet" ];
153+ }else {
154+ [cell setTitle: @" Ta的话题" icon: @" user_info_topic" ];
195155 }
196156 [tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
197157 return cell;
198158 }
199159}
200160
201161- (CGFloat)tableView : (UITableView *)tableView heightForRowAtIndexPath : (NSIndexPath *)indexPath {
202- CGFloat cellHeight = 0 ;
203- if (indexPath.section == 0 ) {
204- cellHeight = [UserInfoTextCell cellHeight ];
205- }else {
206- cellHeight = [UserInfoIconCell cellHeight ];
207- }
208- return cellHeight;
162+ return 44.0 ;
209163}
210164
211165- (CGFloat)tableView : (UITableView *)tableView heightForFooterInSection : (NSInteger )section {
212- if (![self isMe ]
213- && section == [self numberOfSectionsInTableView: self .myTableView] -1 ) {
214- return 0.5 ;
215- }
216166 return 20.0 ;
217167}
218168- (CGFloat)tableView : (UITableView *)tableView heightForHeaderInSection : (NSInteger )section {
@@ -224,27 +174,19 @@ - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger
224174 footerView.backgroundColor = kColorTableSectionBg ;
225175 return footerView;
226176}
177+
227178- (void )tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath {
228179 [tableView deselectRowAtIndexPath: indexPath animated: YES ];
229- if (indexPath.section == 1 ) {
180+ if (indexPath.section == 0 && indexPath. row == 3 ) {
230181 [self goToDetailInfo ];
231- }else if (indexPath.section == 2 ){
182+ }else if (indexPath.section == 1 ){
232183 if (indexPath.row == 0 ) {
233184 [self goToProjects ];
234185 }else if (indexPath.row == 1 ){
235186 [self goToTweets ];
236187 }else if (indexPath.row == 2 ){
237188 [self goToTopic ];
238- }else {
239- [self goToLocalFolders ];
240- }
241- }else if (indexPath.section == 3 ){
242- if ([[FunctionTipsManager shareManager ] needToTip: kFunctionTipStr_Me_Points ]) {
243- [[FunctionTipsManager shareManager ] markTiped: kFunctionTipStr_Me_Points ];
244- UserInfoIconCell *cell = (UserInfoIconCell *)[tableView cellForRowAtIndexPath: indexPath];
245- [cell removeTip ];
246189 }
247- [self goToPoint ];
248190 }
249191}
250192
@@ -337,14 +279,9 @@ - (void)goToProjects{
337279}
338280
339281- (void )goToDetailInfo {
340- if ([self isMe ]) {
341- SettingMineInfoViewController *vc = [[SettingMineInfoViewController alloc ] init ];
342- [self .navigationController pushViewController: vc animated: YES ];
343- }else {
344- UserInfoDetailViewController *vc = [[UserInfoDetailViewController alloc ] init ];
345- vc.curUser = self.curUser ;
346- [self .navigationController pushViewController: vc animated: YES ];
347- }
282+ UserInfoDetailViewController *vc = [[UserInfoDetailViewController alloc ] init ];
283+ vc.curUser = self.curUser ;
284+ [self .navigationController pushViewController: vc animated: YES ];
348285}
349286
350287@end
0 commit comments