DiscussModuleViewController.m 2.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
//
//  DiscussModuleViewController.m
//  Lighting
//
//  Created by 曹云霄 on 2017/3/15.
//  Copyright © 2017年 上海勾芒科技有限公司. All rights reserved.
//

#import "DiscussModuleViewController.h"
#import "DiscussModuleCollectionViewCell.h"
曹云霄's avatar
曹云霄 committed
11
#import "ForumItemListViewController.h"
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

@interface DiscussModuleViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (nonatomic,strong) ForumTypeResponse *result;
@end

@implementation DiscussModuleViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self uiConfigAction];
    [self getClassificationList];
}

#pragma mark - 获取分类帖子列表
- (void)getClassificationList
{
    [XBLoadingView showHUDViewWithDefaultWithView:self.view];
    WS(weakSelf);
32
    [HTTP networkWithDictionaryRequestWithURL:SERVERREQUESTURL(DEFAULTFORUM_CATEGORY) withRequestType:GET withParameter:nil withReturnValueBlock:^(id returnValue) {
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
        
        [XBLoadingView hideHUDViewWithDefaultWithView:self.view];
        if (RESULT(returnValue)) {
            weakSelf.result = [[ForumTypeResponse alloc] initWithDictionary:RESPONSE(returnValue) error:nil];
            [weakSelf.moduleCollectionView reloadData];
        }else {
            [XBLoadingView showHUDViewWithText:MESSAGE(returnValue)];
        }
        [weakSelf.moduleCollectionView reloadData];
    } withFailureBlock:^(NSError *error) {
        [XBLoadingView showHUDViewWithText:error.localizedDescription];
    }];
}


#pragma mark -UI
- (void)uiConfigAction
{
    self.moduleFlowLayout.itemSize = CGSizeMake((ScreenWidth-60)/3.0, (ScreenWidth-60)/3.0*0.4);
    self.moduleFlowLayout.minimumInteritemSpacing = 10;
    self.moduleFlowLayout.minimumLineSpacing = 10;
}


#pragma mark -<UICollectionViewDelegate,UICollectionViewDataSource>
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.result.list.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    DiscussModuleCollectionViewCell *moduleCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DiscussModuleCollectionViewCell" forIndexPath:indexPath];
曹云霄's avatar
曹云霄 committed
66 67
    TOForumCategoryEntity *entity = self.result.list[indexPath.item];
    [moduleCell refreshCell:entity];
68 69 70 71
    return moduleCell;
}


曹云霄's avatar
曹云霄 committed
72 73 74 75 76 77
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    ForumItemListViewController *itemListVc = [[[self class] getLearningCenterStoryboardClass] instantiateViewControllerWithIdentifier:@"ForumItemListViewController"];
    TOForumCategoryEntity *category = self.result.list[indexPath.row];
    category.typeId = self.result.forumType.fid;
    itemListVc.category = category;
78
    
Sandy's avatar
Sandy committed
79
    itemListVc.isPosting = [category.name isEqualToString:@"欧普问问"]?2:1;
曹云霄's avatar
曹云霄 committed
80 81 82 83 84
    [self.navigationController pushViewController:itemListVc animated:YES];
}



85 86

@end