//
//  HomeViewController+PopoverView.swift
//  MobilePortal
//
//  Created by xiejiangbo on 2019/3/22.
//  Copyright © 2019 yin chen. All rights reserved.
//

import UIKit

extension HomeViewController {
    @objc func shouwPopover(){
        let vc:PopoverViewController = PopoverViewController.createViewController(createArgs: nil) as! PopoverViewController
        vc.popoverTypeblock = {[weak self] (value:Any) in
            self?.popoActionGotoVC(popoverType: value as! PopoverType)
        }
        vc.popoverTypeArray = getPopoverTypeArray()
        vc.preferredContentSize = CGSize(width: 100, height: vc.popoverTypeArray.count*40)
        vc.modalPresentationStyle = .popover
        vc.popoverPresentationController?.barButtonItem = self.navigationItem.rightBarButtonItem
        vc.popoverPresentationController?.delegate = self
        self.present(vc, animated: true, completion: nil)
    }
    func getPopoverTypeArray() -> NSMutableArray {
        let array = NSMutableArray()
        if AccountInfo.sharedInstance().UserId != nil {
            array.add(PopoverType.ScanCodeTraceability)
        }
        array.add(PopoverType.IntelligentCustomerService)
        return array
    }
    func popoActionGotoVC(popoverType:PopoverType){
        switch popoverType {
        case .ChangePassword:
            self.gotoChangePassWordViewController(changePassWordType: .OrdinaryChangePassWordType)
            break
        case .DepartmentSwitching:
            
            break
        case .IntelligentCustomerService:
            actionCustomerServiceVC()
            break
        default:
            self.gotoQRCodeSwiftViewController(isHomePushType: .YesIsHomePushType)
            break
        }
    }
    func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
        return UIModalPresentationStyle.none
    }
}
