|
//
// detailContentMoreInfoCell.m
// ThePaperHD
//
// Created by scar1900 on 15/1/15.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "detailContentMoreInfoCell.h"
#import "paperCollectCell.h"
#import "customFlowLayout.h"
@interface detailContentMoreInfoCell() <UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,paperCollectDelegate> {
CAGradientLayer *gradientLayer;
}
@property(nonatomic, strong)UICollectionView *collectView;
@end
@implementation detailContentMoreInfoCell
@synthesize dataList = _dataList;
@synthesize delegate;
static NSString * const paperCollectReuseIdentifier = @"frontPageCollectItem";
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.collectView];
}
return self;
}
- (UICollectionView *)collectView {
if (!_collectView) {
CGSize itemSize = CGSizeMake(300.f, 260-50);
customFlowLayout *layout= [[customFlowLayout alloc]init];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
layout.minimumLineSpacing = 10;
layout.itemSize = itemSize;
_collectView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.bounds), 260) collectionViewLayout:layout];
[_collectView registerClass:[paperCollectCell class] forCellWithReuseIdentifier:paperCollectReuseIdentifier];
_collectView.allowsSelection = YES;
_collectView.scrollEnabled = YES;
_collectView.showsHorizontalScrollIndicator= NO;
_collectView.backgroundColor = [UIColor clearColor];
_collectView.delegate = self;
_collectView.dataSource = self;
}
return _collectView;
}
- (void)setDataList:(NSMutableArray *)dataList {
_dataList = dataList;
[self.collectView reloadData];
}
#pragma mark <UICollectionViewDataSource>
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.dataList?self.dataList.count:0;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
return [self getCollectCell:collectionView cellForItemAtIndexPath:indexPath];
}
- (paperCollectCell *)getCollectCell:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
paperCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:paperCollectReuseIdentifier forIndexPath:indexPath];
id data = self.dataList[indexPath.row];
cell.listContentBO = data;
cell.delegate = self;
return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
return CGSizeMake(300, 260-50);
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
UIEdgeInsets top = {25,0,25,10};
return top;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
id data = self.dataList[indexPath.row];
paperCollectCell *cell = (paperCollectCell*)[collectionView cellForItemAtIndexPath:indexPath];
[UIView animateWithDuration:0.25 animations:^{
cell.transform = CGAffineTransformMakeScale(0.95, 0.95);
} completion:^(BOOL finished) {
cell.transform = CGAffineTransformMakeScale(1.00, 1.00);
if ([self.delegate respondsToSelector:@selector(pushToDetailPage:)]) {
[self.delegate pushToDetailPage:data];
}
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
}];
}
- (void)goToColumnPage:(listContObjectVO *)listBO {
if ([self.delegate respondsToSelector:@selector(pushToColumnPage:)]) {
[self.delegate pushToColumnPage:listBO];
}
}
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat padding = 0;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight) {
padding = 125;
}
self.collectView.frame =CGRectMake(padding, 0, CGRectGetWidth(self.contentView.bounds)-padding, CGRectGetHeight(self.contentView.bounds));
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
|