// // settingNaviController.m // ThePaperHD // // Created by scar1900 on 15/3/2. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "settingNaviController.h" #import "TPSelectButton.h" #import "loginPopUpController.h" #import "loginUserInfoPopUpController.h" #import "fontSizeSlideCell.h" #import "settingHomeController.h" #import "myAskCenterHomeController.h" #import "UIButton+BadgeView.h" #import "detailContentHomeController.h" #import "ImageContentController.h" #import "TPLiveHomeController.h" #import "topicHomeController.h" #import "TPcontentWebController.h" #import "trackTableController.h" #import "collectTableController.h" #import "searchController.h" #import "gambitCenterHomeController.h" #import "creatTopicController.h" #import "topicListController.h" #import "topicListHomeController.h" #import "topicContentController.h" #import "customFlowLayout.h" #import "otherPersonHomepageController.h" #import "messageCenterHomeController.h" @interface settingNaviController () @property(nonatomic, strong)UIView *settingBackView; @property(nonatomic, strong)UIView *maskView; @property(nonatomic, strong)UIButton *maskButton; @property(nonatomic, strong)TPSelectButton *loginButton; @property(nonatomic, strong)TPSelectButton *settingButton; @property(nonatomic, strong)TPSelectButton *followButton; @property(nonatomic, strong)TPSelectButton *collectButton; //@property(nonatomic, strong)TPSelectButton *askButton; @property(nonatomic, strong)UIView *line; @property(nonatomic, strong)TPSelectButton *messageButton; @property(nonatomic, strong)TPSelectButton *nightModeButton; @property(nonatomic, strong)TPSelectButton *searchButton; @property(nonatomic, strong)TPSelectButton *topicButton; @property(nonatomic, strong)fontSizeSlideCell *fontSizeSelectView; @property(nonatomic, strong)UIView *buttonBack; @property(nonatomic, strong)settingHomeController *settingVC; @property(nonatomic, strong)myAskCenterHomeController *myAskVC; @property(nonatomic, strong)trackTableController *trackVC; @property(nonatomic, strong)collectTableController *collectVC; @property(nonatomic, strong)searchController *searchVC; @property(nonatomic, strong)gambitCenterHomeController *gambitVC; @property(nonatomic, strong)loginUserInfoPopUpController *loginVC; @property(nonatomic, strong)messageCenterHomeController *messageVC; @end @implementation settingNaviController @synthesize delegate; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor clearColor]; [self.view addSubview:self.maskView]; [self.maskView addSubview:self.maskButton]; [self.view addSubview:self.settingBackView]; [self.view addSubview:self.buttonBack]; // self.buttonBack.backgroundColor = [UIColor greenColor]; [self.buttonBack addSubview:self.loginButton]; [self.buttonBack addSubview:self.settingButton]; [self.buttonBack addSubview:self.followButton]; [self.buttonBack addSubview:self.collectButton]; // [self.buttonBack addSubview:self.askButton]; [self.buttonBack addSubview:self.messageButton]; [self.buttonBack addSubview:self.line]; [self.buttonBack addSubview:self.nightModeButton]; [self.buttonBack addSubview:self.searchButton]; [self.buttonBack addSubview:self.topicButton]; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { self.settingBackView.frame = CGRectMake(0, 0, 768, 160); self.maskView.frame = CGRectMake(0, 0, 768, 1024); self.buttonBack.frame = CGRectMake(90/2, CGRectGetHeight(self.settingBackView.frame)/2 -130/4, 1360/2, 130/2); [self setButtonVerFrame]; }else { self.settingBackView.frame = CGRectMake(0, 0, 1024, 160); self.maskView.frame = CGRectMake(0, 0, 1024, 768); self.buttonBack.frame = CGRectMake(254/2, CGRectGetHeight(self.settingBackView.frame)/2 -130/4, 1540/2, 130/2); [self setButtonHorFrame]; } self.maskButton.frame = self.maskView.bounds; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(login) name:HAVELOGIN object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginOut) name:HAVELOGINOUT object:nil]; } -(void) setButtonHorFrame{ self.settingButton.frame = CGRectMake(CGRectGetMaxX(self.buttonBack.bounds)-40, 0, 40, 58); self.searchButton.frame = CGRectMake(CGRectGetMinX(self.settingButton.frame)-80, 0, 40, 58); self.nightModeButton.frame = CGRectMake(CGRectGetMinX(self.searchButton.frame)-90, 0, 50, 58); self.followButton.frame = CGRectMake(CGRectGetMaxX(self.loginButton.frame)+50, 0, 40, 58); self.collectButton.frame = CGRectMake(CGRectGetMaxX(self.followButton.frame)+50, 0, 40, 58); self.topicButton.frame = CGRectMake(CGRectGetMaxX(self.collectButton.frame)+50, 0, 40, 58); self.messageButton.frame = CGRectMake(CGRectGetMaxX(self.topicButton.frame)+50, 0, 40, 58); self.line.frame = CGRectMake(CGRectGetMinX(self.nightModeButton.frame)/2 + CGRectGetMaxX(self.messageButton.frame)/2, 0, 1, 58); } -(void) setButtonVerFrame{ self.settingButton.frame = CGRectMake(CGRectGetMaxX(self.buttonBack.bounds)-40, 0, 40, 58); self.searchButton.frame = CGRectMake(CGRectGetMinX(self.settingButton.frame)-70, 0, 40, 58); self.nightModeButton.frame = CGRectMake(CGRectGetMinX(self.searchButton.frame)-80, 0, 50, 58); self.followButton.frame = CGRectMake(CGRectGetMaxX(self.loginButton.frame)+30, 0, 40, 58); self.collectButton.frame = CGRectMake(CGRectGetMaxX(self.followButton.frame)+30, 0, 40, 58); self.topicButton.frame = CGRectMake(CGRectGetMaxX(self.collectButton.frame)+30, 0, 40, 58); self.messageButton.frame = CGRectMake(CGRectGetMaxX(self.topicButton.frame)+30, 0, 40, 58); self.line.frame = CGRectMake(CGRectGetMinX(self.nightModeButton.frame)/2 + CGRectGetMaxX(self.messageButton.frame)/2, 0, 1, 58); } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; __weak typeof(self) Self = self; //个人动态:如此操作有两个异常症状(bug:6060) if([TPUserDefault instance].userBO){ if (self.loginVC && self.loginVC.isNeedHold) { [self presentController:self.loginVC animated:YES presentSize:CGSizeMake(966/2, 1440/2) completion:^{ } dismiss:^{ if (!Self.loginVC.isNeedHold) { Self.loginVC = nil; } }]; } } if (self.myAskVC && self.myAskVC.isNeenHold) { [self presentController:self.myAskVC animated:YES presentSize:myAskCenterPopSize completion:^{ } dismiss:^{ if (!Self.myAskVC.isNeenHold) { Self.myAskVC = nil; } }]; } if (self.trackVC && self.trackVC.isNeedHold) { [self presentController:self.trackVC animated:YES presentSize:trackPopSize completion:^{ } dismiss:^{ if (!Self.trackVC.isNeedHold) { Self.trackVC = nil; } }]; } if (self.collectVC && self.collectVC.isNeedHold) { [self presentController:self.collectVC animated:YES presentSize:collectPopSize completion:^{ } dismiss:^{ if (!Self.collectVC.isNeedHold) { Self.collectVC = nil; } }]; } if (self.searchVC && self.searchVC.isNeedHold) { [self presentController:self.searchVC animated:YES presentSize:searchPopSize completion:^{ } dismiss:^{ if (!Self.searchVC.isNeedHold) { Self.searchVC = nil; } }]; } if (self.gambitVC && self.gambitVC.isNeedHold) { [self presentController:self.gambitVC animated:YES presentSize:gambitCenterPopSize completion:^{ } dismiss:^{ if (!Self.gambitVC.isNeedHold) { Self.gambitVC = nil; } }]; } //个人动态:如此操作有两个异常症状(bug:6060) if ([TPUserDefault instance].userBO) { if (self.messageVC && self.messageVC.isNeedHold) { [self presentController:self.messageVC animated:YES presentSize:hotAskListPopUpSize completion:^{ } dismiss:^{ if (!Self.messageVC.isNeedHold) { Self.messageVC = nil; } }]; } }else{ self.messageVC.isNeedHold = NO; self.messageVC = nil; } } - (void)statusBarOrientationChange:(NSNotification *)notification{ UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { self.settingBackView.frame = CGRectMake(0, 0, 768, 160); self.maskView.frame = CGRectMake(0, 0, 768, 1024); self.buttonBack.frame = CGRectMake(90/2, CGRectGetHeight(self.settingBackView.frame)/2 -130/4, 1360/2, 130/2); [self setButtonVerFrame]; }else { self.settingBackView.frame = CGRectMake(0, 0, 1024, 160); self.maskView.frame = CGRectMake(0, 0, 1024, 768); self.buttonBack.frame = CGRectMake(254/2, CGRectGetHeight(self.settingBackView.frame)/2 -130/4, 1540/2, 130/2); [self setButtonHorFrame]; } self.maskButton.frame = self.maskView.bounds; } - (UIView*)buttonBack { if (!_buttonBack) { _buttonBack = [[UIView alloc]initWithFrame:CGRectZero]; _buttonBack.backgroundColor = [UIColor clearColor]; } return _buttonBack; } - (UIView*)maskView { if (!_maskView) { _maskView = [[UIView alloc]initWithFrame:self.view.bounds]; _maskView.backgroundColor = [UIColor clearColor]; } return _maskView; } - (UIView*)settingBackView { if (!_settingBackView) { _settingBackView = [[UIView alloc]init]; _settingBackView.backgroundColor = [UIColor colorWithHexString:@"0xb0b0b0"]; _settingBackView.alpha = 0.9; } return _settingBackView; } - (UIButton*)maskButton { if (!_maskButton) { _maskButton = [UIButton buttonWithType:UIButtonTypeCustom]; _maskButton.backgroundColor = [UIColor clearColor]; _maskButton.frame = self.maskView.bounds; [_maskButton addTarget:self action:@selector(clickToDissmiss) forControlEvents:UIControlEventTouchUpInside]; } return _maskButton; } - (TPSelectButton*)loginButton { if (!_loginButton) { _loginButton = [[TPSelectButton alloc]initWithFrame:CGRectMake(0, 0, 40, 116/2) target:self selector:@selector(loginEvent:)]; [_loginButton setBUttonNormalImage:Image(@"setting/loginIcon.png") highLightImage:Image(@"setting/loginIcon_h.png") selectedImage:Image(@"setting/loginIcon_s.png")]; _loginButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; if ([TPUserDefault instance].userBO) { [_loginButton setSelect:YES animation:NO]; _loginButton.titleText = @"已登录"; }else { [_loginButton setSelect:NO animation:NO]; _loginButton.titleText = @"登录"; } } return _loginButton; } - (TPSelectButton*)settingButton { if (!_settingButton) { _settingButton = [[TPSelectButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.buttonBack.bounds)-40, 0, 40, 58) target:self selector:@selector(goToSetting:)]; [_settingButton setBUttonNormalImage:Image(@"setting/setting_settingIcon.png") highLightImage:Image(@"setting/setting_settingIcon_h.png") selectedImage:Image(@"setting/setting_settingIcon_h.png")]; _settingButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; _settingButton.titleText = @"设置"; } return _settingButton; } - (TPSelectButton*)searchButton { if (!_searchButton) { _searchButton = [[TPSelectButton alloc]initWithFrame:CGRectMake(CGRectGetMinX(self.settingButton.frame)-80, 0, 40, 58) target:self selector:@selector(goToSearch:)]; [_searchButton setBUttonNormalImage:Image(@"setting/setting_searchIcon.png") highLightImage:Image(@"setting/setting_searchIcon_h.png") selectedImage:Image(@"setting/setting_searchIcon_h.png")]; _searchButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; _searchButton.titleText = @"搜索"; } return _searchButton; } - (TPSelectButton*)followButton { if (!_followButton) { _followButton = [[TPSelectButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.loginButton.frame)+50, 0, 40, 58) target:self selector:@selector(goToFollow:)]; [_followButton setBUttonNormalImage:Image(@"setting/setting_followIcon.png") highLightImage:Image(@"setting/setting_followIcon_h.png") selectedImage:Image(@"setting/setting_followIcon_h.png")]; _followButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; _followButton.titleText = @"跟踪"; } return _followButton; } - (TPSelectButton*)collectButton { if (!_collectButton) { _collectButton = [[TPSelectButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.followButton.frame)+50, 0, 40, 58) target:self selector:@selector(goToCollect:)]; [_collectButton setBUttonNormalImage:Image(@"setting/setting_collectIcon.png") highLightImage:Image(@"setting/setting_collectIcon_h.png") selectedImage:Image(@"setting/setting_collectIcon_h.png")]; _collectButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; _collectButton.titleText = @"收藏"; } return _collectButton; } //- (TPSelectButton*)askButton { // if (!_askButton) { // _askButton = [[TPSelectButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.collectButton.frame)+30, 0, 40, 116/2) // target:self // selector:@selector(goToAsk:)]; // [_askButton setBUttonNormalImage:Image(@"setting/setting_askIcon.png") // highLightImage:Image(@"setting/setting_askIcon_h.png") // selectedImage:Image(@"setting/setting_askIcon_h.png")]; // _askButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; // _askButton.titleText = @"追问"; // } // return _askButton; //} -(TPSelectButton *)messageButton{ if (!_messageButton) { _messageButton = [[TPSelectButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.topicButton.frame)+50, 0, 40, 58) target:self selector:@selector(gotoMessage:)]; [_messageButton setBUttonNormalImage:Image(@"setting/messageIcon.png") highLightImage:Image(@"setting/messageIcon_h.png") selectedImage:Image(@"setting/messageIcon_h.png")]; _messageButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; _messageButton.titleText = @"消息"; } return _messageButton; } -(UIView *)line{ if (!_line) { _line = [[UIView alloc] initWithFrame:CGRectZero]; _line.backgroundColor = [UIColor whiteColor]; } return _line; } -(TPSelectButton *)nightModeButton{ if (!_nightModeButton) { _nightModeButton = [[TPSelectButton alloc] initWithFrame:CGRectMake(CGRectGetMinX(self.searchButton.frame)-90, 0, 50, 58) target:self selector:@selector(gotoNightMode:)]; if ([[TPUserDefault instance].isNightMode isEqualToString:@"1"]) { [_nightModeButton setBUttonNormalImage:Image(@"setting/dayModeIcon.png") highLightImage:Image(@"setting/dayModeIcon_h.png") selectedImage:Image(@"setting/nightModeIcon.png")]; _nightModeButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; _nightModeButton.titleText = @"日间模式"; }else{ [_nightModeButton setBUttonNormalImage:Image(@"setting/nightModeIcon.png") highLightImage:Image(@"setting/nightModeIcon_h.png") selectedImage:Image(@"setting/dayModeIcon.png")]; _nightModeButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; _nightModeButton.titleText = @"夜间模式"; } } return _nightModeButton; } - (TPSelectButton*)topicButton { if (!_topicButton) { _topicButton = [[TPSelectButton alloc]initWithFrame:CGRectMake(CGRectGetMaxX(self.collectButton.frame)+50, 0, 40, 58) target:self selector:@selector(goToTopic:)]; [_topicButton setBUttonNormalImage:Image(@"setting/topicIcon.png") highLightImage:Image(@"setting/topicIcon_h.png") selectedImage:Image(@"setting/topicIcon_h.png")]; _topicButton.textLabel.textColor = [UIColor colorWithHexString:TextAbsoluteBlack]; _topicButton.titleText = @"话题"; } return _topicButton; } - (fontSizeSlideCell*)fontSizeSelectView { if (!_fontSizeSelectView) { _fontSizeSelectView = [[fontSizeSlideCell alloc]initWithFrame:CGRectMake(0, 0, 0, 0)]; } return _fontSizeSelectView; } - (void)clickToDissmiss { if ([self.delegate respondsToSelector:@selector(clickToDismissSetting)]) { [self.delegate clickToDismissSetting]; } } #pragma mark - buttons handler - (void)loginEvent:(UIButton*)btn { if (![TPUserDefault instance].userBO) { loginPopUpController *loginPopVC = loginPopUpController.new; [self presentController:loginPopVC animated:YES presentSize:loginPopUpSize completion:^{ } dismiss:^{ if ([TPUserDefault instance].userBO) { [self.loginButton setSelect:YES animation:YES]; self.loginButton.titleText = @"已登录"; [self refreshMsgMark]; } }]; }else { self.loginVC = loginUserInfoPopUpController.new; self.loginVC.loginUserDele = self; [self presentController:self.loginVC animated:YES presentSize:CGSizeMake(966/2, 1440/2) completion:^{ } dismiss:^{ // if (!self.loginVC.isNeedHold) { // self.loginVC = nil; // } if (![TPUserDefault instance].userBO) { [self.loginButton setSelect:NO animation:YES]; self.loginButton.titleText = @"登录"; [self refreshMsgMark]; } }]; } } - (void)goToSetting:(UIButton*)btn { self.settingVC = settingHomeController.new; __weak typeof(self) Self = self; [self presentController:self.settingVC animated:YES presentSize:settingPopSize completion:^{ } dismiss:^{ Self.settingVC = nil; if ([[TPUserDefault instance].isNightMode intValue] == 0) { TPWindow *window = (TPWindow*)[[UIApplication sharedApplication]keyWindow]; [window setNoNightModeMask]; }else { TPWindow *window = (TPWindow*)[[UIApplication sharedApplication]keyWindow]; [window setMaskAfterOpenNightMode]; } }]; } - (void)goToFollow:(UIButton*)btn { if (![TPUserDefault instance].userBO) { loginPopUpController *loginPopVC = loginPopUpController.new; __weak typeof(self) Self = self; [self presentController:loginPopVC animated:YES presentSize:loginPopUpSize completion:^{ } dismiss:^{ if ([TPUserDefault instance].userBO) { [Self.loginButton setSelect:YES animation:YES]; Self.loginButton.titleText = @"已登录"; if (!Self.trackVC) { Self.trackVC =trackTableController.new; Self.trackVC.delegate = Self; } [Self presentController:self.trackVC animated:YES presentSize:trackPopSize completion:^{ } dismiss:^{ if (!Self.trackVC.isNeedHold) { Self.trackVC = nil; } }]; } }]; }else { if (!self.trackVC) { self.trackVC = trackTableController.new; self.trackVC.delegate = self; } __weak typeof(self) Self = self; [self presentController:self.trackVC animated:YES presentSize:trackPopSize completion:^{ } dismiss:^{ if (!Self.trackVC.isNeedHold) { Self.trackVC = nil; } }]; } } - (void)goToCollect:(UIButton*)btn { if (![TPUserDefault instance].userBO) { loginPopUpController *loginVC = loginPopUpController.new; __weak typeof(self) Self = self; [self presentController:loginVC animated:YES presentSize:loginPopUpSize completion:^{ } dismiss:^{ if ([TPUserDefault instance].userBO) { [Self.loginButton setSelect:YES animation:YES]; Self.loginButton.titleText = @"已登录"; if (!self.collectVC) { Self.collectVC =collectTableController.new; Self.collectVC.collectDelegate = Self; } [Self presentController:Self.collectVC animated:YES presentSize:trackPopSize completion:^{ } dismiss:^{ if (!Self.collectVC.isNeedHold) { Self.collectVC = nil; } }]; } }]; }else { if (!self.collectVC) { self.collectVC = collectTableController.new; self.collectVC.collectDelegate = self; } __weak typeof(self) Self = self; [self presentController:self.collectVC animated:YES presentSize:collectPopSize completion:^{ } dismiss:^{ if (!Self.collectVC.isNeedHold) { Self.collectVC = nil; } }]; } } - (void)goToAsk:(UIButton*)btn { if (![TPUserDefault instance].userBO) { loginPopUpController *loginVC = loginPopUpController.new; __weak typeof(self) Self = self; [self presentController:loginVC animated:YES presentSize:loginPopUpSize completion:^{ } dismiss:^{ if ([TPUserDefault instance].userBO) { [Self.loginButton setSelect:YES animation:YES]; Self.loginButton.titleText = @"已登录"; if (!Self.myAskVC) { Self.myAskVC = myAskCenterHomeController.new; Self.myAskVC.delegate = self; } [Self presentController:Self.myAskVC animated:YES presentSize:myAskCenterPopSize completion:^{ } dismiss:^{ if (!Self.myAskVC.isNeenHold) { Self.myAskVC = nil; } }]; } }]; }else { if (!self.myAskVC) { self.myAskVC = myAskCenterHomeController.new; self.myAskVC.delegate = self; } __weak typeof(self) Self = self; [Self presentController:self.myAskVC animated:YES presentSize:myAskCenterPopSize completion:^{ } dismiss:^{ if (!Self.myAskVC.isNeenHold) { Self.myAskVC = nil; } }]; } } - (void)goToSearch:(UIButton*)btn { if (!self.searchVC) { self.searchVC = [[searchController alloc] init]; self.searchVC.delegate = self; } [self presentController:self.searchVC animated:YES presentSize:searchPopSize completion:^{ } dismiss:^{ if (!self.searchVC.isNeedHold) { self.searchVC = nil; } }]; } //进入我的话题 - (void)goToTopic:(UIButton*)btn { if (![TPUserDefault instance].userBO) { loginPopUpController *loginVC = loginPopUpController.new; __weak typeof(self) Self = self; [self presentController:loginVC animated:YES presentSize:loginPopUpSize completion:^{ } dismiss:^{ if ([TPUserDefault instance].userBO) { [Self.loginButton setSelect:YES animation:YES]; Self.loginButton.titleText = @"已登录"; if (!Self.gambitVC) { Self.gambitVC = gambitCenterHomeController.new; Self.gambitVC.delegate = self; } [Self presentController:Self.gambitVC animated:YES presentSize:gambitCenterPopSize completion:^{ } dismiss:^{ if (!Self.gambitVC.isNeedHold) { Self.gambitVC = nil; } }]; } }]; }else { if (!self.gambitVC) { self.gambitVC = gambitCenterHomeController.new; self.gambitVC.delegate = self; } __weak typeof(self) Self = self; [Self presentController:self.gambitVC animated:YES presentSize:gambitCenterPopSize completion:^{ } dismiss:^{ if (!Self.gambitVC.isNeedHold) { Self.gambitVC = nil; } }]; } } -(void)goToTopicList{ __weak typeof(self) Self = self; [self.gambitVC dismissControllerAnimated:YES completion:^{ if (!Self.gambitVC.isNeedHold) { Self.gambitVC = nil; } customFlowLayout *layout = nil; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; CGSize itemSize = CGSizeZero; layout= [[customFlowLayout alloc]init]; layout.scrollDirection = UICollectionViewScrollDirectionVertical; layout.minimumLineSpacing = 35; layout.minimumInteritemSpacing = 35; CGFloat width = 0; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { width = (self.view.bounds.size.width-35*3)/2; }else { width = (self.view.bounds.size.width-35*4)/3; } CGFloat viewScale = width/600; itemSize = CGSizeMake(width, 450*viewScale); layout.itemSize = itemSize; topicListHomeController *topicController = [[topicListHomeController alloc]initWithCollectionViewLayout:layout]; [Self.navigationController pushViewController:topicController animated:YES]; }]; } -(void)goToCreateList:(TopicInfoBO *)topicInfo tag:(NSString *)tag{//【需求】话题:话题修改(bug:4313) __weak typeof(self) Self = self; [self.gambitVC dismissControllerAnimated:YES completion:^{ if (!Self.gambitVC.isNeedHold) { Self.gambitVC = nil; } creatTopicController *creatTopicVC = [[creatTopicController alloc]init]; if (topicInfo) { creatTopicVC.topicBO = topicInfo; } creatTopicVC.tag = tag; [Self.navigationController pushViewController:creatTopicVC animated:YES]; }]; } //-(void) goToCreateList:(TopicInfoBO *)topicInfo{ // __weak typeof(self) Self = self; // [self.gambitVC dismissControllerAnimated:YES completion:^{ // if (!Self.gambitVC.isNeedHold) { // Self.gambitVC = nil; // } // creatTopicController *creatTopicVC = [[creatTopicController alloc]init]; // if (topicInfo) { // creatTopicVC.topicBO = topicInfo; // } // [Self.navigationController pushViewController:creatTopicVC animated:YES]; // }]; //} -(void)goTopicInfo:(TopicInfoBO *)topicInfo{ __weak typeof(self) Self = self; [self.gambitVC dismissControllerAnimated:YES completion:^{ if (!Self.gambitVC.isNeedHold) { Self.gambitVC = nil; } topicContentController *topicControllerVC = [[topicContentController alloc]init]; if (topicInfo) { topicControllerVC.preTopicInfo = topicInfo; topicControllerVC.creatUser = setJsonDicToDataModel(topicInfo.userInfo, [userBO class]); } topicControllerVC.currentIndex = @"1"; [Self.navigationController pushViewController:topicControllerVC animated:YES]; }]; } -(void)gotoGambit:(commentObjectVO *)comment{ __weak typeof(self) Self = self; self.myAskVC.isNeenHold = YES; [self.myAskVC dismissControllerAnimated:YES completion:^{ if (!Self.myAskVC.isNeenHold) { Self.myAskVC = nil; } otherPersonHomepageController *otherVC = [otherPersonHomepageController new]; otherVC.commentBo = comment; [self.navigationController pushViewController:otherVC animated:YES]; }]; } -(void)messageHomeToOtherVC:(letterBO *)bo{ __weak typeof(self) Self = self; self.messageVC.isNeedHold = YES; [Self.messageVC dismissControllerAnimated:YES completion:^{ if (!Self.messageVC.isNeedHold) { Self.messageVC = nil; } pushLetterPageWithLetterBO(Self.navigationController, bo); }]; } -(void)notificationToOther:(commentObjectVO *)bo{ __weak typeof(self) Self = self; self.messageVC.isNeedHold = YES; [Self.messageVC dismissControllerAnimated:YES completion:^{ if (!Self.messageVC.isNeedHold) { Self.messageVC = nil; } otherPersonHomepageController *otherVC = [otherPersonHomepageController new]; otherVC.commentBo = bo; [Self.navigationController pushViewController:otherVC animated:YES]; }]; } -(void)pushMsgToOtherVC:(letterBO *)bo{ __weak typeof(self) Self = self; self.messageVC.isNeedHold = YES; [Self.messageVC dismissControllerAnimated:YES completion:^{ if (!Self.messageVC.isNeedHold) { Self.messageVC = nil; } pushLetterPageWithLetterBO(self.navigationController, bo); }]; } -(void)msgHomeToUserGamb:(commentObjectVO *)bo{ __weak typeof(self) Self = self; self.messageVC.isNeedHold = YES; [Self.messageVC dismissControllerAnimated:YES completion:^{ if (!Self.messageVC.isNeedHold) { Self.messageVC = nil; } otherPersonHomepageController *otherVC = [otherPersonHomepageController new]; otherVC.commentBo = bo; [Self.navigationController pushViewController:otherVC animated:YES]; }]; } - (void)hasAppearMyAskCenter { [self refreshMsgMark]; } - (void)hasAppearTrackCenter { [self refreshMsgMark]; } -(void) hasAppearCollectCenter{ [self refreshMsgMark]; } -(void) hasAppearSearchCenter{ [self refreshMsgMark]; } -(void) hasAppearMyGambitCenter{ [self refreshMsgMark]; } -(void)hasAppearMsgCenter{ [self refreshMsgMark]; } - (void)goToContent:(id)data { objInfoBO *commentBO = data; __weak typeof(self) Self = self; [self.myAskVC dismissControllerAnimated:YES completion:^{ pushContentWithObjInfo(Self.navigationController, commentBO); }]; } -(void)gotoTopicInfo:(TopicInfoBO *)topic user:(userBO *)user{ __weak typeof(self) Self = self; self.myAskVC.isNeenHold = YES; [self.myAskVC dismissControllerAnimated:YES completion:^{ if (!Self.myAskVC.isNeenHold) { Self.myAskVC = nil; } // topic.topicId = @"7"; topicContentController *topicControllerVC = [[topicContentController alloc]init]; if (topic) { topicControllerVC.preTopicInfo = topic; topicControllerVC.creatUser = user; } [Self.navigationController pushViewController:topicControllerVC animated:YES]; }]; } - (void)trackGoToContent:(id)data { __weak typeof(self) Self = self; [self.trackVC dismissControllerAnimated:YES completion:^{ if ([data isKindOfClass:[listContObjectVO class]]) { listContObjectVO *listItem = data; pushContentWithListContentObject(Self.navigationController, listItem); } }]; } -(void) collectGoToContent:(id)data{ __weak typeof(self) Self = self; [self.collectVC dismissControllerAnimated:YES completion:^{ if ([data isKindOfClass:[listContObjectVO class]]) { listContObjectVO *listItem = data; pushContentWithListContentObject(Self.navigationController, listItem); } }]; } -(void) searchGoToContent:(id)data{ __weak typeof(self) Self = self; [self.searchVC dismissControllerAnimated:YES completion:^{ if ([data isKindOfClass:[listContObjectVO class]]) { listContObjectVO *listItem = data; pushContentWithListContentObject(Self.navigationController, listItem); } }]; } -(void)gotoNightMode:(UIButton*)btn{//夜间模式 if ([[TPUserDefault instance].isNightMode isEqualToString:@"0"]) { [self.nightModeButton setBUttonNormalImage:Image(@"setting/dayModeIcon.png") highLightImage:Image(@"setting/dayModeIcon_h.png") selectedImage:Image(@"setting/nightModeIcon.png")]; self.nightModeButton.titleText = @"日间模式"; [TPUserDefault instance].isNightMode = @"1"; [UIView animateWithDuration:0.3 animations:^{ TPWindow *window = (TPWindow*)[[UIApplication sharedApplication]keyWindow]; [window setMaskAfterOpenNightMode]; } completion:^(BOOL finished) { [MobClick event:@"44"]; [[NSNotificationCenter defaultCenter]postNotificationName:REFRESHAFTERNIGHTMODE object:nil]; }]; }else { [self.nightModeButton setBUttonNormalImage:Image(@"setting/nightModeIcon.png") highLightImage:Image(@"setting/nightModeIcon_h.png") selectedImage:Image(@"setting/dayModeIcon.png")]; self.nightModeButton.titleText = @"夜间模式"; [TPUserDefault instance].isNightMode = @"0"; [UIView animateWithDuration:0.3 animations:^{ TPWindow *window = (TPWindow*)[[UIApplication sharedApplication]keyWindow]; [window setNoNightModeMask]; } completion:^(BOOL finished) { [MobClick event:@"44"]; [[NSNotificationCenter defaultCenter]postNotificationName:REFRESHAFTERNIGHTMODE object:nil]; }]; } } -(void)gotoMessage:(UIButton*)btn{ // 社区红点:社区的消息上有红点提示,进入消息(不查看)返回,在进入跟踪、收藏、话题后返回,红点异常(bug:5388) NSMutableDictionary *mak = [NSMutableDictionary dictionaryWithDictionary:[TPUserDefault instance].msgMark]; [mak setObject:@(0) forKey:@"status"]; [mak setObject:@(0) forKey:@"questionMark"]; [mak setObject:@(0) forKey:@"attendMark"]; [mak setObject:@(0) forKey:@"replyedMark"]; [mak setObject:@(0) forKey:@"letterMark"]; [TPUserDefault instance].msgMark = [NSMutableDictionary dictionaryWithDictionary:mak]; [self.messageButton.button clearBadgeView]; if (![TPUserDefault instance].userBO) { loginPopUpController *loginVC = loginPopUpController.new; __weak typeof(self) Self = self; [self presentController:loginVC animated:YES presentSize:loginPopUpSize completion:^{ } dismiss:^{ if ([TPUserDefault instance].userBO) { [Self.loginButton setSelect:YES animation:YES]; Self.loginButton.titleText = @"已登录"; if (!Self.messageVC) { Self.messageVC = messageCenterHomeController.new; Self.messageVC.homeDelegate = self; } [Self presentController:Self.messageVC animated:YES presentSize:hotAskListPopUpSize completion:^{ } dismiss:^{ if (!Self.messageVC.isNeedHold) { Self.messageVC = nil; } }]; } }]; }else { if (!self.messageVC) { self.messageVC = messageCenterHomeController.new; self.messageVC.homeDelegate = self; } __weak typeof(self) Self = self; [Self presentController:self.messageVC animated:YES presentSize:hotAskListPopUpSize completion:^{ } dismiss:^{ if (!Self.messageVC.isNeedHold) { Self.messageVC = nil; } }]; } // if (!self.messageVC) { // self.messageVC = [[messageCenterHomeController alloc] init]; // self.messageVC.homeDelegate = self; // } // // [self presentController:self.messageVC animated:YES presentSize:hotAskListPopUpSize completion:^{ // // } dismiss:^{ // if (!self.messageVC.isNeedHold) { // self.messageVC = nil; // } // }]; } - (void)messageToContent:(id)data { // commentObjectVO *commentBO = data; //全景现场:全景现场的问答详情页,点击进入原新闻必闪退(bug:5814) // commentObjectVO *commentBO = data; __weak typeof(self) Self = self; [Self.messageVC dismissControllerAnimated:YES completion:^{ if([data isKindOfClass:[objInfoBO class]]){ pushContentWithObjInfo(Self.navigationController, (objInfoBO*)data); }else{ pushContentWithCommentBO(self.navigationController, (commentObjectVO*)data); } }]; } -(void)messageTopicInfo:(TopicInfoBO *)topic user:(userBO *)user{ __weak typeof(self) Self = self; self.messageVC.isNeedHold = YES; [Self.messageVC dismissControllerAnimated:YES completion:^{ if (!Self.messageVC.isNeedHold) { Self.messageVC = nil; } topicContentController *topicControllerVC = [[topicContentController alloc]init]; if (topic) { topicControllerVC.preTopicInfo = topic; topicControllerVC.creatUser = user; } [Self.navigationController pushViewController:topicControllerVC animated:YES]; }]; } -(void)messageToTopicList{ __weak typeof(self) Self = self; self.messageVC.isNeedHold = YES; [Self.messageVC dismissControllerAnimated:YES completion:^{ if (!Self.messageVC.isNeedHold) { Self.messageVC = nil; } customFlowLayout *layout1 = nil; UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; CGSize itemSize = CGSizeZero; layout1= [[customFlowLayout alloc]init]; layout1.scrollDirection = UICollectionViewScrollDirectionVertical; layout1.minimumLineSpacing = 35; layout1.minimumInteritemSpacing = 35; CGFloat width = 0; if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown) { width = (self.view.bounds.size.width-35*3)/2; }else { width = (self.view.bounds.size.width-35*4)/3; } CGFloat viewScale = width/600; itemSize = CGSizeMake(width, 450*viewScale); layout1.itemSize = itemSize; topicListHomeController *vc = [[topicListHomeController alloc] initWithCollectionViewLayout:layout1]; [Self.navigationController pushViewController:vc animated:YES]; }]; } #pragma mark - login handler - (void)login { [self.loginButton setSelect:YES animation:YES]; self.loginButton.titleText = @"已登录"; [self refreshMsgMark]; } - (void)loginOut { [self.loginButton setSelect:NO animation:YES]; self.loginButton.titleText = @"登录"; [self refreshMsgMark]; } -(void)userInfoToSetting:(commentObjectVO *)comment{ __weak typeof(self) Self = self; Self.loginVC.isNeedHold = YES; [Self.loginVC dismissControllerAnimated:YES completion:^{ otherPersonHomepageController *vc = [otherPersonHomepageController new]; vc.commentBo = comment; [Self.navigationController pushViewController:vc animated:YES]; }]; } -(void)userInfoToReadInfo:(listContObjectVO *)data{ __weak typeof(self) Self = self; Self.loginVC.isNeedHold = YES; [Self.loginVC dismissControllerAnimated:YES completion:^{ pushContentWithListContentObject(self.navigationController, data); }]; } #pragma mark - refresh fontsize and msgMark when appear - (void)settingNaviBarAppear { [MobClick event:@"10"]; self.fontSizeSelectView.fontSize = [TPUserDefault instance].contFontSize; [self refreshMsgMark]; } - (void)settingNaviBarDisappear { otherPersonHomepageController *otherVC = [otherPersonHomepageController new]; [self.navigationController pushViewController:otherVC animated:YES]; } - (void)refreshMsgMark { if ([TPUserDefault instance].userBO) { NSDictionary *dic = [TPUserDefault instance].msgMark; if ([dic[@"trackMark"] longValue] > 0) { [self.followButton.button addBadgeView]; }else { [self.followButton.button clearBadgeView]; } // if ([dic[@"questionMark"] longValue] >0 || [dic[@"attendMark"] longValue] > 0) { // [self.askButton.button addBadgeView]; // }else { // [self.askButton.button clearBadgeView]; // } if ([dic[@"createdTopicMark"] longValue] > 0 || [dic[@"attendTopicMark"] longValue] > 0) { [self.topicButton.button addBadgeView]; }else { [self.topicButton.button clearBadgeView]; } if([dic[@"questionMark"] longValue] >0 || [dic[@"attendMark"] longValue] >0||[dic[@"replyedMark"] longValue] >0 || [dic[@"letterMark"] longValue] >0){ [self.messageButton.button addBadgeView]; }else{ [self.messageButton.button clearBadgeView]; } }else { [self.followButton.button clearBadgeView]; // [self.askButton.button clearBadgeView]; [self.topicButton.button clearBadgeView]; [self.messageButton.button clearBadgeView]; } } - (void)dealloc { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(login) name:HAVELOGIN object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginOut) name:HAVELOGINOUT object:nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end