//
//  ProductLibraryViewController.m
//  Lighting
//
//  Created by 曹云霄 on 16/5/4.
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

#import "ProductLibraryViewController.h"
#import "ProductCollectionViewCell.h"
#import "ProductDetailsViewController.h"





@interface ProductLibraryViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@end

@implementation ProductLibraryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blueColor];
    
    [self uiConfigAction];
    
}

#pragma mark -布局
- (void)uiConfigAction
{
    self.productCollectionLayout.itemSize = CGSizeMake((ScreenWidth-100)/3, (ScreenWidth-100)/3);
    self.productCollectionLayout.sectionInset = UIEdgeInsetsMake(20, 30, 20, 30);
    self.productCollectionLayout.minimumLineSpacing = 20;
    self.productCollectionLayout.minimumInteritemSpacing = 20;
    self.productCollectionView.dataSource = self;
    self.productCollectionView.delegate = self;
    
    [self CreatescreeningButton];
}



#pragma mark -筛选按钮
- (void)CreatescreeningButton
{
    UIButton *screeningbutton = [UIButton buttonWithType:UIButtonTypeSystem];
    screeningbutton.frame = CGRectMake(ScreenWidth-100, ScreenHeight*6/10, 50, 50);
    
    //阴影层
    CALayer *layer = [CALayer layer];
    layer.frame = CGRectMake(ScreenWidth-97.5, ScreenHeight*6/10+2.5, 45, 45);//保证layer的size比筛选按钮高宽都短5像素
    layer.backgroundColor = [UIColor blackColor].CGColor;
    layer.shadowOffset = CGSizeMake(0, 8);
    layer.shadowOpacity = 0.7;
    layer.cornerRadius = 25;
    [self.view.layer addSublayer:layer];
    
    //筛选按钮
    screeningbutton.layer.masksToBounds = YES;
    screeningbutton.layer.cornerRadius = 25;
    [screeningbutton setTitle:@"筛选" forState:UIControlStateNormal];
    screeningbutton.titleLabel.font = [UIFont systemFontOfSize:15];
    [screeningbutton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [screeningbutton setTitleColor:kMainBlueColor forState:UIControlStateSelected];
    screeningbutton.backgroundColor = kMainBlueColor;
    [self.view addSubview:screeningbutton];
    
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    ProductCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"productcell" forIndexPath:indexPath];
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 20;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"StoryboardwithCYX" bundle:nil];
    ProductDetailsViewController *productDetails = [storyboard instantiateViewControllerWithIdentifier:@"productdetails"];
    [self.navigationController pushViewController:productDetails animated:YES];
}













- (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
