LNMainViewController.swift 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // LNMainViewController.swift
  3. // Lanu
  4. //
  5. // Created by OneeChan on 2025/12/2.
  6. //
  7. import Foundation
  8. import UIKit
  9. class LNMainViewController: UITabBarController {
  10. override func viewDidLoad() {
  11. super.viewDidLoad()
  12. LNEventDeliver.addObserver(self)
  13. // if #available(iOS 26, *) {
  14. // let container = tabBar.subviews.first
  15. // container?.layer.shadowColor = UIColor.black.withAlphaComponent(0.2).cgColor
  16. // container?.layer.shadowOffset = .init(width: 0, height: 2)
  17. // container?.layer.shadowRadius = 6
  18. // container?.layer.shadowOpacity = 0.8
  19. // container?.layer.masksToBounds = false
  20. // } else {
  21. let tabBar = LNMainTabBar()
  22. tabBar.delegate = self
  23. setValue(tabBar, forKey: "tabBar")
  24. // }
  25. let home = LNHomeViewController()
  26. home.tabBarItem.image = .icMainHomeDefault.withRenderingMode(.alwaysOriginal)
  27. home.tabBarItem.selectedImage = .icMainHomeSelected.withRenderingMode(.alwaysOriginal)
  28. let message = LNIMConversationListController()
  29. message.tabBarItem.image = .icMainChatDefault.withRenderingMode(.alwaysOriginal)
  30. message.tabBarItem.selectedImage = .icMainChatSelected.withRenderingMode(.alwaysOriginal)
  31. let mine = LNMineViewController()
  32. mine.tabBarItem.image = .icMainMineDefault.withRenderingMode(.alwaysOriginal)
  33. mine.tabBarItem.selectedImage = .icMainMineSelected.withRenderingMode(.alwaysOriginal)
  34. viewControllers = [home, message, mine]
  35. if let mainTabBar = tabBar as? LNMainTabBar {
  36. mainTabBar.setupViews()
  37. }
  38. selectedViewController = message // 触发消息界面加载逻辑
  39. selectedViewController = home
  40. delegate = self
  41. }
  42. override func viewWillAppear(_ animated: Bool) {
  43. super.viewWillAppear(animated)
  44. navigationController?.setNavigationBarHidden(true, animated: animated)
  45. }
  46. }
  47. extension LNMainViewController: UITabBarControllerDelegate {
  48. func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
  49. if viewController is LNHomeViewController { return true }
  50. if !hasLogin {
  51. LNLoginPanel.show(container: view)
  52. }
  53. return hasLogin
  54. }
  55. }
  56. extension LNMainViewController: LNProfileManagerNotify, LNNetworkMonitorNotify {
  57. func onUserInfoChanged(userInfo: LNUserProfileVO) {
  58. guard userInfo.userNo.isMyUid else { return }
  59. if !userInfo.isAvailable {
  60. view.pushToGenderSetup()
  61. }
  62. }
  63. }