1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // TSSetingVC.swift
- // AIEmoji
- //
- // Created by 100Years on 2025/1/16.
- //
- import Combine
- import SwiftUI
- class ListEventPublisher {
- /// 设置
- let settingPublisher = PassthroughSubject<SettingType, Never>()
- /// 进入订阅详情页
- let enterPurchasePublisher = PassthroughSubject<Bool, Never>()
- }
- class TSSetingVC: TSBaseVC {
-
- var viewModel: TSSetingViewModel = TSSetingViewModel()
- var publisher: ListEventPublisher = .init()
-
-
- lazy var hostVc: UIHostingController<TSSettingListView> = {
- let vc = UIHostingController(rootView: TSSettingListView(viewModel: viewModel, publisher: publisher))
- vc.view.backgroundColor = .clear
- return vc
- }()
-
- override func createView() {
- edgesForExtendedLayout = []
- setNavBarViewHidden(true)
-
- contentView.addSubview(hostVc.view)
- hostVc.view.snp.makeConstraints { make in
- make.top.equalTo(k_Height_StatusBar+16)
- make.leading.trailing.bottom.equalToSuperview()
- }
- }
-
- override func dealThings() {
-
- publisher.enterPurchasePublisher.receive(on: DispatchQueue.main).sink { [weak self] _ in
- guard let self = self else { return }
- viewModel.pushVipPurchase(parent: self)
- }.store(in: &cancellable)
-
- publisher.settingPublisher.receive(on: DispatchQueue.main).sink{ [weak self] type in
- guard let self = self else {
- return
- }
-
- switch type {
- case .howToUse:
- viewModel.pushTutorials(parent: self)
- case .shareus:
- viewModel.shareApp(parent: self)
- case .agreement:
- viewModel.showAgreement(parent: self)
- case .privacy:
- viewModel.showPrivacy(parent: self)
- case .update:
- viewModel.updateApp(parent: self)
- break
- case .removeCloudData:
- viewModel.removeCloudData(parent: self)
- break
- case .AboutData:
- viewModel.AboutData(parent: self)
- break
- case .about:
- break
- case .rateus:
- viewModel.rateAction()
- }
-
- }.store(in: &cancellable)
- vipInfoChanged()
- refreshView()
- NotificationCenter.default.addObserver(self, selector: #selector(vipInfoChanged), name: .kPurchaseDidChanged, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(refreshView), name: .kRefreshSettingView, object: nil)
- }
-
- @objc func vipInfoChanged() {
- kExecuteOnMainThread {
- self.viewModel.isViper = PurchaseManager.default.isVip
- }
- }
-
- @objc func refreshView() {
-
- if UIApplication.compareAppVersions(newVersion1: kAppNewVerison, oldVersion: appShortVersion()) == .newer {
- self.viewModel.isHaveNewVersion = true
- }
- }
- }
|