|
//
// topicDeatilControllerViewx.m
// ThePaperBase
//
// Created by zhousan on 15/8/12.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "topicDeatilController.h"
#import "askDetailController.h"
#import "writeCommentAndAskController.h"
#import "topicDetailListController.h"
#import "loginHomeController.h"
#import "topicContentController.h"
#import "imageShareContent.h"
@interface topicDeatilController () <topicDetailListDelegate,commentBarDelegate,writeContentDelegate>
@property(nonatomic, strong)topicDetailListController *topicDetailListController;
@property(nonatomic, strong)commentBarView *commentBar;
@property(nonatomic, strong)objInfoBO *objInfo;
@property(nonatomic, strong)writeCommentAndAskController *writeCommentContentVC;
@end
@implementation topicDeatilController
- (void)viewDidLoad {
[super viewDidLoad];
self.titleStr = @"进入原话题";
self.view.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
[self addChildViewController:self.topicDetailListController];
[self.view addSubview:self.topicDetailListController.view];
[self.view addSubview:self.commentBar];
if ([self.commentBO.type intValue]== 2 || [self.commentBO.type intValue]== 24) {
self.topicDetailListController.commmentId = self.commentBO.commentId;
}else {
if ([self.commentBO.objectType intValue] ==3) {
self.topicDetailListController.commmentId = self.commentBO.parent[@"commentId"];
}else{
self.topicDetailListController.commmentId = self.commentBO.parentId;
}
}
NSDictionary *dic = @{@"topicId":self.commentBO.contId};
[Remote doJsonActionWithBlock:1 requestUrl:topicInfoURL parameter:dic withWaitCursor:NO completion:^(BOOL success, NSString *message, id responseData) {
NSDictionary *dic = responseData;
TopicInfoBO *topic = setJsonDicToDataModel(dic[@"topicInfo"], [TopicInfoBO class]);
userBO *user = setJsonDicToDataModel(topic.userInfo, [userBO class]);
self.topicDetailListController.topicHostId =user.userId;
}];
self.topicDetailListController.answerNums = self.commentBO.answerNums;
self.topicDetailListController.topicShareTitle = self.commentBO.contName;
self.topicDetailListController.topicShareUrl = self.commentBO.shareUrl;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
- (void)needrefreshNightMode:(id)sender{
self.topicDetailListController.tableView.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.commentBar.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
self.view.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
}
- (topicDetailListController*)topicDetailListController {
if (!_topicDetailListController) {
_topicDetailListController = [[topicDetailListController alloc]init];
_topicDetailListController.delegate = self;
_topicDetailListController.view.frame = CGRectMake(0,
self.barHeight,
CGRectGetWidth(self.view.bounds),
CGRectGetHeight(self.view.bounds)-self.barHeight-CGRectGetHeight(self.commentBar.frame));
}
return _topicDetailListController;
}
- (commentBarView*)commentBar {
if (!_commentBar) {
_commentBar = [[commentBarView alloc]initWithFrame:CGRectMake(0,
CGRectGetHeight(self.view.bounds)-50,
CGRectGetWidth(self.view.bounds), 50)];
_commentBar.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
_commentBar.inviteBtn.hidden = YES;
_commentBar.textLabel.text = @"回复";
_commentBar.delegate = self;
[_commentBar relayouSubView];
}
return _commentBar;
}
- (void)setCommentBO:(commentObjectVO *)obj {
_commentBO = obj;
}
-(void)remoteResponsSuccess:(int)actionTag withResponsData:(id)responsData{
TopicInfoBO *topic = setJsonDicToDataModel(responsData[@"topicInfo"], [TopicInfoBO class]);
userBO *user = setJsonDicToDataModel(topic.userInfo, [userBO class]);
self.topicDetailListController.topicHostId =user.userId;
}
- (void)refreshObjInfo:(objInfoBO*)infoBO {
self.objInfo = infoBO;
}
- (void)tapNaviBar:(id)sender {
if (self.objInfo) {
topicContentController *vc = [topicContentController new];
vc.preTopicInfo = self.topicInfo;
[self.navigationController pushViewController:vc animated:YES];
addHaveReadFlag(self.objInfo.forwordNodeId);
}
}
- (void)clickToAsk:(UIButton*)btn {
if ([TPUserDefault instance].userBO) {
self.writeCommentContentVC = [[writeCommentAndAskController alloc]init];
self.writeCommentContentVC.type = aswerType;
self.writeCommentContentVC.nodeId = self.commentBO.contId;
self.writeCommentContentVC.delegate = self;
self.writeCommentContentVC.commentBO = self.commentBO;
self.writeCommentContentVC.isPush = YES;
if ([self.commentBO.objectType isEqualToString:@"3"]) {//0004269: 个人主页: 通过头像进入个人主页,对列表中的评论、话题的提问进行回复时提示不存在或下线的提示信息(bug:4269)
self.writeCommentContentVC.commentOT = @"3";
}
((MLNavigationController *)self.navigationController).canDragBack = NO;
[self presentController:self.writeCommentContentVC animated:YES completion:^{
}];
}else {
loginHomeController *vc = loginHomeController.new;
[self.navigationController pushViewController:vc animated:YES];
}
}
- (void)dismissWriteContent:(commentAndAskType)type{
__weak typeof(self) Self = self;
[self dismissViewController:self.writeCommentContentVC animated:YES completion:^{
Self.writeCommentContentVC = nil;
((MLNavigationController *)self.navigationController).canDragBack = YES;
}];
}
- (void)commentSuccess:(commentAndAskType)type {
__weak typeof(self) Self = self;
[self dismissViewController:self.writeCommentContentVC animated:YES completion:^{
[self.topicDetailListController manualRefresh];
((MLNavigationController *)self.navigationController).canDragBack = YES;
Self.writeCommentContentVC = nil;
}];
}
- (void)presentAskToUserContent:(commentObjectVO *)commentBO {
self.writeCommentContentVC = [[writeCommentAndAskController alloc]init];
self.writeCommentContentVC.type = askForUserType;
self.writeCommentContentVC.nodeId = self.commentBO.contId;
self.writeCommentContentVC.delegate = self;
self.writeCommentContentVC.commentBO = commentBO;
if([self.commentBO.objectType isEqualToString:@"3"]){//0004269: 个人主页: 通过头像进入个人主页,对列表中的评论、话题的提问进行回复时提示不存在或下线的提示信息(bug:4269)
self.writeCommentContentVC.commentOT = @"3";
}
((MLNavigationController *)self.navigationController).canDragBack = NO;
[self presentController:self.writeCommentContentVC animated:YES completion:^{
}];
}
- (void)gotoCommentFromHotAnwser:(commentObjectVO *)comment {
if ([TPUserDefault instance].userBO) {
[self presentAskToUserContent:comment];
}else {
[self askPushToLoginView];
}
}
- (void)askPushToLoginView {
loginHomeController *vc = [loginHomeController new];
[self.navigationController pushViewController:vc animated:YES];
}
-(void)topicDetailToShare:(UIImage *)img contenBO:(contentObjectBO *)contentBO{
imageShareContent *shareContentView = [[imageShareContent alloc]initWithFrame:CGRectMake(0,
0,
CGRectGetWidth(self.view.bounds),
CGRectGetHeight(self.view.bounds))];
shareContentView.contentBO = contentBO;
shareContentView.shareImg = img;
shareContentView.baseController = self;
shareContentView.sharestyle = shareTopicStyle;
[shareContentView presentShareContentInView:self.view sender: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
|