123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- //
- // SourceHomeVC.m
- // smartRhino
- //
- // Created by niuzhen on 2020/5/6.
- // Copyright © 2020 tederen. All rights reserved.
- //
- #import "SourceHomeVC.h"
- #import "GHRefreshCollectionView.h"
- #import "MyTDGroupView.h"
- #import "MenuListView.h"
- #import "ShowBtn.h"
- #import "ChatMsgCollectionCell.h"
- #import "ChatMsgListVC.h"
- #import "TopicGroupManageModel.h"
- #import "MyTDTopicGroupManageVC.h"
- #import "MyTDTopicSearchVC.h"
- #import "MyTDTopicBookVC.h"
- #import "MyTDGroupViewController.h"
- #import "MyTDTopicBookVC.h"
- #import "GroupSquareVC.h"
- #import "SourceListVC.h"
- @interface SourceHomeVC ()<UICollectionViewDelegate,UICollectionViewDataSource>
- @property (nonatomic, strong) UIView *NavBar;
- @property (nonatomic, strong) ShowBtn *showBtn;
- @property (nonatomic, strong) UIButton *addBtn;
- @property (nonatomic, strong) UIView *headView;
- @property (nonatomic, strong) GHRefreshCollectionView *collectionView;
- @property (strong, nonatomic) MyTDGroupView *SearchView;
- @property (strong, nonatomic) NSMutableArray *collectionDataSource;
- @property (strong, nonatomic) NSMutableArray *selectGIdArray;
- @property (strong, nonatomic) NSMutableArray *groupListArray;
- @property (copy, nonatomic) NSString *listName;
- @property (strong, nonatomic) SourceListVC *listVC;
- @property (strong, nonatomic) MenuListView *menuListView;
- @property (assign, nonatomic) BOOL menuIsShow;
- @end
- @implementation SourceHomeVC
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- }
- - (void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- [self.showBtn dismissCom];
- self.menuIsShow = NO;
- [self.menuListView dismiss];
- }
- - (BOOL)hidesBottomBarWhenPushed
- {
- [self.tabBarController.tabBar setHidden:NO];
- return NO;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- [self loadStatusBarColor:[UIColor whiteColor]];
- [self.view addSubview:self.NavBar];
- [self.NavBar addSubview:self.showBtn];
- [self.NavBar addSubview:self.addBtn];
- [self.NavBar mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.statusBar.mas_bottom);
- make.left.right.equalTo(self.view);
- make.height.equalTo(@44);
- }];
- [self.showBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.center.mas_equalTo(self.NavBar);
- }];
- [self.addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.statusBar.mas_bottom);
- make.right.mas_offset(-10);
- make.size.mas_offset(CGSizeMake(44, 44));
- }];
- WS(weakSelf);
- [self setShowData];
- [self.addBtn setAction:^{
- MyTDTopicCreateVC * vc = [MyTDTopicCreateVC initMyTDTopicCreateVC];
- vc.type = CollectModel_NewTopic;
- vc.hidesBottomBarWhenPushed = YES;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- [self addHeadView];
- [self setCusPageVC];
- [self initCollectionData];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PushSettingVC:) name:DRAWERPUSHVC object:nil];
- }
- - (void)PushSettingVC:(NSNotification *)notification
- {
- NSInteger index = [[notification.userInfo objectForKey:VCINDEX] integerValue];
- if (index == 1) {
- MyTDGroupViewController *vc = [[MyTDGroupViewController alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:NO];
- }
- }
- - (void)dealloc
- {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- - (void)addHeadView
- {
- UIView * lineV = [UIView new];
- lineV.backgroundColor = UIColorHex(0xEAEAEA);
- [self.headView addSubview:lineV];
- [self.headView addSubview:self.SearchView];
- [self.headView addSubview:self.collectionView];
- [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_equalTo(self.headView);
- make.height.mas_offset(0.5);
- }];
- [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.mas_equalTo(self.headView);
- make.bottom.mas_equalTo(lineV.mas_top);
- make.height.mas_offset(69);
- }];
- [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_offset(5);
- make.left.right.mas_equalTo(self.headView);
- make.bottom.mas_equalTo(self.collectionView.mas_top);
- }];
- WS(weakSelf);
- [self.SearchView.button setAction:^{
- MyTDTopicSearchVC * vc = [[MyTDTopicSearchVC alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- }];
- }
- -(NSMutableArray *)collectionDataSource{
- if(!_collectionDataSource){
- _collectionDataSource = [[NSMutableArray alloc] init];
- }
- return _collectionDataSource;
- }
- -(NSMutableArray *)selectGIdArray{
- if(!_selectGIdArray){
- _selectGIdArray = [[NSMutableArray alloc] init];
- }
- return _selectGIdArray;
- }
- -(NSMutableArray *)groupListArray{
- if(!_groupListArray){
- _groupListArray = [[NSMutableArray alloc] init];
- }
- return _groupListArray;
- }
- - (UIView *)NavBar
- {
- if (!_NavBar) {
- _NavBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 44)];
- _NavBar.backgroundColor = [UIColor whiteColor];
- }
- return _NavBar;
- }
- - (ShowBtn *)showBtn
- {
- if (!_showBtn) {
- _showBtn = [ShowBtn new];
- }
- return _showBtn;
- }
- - (UIButton *)addBtn
- {
- if (!_addBtn) {
- _addBtn = [UIButton new];
- [_addBtn setImage:IMG(@"detailsEditor") forState:UIControlStateNormal];
- }
- return _addBtn;
- }
- - (UIView *)headView
- {
- if (!_headView) {
- _headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 115.5)];
- _headView.backgroundColor = [UIColor whiteColor];
- }
- return _headView;
- }
- - (MyTDGroupView *)SearchView
- {
- if (!_SearchView) {
- _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)];
- }
- return _SearchView;
- }
- - (void)setCusPageVC
- {
- CGFloat height = SCREEN_HEIGHT - NAVH - self.tabBarController.tabBar.frame.size.height;
- WS(weakSelf);
- NSMutableArray * data = [NSMutableArray array];
- NSMutableArray * vcArr = [NSMutableArray array];
- self.listVC = [[SourceListVC alloc] init];
- [data addObject:@""];
- [vcArr addObject:self.listVC];
- WMZPageParam *param = PageParam()
- .wTitleArrSet(data)
- .wControllersSet(vcArr)
- //固定在所有子控制器底部 需要放在第一个控制器里 例如此例子
- .wFixFirstSet(YES)
- //悬浮开启
- .wTopSuspensionSet(YES)
- //等分
- .wTopOffsetSet(NAVH)
- .wFromNaviSet(YES)
- .wMenuAnimalSet(PageTitleMenuNone)
- .wMenuTitleFontSet(15.f)
- .wMenuTitleSelectColorSet(UIColorHex(0x3979D3))
- .wMenuIndicatorYSet(0.f)
- .wMenuIndicatorColorSet(UIColorHex(0x3979D3))
- .wMenuTitleColorSet(UIColorHex(0x666666))
- .wMenuTitleSelectFontSet(15.f)
- .wMenuFixShadowSet(NO)
- .wMenuFixRightDataSet(@" ")
- .wMenuFixWidthSet(0)
- .wNoMenuSet(YES)
- .wScrollCanTransferSet(NO)
- //头部
- .wMenuHeadViewSet(^UIView *{
- return self.headView;
- });
- self.param = param;
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- dispatch_async(dispatch_get_main_queue(), ^{
- for (UIView * view in weakSelf.view.subviews) {
- if ([view isKindOfClass:[WMZPageScroller class]]) {
- [view setFrame:CGRectMake(0, NAVH, SCREEN_WIDTH, height)];
- }
- if ([view isKindOfClass:[UIScrollView class]]) {
- UIScrollView * sView = (UIScrollView *)view;
- sView.showsVerticalScrollIndicator = NO;
- }
- }
- });
- });
- }
- - (GHRefreshCollectionView *)collectionView {
- if (!_collectionView) {
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
- _collectionView = [[GHRefreshCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
- _collectionView.delegate = self;
- _collectionView.dataSource = self;
- _collectionView.showsHorizontalScrollIndicator = NO;
- [_collectionView registerNib:[UINib nibWithNibName:@"ChatMsgCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"ChatMsgCollectionCell"];
- _collectionView.backgroundColor = [UIColor whiteColor];
- }
- return _collectionView;
- }
- -(void)initCollectionData
- {
- [self.collectionDataSource removeAllObjects];
- NSMutableArray * array = [NSMutableArray array];
- for (int i= 0;i < 3; i++) {
- MoreAppInfoModel *model = [[MoreAppInfoModel alloc] init];
- switch (i) {
- case 0:{
- model.title = @"话题本";
- model.imgName = @"Soucre_topicBook";
- model.notImgName = @"Soucre_topicBook";
- model.type = ChatMenuTopicBookType;
- model.readNum = 0;
- model.showEditFlag = YES;
- }break;
- case 1:{
- model.title = @"我的小组";
- model.imgName = @"Soucre_group";
- model.notImgName = @"Soucre_group";
- model.type = ChatMenuGroupType;
- model.readNum = 0;
- model.showEditFlag = YES;
- }break;
- default:{
- model.title = @"小组广场";
- model.imgName = @"Soucre_square";
- model.notImgName = @"Soucre_square";
- model.type = ChatMenuSquareType;
- model.readNum = 0;
- model.showEditFlag = YES;
- }break;
- }
- [array addObject:model];
- }
- self.collectionDataSource = array;
- [self.collectionView reloadData];
- }
- #pragma mark -UICollectionViewDataSource
- /**********************************************************************/
- - (NSInteger)collectionView:(GHRefreshCollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return self.collectionDataSource.count;
- }
- - (UICollectionViewCell *)collectionView:(GHRefreshCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- MoreAppInfoModel *bean = [self.collectionDataSource objectAtIndex:indexPath.item];
- ChatMsgCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ChatMsgCollectionCell" forIndexPath:indexPath];
- cell.cell0IconImg.image = [UIImage imageNamed:bean.imgName];
- cell.cell0TitleLabel.text = bean.title;
- cell.imagH.constant = 25.f;
- cell.imagW.constant = 25.f;
- cell.cell0MengCengView.hidden = YES;
- cell.cell0ReadNumLabel.hidden = YES;
- return cell;
- }
- /****************************************************/
- #pragma mark --UICollectionViewDelegateFlowLayout
- /****************************************************/
- - (CGSize)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- CGFloat width = (SCREEN_WIDTH - 20) / self.collectionDataSource.count;
- CGFloat height = 69;
- return CGSizeMake(width, height);
- }
- -(UIEdgeInsets)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
- {
- CGFloat W = 10;
- return UIEdgeInsetsMake(0,W,0,W);
- }
- - (CGFloat)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
- return 0;
- }
- - (CGFloat)collectionView:(GHRefreshCollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
- return 0;
- }
- - (void)collectionView:(GHRefreshCollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
- [collectionView deselectItemAtIndexPath:indexPath animated:YES];
- MoreAppInfoModel * model = [self.collectionDataSource objectAtIndex:indexPath.item];
- switch (model.type) {
- case ChatMenuTopicBookType:{
- MyTDTopicBookVC * vc = [MyTDTopicBookVC initMyTDTopicBookVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- case ChatMenuGroupType:{
- MyTDGroupViewController *vc = [[MyTDGroupViewController alloc] init];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- default:{
- GroupSquareVC *vc = [GroupSquareVC initGroupSquareVC];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }break;
- }
- }
- - (void)autoSizeBtn:(NSString *)title
- {
- [self.showBtn setcomTitle:title];
- }
- - (void)setShowData
- {
- [self getGroupList];
- self.menuIsShow = NO;
- WS(weakSelf);
- [self.showBtn setAction:^{
- if (!weakSelf.menuIsShow) {
- [weakSelf.menuListView show];
- [weakSelf.showBtn showCom];
- weakSelf.menuListView.SelectBtnblock = ^(NSArray * _Nonnull array) {
- [weakSelf.showBtn dismissCom];
- [weakSelf.selectGIdArray removeAllObjects];
- NSMutableString * showName = [[NSMutableString alloc] init];
- for (NSArray * subArray in array) {
- for (TopicGroupManageModel * model in subArray) {
- if (model.isSelect) {
- weakSelf.listVC.GroupNoUser = model.IncludeCount == 0 ? YES : NO;
- [showName appendString:model.Name];
- [weakSelf.selectGIdArray addObject:@(model.Id)];
- }
- }
- }
- weakSelf.listName = showName;
- if (weakSelf.selectGIdArray.count > 0) {
- [weakSelf.listVC headRefresh];
- }
- };
- weakSelf.menuListView.dismissBlock = ^{
- [weakSelf.showBtn dismissCom];
- };
- weakSelf.menuListView.SelectGroupblock = ^{
- [weakSelf.showBtn dismissCom];
- weakSelf.menuIsShow = NO;
- [weakSelf.menuListView dismiss];
- MyTDTopicGroupManageVC * vc = [MyTDTopicGroupManageVC initMyTDTopicGroupManageVC];
- vc.RefreshListBlock = ^{
- [weakSelf getGroupList];
- };
- vc.hidesBottomBarWhenPushed = YES;
- [weakSelf.navigationController pushViewController:vc animated:YES];
- };
- weakSelf.menuIsShow = YES;
- }else{
- weakSelf.menuIsShow = NO;
- [weakSelf.showBtn dismissCom];
- [weakSelf.menuListView dismiss];
- }
- }];
- [self autoSizeBtn:self.listName.length > 0 ? self.listName : @"全部"];
- }
- - (void)getGroupList
- {
- WS(weakSelf);
- [[HttpManager sharedHttpManager] GETUrl:Host(APP_Topic_Group) parameters:@{} responseStyle:JOSN success:^(id _Nonnull responseObject) {
- NSLog(@"======%@",responseObject);
- [weakSelf.groupListArray removeAllObjects];
- NSArray * array = responseObject;
- [array enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- NSDictionary * dict = (NSDictionary *)obj;
- TopicGroupManageModel * model = [TopicGroupManageModel modelWithDictionary:dict];
- [weakSelf.groupListArray addObject:model];
- }];
- dispatch_async(dispatch_get_main_queue(), ^{
- weakSelf.menuListView = [MenuListView MenuListViewaddArray:@[weakSelf.groupListArray] height:NAVH MenuType:MenuMoreSelectType];
- });
- } failure:^(NSError * _Nonnull error) {
- }];
- }
- @end
|