//
//  TSTutorialsVC.swift
//  AIRingtone
//
//  Created by 100Years on 2025/2/27.
//

class TSTutorialsVC: TSBaseVC {
    
    var pageTitle:String
    var tutorialNamed:String
    
    init(pageTitle: String, tutorialNamed: String) {
        self.pageTitle = pageTitle
        self.tutorialNamed = tutorialNamed
        super.init()
    }
    
    @MainActor required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

    lazy var scrollView: UIScrollView = {
        let scrollView = UIScrollView()
        scrollView.backgroundColor = .clear
        scrollView.translatesAutoresizingMaskIntoConstraints = false
        scrollView.backgroundColor = .clear
        scrollView.frame = self.contentView.bounds
        scrollView.contentSize = imageView.size
        scrollView.contentInset = UIEdgeInsets(top:0, left: 0, bottom: 40, right: 0)
        return scrollView
    }()
    
    lazy var imageView: UIImageView = {
        let imageView = UIImageView.createImageView(imageName: tutorialNamed,contentMode: .scaleToFill)
        // 计算图片的实际高度
        let imageWidth = imageView.image?.size.width ?? k_ScreenWidth
        let imageHeight = imageView.image?.size.height ?? k_ScreenHeight
    
        let w = k_ScreenWidth-32
        let scale = w / imageWidth
        let scaledHeight = imageHeight * scale
        imageView.frame = CGRectMake(16, 8, w, scaledHeight)
        return imageView
    }()
    
    override func createView() {
        addNormalNavBarView()
        setPageTitle(pageTitle.localized)
        view.backgroundColor = .gray
        contentView.addSubview(scrollView)
        scrollView.addSubview(imageView)
    }
}
