Skip to content

Commit 3453e33

Browse files
committed
App 的通知页面,对通知不再分类
1 parent 469c27f commit 3453e33

File tree

5 files changed

+54
-38
lines changed

5 files changed

+54
-38
lines changed

Coding_iOS/Controllers/RootControllers/Message_RootViewController.m

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// Copyright (c) 2014年 Coding. All rights reserved.
77
//
88

9+
#define kTopItemNum 1
10+
911
#import "Message_RootViewController.h"
1012
#import "ODRefreshControl.h"
1113
#import "Coding_NetAPIManager.h"
@@ -24,7 +26,7 @@ @interface Message_RootViewController ()
2426
@property (nonatomic, strong) UITableView *myTableView;
2527
@property (nonatomic, strong) ODRefreshControl *refreshControl;
2628
@property (strong, nonatomic) PrivateMessages *myPriMsgs;
27-
@property (strong, nonatomic) NSMutableDictionary *notificationDict;
29+
//@property (strong, nonatomic) NSMutableDictionary *notificationDict;
2830
@end
2931

3032
@implementation Message_RootViewController
@@ -120,16 +122,16 @@ - (void)sendMsgBtnClicked:(id)sender{
120122
}
121123

122124
- (void)refresh{
123-
__weak typeof(self) weakSelf = self;
124-
[[Coding_NetAPIManager sharedManager] request_UnReadNotificationsWithBlock:^(id data, NSError *error) {
125-
if (data) {
126-
weakSelf.notificationDict = [NSMutableDictionary dictionaryWithDictionary:data];
127-
[weakSelf.myTableView reloadData];
128-
[weakSelf.myTableView configBlankPage:EaseBlankPageTypeMessageList hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:(error != nil) offsetY:(3 * [ToMessageCell cellHeight]) reloadButtonBlock:^(id sender) {
129-
[weakSelf refresh];
130-
}];
131-
}
132-
}];
125+
// __weak typeof(self) weakSelf = self;
126+
// [[Coding_NetAPIManager sharedManager] request_UnReadNotificationsWithBlock:^(id data, NSError *error) {
127+
// if (data) {
128+
// weakSelf.notificationDict = [NSMutableDictionary dictionaryWithDictionary:data];
129+
// [weakSelf.myTableView reloadData];
130+
// [weakSelf.myTableView configBlankPage:EaseBlankPageTypeMessageList hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:(error != nil) offsetY:(kTopItemNum * [ToMessageCell cellHeight]) reloadButtonBlock:^(id sender) {
131+
// [weakSelf refresh];
132+
// }];
133+
// }
134+
// }];
133135
[[UnReadManager shareManager] updateUnRead];
134136

135137
if (_myPriMsgs.isLoading) {
@@ -156,7 +158,7 @@ - (void)sendRequest_PrivateMessages{
156158
[weakSelf.myPriMsgs configWithObj:data];
157159
[weakSelf.myTableView reloadData];
158160
weakSelf.myTableView.showsInfiniteScrolling = weakSelf.myPriMsgs.canLoadMore;
159-
[weakSelf.myTableView configBlankPage:EaseBlankPageTypeMessageList hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:(error != nil) offsetY:(3 * [ToMessageCell cellHeight]) reloadButtonBlock:^(id sender) {
161+
[weakSelf.myTableView configBlankPage:EaseBlankPageTypeMessageList hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:(error != nil) offsetY:(kTopItemNum * [ToMessageCell cellHeight]) reloadButtonBlock:^(id sender) {
160162
[weakSelf refresh];
161163
}];
162164
}
@@ -165,35 +167,37 @@ - (void)sendRequest_PrivateMessages{
165167

166168
#pragma mark Table M
167169
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
168-
NSInteger row = 3;
170+
NSInteger row = kTopItemNum;
169171
if (_myPriMsgs.list) {
170172
row += [_myPriMsgs.list count];
171173
}
172174
return row;
173175
}
174176

175177
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
176-
if (indexPath.row < 3) {
178+
if (indexPath.row < kTopItemNum) {
177179
ToMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_ToMessage forIndexPath:indexPath];
178-
switch (indexPath.row) {
179-
case 0:
180-
cell.type = ToMessageTypeAT;
181-
cell.unreadCount = [_notificationDict objectForKey:kUnReadKey_notification_AT];
182-
break;
183-
case 1:
184-
cell.type = ToMessageTypeComment;
185-
cell.unreadCount = [_notificationDict objectForKey:kUnReadKey_notification_Comment];
186-
break;
187-
default:
188-
cell.type = ToMessageTypeSystemNotification;
189-
cell.unreadCount = [_notificationDict objectForKey:kUnReadKey_notification_System];
190-
break;
191-
}
180+
cell.type = ToMessageTypeAllNotification;
181+
cell.unreadCount = [UnReadManager shareManager].notifications;
182+
// switch (indexPath.row) {
183+
// case 0:
184+
// cell.type = ToMessageTypeAT;
185+
// cell.unreadCount = [_notificationDict objectForKey:kUnReadKey_notification_AT];
186+
// break;
187+
// case 1:
188+
// cell.type = ToMessageTypeComment;
189+
// cell.unreadCount = [_notificationDict objectForKey:kUnReadKey_notification_Comment];
190+
// break;
191+
// default:
192+
// cell.type = ToMessageTypeSystemNotification;
193+
// cell.unreadCount = [_notificationDict objectForKey:kUnReadKey_notification_System];
194+
// break;
195+
// }
192196
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:75 hasSectionLine:NO];
193197
return cell;
194198
}else{
195199
ConversationCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_Conversation forIndexPath:indexPath];
196-
PrivateMessage *msg = [_myPriMsgs.list objectAtIndex:indexPath.row-3];
200+
PrivateMessage *msg = [_myPriMsgs.list objectAtIndex:indexPath.row-kTopItemNum];
197201
cell.curPriMsg = msg;
198202
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:75 hasSectionLine:NO];
199203
return cell;
@@ -202,7 +206,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
202206

203207
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
204208
CGFloat cellHeight;
205-
if (indexPath.row < 3) {
209+
if (indexPath.row < kTopItemNum) {
206210
cellHeight = [ToMessageCell cellHeight];
207211
}else{
208212
cellHeight = [ConversationCell cellHeight];
@@ -212,12 +216,13 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
212216

213217
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
214218
[tableView deselectRowAtIndexPath:indexPath animated:YES];
215-
if (indexPath.row < 3) {
219+
if (indexPath.row < kTopItemNum) {
216220
TipsViewController *vc = [[TipsViewController alloc] init];
217-
vc.myCodingTips = [CodingTips codingTipsWithType:indexPath.row];
221+
// vc.myCodingTips = [CodingTips codingTipsWithType:indexPath.row];
222+
vc.myCodingTips = [CodingTips codingTipsWithType:ToMessageTypeAllNotification];
218223
[self.navigationController pushViewController:vc animated:YES];
219224
}else{
220-
PrivateMessage *curMsg = [_myPriMsgs.list objectAtIndex:indexPath.row-3];
225+
PrivateMessage *curMsg = [_myPriMsgs.list objectAtIndex:indexPath.row-kTopItemNum];
221226
ConversationViewController *vc = [[ConversationViewController alloc] init];
222227
User *curFriend = curMsg.friend;
223228

@@ -231,11 +236,11 @@ - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButto
231236
return @"删除会话";
232237
}
233238
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
234-
return (indexPath.row >= 3);
239+
return (indexPath.row >= kTopItemNum);
235240
}
236241
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
237242
[tableView setEditing:NO animated:YES];
238-
PrivateMessage *msg = [_myPriMsgs.list objectAtIndex:indexPath.row-3];
243+
PrivateMessage *msg = [_myPriMsgs.list objectAtIndex:indexPath.row-kTopItemNum];
239244

240245
__weak typeof(self) weakSelf = self;
241246
UIActionSheet *actionSheet = [UIActionSheet bk_actionSheetCustomWithTitle:[NSString stringWithFormat:@"这将删除你和 %@ 的所有私信", msg.friend.name] buttonTitles:nil destructiveTitle:@"确认删除" cancelTitle:@"取消" andDidDismissBlock:^(UIActionSheet *sheet, NSInteger index) {
@@ -253,7 +258,7 @@ - (void)removeConversation:(PrivateMessage *)curMsg inTableView:(UITableView *)t
253258
if (data) {
254259
[weakSelf.myPriMsgs.list removeObject:data];
255260
[weakSelf.myTableView reloadData];
256-
[weakSelf.myTableView configBlankPage:EaseBlankPageTypeMessageList hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:(error != nil) offsetY:(3 * [ToMessageCell cellHeight]) reloadButtonBlock:^(id sender) {
261+
[weakSelf.myTableView configBlankPage:EaseBlankPageTypeMessageList hasData:(weakSelf.myPriMsgs.list.count > 0) hasError:(error != nil) offsetY:(kTopItemNum * [ToMessageCell cellHeight]) reloadButtonBlock:^(id sender) {
257262
[weakSelf refresh];
258263
}];
259264
}

Coding_iOS/Controllers/TipsViewController.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ - (void)viewDidLoad
5252
titleStr = @"系统通知";
5353
break;
5454
default:
55+
titleStr = @"通知";
5556
break;
5657
}
5758
self.title = titleStr;

Coding_iOS/Models/CodingTips.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ - (NSDictionary *)toTipsParams{
7878
params = @{@"type" : @[@(4), @(6)],
7979
@"page" : _willLoadMore? [NSNumber numberWithInteger:_page.integerValue +1]: [NSNumber numberWithInteger:1],
8080
@"pageSize" : _pageSize};
81+
}else if (_type == 3){
82+
params = @{@"page" : _willLoadMore? [NSNumber numberWithInteger:_page.integerValue +1]: [NSNumber numberWithInteger:1],
83+
@"pageSize" : _pageSize};
8184
}
8285
return params;
8386
}
@@ -93,6 +96,8 @@ - (NSDictionary *)toMarkReadParams{
9396
}else if (_type == 2){
9497
params = @{@"type" : @(4),
9598
@"all" : @(1)};
99+
}else if (_type == 3){
100+
params = @{@"all" : @(1)};
96101
}
97102
return params;
98103
}

Coding_iOS/Views/Cell/ToMessageCell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ typedef NS_ENUM(NSInteger, ToMessageType) {
1313
ToMessageTypeAT = 0,
1414
ToMessageTypeComment,
1515
ToMessageTypeSystemNotification,
16+
ToMessageTypeAllNotification,
1617
ToMessageTypeProjectFollows,
1718
ToMessageTypeProjectFans,
1819
};

Coding_iOS/Views/Cell/ToMessageCell.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ - (void)setType:(ToMessageType)type{
3737
imageName = @"messageSystem";
3838
titleStr = @"系统通知";
3939
break;
40-
case ToMessageTypeProjectFollows:
40+
case ToMessageTypeAllNotification:
41+
imageName = @"messageSystem";
42+
titleStr = @"通知";
43+
break;
44+
case ToMessageTypeProjectFollows:
4145
imageName = @"messageProjectFollows";
4246
titleStr = @"我的关注";
4347
break;
44-
case ToMessageTypeProjectFans:
48+
case ToMessageTypeProjectFans:
4549
imageName = @"messageProjectFans";
4650
titleStr = @"我的粉丝";
4751
break;

0 commit comments

Comments
 (0)