//
//  LUXToponManager.swift
//  wallpaper_project
//
//  Created by 忆海16 on 2024/8/5.
//

import UIKit
import AnyThinkInterstitial


typealias LuxADManagerActionBlock = (UIViewController) -> Void

var adItemsArr =  ["n66acb8888353f","n66acb8894e8df","n66acb888b9441","n66acb8891f516"]

class LUXToponManager:NSObject,ATInterstitialDelegate {
    static let shared = LUXToponManager()
    
    private override init() {}
    
    
    func isADSSMode() -> Bool{
        
        return UserDefaults.standard.bool(forKey: "kLuxSSFaceKey")
        
    }
    
    func addAD(withInterstitialId id: String, actionBlock block: @escaping LuxADManagerActionBlock) {
        
    }
    
    func configureadWithTopOn(){
        initializationTopOn.toponeSDK()
        
    }
    
    
    
    func initOtherInitIntersitialAD() {
        for i in 1..<adItemsArr.count {
            let item = adItemsArr[i]
            let extra: [String: Any] = [
                kATAdLoadingExtraMediaExtraKey: "custom_values"
            ]
            ATAdManager.shared().loadAD(withPlacementID: item, extra: extra, delegate: self)
            
        }
    }
    
    
    
    
    //        插页广告展示成功
    @objc func interstitialDidShow(forPlacementID placementID: String, extra: [AnyHashable : Any]) {
        
        print("----成功")
    }
    /// 插页广告被点击
    @objc func interstitialDidClick(forPlacementID placementID: String, extra: [AnyHashable : Any]) {
        print("----点击")
    }
    //    插页广告已关闭
    @objc  func interstitialDidClose(forPlacementID placementID: String, extra: [AnyHashable : Any]) {
        print("----关闭")
        //        WA_TabbarCommon.TabBarController()
        
        
    }
    
    @objc func didFinishLoadingAD(withPlacementID placementID: String!) {
        print("ATInterstitialViewController::didFailToLoadADWithPlacementID:\(placementID)")
    }
    
    //    load失败
    @objc func didFailToLoadAD(withPlacementID placementID: String!, error: (any Error)!) {
        print("----load失败")
        print("ATInterstitialViewController::didFailToLoadADWithPlacementID:\(String(describing: placementID))---error\(String(describing: error))")
        
    }
    
}
