//
//  MorePopOverViewController.m
//  OneCable
//
//  Created by nComz on 2017. 3. 6..
//  Copyright © 2017년 ntels. All rights reserved.
//

#import "MorePopOverViewController.h"
#import "WYPopoverController.h"
#import "HomeMemberViewController.h"
#import "MoreBtnModel.h"

@interface MorePopOverViewController ()

@property (strong, nonatomic) IBOutletCollection(CustomButton) NSArray *btnCollArray;

@end

@implementation MorePopOverViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self initUI];
}

- (void)initUI {

    self.preferredContentSize = CGSizeMake(self.view.frame.size.width, self.viewPopup.frame.size.height);

    
}


- (void)popButtonSet:(NSArray *)btnArray{
    
    for (UIButton *btn in _btnCollArray) {
        btn.hidden = YES;
    }

    int i = 0;
    for (MoreBtnModel *btnInfo in btnArray)
    {
        if (btnInfo.isShow) {
            [self setBtn:i btnInfo:btnInfo];
        }

        i++;
    }
//
//    for (int i = 0; i < btnArray.count; i++)
//    {
//        
//    }
}

-(void)setBtn:(int)index btnInfo:(MoreBtnModel *)btnInfo
{
    UIButton *btn = _btnCollArray[index];

    [btn setImage:[btnInfo getBtnImg:UIControlStateNormal] forState:UIControlStateNormal];
    [btn setImage:[btnInfo getBtnImg:UIControlStateHighlighted] forState:UIControlStateHighlighted];
//    for ( int i = UIControlStateNormal; i <= UIControlStateReserved; i++)
//    {
//        if ([btnInfo getBtnImg:i] != nil)
//        {
//            [btn setImage:[btnInfo getBtnImg:i]  forState:i];
//        }
//    }
    [btn setHidden:NO];
    [btn setTag:btnInfo.btnType];
    [btn setEnabled:btnInfo.isEnable];
}


- (IBAction)btnAction:(id)sender {
    [_poc dismissPopoverAnimated:YES completion:^{
        if([self.delegate respondsToSelector:@selector(moreBtnAction:)]){
            [self.delegate moreBtnAction:sender];
        }
    }];
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
