TSSetingVC.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // TSSetingVC.swift
  3. // AIEmoji
  4. //
  5. // Created by 100Years on 2025/1/16.
  6. //
  7. import Combine
  8. import SwiftUI
  9. class ListEventPublisher {
  10. /// 设置
  11. let settingPublisher = PassthroughSubject<SettingType, Never>()
  12. /// 进入订阅详情页
  13. let enterPurchasePublisher = PassthroughSubject<Bool, Never>()
  14. }
  15. class TSSetingVC: TSBaseVC {
  16. var viewModel: TSSetingViewModel = TSSetingViewModel()
  17. var publisher: ListEventPublisher = .init()
  18. lazy var hostVc: UIHostingController<TSSettingListView> = {
  19. let vc = UIHostingController(rootView: TSSettingListView(viewModel: viewModel, publisher: publisher))
  20. vc.view.backgroundColor = .clear
  21. return vc
  22. }()
  23. override func createView() {
  24. addNormalNavBarView()
  25. setPageTitle("Setting")
  26. contentView.addSubview(hostVc.view)
  27. hostVc.view.snp.makeConstraints { make in
  28. make.edges.equalToSuperview()
  29. }
  30. }
  31. override func dealThings() {
  32. publisher.enterPurchasePublisher.receive(on: DispatchQueue.main).sink { [weak self] _ in
  33. guard let self = self else { return }
  34. viewModel.pushVipPurchase(parent: self)
  35. }.store(in: &cancellable)
  36. publisher.settingPublisher.receive(on: DispatchQueue.main).sink{ [weak self] type in
  37. guard let self = self else {
  38. return
  39. }
  40. switch type {
  41. case .howToUse:
  42. viewModel.pushTutorials(parent: self)
  43. case .shareus:
  44. viewModel.shareApp(parent: self)
  45. case .agreement:
  46. viewModel.showAgreement(parent: self)
  47. case .privacy:
  48. viewModel.showPrivacy(parent: self)
  49. case .about:
  50. break
  51. case .rateus:
  52. viewModel.rateAction()
  53. }
  54. }.store(in: &cancellable)
  55. }
  56. }