//
//  TSBootPageVC.swift
//  Girly
//
//  Created by 100Years on 2025/1/14.
//

class TSBootPageVC: TSBaseVC {
    
    var onComplete:(()->Void)
    
    init(onComplete: @escaping () -> Void) {
        self.onComplete = onComplete
        super.init()
    }
    
    @MainActor required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var scrollView: UIScrollView = {
        let scrollView = UIScrollView()
        scrollView.isScrollEnabled = false
        scrollView.frame = self.view.bounds

        let imageView0 = UIImageView.createImageView(imageName: "bootPage_0")
        imageView0.frame = CGRectMake(0, 0, k_ScreenWidth, k_ScreenHeight)// 813*kDesignScale)
        scrollView.addSubview(imageView0)
        
        let imageView1 = UIImageView.createImageView(imageName: "bootPage_1")
        imageView1.frame = CGRectMake(k_ScreenWidth, 0, k_ScreenWidth, 813*kDesignScale)
        scrollView.addSubview(imageView1)
        
        let imageView2 = UIImageView.createImageView(imageName: "bootPage_2")
        imageView2.frame = CGRectMake(k_ScreenWidth*2, 0, k_ScreenWidth, 813*kDesignScale)
        scrollView.addSubview(imageView2)
        
        let btnH = k_ScreenHeight/5
        let btnTop = btnH*4
        
        let button0 = UIButton(frame: CGRectMake(0, btnTop, k_ScreenWidth, btnH))
        button0.tag = 1
        button0.addTarget(self, action: #selector(clickBtn(_:)), for: .touchUpInside)
        scrollView.addSubview(button0)
        
        let button1 = UIButton(frame: CGRectMake(k_ScreenWidth, btnTop, k_ScreenWidth, btnH))
        button1.tag = 2
        button1.addTarget(self, action: #selector(clickBtn(_:)), for: .touchUpInside)
        scrollView.addSubview(button1)
        
        let button2 = UIButton(frame: CGRectMake(k_ScreenWidth*2, btnTop, k_ScreenWidth, btnH))
        button2.tag = 3
        button2.addTarget(self, action: #selector(clickBtn(_:)), for: .touchUpInside)
        scrollView.addSubview(button2)
        
        return scrollView
    }()
    
    
    @objc func clickBtn(_ btn:UIButton){
        if btn.tag <= 2{
            scrollView.contentOffset = CGPointMake(k_ScreenWidth*CGFloat(btn.tag), 0)
        }else{
            onComplete()
            self.navBarClickLeftAction()
        }
    }
    
    override func createView() {
        setNavBarViewHidden(true)
        self.view.backgroundColor = .black
        self.view.addSubview(scrollView)
    }

}
