//
//  PMHintsController.swift
//  PhoneManager
//
//  Created by edy on 2025/5/16.
//

import UIKit

class PMHintsController: BaseViewController , UIScrollViewDelegate {

    @IBOutlet weak var PMHintsPage: UIPageControl!
    @IBOutlet weak var scrollView: UIScrollView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        PMHintsPage.numberOfPages = 5
    }
    
    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        ScrollToCurrent(scrollView)
    }
    
    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
        if decelerate {
            ScrollToCurrent(scrollView)
        }
    }
    
    private func ScrollToCurrent(_ scroll:UIScrollView) -> Void {
        let orx = scroll.contentOffset.x / scroll.width
        PMHintsPage.currentPage = Int(round(orx))
    }
}
