// // AccountCenterController.swift // PDF Reader Pro // // Created by User-Tangchao on 2024/10/29. // import Cocoa class AccountCenterController: NSViewController { @IBOutlet weak var contentBox: NSBox! private lazy var closeButton_: NSButton = { let view = NSButton() view.isBordered = false view.title = "" return view }() private var profileC_ = AccountProfileController() private var moreBenefitC = AccountMoreBenefitsController() var rightDatas: [String] = [] var model: AccountRightModel? var infoModel: AccountInfoModel? convenience init() { self.init(nibName: "AccountCenterController", bundle: MainBundle) } override func viewDidLoad() { super.viewDidLoad() // Do view setup here. self.contentBox.borderWidth = 0 self.view.addSubview(self.closeButton_) self.closeButton_.km_add_right_constraint(constant: -25) self.closeButton_.km_add_top_constraint(constant: 20) self.closeButton_.km_add_size_constraint(size: .init(width: 16, height: 16)) self.closeButton_.target = self self.closeButton_.action = #selector(_closeAction) self.closeButton_.image = NSImage(named: "KMImageNameAccountClose2") self.gotoProfile() } func gotoProfile() { self.profileC_.rightDatas = self.rightDatas self.profileC_.model = self.model self.profileC_.userInfoModel = self.infoModel self.contentBox.contentView = self.profileC_.view self.profileC_.itemClick = { [weak self] idx, _ in if idx == 1 { // 更多权益 self?.gotoMoreBenefit() } } } func gotoMoreBenefit() { self.moreBenefitC.rightDatas = self.rightDatas self.moreBenefitC.datas = self.model?.moreBenefits ?? [] self.contentBox.contentView = self.moreBenefitC.view self.moreBenefitC.itemClick = { [weak self] idx, _ in self?.gotoProfile() } } // MARK: - Private Methods @objc private func _closeAction() { self.view.window?.windowController?.km_quick_endSheet() } }