//
//  ThingsDelPlugCompleteViewController.m
//  OneCable
//
//  Created by nComz on 2017. 3. 21..
//  Copyright © 2017년 ntels. All rights reserved.
//
#import "JDObject.h"
#import "ThingsForcedDelCompleteViewController.h"
#import "CustomLabel.h"
#import "CustomButton.h"
#import "CustomImageView.h"

#import "MainViewController.h"
#import "ThingsViewController.h"
#import "ThingsDetailViewController.h"

@interface ThingsForcedDelCompleteViewController ()

@end

@implementation ThingsForcedDelCompleteViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self initUI];
    [self prepareViewDidLoad];
}

- (void)initUI {
  
}

- (void)prepareViewDidLoad {
 
    NSMutableString *title = [NSMutableString stringWithString:_delDevice.prdName];
    [title appendString:@" 삭제"];
    
    _imgThings.image = [_delDevice imgaeForAddDel];
    _lblManufacturer.text = [_delDevice manufacturerName];

    
    _imgThingsSuccess.hidden = !_isSuccess;
    _imgThingsFail.hidden = _isSuccess;
    if (_isSuccess) {
        [title appendString:@" 성공"];
    } else {
        [title appendString:@" 실패"];
    }
    
    _lblTitle.text = title;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

- (IBAction)btnConfirmTouched:(id)sender {
    
    
    [self dismissViewControllerAnimated:YES completion:^{

//        ThingsViewController *vc = [JDFacade facade].mainViewController.tvc;
//
//        if (vc && [vc isKindOfClass:[ThingsViewController class]]) {
//            [vc finishDeviveDelete];
//        } else {
//            ThingsDetailViewController *vc2 = (ThingsDetailViewController *)vc;
//            [vc2 finishDeviveDelete];
//        }
        
        ThingsDetailViewController *vc = (ThingsDetailViewController*)[JDFacade facade].currentViewController;
        
        if (vc && [vc isKindOfClass:[ThingsDetailViewController class]]) {
            
            [vc finishDeviveDelete];
            
        }  else {
            
            ThingsViewController *vc2 = [JDFacade facade].mainViewController.tvc;
            [vc2 finishDeviveDelete];
        }
        
    }];
}

@end
