澎湃iPad上线版本

notificationController.m 7.7KB

    // // notificationController.m // ThePaperHD // // Created by liyuan on 15/7/15. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "notificationController.h" #import "notificationCell.h" #import "otherPersonHomepageController.h" #import "pushMsgController.h" #import "MLNavigationController.h" #import "messageAsksController.h" #import "messageAnswersController.h" #import "messageFocusController.h" #import "messageViewModel.h" #import "KGModal.h" @interface notificationController ()<messageViewModelDelegate,pushMsgDelegate,myAsksDelegate,myFocusDelegate,myFocusDelegate,myAsksDelegate,myAnswerDelegate> @property(nonatomic, strong)NSArray *dataList; @property(nonatomic, strong)messageViewModel *model; @property(nonatomic, strong)NSMutableDictionary *msgDic; @end @implementation notificationController @synthesize dataList = _dataList; @synthesize msgDic = _msgDic; static NSString *notificationCellID = @"notificationCellID"; - (void)viewDidLoad { [super viewDidLoad]; // 0XECEEEC self.view.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; _dataList = @[@[@"我的提问",@"关注的提问",@"回复我的"],@[@"推送消息"],@[@"我的动态"]]; self.tableView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; self.tableView.scrollEnabled = NO; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; [self.tableView registerClass:[notificationCell class] forCellReuseIdentifier:notificationCellID]; } -(void)viewWillAppear:(BOOL)animated{ self.model = messageViewModel.new; [KGModal sharedInstance].tapOutsideToDismiss = YES; self.model.delegate = self; self.model.msgMark = nil; // [self.tableView reloadData]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark -- tableView - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return _dataList.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return ((NSArray*)_dataList[section]).count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 60.0; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return 10; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView *view = [[UIView alloc]init]; view.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR]; return view; } - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { notificationCell *cell = [tableView dequeueReusableCellWithIdentifier:notificationCellID]; if (nil == cell) { cell = [[notificationCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:notificationCellID]; } cell.msgDic = self.msgDic; cell.topic = _dataList[indexPath.section][indexPath.row]; cell.indexPath = indexPath; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (0 ==indexPath.section) { if(0 == indexPath.row){ messageAsksController *vc =[messageAsksController new]; vc.myAsksDelegate = self; NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[TPUserDefault instance].msgMark]; [dic setValue:@(0) forKey:@"questionMark"]; [TPUserDefault instance].msgMark = dic; [(MLNavigationController*)self.navigationController pushViewControllerWithAnimateFlip:vc]; }else if(1 == indexPath.row){ messageFocusController *vc = [messageFocusController new]; vc.delegate = self; NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[TPUserDefault instance].msgMark]; [dic setValue:@(0) forKey:@"attendMark"]; [TPUserDefault instance].msgMark = dic; [(MLNavigationController*)self.navigationController pushViewControllerWithAnimateFlip:vc]; }else if (2 == indexPath.row){ messageAnswersController *vc = [messageAnswersController new]; vc.myAsksDelegate = self; NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithDictionary:[TPUserDefault instance].msgMark]; [dic setValue:@(0) forKey:@"replyedMark"]; [TPUserDefault instance].msgMark = dic; [(MLNavigationController*)self.navigationController pushViewControllerWithAnimateFlip:vc]; } }else if (1 == indexPath.section){ pushMsgController *pushMsg = [pushMsgController new]; pushMsg.pushDelegate = self; [(MLNavigationController*)self.navigationController pushViewControllerWithAnimateFlip:pushMsg]; }else if (2 == indexPath.section){ commentObjectVO *comment = commentObjectVO.new; comment.userInfo = setDataModelToDic([TPUserDefault instance].userBO, [userBO class]) ; if ([self.notificationDele respondsToSelector:@selector(notificationToNavi:)]) { [self.notificationDele notificationToNavi:comment]; } } } -(void)viewWillLayoutSubviews{ [super viewWillLayoutSubviews]; //我的消息:感觉“我的动态”条很难点击到(bug:6059) self.tableView.frame = CGRectMake(0, 0, messagePopSize.width, CGRectGetHeight(self.view.bounds)); } #pragma mark -- delegate -(void)pushMsgToNotification:(letterBO *)bo{ if([self.notificationDele respondsToSelector:@selector(pushMsgTomessageCenter:)]){ [self.notificationDele pushMsgTomessageCenter:bo]; } } -(void)gotoUserGambit:(commentObjectVO *)comment{ if ([self.notificationDele respondsToSelector:@selector(notifiToUserGamb:)]) { [self.notificationDele notifiToUserGamb:comment]; } } -(void)msgToTopicList{ if ([self.notificationDele respondsToSelector:@selector(notifiToTopicList)]) { [self.notificationDele notifiToTopicList]; } } -(void)foucsToTopicList{ if ([self.notificationDele respondsToSelector:@selector(notifiToTopicList)]) { [self.notificationDele notifiToTopicList]; } } -(void)msgAskToNews:(NSDictionary *)dic{//我的提问进入原新闻 if ([self.notificationDele respondsToSelector:@selector(notiToNews:)]) { [self.notificationDele notiToNews:dic]; } } -(void)msgAskToTopic:(NSDictionary *)dic{//我的提问进入原话题 if ([self.notificationDele respondsToSelector:@selector(notiToTopic:)]) { [self.notificationDele notiToTopic:dic]; } } -(void)msgFocusToNews:(NSDictionary *)dic{//关注的提问进入原新闻 if ([self.notificationDele respondsToSelector:@selector(notiToNews:)]) { [self.notificationDele notiToNews:dic]; } } -(void)msgFocusToTopic:(NSDictionary *)dic{//关注的提问进入原话题 if ([self.notificationDele respondsToSelector:@selector(notiToTopic:)]) { [self.notificationDele notiToTopic:dic]; } } -(void)msgAnswerToNews:(NSDictionary *)dic{//回复我的进入原新闻 if ([self.notificationDele respondsToSelector:@selector(notiToNews:)]) { [self.notificationDele notiToNews:dic]; } } -(void)msgAnswerToTopic:(NSDictionary *)dic{//回复我的进入原话题 if ([self.notificationDele respondsToSelector:@selector(notiToTopic:)]) { [self.notificationDele notiToTopic:dic]; } } #pragma mark -- view model -(void)returnMsgMark:(NSMutableDictionary *)dic{ NSMutableDictionary *messageDic = [NSMutableDictionary dictionaryWithDictionary:dic]; if ([self.notificationDele respondsToSelector:@selector(appearLettreMark:)]) { [self.notificationDele appearLettreMark:messageDic]; } _msgDic = dic; [self.tableView reloadData]; } @end