//
//  ExcelViewController.swift
//  iPOS
//
//  Created by BBC on 11/04/17.
//  Copyright © 2017 BBC. All rights reserved.
//

import Foundation
import QuickLook
class ExcelViewController: UIViewController, QLPreviewControllerDelegate, QLPreviewControllerDataSource{
    @IBAction func openButton_Click(_ sender: Any) {
        Util.SetNetworkActivityIndicatorVisibilty(text: Util.getString("Please wait")+"...", visible: true)
        let viewPDF = Preview()
        viewPDF.dataSource = self
        self.present(viewPDF, animated: true, completion: nil)
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
        return 1
    }
    
    func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
        
        return URL(fileURLWithPath: "/Users/BBC/Desktop/Contacts.xlsx") as QLPreviewItem
    }
}

class Preview: QLPreviewController{
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
    }
    
    override func viewDidAppear(_ animated: Bool) {
        Util.SetNetworkActivityIndicatorVisibilty(text: nil, visible: false)
        super.viewDidAppear(animated)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
}
