77 lines
2.0 KiB
Swift
77 lines
2.0 KiB
Swift
//
|
|
// SPGuideViewController.swift
|
|
// MoviaBox
|
|
//
|
|
// Created by 佳尔 on 2025/5/9.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class SPGuideViewController: SPViewController {
|
|
|
|
var openAppBlock: (() -> Void)?
|
|
|
|
private(set) lazy var lanuchVC: UIViewController? = {
|
|
let vc = SPAPPTool.getLanuchViewController()
|
|
return vc
|
|
}()
|
|
|
|
private lazy var button: UIButton = {
|
|
let button = JXButton(type: .custom)
|
|
button.setTitle("Open".localized, for: .normal)
|
|
button.setTitleColor(.colorFFFFFF(), for: .normal)
|
|
button.jx_font = .fontRegular(ofSize: 18)
|
|
button.leftAndRightMargin = 33
|
|
button.layer.cornerRadius = 17
|
|
button.layer.masksToBounds = true
|
|
button.layer.borderWidth = 1
|
|
button.layer.borderColor = UIColor.colorFFFFFF().cgColor
|
|
button.addTarget(self, action: #selector(handleButton), for: .touchUpInside)
|
|
return button
|
|
}()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
_setupUI()
|
|
}
|
|
|
|
|
|
@objc private func handleButton() {
|
|
|
|
SPAPPTool.isAppOpen = true
|
|
UserDefaults.standard.set(true, forKey: kSPHasBeenOpenedAPPDefaultsKey)
|
|
|
|
self.openAppBlock?()
|
|
NotificationCenter.default.post(name: SPGuideViewController.didOpenAppNotification, object: nil, userInfo: nil)
|
|
}
|
|
|
|
}
|
|
|
|
extension SPGuideViewController {
|
|
|
|
private func _setupUI() {
|
|
if let vc = lanuchVC {
|
|
addChild(vc)
|
|
view.addSubview(vc.view)
|
|
}
|
|
|
|
|
|
view.addSubview(button)
|
|
|
|
button.snp.makeConstraints { make in
|
|
make.centerX.equalToSuperview()
|
|
make.height.equalTo(34)
|
|
make.bottom.equalToSuperview().offset(-(kSPTabbarSafeBottomMargin + 100))
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extension SPGuideViewController {
|
|
///开启app通知
|
|
@objc static let didOpenAppNotification = NSNotification.Name(rawValue: "SPGuideViewController.didOpenAppNotification")
|
|
|
|
}
|