From 0b15e10ebca6cb2f7865f7960ee7d38bb0b7a329 Mon Sep 17 00:00:00 2001 From: mh <729263080@qq.com> Date: Thu, 13 Nov 2025 19:26:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E8=AE=BE=E7=BD=AE=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Chat/Setting/Cell/ChatFontCell.swift | 4 +- .../Setting/Cell/ChatResponseTokenCell.swift | 5 +- .../Setting/Cell/ChatSettingBaseCell.swift | 7 ++- .../Chat/Setting/Cell/ChatSwipeCell.swift | 4 +- .../Chat/Setting/Cell/SectionTextCell.swift | 51 +++++++++++++++++++ .../Setting/View/ChatSettingSwipeView.swift | 18 +++++-- 6 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/SectionTextCell.swift diff --git a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatFontCell.swift b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatFontCell.swift index c419bc8..5fe934f 100644 --- a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatFontCell.swift +++ b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatFontCell.swift @@ -158,8 +158,8 @@ class ChatFontCell: ChatSettingBaseCell, CellConfigurable { } } - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) + override init(reuseIdentifier: String?) { + super.init(reuseIdentifier: reuseIdentifier) configureViews() } diff --git a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatResponseTokenCell.swift b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatResponseTokenCell.swift index d8988f4..c1eff26 100644 --- a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatResponseTokenCell.swift +++ b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatResponseTokenCell.swift @@ -52,9 +52,8 @@ class ChatResponseTokenCell: ChatSettingBaseCell, CellConfigurable { countLab.text = row.count } - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - + override init(reuseIdentifier: String?) { + super.init(reuseIdentifier: reuseIdentifier) configureViews() } diff --git a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatSettingBaseCell.swift b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatSettingBaseCell.swift index 20a7e7e..a587fcb 100644 --- a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatSettingBaseCell.swift +++ b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatSettingBaseCell.swift @@ -8,7 +8,7 @@ import UIKit import SnapKit -class ChatSettingBaseCell: UITableViewCell { +class ChatSettingBaseCell: UITableViewHeaderFooterView { var containerHeightConstraint: Constraint? @@ -19,9 +19,8 @@ class ChatSettingBaseCell: UITableViewCell { return view }() - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - + override init(reuseIdentifier: String?) { + super.init(reuseIdentifier: reuseIdentifier) setupViews() } diff --git a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatSwipeCell.swift b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatSwipeCell.swift index 6dc5ae9..41cd5fd 100644 --- a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatSwipeCell.swift +++ b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/ChatSwipeCell.swift @@ -112,8 +112,8 @@ class ChatSwipeCell: ChatSettingBaseCell, CellConfigurable { } } - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) + override init(reuseIdentifier: String?) { + super.init(reuseIdentifier: reuseIdentifier) configureViews() } diff --git a/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/SectionTextCell.swift b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/SectionTextCell.swift new file mode 100644 index 0000000..ade1505 --- /dev/null +++ b/Visual_Novel_iOS/Src/Modules/Chat/Setting/Cell/SectionTextCell.swift @@ -0,0 +1,51 @@ +// +// SectionTextCell.swift +// Visual_Novel_iOS +// +// Created by mh on 2025/11/13. +// + +import UIKit + +struct SectionTextRow: RowModel { + let title: String + var cellReuseID: String { "SectionTextCell" } + + func cellHeight(tableWidth: CGFloat) -> CGFloat { + return UITableView.automaticDimension + } +} + +class SectionTextCell: UITableViewHeaderFooterView, CellConfigurable { + + lazy var titleLab: UILabel = { + let lab = UILabel() + lab.font = UIFont.boldSystemFont(ofSize: 14) + lab.textColor = UIColor(hex: "#333333") + return lab + }() + + override init(reuseIdentifier: String?) { + super.init(reuseIdentifier: reuseIdentifier) + configureViews() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func configureViews() { + contentView.addSubview(titleLab) + + titleLab.snp.makeConstraints { make in + make.left.equalToSuperview().inset(20) + make.top.equalToSuperview().inset(10) + make.centerY.equalToSuperview() + } + } + + func configure(with row: any RowModel) { + guard let row = row as? SectionTextRow else { return } + titleLab.text = row.title + } +} diff --git a/Visual_Novel_iOS/Src/Modules/Chat/Setting/View/ChatSettingSwipeView.swift b/Visual_Novel_iOS/Src/Modules/Chat/Setting/View/ChatSettingSwipeView.swift index 92fb2b7..6ed043f 100644 --- a/Visual_Novel_iOS/Src/Modules/Chat/Setting/View/ChatSettingSwipeView.swift +++ b/Visual_Novel_iOS/Src/Modules/Chat/Setting/View/ChatSettingSwipeView.swift @@ -57,14 +57,20 @@ class ChatSettingSwipeView: CLContainer { ]) rows = [ - [modelRow, ImageRow(icon: "role_text_mode", title: "Short Text Mode", showAvatar: false, showArrow: false, showSwitch: true)], - [ImageRow(icon: "role_voice", title: "Voice actor", showAvatar: true, showArrow: true, showSwitch: false, voiceActorItems: createVoiceActorItems()), ImageRow(icon: "role_talk", title: "Play dialogue only", showAvatar: false, showArrow: false, showSwitch: true)], + [ImageRow(icon: "", title: "")], + [modelRow], + [ImageRow(icon: "role_text_mode", title: "Short Text Mode", showAvatar: false, showArrow: false, showSwitch: true)], + [ImageRow(icon: "role_voice", title: "Voice actor", showAvatar: true, showArrow: true, showSwitch: false, voiceActorItems: createVoiceActorItems())], + [ImageRow(icon: "role_talk", title: "Play dialogue only", showAvatar: false, showArrow: false, showSwitch: true)], [TokenRow(count: "2500")], - [FontRow(count: "20", icon: "role_font", title: "Font size"), ImageRow(icon: "role_chat_mode", title: "Chat Mode", showAvatar: false, showArrow: true, showSwitch: false, chatModeItems: createChatModeItems()), buttleRow], + [FontRow(count: "20", icon: "role_font", title: "Font size")], + [ImageRow(icon: "role_chat_mode", title: "Chat Mode", showAvatar: false, showArrow: true, showSwitch: false, chatModeItems: createChatModeItems())], + [buttleRow], [BackgroundRow(count: 50)], [HistoryRow(time: "", icon: "", title: "", itemCount: 30)] ] + setupViews() } @@ -116,6 +122,7 @@ class ChatSettingSwipeView: CLContainer { tableView.register(ChatButtleCollectionCell.self, forCellReuseIdentifier: "ChatButtleCollectionCell") tableView.register(ChatModeContainerCell.self, forCellReuseIdentifier: "ChatModeContainerCell") tableView.register(VoiceActorContainerCell.self, forCellReuseIdentifier: "VoiceActorContainerCell") + tableView.register(SectionTextCell.self, forHeaderFooterViewReuseIdentifier: "SectionTextCell") tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) return tableView }() @@ -360,7 +367,10 @@ extension ChatSettingSwipeView: UITableViewDelegate, UITableViewDataSource { } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return rows[section].count + if let model = rows[section].first, model is ImageRow { + return 1 + } + return 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {