//
//  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()
//        vc.popoverTypeblock = {[weak self] (value:Any) in
//            self?.popoActionGotoVC(popoverType: value as! PopoverType)
//        }
//        vc.modalPresentationStyle = .overCurrentContext
//        vc.popoverTypeArray = getPopoverTypeArray()
//        vc.preferredContentSize = CGSize(width: 115, height: vc.popoverTypeArray.count*45)
//        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
    }
    
    @objc func shouwPopover(){
        let popOption = FKGPopOption.init(frame: CGRect(x:0, y: 0, width:SCREEN_WHIDTH() , height:SCREEN_HEIGHT() ))
        self.getArray(popOption: popOption)
        popOption.option_lineHeight = 45
        popOption.option_mutiple = 115/360
        popOption.option_setupPopOption({[weak self] (index, content) in
            if (content == "扫码追溯") {
                self?.gotoQRCodeSwiftViewController(isHomePushType: .YesIsHomePushType)
            } else if (content == "智能客服") {
                self?.actionCustomerServiceVC()
            }
        }, whichFrame: CGRect(x:SCREEN_WHIDTH()-128, y: STATUBAR_HEIGHT()-10, width:115 , height:45 ), animate: true)?.option_show()
    }
    func getArray(popOption: FKGPopOption) {
        if AccountInfo.sharedInstance().UserId != nil {
            popOption.option_optionContents = ["扫码追溯","智能客服"]
            popOption.option_optionImages = ["scanCode_image","customerService_image"]
        } else {
            popOption.option_optionContents = ["智能客服"]
            popOption.option_optionImages = ["customerService_image"]
        }
    }
    
}
