diff --git a/Visual_Novel_iOS/Src/Components/UI/Header/TopHeaderManager.swift b/Visual_Novel_iOS/Src/Components/UI/Header/TopHeaderManager.swift new file mode 100644 index 0000000..42e6b74 --- /dev/null +++ b/Visual_Novel_iOS/Src/Components/UI/Header/TopHeaderManager.swift @@ -0,0 +1,59 @@ +// +// TopHeaderManager.swift +// Visual_Novel_iOS +// +// Created by mh on 2025/11/10. +// + +import UIKit +import Combine +import SnapKit + +final class TopHeaderManager { + + static let shared = TopHeaderManager() + + private(set) lazy var headerView: CLTopHeaderView = { + let view = CLTopHeaderView() + return view + }() + + private var hostingView: UIView? + private var topConstraint: Constraint? + private var heightConstraint: Constraint? + + private init() {} + + var jumpPublisher: AnyPublisher { + headerView.jumpPublisher + } + + func attachIfNeeded(to viewController: UIViewController) { + guard hostingView !== viewController.view else { return } + detach() + let container = viewController.view! + container.addSubview(headerView) + headerView.snp.makeConstraints { make in + topConstraint = make.top.equalToSuperview().constraint + make.leading.trailing.equalToSuperview() + heightConstraint = make.height.equalTo(UIDevice().navHeight).constraint + } + hostingView = container + headerView.isHidden = false + } + + func show() { + headerView.isHidden = false + } + + func hide() { + headerView.isHidden = true + } + + func detach() { + headerView.removeFromSuperview() + hostingView = nil + } +} + + diff --git a/Visual_Novel_iOS/Src/Modules/Chat/Session/SessionController.swift b/Visual_Novel_iOS/Src/Modules/Chat/Session/SessionController.swift index d28e29a..2dee45d 100755 --- a/Visual_Novel_iOS/Src/Modules/Chat/Session/SessionController.swift +++ b/Visual_Novel_iOS/Src/Modules/Chat/Session/SessionController.swift @@ -28,6 +28,7 @@ class SessionController: CLBaseViewController { var pureBgOperateView:SessionPureBgOperateView! var titleStr: String? = nil + var avatar: String? = nil // 长按菜单响应的cell var menuCell: SessionCell? @@ -83,10 +84,12 @@ class SessionController: CLBaseViewController { } } - convenience init(conversationId: String, title: String? = "") { + convenience init(conversationId: String, title: String? = "", avatar: String? = "") { self.init() self.conversationId = conversationId self.titleStr = title + self.avatar = avatar + self.navigationView.iconImgView.sd_setImage(with: URL(string: avatar ?? ""), placeholderImage: nil) conversation = V2NIMConversation() let stings = conversationId.components(separatedBy: "|") @@ -491,7 +494,7 @@ extension SessionController { } // self.bottomViewsStackV.setNeedsDisplay() // self.bottomViewsStackV.layoutIfNeeded() -// +// // // 添加这行来动态调整tableView的contentInset // DispatchQueue.main.async { [weak self] in // self?.adjustTableViewContentInset() diff --git a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Model/ChatRoleViewModel.swift b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Model/ChatRoleViewModel.swift index 3c6aa1d..71fc0b5 100644 --- a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Model/ChatRoleViewModel.swift +++ b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Model/ChatRoleViewModel.swift @@ -16,7 +16,7 @@ struct RoleListRequest: Codable { var limit = 20 var name: String = "" var sourceId: String = "" - var tagId: [String]? + var tagIds: [String]? } // model @@ -31,12 +31,20 @@ struct RoleItem: Codable { var id: String = "" var name: String = "" var coverImage: String = "" + // 角色头像 + var headPortrait: String = "" var score: Double? var description: String = "" var updateTime: String = "" var sourceId: String = "" var sourceType: Int = 0 var commonCount: Int? + var tags: [tagItem] = [] +} + +struct tagItem: Codable { + var name: String = "" + var tagId: String = "" } class ChatRoleViewModel { @@ -47,7 +55,7 @@ class ChatRoleViewModel { req.limit = limit req.name = name req.sourceId = sourceId - req.tagId = tagId + req.tagIds = tagId let params = req.toNonNilDictionary() diff --git a/Visual_Novel_iOS/Src/Modules/Roles/View/CLRoleCollectionCell.swift b/Visual_Novel_iOS/Src/Modules/Roles/View/CLRoleCollectionCell.swift index 2d4f85c..f883f33 100644 --- a/Visual_Novel_iOS/Src/Modules/Roles/View/CLRoleCollectionCell.swift +++ b/Visual_Novel_iOS/Src/Modules/Roles/View/CLRoleCollectionCell.swift @@ -133,9 +133,13 @@ class CLRoleCollectionCell: UICollectionViewCell { // MARK: data func setupData(item: RoleItem) { - descLab.text = item.name + descLab.text = item.description nameLab.text = item.name coverImgView.sd_setImage(with: URL(string: item.coverImage), placeholderImage: nil) + tagLab.text = item.tags.compactMap { $0.name }.joined(separator: "/") + // 0:小说;1:漫剧;2:用户自定义 + self.bookBgImgView.isHidden = item.sourceType != 0 + self.playImgView.isHidden = item.sourceType != 1 // coverImgView. } @@ -180,7 +184,7 @@ class CLRoleCollectionCell: UICollectionViewCell { bookBgImgView.snp.makeConstraints { make in make.top.left.equalToSuperview() } -// +// // fromImgView.snp.makeConstraints { make in // make.top.left.equalToSuperview() // } diff --git a/Visual_Novel_iOS/Src/Modules/Roles/View/RolesRootPageView.swift b/Visual_Novel_iOS/Src/Modules/Roles/View/RolesRootPageView.swift index 12dfacf..b51b3a8 100644 --- a/Visual_Novel_iOS/Src/Modules/Roles/View/RolesRootPageView.swift +++ b/Visual_Novel_iOS/Src/Modules/Roles/View/RolesRootPageView.swift @@ -184,7 +184,7 @@ extension RolesRootPageView: UICollectionViewDelegate, UICollectionViewDataSourc if data.count > indexPath.item { let item = data[indexPath.item] let sessionId = "439217670979585@r@t" - AppRouter.goChatVC(conversationId: sessionId, title: item.name, complete: nil) + AppRouter.goChatVC(conversationId: sessionId, title: item.name, avatar: item.headPortrait, complete: nil) } } diff --git a/Visual_Novel_iOS/Src/Utils/Router/AppRouterChat.swift b/Visual_Novel_iOS/Src/Utils/Router/AppRouterChat.swift index 74ddd13..7dd1d34 100644 --- a/Visual_Novel_iOS/Src/Utils/Router/AppRouterChat.swift +++ b/Visual_Novel_iOS/Src/Utils/Router/AppRouterChat.swift @@ -35,11 +35,11 @@ extension AppRouter{ complete?() } - static func goChatVC(conversationId: String?, title: String? = nil, complete: (() -> Void)? = nil) { + static func goChatVC(conversationId: String?, title: String? = nil, avatar: String? = nil, complete: (() -> Void)? = nil) { // guard UserCore.shared.checkUserLoginIfNotPushUserToLogin() else{return} guard let sessionId = conversationId else{return} - let vc = SessionController(conversationId: sessionId, title: title) + let vc = SessionController(conversationId: sessionId, title: title, avatar: avatar) let nvc = UIWindow.getTopViewController(base: UIWindow.applicationKey?.rootViewController)?.navigationController nvc?.pushViewController(vc, animated: true) complete?()