//
// © 2017-2020 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
//

import UIKit

class AboutViewController: ModalTableViewController {
    private struct Segues {
        static let showTerms = "showTerms"
        static let showLegal = "showLegal"
    }

	@IBOutlet weak var versionLabel: UILabel!
}

extension AboutViewController {
	override func viewDidLoad() {
		super.viewDidLoad()
		title = NSLocalizedString("ABOUT", comment: "About view title")


		guard let infoDictionary = Bundle.main.infoDictionary,
			let version = infoDictionary["CFBundleShortVersionString"] as? String else {
			versionLabel.text = ""
			return
		}
		versionLabel.text = NSString.localizedStringWithFormat("Version %@", version) as String
	}
    
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        guard let textVC = segue.destination as? TextViewController else {
            print ("Not TextViewController")
            return
        }
        
        if let id = segue.identifier {
			navigationItem.backBarButtonItem?.makeAccessible(Accessibility.Navigation.modalCloseButton)
            
            switch id {
            case Segues.showTerms:
                textVC.contents = .termsOfService
                textVC.title = NSLocalizedString("TERMS OF SERVICE", comment: "Terms of service screen title")
            case Segues.showLegal:
                textVC.contents = .legalNotices
                textVC.title = NSLocalizedString("LEGAL NOTICES", comment: "Terms of service screen title")
            default:
                break
            }
        }
    }
}
