| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- //
- // YHTimeLineViewController.m
- // BuguLive
- //
- // Created by 宋晨光 on 2019/8/23.
- // Copyright © 2019年 xfg. All rights reserved.
- //
- #import "YHTimeLineViewController.h"
- #import "YHTimeLineListController.h"
- #import "ReleaseTopicVC.h"//话题搜索
- #import "MGNewDTNavView.h"
- //#import "MGNewDTHeadView.h"
- #import "BogoDTHeadView.h"
- #import "BzoneLogic.h"
- #import "TCUtil.h"
- #import "BGTopicTimeLineListController.h"
- #import "BGSystemMsgVC.h"
- //附近的人
- #import "MGNewDTNearByViewController.h"
- #import "BogoTimeLineListViewController.h"
- #define YHTimeLineMagrin 20 //
- @interface YHTimeLineViewController ()<UIScrollViewDelegate,MGTimeLineDidScrollViewDelegate,BogoTimeLineDidScrollViewDelegate>
- @property (nonatomic, strong) MLMSegmentHead *segHead;
- @property (nonatomic, strong) MLMSegmentScroll *segScroll;
- //@property(nonatomic, strong) YHTimeLineListController *firstVC;
- //@property(nonatomic, strong) YHTimeLineListController *mineVC;
- //@property(nonatomic, strong) YHTimeLineListController *recommandVC;
- //@property(nonatomic, strong) YHTimeLineListController *nearVC;
- @property(nonatomic, strong) BogoTimeLineListViewController *firstVC;
- @property(nonatomic, strong) BogoTimeLineListViewController *mineVC;
- @property(nonatomic, strong) BogoTimeLineListViewController *recommandVC;
- @property(nonatomic, strong) BogoTimeLineListViewController *nearVC;
- //view
- @property(nonatomic, strong) MGNewDTNavView *navView;
- @property(nonatomic, strong) BogoDTHeadView *headView;
- @property(nonatomic, strong) UIScrollView *scrollView;
- @property(nonatomic, strong) NSArray *list;
- @property(nonatomic, strong) QMUIButton *postBtn;
- @property(nonatomic, strong) BzoneLogic *logic;
- @property(nonatomic, strong) UIView *lineView;
- @end
- @implementation YHTimeLineViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- [self setUpView];
- [self segmentStyle1];
- [self requsetModel];
- }
- -(void)setUpView{
- self.navView.hidden = YES;
- [self.view addSubview:self.navView];
- [self.view addSubview:self.scrollView];
- [self.scrollView addSubview:self.headView];
- // self.scrollView.frame = CGRectMake(0, self.navView.bottom, kScreenW, kScreenH - kTabBarHeight - self.navView.bottom);
- self.scrollView.frame = CGRectMake(0, 0, kScreenW, kScreenH - kTabBarHeight - kTopHeight);
- self.navigationController.navigationBarHidden = YES;
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- self.navigationController.navigationBarHidden = YES;
- // [self requsetModel];
- [self requsetUnRead_Msg];
- }
- -(void)requsetModel{
-
- self.logic = [BzoneLogic new];
-
- if (kIsCheckingVersion())
- {
- return;
- }
-
- [self.logic dynamicGetTopicModelWithUID:[BGIMLoginManager sharedInstance].loginParam.identifier Success:^(NSDictionary * _Nonnull dic) {
- if ([[dic valueForKey:@"status"] integerValue] == 1) {
-
- for (NSDictionary *subDic in [dic valueForKey:@"data"]) {
- MGDynamicTopicModel *model = [MGDynamicTopicModel itemWithDic:subDic];
- [self.logic.topicArr addObject:model];
- }
- [self.headView resetTopicModel:self.logic.topicArr];
- }
- }];
- }
- -(void)requsetUnRead_Msg{
-
- self.logic = [BzoneLogic new];
- [self.logic fetchUnRead_MsgSuccess:^(NSDictionary * _Nonnull dic) {
- if ([[dic valueForKey:@"status"] integerValue] == 1) {
- if ([dic[@"no_read_msg"] intValue] ==0) {
- self.navView.jsbadge.badgeText = nil;
- }else{
- self.navView.jsbadge.badgeText = [NSString stringWithFormat:@"%@",dic[@"no_read_msg"]];
- }
- [ self.navView.jsbadge setNeedsLayout];
- }
- }];
- }
- - (void)segmentStyle1 {
-
- self.firstVC = [[BogoTimeLineListViewController alloc]initWithIndexAct:MGDTHOMETYPE_RECOMMAND withUID:@"" isHomePageFrame:CGRectMake(0, 0, kScreenW, kScreenH - kTopHeight - kTabBarHeight - MG_BOTTOM_MARGIN)];
- // alloc]initWithIndexAct:MGDTHOMETYPE_RECOMMAND withUID:@""];
-
- _list = @[ ASLocalizedString(@"推荐"),ASLocalizedString(@"关注"),/*ASLocalizedString(@"附近"),*/ASLocalizedString(@"我的")];
-
- _segHead = [[MLMSegmentHead alloc] initWithFrame:CGRectMake(15, self.headView.bottom, SCREEN_WIDTH - 60 , 40) titles:_list headStyle:SegmentHeadStyleLine layoutStyle:MLMSegmentLayoutLeft];
- // _segHead.centerX = kScreenW / 2;
- _segHead.backgroundColor = UIColor.clearColor;
- _segHead.headColor = UIColor.clearColor;
- //tab颜色
- _segHead.selectColor = [UIColor colorWithHexString:@"#333333"];
- _segHead.deSelectColor = [UIColor colorWithHexString:@"#666666"];
- _segHead.selectFont = [UIFont boldSystemFontOfSize:18];
- _segHead.deSelectFont = [UIFont systemFontOfSize:15];
- _segHead.titlesScroll.backgroundColor = UIColor.clearColor;
-
- _segHead.lineScale = 0.3;
- _segHead.lineHeight = 3.5;
- _segHead.lineColor = [UIColor colorWithHexString:@"#78FFCB"];
- _segHead.bottomLineHeight = 0;
- UIView * line = [self.segHead getScrollLineView];
- CGRect rect = line.frame;
- rect.origin.y -= 7;
- line.frame = rect;
-
- // _segHead.deSelectColor = [UIColor colorWithRed:0.91 green:0.47 blue:0.62 alpha:1.00];
- self.view.backgroundColor = kClearColor;
- // CF6;
- _segScroll = [[MLMSegmentScroll alloc] initWithFrame:CGRectMake(0, _segHead.bottom, SCREEN_WIDTH, SCREEN_HEIGHT-self.headView.height-self.navView.height - kTabBarHeight) vcOrViews:[self vcArr:_list.count]];
- _segScroll.loadAll = NO;
- _segScroll.showIndex = 0;
- _segScroll.backgroundColor = UIColor.clearColor;
-
- [MLMSegmentManager associateHead:_segHead withScroll:_segScroll completion:^{
- [self.scrollView addSubview:_segHead];
- self.lineView.top = _segHead.bottom + 8;
- [self.scrollView addSubview:self.lineView];
- [self.scrollView addSubview:_segScroll];
- // [self setHeadBottomLineView];
- }];
- }
- //-(void)setHeadBottomLineView{
- // UIView *line = [_segHead getScrollLineView];
- //
- // line.layer.cornerRadius = 2;
- // line.layer.masksToBounds = YES;
- //
- // CAGradientLayer *gl = [CAGradientLayer layer];
- // gl.frame = line.bounds;
- // gl.startPoint = CGPointMake(0, 0.5);
- // gl.endPoint = CGPointMake(1, 0.5);
- // gl.colors = @[(__bridge id)[UIColor colorWithHexString:@"#9E64FF"].CGColor, (__bridge id)[UIColor colorWithHexString:@"#EF60F6"].CGColor];
- // gl.locations = @[@(0), @(1.0f)];
- // [line.layer insertSublayer:gl atIndex:0];
- //}
- -(void)handleSearchEvent{
- // [self.firstVC handleSearchEvent];
- //// [self.mineVC handleSearchEvent];
- //// [self.nearVC handleSearchEvent];
- }
- -(void)reloadDynamicData{
- // [self.firstVC reloadDynamicData];
- // [self.mineVC reloadDynamicData];
- // [self.nearVC reloadDynamicData];
- }
- -(void)protocolTimeLineDidScrollView:(UIScrollView *)scrollView offset:(CGFloat)offset{
-
- NSLog(@"offset%f",offset);
- NSLog(@"offset%f",offset);
- NSLog(@"%@",scrollView);
- NSLog(@"View.contentSize.height:%f",scrollView.contentSize.height);
- NSLog(@"%f",kScreenH - self.headView.height - kTabBarHeight - MG_TOP_MARGIN - MG_BOTTOM_MARGIN)
-
- if (scrollView.contentSize.height < kScreenH - kTopHeight - kTabBarHeight) {
- [self.scrollView setContentOffset:CGPointMake(0, offset < 0 ? 0 : offset)];
- self.segScroll.height = scrollView.height = kScreenH - kTopHeight - kTabBarHeight - YHTimeLineMagrin;
- return;
- }
-
- if (offset > self.headView.height) {
- [self.scrollView setContentOffset:CGPointMake(0, self.headView.height)];
- self.segScroll.height = scrollView.height = kScreenH - kTopHeight - 49 - MG_BOTTOM_MARGIN;// - self.headView.height
- // kScreenH - self.navView.height - kTabBarHeight - self.headView.height;
- //
-
- NSLog(@"%f",kStatusBarHeight);
- NSLog(@"%f",kTopHeight);
- NSLog(@"%f",MG_BOTTOM_SAFE_HEIGHT);
- NSLog(@"%f",self.headView.height);
-
- // self.segScroll.height = scrollView.height = kScreenH - self.navView.height - kTabBarHeight - self.headView.height;
- return;
- }
-
- if (scrollView.height < kScreenH - self.navView.height - self.segHead.height - kTabBarHeight && offset > 0) {
- return;
- }
-
- self.segScroll.height = scrollView.height = kScreenH - self.navView.height - self.segHead.height - kTabBarHeight - YHTimeLineMagrin;
- [self.scrollView setContentOffset:CGPointMake(0, offset < 0 ? 0 : offset)];
- }
- #pragma mark - 数据源
- - (NSArray *)vcArr:(NSInteger)count
- {
- NSMutableArray *arr = [NSMutableArray array];
-
- CGRect frame = CGRectMake(0, 0, kScreenW, kScreenH - kTopHeight - kTabBarHeight - MG_BOTTOM_MARGIN);
-
- BogoTimeLineListViewController *vc2 = [[BogoTimeLineListViewController alloc]initWithIndexAct:MGDTHOMETYPE_CONCERT withUID:@"" isHomePageFrame:frame];
- BogoTimeLineListViewController *vc3 = [[BogoTimeLineListViewController alloc]initWithIndexAct:MGDTHOMETYPE_NEARBY withUID:@"" isHomePageFrame:frame];
- // YHTimeLineListController *vc4 = [[YHTimeLineListController alloc]initWithIndexAct:MGDTHOMETYPE_VIDEO withUID:@""];
- BogoTimeLineListViewController *vc5 = [[BogoTimeLineListViewController alloc]initWithIndexAct:MGDTHOMETYPE_MY withUID:[BGIMLoginManager sharedInstance].loginParam.identifier isHomePageFrame:frame];;
-
-
- self.firstVC.timeLineDelegate = self;
- vc2.timeLineDelegate = self;
- vc3.timeLineDelegate = self;
- // vc4.timeLineDelegate = self;
- vc5.timeLineDelegate = self;
-
- [arr addObject:self.firstVC];
- [arr addObject:vc2];
- // [arr addObject:vc3];
- // [arr addObject:vc4];
- [arr addObject:vc5];
-
- return arr;
- }
- -(UIScrollView *)scrollView{
- if (!_scrollView) {
- _scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH)];
- _scrollView.delegate = self;
- _scrollView.backgroundColor = UIColor.clearColor;
- }
- return _scrollView;
- }
- //放在当前view上
- -(MGNewDTNavView *)navView{
- if (!_navView) {
- _navView = [[MGNewDTNavView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kTopHeight)];
- __weak __typeof(self)weakSelf = self;
- _navView.clickPostBlock = ^(NSInteger i) {
- if (i == 0) {
- ReleaseTopicVC *pushVC = [ReleaseTopicVC new];
- pushVC.releaseTopicBlock = ^(MGDynamicTopicModel * _Nonnull topic) {
- BGTopicTimeLineListController *pushVC = [BGTopicTimeLineListController new];
- pushVC.topic = topic;
- [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
- };
- [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
- // presentViewController:pushVC animated:YES completion:nil];
- }else if (i == 1){
- [weakSelf handleSearchEvent];
- }else if (i == 2){
- BGSystemMsgVC *pushVC = [BGSystemMsgVC new];
- [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
- }
- };
- }
- return _navView;
- }
- //放在scrollview上的
- -(BogoDTHeadView *)headView{
- if (!_headView) {
-
- _headView = [[NSBundle mainBundle]loadNibNamed:@"BogoDTHeadView" owner:self options:nil].firstObject;
- _headView.backgroundColor = kClearColor;
-
- if (isIPhone6()) {
- _headView.frame = CGRectMake(0, 0, kScreenW, kRealValue(116 + 15 + 15 ));
- }else{
- _headView.frame = CGRectMake(0, 0, kScreenW, kRealValue(116 + 15 + 15 + 20));
- }
-
-
- // _headView = [[MGNewDTHeadView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(130))];
- // FWWeakify(self)
- // _headView.MGNewDTHeadViewTopicBlock = ^(NSInteger index) {
- // FWStrongify(self)
- //
- // if (index == 1000) {//全部话题
- // MGNewDTNearByViewController *pushVC = [[MGNewDTNearByViewController alloc]initWithType:MGNEWDTTYPE_TOPIC];
- // [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
- // }else{
- // BGTopicTimeLineListController *pushVC = [BGTopicTimeLineListController new];
- //// if (self.logic.topicArr.count > index - 1) {
- // pushVC.topic = _headView.topicArr[index];
- //// self.logic.topicArr[index];
- // [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
- //// }
- // }
- // };
- }
- return _headView;
- }
- -(UIView *)lineView{
- if (!_lineView) {
- _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 3)];
- _lineView.backgroundColor = kClearColor;
-
- }
- return _lineView;
- }
- @end
|