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

#import "FollowHeartViewController.h"

@interface FollowHeartViewController ()

@end

@implementation FollowHeartViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self configSubView];
    
}
-(void)configSubView
{
    UIImageView* imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"backView.png"]];
    imageView.frame=CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
    [self.view addSubview:imageView];
    self.leftSubView=[[LeftSubView alloc]initWithFrame:CGRectMake(0, 0, 200, self.view.bounds.size.height-200)];
    self.leftSubView.delegate=self;
    [self.view addSubview:self.leftSubView];
    self.rightSubView=[[RightSubView alloc]initWithFrame:CGRectMake(self.view.bounds.size.width-200, 0, 200, self.view.bounds.size.height-200)];
    [self.view addSubview:self.rightSubView];
    
    self.footSubView=[[FootSubView alloc]initWithFrame:CGRectMake(0, self.view.bounds.size.height-200, self.view.bounds.size.width, 200)];
    [self.view addSubview:self.footSubView];


}
#pragma  leftsubView  delegate
- (void)buttonClick:(NSInteger)btnTag withButton:(UIButton *)button
{
    switch (btnTag) {
        case 100:  //返回
        {
            [self.view removeFromSuperview];
        }
            break;
        case 101:  //购物车
        {
            
        }
            break;
        case 102:  //分享
        {
            
        }
            break;
        case 103:  //自定义场景
        {
            
        }
            break;
        case 104:  //全屏
        {

            [self setViewAnimations:button];
            
        }
            break;
        case 105: //帮助
        {
            
        }
            break;
            
        default:
            break;
    }

}
-(void)setViewAnimations:(UIButton *)sender
{
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame=sender.frame;
    [btn setTitle:@"缩小" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(resetViewDidSelected:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDuration:1.0f];
    self.leftSubView.frame=CGRectMake(-200, 0, 200, self.view.bounds.size.height-200);
    self.rightSubView.frame=CGRectMake(self.view.bounds.size.width, 0, 200, self.view.bounds.size.height-200);
    self.footSubView.frame=CGRectMake(0, self.view.bounds.size.height, self.view.bounds.size.width, 200);
    btn.frame=CGRectMake(sender.frame.origin.x, 20, sender.frame.size.width, sender.frame.size.height);
    [UIView commitAnimations];
}
-(void)resetViewDidSelected:(UIButton *)sender
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDuration:1.0f];
    self.leftSubView.frame=CGRectMake(0, 0, 200, self.view.bounds.size.height-200);
    self.rightSubView.frame=CGRectMake(self.view.bounds.size.width-200, 0, 200, self.view.bounds.size.height-200);
    self.footSubView.frame=CGRectMake(0, self.view.bounds.size.height-200, self.view.bounds.size.width, 200);
    sender.hidden=YES;
    [UIView commitAnimations];

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