SceneLibraryViewController.m 5.43 KB
Newer Older
曹云霄's avatar
曹云霄 committed
1
//
2
//  SceneLibraryViewController.m
曹云霄's avatar
曹云霄 committed
3 4
//  Lighting
//
5
//  Created by 曹云霄 on 16/5/4.
曹云霄's avatar
曹云霄 committed
6 7 8
//  Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//

9
#import "SceneLibraryViewController.h"
曹云霄's avatar
曹云霄 committed
10
#import "SeceneLibraryCollectionViewCell.h"
曹云霄's avatar
曹云霄 committed
11

曹云霄's avatar
曹云霄 committed
12
@interface SceneLibraryViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
曹云霄's avatar
曹云霄 committed
13

14 15 16 17 18 19 20 21 22 23 24


/**
 *  筛选数据源
 */
@property (nonatomic,strong)  SceneFilter *filter;

/**
 *  列表数据
 */
@property (nonatomic,strong) SceneResponse *response;
曹云霄's avatar
曹云霄 committed
25 26
@end

27
@implementation SceneLibraryViewController
曹云霄's avatar
曹云霄 committed
28 29 30 31

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
曹云霄's avatar
曹云霄 committed
32 33
    
    [self uiConfigAction];
34 35
    [self getdatasAction];
    [self getSceneLibrarydatas];
曹云霄's avatar
曹云霄 committed
36 37
}

曹云霄's avatar
曹云霄 committed
38 39 40 41 42 43 44 45 46 47 48 49
#pragma mark -UI
- (void)uiConfigAction
{
    self.seceneLibraryCollectionLayout.itemSize = CGSizeMake((ScreenWidth-6)/3, (ScreenWidth-6)/3-50);
    self.seceneLibraryCollectionLayout.minimumLineSpacing = 2;
    self.seceneLibraryCollectionLayout.minimumInteritemSpacing = 2;
    self.seceneLibraryCollectionLayout.sectionInset = UIEdgeInsetsMake(5, 0, 5, 0);
    self.seceneLibararyCollectionView.dataSource = self;
    self.seceneLibararyCollectionView.delegate = self;
}


曹云霄's avatar
曹云霄 committed
50 51 52
#pragma mark -获取场景筛选数据
- (void)getdatasAction
{
曹云霄's avatar
曹云霄 committed
53
  
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
    [self CreateMBProgressHUDLoding];
    [[NetworkRequestClassManager Manager] NetworkRequestWithURL:[NSString stringWithFormat:@"%@%@",ServerAddress,@"/scene/getSceneFilter"] WithRequestType:1 WithParameter:nil WithReturnValueBlock:^(id returnValue) {
        
        [self RemoveMBProgressHUDLoding];
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
            
          self.filter = [[SceneFilter alloc]initWithDictionary:returnValue[@"data"] error:nil];
    
        }
        else
        {
            [self ErrorMBProgressView:returnValue[@"message"]];
        }
        
    } WithErrorCodeBlock:^(id errorCodeValue) {
        
    } WithFailureBlock:^(id error) {
        
        [self RemoveMBProgressHUDLoding];
    }];
}

曹云霄's avatar
曹云霄 committed
76

77 78 79
#pragma mark -获取场景列表数据
- (void)getSceneLibrarydatas
{
曹云霄's avatar
曹云霄 committed
80
    
81 82 83 84
    SceneCondition *condition = [[SceneCondition alloc]init];
    DataPage *page = [[DataPage alloc]init];
    page.page = 0;
    condition.page = page;
曹云霄's avatar
曹云霄 committed
85
    
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    [[NetworkRequestClassManager Manager] NetworkRequestWithURL:[NSString stringWithFormat:@"%@%@",ServerAddress,@"/scene/query"] WithRequestType:0 WithParameter:condition WithReturnValueBlock:^(id returnValue) {
        
        if ([returnValue[@"code"] isEqualToNumber:@0]) {
            
            NSLog(@"%@",returnValue);
            self.response = [[SceneResponse alloc]initWithDictionary:returnValue[@"data"] error:nil];
            
        }
        else
        {
            [self ErrorMBProgressView:returnValue[@"message"]];
        }
        
    } WithErrorCodeBlock:^(id errorCodeValue) {
        
    } WithFailureBlock:^(id error) {
        
        
    }];
曹云霄's avatar
曹云霄 committed
105 106 107 108
}



曹云霄's avatar
曹云霄 committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    SeceneLibraryCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"secenelibrary" forIndexPath:indexPath];
    
    return cell;
}

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


#pragma mark -切换显示风格
- (IBAction)SwitchdisplayStyleClick:(UIButton *)sender {
    
    self.seceneLibraryCollectionLayout.itemSize = CGSizeMake((ScreenWidth-10)/6, (ScreenWidth-10)/6-50);
    [self.seceneLibararyCollectionView reloadData];
    
}


131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
#pragma mark -筛选风格
- (IBAction)screeningStyleButtonClick:(UIButton *)sender {
    
    PopoverViewController *popover = [[PopoverViewController alloc]init];
    popover.datasArray = @[@"你好",@"你好"];
    popover.contentSize = CGSizeMake(150, 300);
    popover.preferredContentSize = CGSizeMake(150, 300);
    popover.modalPresentationStyle = UIModalPresentationPopover;
    UIPopoverPresentationController *pop = popover.popoverPresentationController;
    pop.permittedArrowDirections = UIPopoverArrowDirectionAny;
    pop.sourceView = popover.view;
    pop.barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:sender];
    [self presentViewController:popover animated:YES completion:nil];
    
}


#pragma mark -房型风格
- (IBAction)HouseStyleButtonClick:(UIButton *)sender {
    
    PopoverViewController *popover = [[PopoverViewController alloc]init];
    popover.datasArray = @[@"你好",@"你好"];
    popover.contentSize = CGSizeMake(150, 300);
    popover.preferredContentSize = CGSizeMake(150, 300);
    popover.modalPresentationStyle = UIModalPresentationPopover;
    UIPopoverPresentationController *pop = popover.popoverPresentationController;
    pop.permittedArrowDirections = UIPopoverArrowDirectionAny;
    pop.sourceView = popover.view;
    pop.barButtonItem = [[UIBarButtonItem alloc]initWithCustomView:sender];
    [self presentViewController:popover animated:YES completion:nil];
}
曹云霄's avatar
曹云霄 committed
162 163 164 165




曹云霄's avatar
曹云霄 committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
- (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