//
//  HeadViewController.swift
//  sdk-demo-ios
//
//  Created by Smaato Inc on 31.05.19.
//  Copyright © 2019 Smaato Inc. All rights reserved.
//

import UIKit
import SmaatoSDKCore

class HeadViewController: UIViewController {
    @IBOutlet weak var versionLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        versionLabel.text = "Smaato SDK version " + SmaatoSDK.sdkVersion
        splitViewController?.preferredDisplayMode = .allVisible
        if #available(iOS 11.0, *) {
            navigationController?.navigationBar.prefersLargeTitles = true
        }
        
        setupAppearance()
    }
    
    private func setupAppearance()
    {
        #if compiler(>=5.1)
        if #available(iOS 13.0, *) {
            let appearance = UINavigationBarAppearance()
            appearance.configureWithOpaqueBackground()
            appearance.backgroundColor = .appColor
            appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
            appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
            appearance.shadowImage = UIImage()
            
            navigationController?.navigationItem.largeTitleDisplayMode = .always
            navigationController?.navigationBar.isTranslucent = true
            navigationController?.navigationBar.standardAppearance = appearance
            navigationController?.navigationBar.scrollEdgeAppearance = appearance
            navigationController?.navigationBar.compactAppearance = appearance
        }
        #endif
    }
}
