//
//  ThingsAddFailViewController.m
//  kneet2
//
//  Created by Jason Lee on 11/13/15.
//  Copyright © 2015 ntels. All rights reserved.
//

#import "ThingsAddFailViewController.h"
#import "ThingsAddIncludeViewController.h"

#import "ThingsAddInitCompleteViewController.h"


@interface ThingsAddFailViewController () {

}
@end


#pragma mark - Class Definition

@implementation ThingsAddFailViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initUI];
    [self prepareViewDidLoad];
}


- (void)initUI {
    
    
    _imgThings.image = [_addDevice imgaeForAddDel];
    _lblTitle.text = [NSString stringWithFormat:@"%@ 추가 실패", _addDevice.prdName];
    
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
    [UIView animateWithDuration:kfAnimationDur animations:^{
        _maskView.alpha = 0.7;
    } completion:^(BOOL finished) {
        
        _constraintPopViewTop.constant = (IPHONE_HEIGHT - _popView.height) / 2;
        
        [UIView animateWithDuration:kfAnimationDur animations:^{
            [self.view layoutIfNeeded];
        }];
    }];
}

- (void)prepareViewDidLoad {
    
}

#pragma mark - Main Logic



#pragma mark - UI Events
- (IBAction)btnRetryTouched:(id)sender {
    if ([[JDFacade facade].loginUser.homehubOnlineState isEqualToString:@"OFF"]) {
        [[JDFacade facade] toast:@"홈허브가 온라인 상태로\r연결되어 있을 때 시도해주세요"];
        return;
    }
    
    ThingsAddInitCompleteViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsAddInitCompleteViewController" storyboardName:@"Things"];
    vc.addDevice = _addDevice;
    vc.selectHub = _selectHub;
    
    [self showTransparencyModalView:vc];

}

- (IBAction)btnCancelTouched:(id)sender {
    
    [[JDFacade facade] dismissModalStack:YES completion:^{
        [[JDFacade facade] gotoWishMenu:KNMenuIdThings];
    }];
}

#pragma mark - MemoryWarning
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
