LNMainViewController.swift 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 room = LNRoomListViewController()
  29. room.tabBarItem.image = .icMainRoomDefault.withRenderingMode(.alwaysOriginal)
  30. room.tabBarItem.selectedImage = .icMainRoomSelected.withRenderingMode(.alwaysOriginal)
  31. let message = LNIMConversationListController()
  32. message.tabBarItem.image = .icMainChatDefault.withRenderingMode(.alwaysOriginal)
  33. message.tabBarItem.selectedImage = .icMainChatSelected.withRenderingMode(.alwaysOriginal)
  34. let mine = LNMineViewController()
  35. mine.tabBarItem.image = .icMainMineDefault.withRenderingMode(.alwaysOriginal)
  36. mine.tabBarItem.selectedImage = .icMainMineSelected.withRenderingMode(.alwaysOriginal)
  37. viewControllers = [home, room, message, mine]
  38. if let mainTabBar = tabBar as? LNMainTabBar {
  39. mainTabBar.setupViews()
  40. }
  41. selectedViewController = message // 触发消息界面加载逻辑
  42. selectedViewController = home
  43. delegate = self
  44. }
  45. override func viewWillAppear(_ animated: Bool) {
  46. super.viewWillAppear(animated)
  47. navigationController?.setNavigationBarHidden(true, animated: animated)
  48. }
  49. }
  50. extension LNMainViewController: UITabBarControllerDelegate {
  51. func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
  52. if viewController is LNHomeViewController { return true }
  53. if !hasLogin {
  54. LNLoginPanel.show(container: view)
  55. }
  56. return hasLogin
  57. }
  58. }
  59. extension LNMainViewController: LNProfileManagerNotify, LNNetworkMonitorNotify {
  60. func onUserInfoChanged(userInfo: LNUserProfileVO) {
  61. guard userInfo.userNo.isMyUid else { return }
  62. if !userInfo.isAvailable {
  63. view.pushToGenderSetup()
  64. }
  65. }
  66. }