//
//  AboutUsViewController.swift
//  iPOS
//
//  Created by bbc on 06/06/17.
//  Copyright © 2017 BBC. All rights reserved.
//

import Foundation
import UIKit

class AboutUsViewController: UIViewController{
    
    @IBOutlet weak var textView: UITextView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = Util.getString("About us")
        self.textView.isEditable = false
        self.textView.dataDetectorTypes = .all
        self.textView.linkTextAttributes = convertToOptionalNSAttributedStringKeyDictionary([ NSAttributedString.Key.foregroundColor.rawValue: UIColor.black, NSAttributedString.Key.underlineStyle.rawValue : NSUnderlineStyle.single.rawValue, NSAttributedString.Key.underlineColor.rawValue: UIColor.lightGray ])
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        createAboutUsMessage()
    }
    
    func createAboutUsMessage(){
        let info = Util.getString("CompanyInfo")            + "\n\n"
        
        let mail1 = "info@bbctech.it"                       + "\n"
        let mail2 = "helpdesk@bbctech.it"                   + "\n\n"
        
        let tel = "Tel: +39 051 0826005"                    + "\n"
        let cell = "Cell: +39 349 2356332"                  + "\n"
        let fax = "Fax: +39 051 6135552"                    + "\n\n"
        
        let address = "Via Domenico Cimarosa 101"           + "\n"
                    + "40033 Casalecchio di Reno (BO) IT"   + "\n\n"
        
        let site = Util.getString("Site") + ": www.iposvision.com"          + "\n\n"
        
        let  message = info + mail1 + mail2 + tel + cell + fax + address + site
        
        self.textView.text = message
    }
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToOptionalNSAttributedStringKeyDictionary(_ input: [String: Any]?) -> [NSAttributedString.Key: Any]? {
	guard let input = input else { return nil }
	return Dictionary(uniqueKeysWithValues: input.map { key, value in (NSAttributedString.Key(rawValue: key), value)})
}
