From: liangzhenying <867174124@qq.com> Date: Wed, 27 Aug 2025 08:27:03 +0000 (+0800) Subject: 完善UI X-Git-Tag: 1.0.2~104 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=a8922baa4e37454c9a209721cdcf9bb76bff07bb;p=mirrors%2FShenYin.git 完善UI --- diff --git a/ShenYin/ShenYin/Assets.xcassets/home/btn_record_normal.imageset/Contents.json b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_normal.imageset/Contents.json new file mode 100644 index 0000000..04fa73f --- /dev/null +++ b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_normal.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Group 2104@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Group 2104@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ShenYin/ShenYin/Assets.xcassets/home/btn_record_normal.imageset/Group 2104@2x.png b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_normal.imageset/Group 2104@2x.png new file mode 100644 index 0000000..238251e Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_normal.imageset/Group 2104@2x.png differ diff --git a/ShenYin/ShenYin/Assets.xcassets/home/btn_record_normal.imageset/Group 2104@3x.png b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_normal.imageset/Group 2104@3x.png new file mode 100644 index 0000000..052a3af Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_normal.imageset/Group 2104@3x.png differ diff --git a/ShenYin/ShenYin/Assets.xcassets/home/btn_record_stop.imageset/Contents.json b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_stop.imageset/Contents.json new file mode 100644 index 0000000..3adc415 --- /dev/null +++ b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_stop.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Group_2122@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Group_2122@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ShenYin/ShenYin/Assets.xcassets/home/btn_record_stop.imageset/Group_2122@2x.png b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_stop.imageset/Group_2122@2x.png new file mode 100644 index 0000000..1ffb38a Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_stop.imageset/Group_2122@2x.png differ diff --git a/ShenYin/ShenYin/Assets.xcassets/home/btn_record_stop.imageset/Group_2122@3x.png b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_stop.imageset/Group_2122@3x.png new file mode 100644 index 0000000..93b3ac8 Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/btn_record_stop.imageset/Group_2122@3x.png differ diff --git a/ShenYin/ShenYin/Assets.xcassets/home/record_pause.imageset/Contents.json b/ShenYin/ShenYin/Assets.xcassets/home/record_pause.imageset/Contents.json new file mode 100644 index 0000000..0eb1e60 --- /dev/null +++ b/ShenYin/ShenYin/Assets.xcassets/home/record_pause.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Frame_2245@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Frame_2245@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ShenYin/ShenYin/Assets.xcassets/home/record_pause.imageset/Frame_2245@2x.png b/ShenYin/ShenYin/Assets.xcassets/home/record_pause.imageset/Frame_2245@2x.png new file mode 100644 index 0000000..08d52df Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/record_pause.imageset/Frame_2245@2x.png differ diff --git a/ShenYin/ShenYin/Assets.xcassets/home/record_pause.imageset/Frame_2245@3x.png b/ShenYin/ShenYin/Assets.xcassets/home/record_pause.imageset/Frame_2245@3x.png new file mode 100644 index 0000000..6013525 Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/record_pause.imageset/Frame_2245@3x.png differ diff --git a/ShenYin/ShenYin/Assets.xcassets/home/record_play.imageset/Contents.json b/ShenYin/ShenYin/Assets.xcassets/home/record_play.imageset/Contents.json new file mode 100644 index 0000000..194398d --- /dev/null +++ b/ShenYin/ShenYin/Assets.xcassets/home/record_play.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Frame_2246@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Frame_2246@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ShenYin/ShenYin/Assets.xcassets/home/record_play.imageset/Frame_2246@2x.png b/ShenYin/ShenYin/Assets.xcassets/home/record_play.imageset/Frame_2246@2x.png new file mode 100644 index 0000000..1eaefed Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/record_play.imageset/Frame_2246@2x.png differ diff --git a/ShenYin/ShenYin/Assets.xcassets/home/record_play.imageset/Frame_2246@3x.png b/ShenYin/ShenYin/Assets.xcassets/home/record_play.imageset/Frame_2246@3x.png new file mode 100644 index 0000000..cccb1e0 Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/record_play.imageset/Frame_2246@3x.png differ diff --git a/ShenYin/ShenYin/Assets.xcassets/home/record_select_language.imageset/Contents.json b/ShenYin/ShenYin/Assets.xcassets/home/record_select_language.imageset/Contents.json new file mode 100644 index 0000000..59c99fd --- /dev/null +++ b/ShenYin/ShenYin/Assets.xcassets/home/record_select_language.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "Group_2299@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "Group_2299@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/ShenYin/ShenYin/Assets.xcassets/home/record_select_language.imageset/Group_2299@2x.png b/ShenYin/ShenYin/Assets.xcassets/home/record_select_language.imageset/Group_2299@2x.png new file mode 100644 index 0000000..310df38 Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/record_select_language.imageset/Group_2299@2x.png differ diff --git a/ShenYin/ShenYin/Assets.xcassets/home/record_select_language.imageset/Group_2299@3x.png b/ShenYin/ShenYin/Assets.xcassets/home/record_select_language.imageset/Group_2299@3x.png new file mode 100644 index 0000000..0b5ba98 Binary files /dev/null and b/ShenYin/ShenYin/Assets.xcassets/home/record_select_language.imageset/Group_2299@3x.png differ diff --git a/ShenYin/ShenYin/SceneDelegate.swift b/ShenYin/ShenYin/SceneDelegate.swift index 90b78c5..c31a65d 100644 --- a/ShenYin/ShenYin/SceneDelegate.swift +++ b/ShenYin/ShenYin/SceneDelegate.swift @@ -21,7 +21,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { App.shared.window = window setConfig() window?.rootViewController = BaseTC() -// window?.rootViewController = UINavigationController(rootViewController: TextTranlateVC()) + window?.rootViewController = UINavigationController(rootViewController: ChatVC()) } diff --git a/ShenYin/ShenYin/UI/Base/BaseTC.swift b/ShenYin/ShenYin/UI/Base/BaseTC.swift index afa86ac..06eddf7 100644 --- a/ShenYin/ShenYin/UI/Base/BaseTC.swift +++ b/ShenYin/ShenYin/UI/Base/BaseTC.swift @@ -55,6 +55,6 @@ class BaseTC:UITabBarController{ self.tabBar.backgroundColor = .white view.backgroundColor = .color(.bgColor) - self.selectedIndex = 4 + self.selectedIndex = 0 } } diff --git a/ShenYin/ShenYin/UI/Base/BaseVC.swift b/ShenYin/ShenYin/UI/Base/BaseVC.swift index 4864f34..0d7b007 100644 --- a/ShenYin/ShenYin/UI/Base/BaseVC.swift +++ b/ShenYin/ShenYin/UI/Base/BaseVC.swift @@ -44,6 +44,7 @@ open class BaseVC:UIViewController, UIGestureRecognizerDelegate { } setupViews() setupLayout() + loadData() addLog() } open override func viewWillAppear(_ animated: Bool) { @@ -79,7 +80,9 @@ open class BaseVC:UIViewController, UIGestureRecognizerDelegate { func setupLayout(){ } - + func loadData(){ + + } func addLog(){ logBtn.frame = CGRect(x: UIScreen.main.bounds.size.width - 80, y: 200, width:60, height: 60) logBtn.backgroundColor = .blue diff --git a/ShenYin/ShenYin/UI/Base/GlobalConfig.swift b/ShenYin/ShenYin/UI/Base/GlobalConfig.swift new file mode 100644 index 0000000..1a46c8d --- /dev/null +++ b/ShenYin/ShenYin/UI/Base/GlobalConfig.swift @@ -0,0 +1,10 @@ +// +// GlobalConfig.swift +// ShenYin +// +// Created by liangshi on 2025/8/27. +// + +class GlobalConfig{ + static let languages = ["简体中文","English","日语","法语"] +} diff --git a/ShenYin/ShenYin/UI/Home/CallingRecordVC.swift b/ShenYin/ShenYin/UI/Home/CallingRecordVC.swift index d9af3cb..a6febb5 100644 --- a/ShenYin/ShenYin/UI/Home/CallingRecordVC.swift +++ b/ShenYin/ShenYin/UI/Home/CallingRecordVC.swift @@ -8,17 +8,46 @@ import UIKit class CallingRecordVC:BaseVC{ - + let toolBar = FieldRecordBar() + let textView = UITextView() + let rhythView = RhythView() override func viewDidLoad() { super.viewDidLoad() - - } override func setupViews() { - self.navBar.title = "通话录音" + navBar.title = "通话录音" + navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) + + textView.do { v in + v.text = "好优美的一篇文章,山花落尽,我心犹青|||记得春日时分,山花绽放得那样热烈,鲜红的、明黄的、洁白的,仿佛将整片山野染成了一幅画。那时的心也如山花般明亮,轻快地跳跃在生活的每一个角落。然而,繁华易逝,花朵终会飘落。花落的那天,我站在同一片山坡上,听着风带走它们的碎影。那种空落感从心底涌起,像极了许多未能言说的遗憾,带着些许酸涩。" + v.font = .regular(14) + v.textColor = .hexString("#121212") + v.contentInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18) + } + view.addSubviews([rhythView,textView,toolBar]) + } override func setupLayout() { + rhythView.snp.makeConstraints { make in + make.width.centerX.equalToSuperview() + make.height.equalTo(100) + make.top.equalToSuperview().inset(kNavBtm) + } + toolBar.snp.makeConstraints { make in + make.width.centerX.equalToSuperview() + make.height.equalTo(120) + make.bottom.equalToSuperview().inset(20) + } + textView.snp.makeConstraints { make in + make.top.equalTo(rhythView.snp.bottom) + make.left.right.equalToSuperview() + make.bottom.equalTo(toolBar.snp.top) + } + } + override func navRightViewTapped() { + + } + func scrollToBottom(){ } - } diff --git a/ShenYin/ShenYin/UI/Home/Chat/ChatCell.swift b/ShenYin/ShenYin/UI/Home/Chat/ChatCell.swift new file mode 100644 index 0000000..db089d6 --- /dev/null +++ b/ShenYin/ShenYin/UI/Home/Chat/ChatCell.swift @@ -0,0 +1,86 @@ +// +// ChatCell.swift +// ShenYin +// +// Created by liangshi on 2025/8/27. +// +/// Ai回应模型 +public class ChatCellModel { + public var type: Int = 0 + + public var content: String = "" + + public var description: String { + return "UBAiResponse(type: \(type), state:\(type), content:\(content))" + } +} + +class ChatCell:BaseTableViewCell{ + let bgView = UIView() + let originalLabel = UILabel() + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + override func setupViews() { + contentView.backgroundColor = .rgb(0xF6F6F6) + + bgView.do { v in + v.yc.setCornerRadius(12) + v.backgroundColor = .white + } + originalLabel.do { v in + v.text = "你好,欢迎使用AI翻译,点击下方按钮立即开始咱们的对话吧" + v.font = .bold(14) + v.textColor = .hexString("#606D80") + v.numberOfLines = 0 + v.textAlignment = .left + } + + contentView.addSubview(bgView) + bgView.addSubviews([originalLabel]) + } + + override func setupLayout() { + bgView.snp.makeConstraints { make in + make.top.bottom.equalToSuperview().inset(10) + make.width.lessThanOrEqualTo(kScreenWid - 36) + make.left.equalToSuperview().inset(18) + } + + originalLabel.snp.makeConstraints { make in + make.left.right.top.bottom.equalToSuperview().inset(10) + make.width.lessThanOrEqualTo(kScreenWid - 56) + } + } + + var data:ChatCellModel!{ + didSet{ + if data.type == 1 { + bgView.backgroundColor = .color(.theme) + originalLabel.textColor = .white + + bgView.snp.remakeConstraints { make in + make.top.bottom.equalToSuperview().inset(10) + make.right.equalToSuperview().inset(20) + } + } + else{ + bgView.backgroundColor = .white + originalLabel.textColor = .hexString("#121212") + + bgView.snp.remakeConstraints { make in + make.top.bottom.equalToSuperview().inset(10) + make.left.equalToSuperview().inset(20) + } + } + originalLabel.text = data.content + } + } +} diff --git a/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift b/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift new file mode 100644 index 0000000..1caf717 --- /dev/null +++ b/ShenYin/ShenYin/UI/Home/Chat/ChatVC.swift @@ -0,0 +1,97 @@ +// +// ChatVC.swift +// ShenYin +// +// Created by liangshi on 2025/8/6. +// + +import UIKit + +class ChatVC:BaseVC{ + let toolBar = SendToolBar() + let tableView = UITableView(frame: CGRectZero, style: .plain) + var dataList:[ChatCellModel] = [] + override func viewDidLoad() { + super.viewDidLoad() + } + override func setupViews() { + navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) + + + tableView.backgroundColor = .clear + tableView.delegate = self + tableView.dataSource = self + tableView.estimatedRowHeight = 60 + tableView.separatorStyle = .none + tableView.register(ChatCell.self, forCellReuseIdentifier: ChatCell.reuseID) + view.addSubview(tableView) + + + toolBar.textField.text = "" + toolBar.delegate = self + view.addSubview(toolBar) + + } + override func setupLayout() { + toolBar.snp.makeConstraints { make in + make.width.centerX.equalToSuperview() + make.height.equalTo(52) + make.bottom.equalToSuperview().inset(20) + } + tableView.snp.makeConstraints { make in + make.top.equalToSuperview().inset(80) + make.left.right.equalToSuperview() + make.bottom.equalTo(toolBar.snp.top) + } + } + override func loadData() { + let model1 = ChatCellModel() + model1.type = 0 + model1.content = "您好,有什么可以帮助您" + + let model2 = ChatCellModel() + model2.type = 1 + model2.content = "明天会下雨吗" + + let model3 = ChatCellModel() + model3.type = 0 + model3.content = "明天晴转多云,不下雨。明天去哪里玩呀,有没有选好地方,我知道好很多好玩的地方哦" + + let model4 = ChatCellModel() + model4.type = 1 + model4.content = "好的,谢谢啊" + dataList = [model1,model2,model3,model4] + tableView.reloadData() + } + override func navRightViewTapped() { + App.shared.goToPage(RoleListVC()) + } + func scrollToBottom(){ + if dataList.count > 0 { + tableView.scrollToRow(at: IndexPath(row: dataList.count - 1, section: 0), at: .none, animated: true) + } + } +} +extension ChatVC:UITableViewDelegate,UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return dataList.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = ChatCell.cell(withTableView: tableView, indexPath: indexPath) + cell.data = dataList[indexPath.row] + return cell + } + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + + } +} +extension ChatVC:SendToolBarDelegate{ + func sendToolBar(_ toolBar: SendToolBar, _ text: String) { + toolBar.textField.resignFirstResponder() + // list.append(ChatCellModel(isSend:true,content:text)) + // tableView.reloadData() + // scrollToBottom() + // StartburstGlassesSdk.shared().chat.fireText(text) + } +} diff --git a/ShenYin/ShenYin/UI/Home/RoleListVC.swift b/ShenYin/ShenYin/UI/Home/Chat/RoleListVC.swift similarity index 99% rename from ShenYin/ShenYin/UI/Home/RoleListVC.swift rename to ShenYin/ShenYin/UI/Home/Chat/RoleListVC.swift index fba3b1f..1cccb22 100644 --- a/ShenYin/ShenYin/UI/Home/RoleListVC.swift +++ b/ShenYin/ShenYin/UI/Home/Chat/RoleListVC.swift @@ -8,7 +8,7 @@ import UIKit class RoleListVC: BaseVC{ let tableView = UITableView(frame: .zero, style: .plain) - var list:[MineCellType] = [] + var list = [1,2,3,4,5,6,7] override func viewDidLoad() { super.viewDidLoad() diff --git a/ShenYin/ShenYin/UI/Home/ChatVC.swift b/ShenYin/ShenYin/UI/Home/ChatVC.swift deleted file mode 100644 index 42186a4..0000000 --- a/ShenYin/ShenYin/UI/Home/ChatVC.swift +++ /dev/null @@ -1,24 +0,0 @@ -// -// ChatVC.swift -// ShenYin -// -// Created by liangshi on 2025/8/6. -// - -import UIKit - -class ChatVC:BaseVC{ - - override func viewDidLoad() { - super.viewDidLoad() - - - } - override func setupViews() { - self.navBar.title = "对话" - } - override func setupLayout() { - - } - -} diff --git a/ShenYin/ShenYin/UI/Home/Chinese2EnglishVC.swift b/ShenYin/ShenYin/UI/Home/Chinese2EnglishVC.swift index e7db819..e9f183b 100644 --- a/ShenYin/ShenYin/UI/Home/Chinese2EnglishVC.swift +++ b/ShenYin/ShenYin/UI/Home/Chinese2EnglishVC.swift @@ -5,21 +5,62 @@ // Created by liangshi on 2025/8/6. // - import UIKit class Chinese2EnglishVC:BaseVC{ - + let toolBar = RecordBar() + let tableView = UITableView(frame: CGRectZero, style: .plain) + var dataList = [1,2,3] override func viewDidLoad() { super.viewDidLoad() - - } override func setupViews() { - self.navBar.title = "中英互译" + navBar.title = "中英互译" + navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) + + + tableView.backgroundColor = .clear + tableView.delegate = self + tableView.dataSource = self + tableView.estimatedRowHeight = 60 + tableView.separatorStyle = .none + tableView.register(TranslateCell.self, forCellReuseIdentifier: TranslateCell.reuseID) + view.addSubview(tableView) + view.addSubview(toolBar) + } override func setupLayout() { + toolBar.snp.makeConstraints { make in + make.width.centerX.equalToSuperview() + make.height.equalTo(120) + make.bottom.equalToSuperview().inset(20) + } + tableView.snp.makeConstraints { make in + make.top.equalToSuperview().inset(80) + make.left.right.equalToSuperview() + make.bottom.equalTo(toolBar.snp.top) + } + } + override func navRightViewTapped() { } + func scrollToBottom(){ + if dataList.count > 0 { + tableView.scrollToRow(at: IndexPath(row: dataList.count - 1, section: 0), at: .none, animated: true) + } + } +} +extension Chinese2EnglishVC:UITableViewDelegate,UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return dataList.count + } + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = TranslateCell.cell(withTableView: tableView, indexPath: indexPath) + // cell.data = dataList[indexPath.row] + return cell + } + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + + } } diff --git a/ShenYin/ShenYin/UI/Home/DialogTranlateVC.swift b/ShenYin/ShenYin/UI/Home/DialogTranlateVC.swift index c7e4f60..4871fde 100644 --- a/ShenYin/ShenYin/UI/Home/DialogTranlateVC.swift +++ b/ShenYin/ShenYin/UI/Home/DialogTranlateVC.swift @@ -8,17 +8,59 @@ import UIKit class DialogTranlateVC:BaseVC{ - + let toolBar = RecordBar() + let tableView = UITableView(frame: CGRectZero, style: .plain) + var dataList = [1,2,3] override func viewDidLoad() { super.viewDidLoad() - - } override func setupViews() { - self.navBar.title = "对话翻译" + navBar.title = "对话翻译" + navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) + + + tableView.backgroundColor = .clear + tableView.delegate = self + tableView.dataSource = self + tableView.estimatedRowHeight = 60 + tableView.separatorStyle = .none + tableView.register(TranslateCell.self, forCellReuseIdentifier: TranslateCell.reuseID) + view.addSubview(tableView) + view.addSubview(toolBar) + } override func setupLayout() { + toolBar.snp.makeConstraints { make in + make.width.centerX.equalToSuperview() + make.height.equalTo(120) + make.bottom.equalToSuperview().inset(20) + } + tableView.snp.makeConstraints { make in + make.top.equalToSuperview().inset(80) + make.left.right.equalToSuperview() + make.bottom.equalTo(toolBar.snp.top) + } + } + override func navRightViewTapped() { } + func scrollToBottom(){ + if dataList.count > 0 { + tableView.scrollToRow(at: IndexPath(row: dataList.count - 1, section: 0), at: .none, animated: true) + } + } +} +extension DialogTranlateVC:UITableViewDelegate,UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return dataList.count + } + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = TranslateCell.cell(withTableView: tableView, indexPath: indexPath) + // cell.data = dataList[indexPath.row] + return cell + } + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + + } } diff --git a/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordBar.swift b/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordBar.swift new file mode 100644 index 0000000..ceb1103 --- /dev/null +++ b/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordBar.swift @@ -0,0 +1,153 @@ +// +// Untitled.swift +// ShenYin +// +// Created by liangshi on 2025/8/27. +// + +enum RecordSate:Int{ + case normal + case recording + case pause +} + +class FieldRecordBar: BaseView { + let recordBtn = UIButton() + let leftItem = RecordBarItem() + let rightItem = RecordBarButton() + var state:RecordSate = .normal + + override func setupViews() { + backgroundColor = .white + addSubviews([leftItem,rightItem,recordBtn]) + + recordBtn.do { v in + v.setImage(UIImage(named: "btn_record_normal"), for: .normal) + v.setImage(UIImage(named: "btn_record_stop"), for: .selected) + v.addTarget(self, action: #selector(recordBtnAction), for: .touchUpInside) + } + leftItem.do {v in + v.yc.addTap(target: self, action: #selector(leftAction)) + } + rightItem.do {v in + v.state = .normal + v.yc.addTap(target: self, action: #selector(pauseAction)) + } + } + + override func setupLayout() { + recordBtn.snp.makeConstraints { make in + make.size.equalTo(56) + make.center.equalToSuperview() + } + leftItem.snp.makeConstraints { make in + make.size.equalTo(56) + make.centerY.equalTo(recordBtn) + make.right.equalToSuperview().offset(-(kScreenWid/2 + 60)) + } + rightItem.snp.makeConstraints { make in + make.size.equalTo(56) + make.centerY.equalTo(recordBtn) + make.left.equalToSuperview().offset(kScreenWid/2 + 60) + } + } + @objc func leftAction(){ + if recordBtn.isSelected { + return + } + let v = CustomPicker(title: "请选择语言", list: GlobalConfig.languages) + v.selectedIndex = 0 + v.show() + v.didSelected = {[weak self] (index,value) in + guard let self = self else { return } + leftItem.titleLabel.text = value + } + return + } + @objc func recordBtnAction(){ + recordBtn.isSelected = !recordBtn.isSelected + rightItem.state = .recording + rightItem.isHidden = !recordBtn.isSelected + + if recordBtn.isSelected { + leftItem.alpha = 0.5 + } + else{ + leftItem.alpha = 1 + } + } + @objc func pauseAction(){ + if rightItem.state == .recording { + rightItem.state = .pause + } + else if rightItem.state == .pause { + rightItem.state = .recording + } + } + + class RecordBarItem: BaseView { + let icon = UIImageView() + let titleLabel = UILabel() + override func setupViews() { + addSubviews([titleLabel,icon]) + icon.do { v in + v.image = UIImage(named: "record_select_language") + } + titleLabel.do { v in + v.textColor = .rgb(0x121212) + v.font = .regular(10) + v.text = "中文" + } + } + + override func setupLayout() { + icon.snp.makeConstraints { make in + make.size.equalTo(28) + make.top.equalToSuperview().inset(10) + make.centerX.equalToSuperview() + } + titleLabel.snp.makeConstraints { make in + make.top.equalTo(icon.snp.bottom).offset(5) + make.centerX.equalTo(icon) + } + } + } + class RecordBarButton: BaseView { + let icon = UIImageView() + let titleLabel = UILabel() + var state:RecordSate = .normal{ + didSet{ + if state == .pause { + titleLabel.text = "ç»§ç»­" + icon.image = UIImage(named: "record_play") + } + else if state == .recording{ + titleLabel.text = "暂停" + icon.image = UIImage(named: "record_pause") + } + } + } + + override func setupViews() { + addSubviews([titleLabel,icon]) + icon.do { v in + } + titleLabel.do { v in + v.textColor = .rgb(0x121212) + v.font = .regular(10) + } + } + + override func setupLayout() { + icon.snp.makeConstraints { make in + make.size.equalTo(28) + make.top.equalToSuperview().inset(10) + make.centerX.equalToSuperview() + } + titleLabel.snp.makeConstraints { make in + make.top.equalTo(icon.snp.bottom).offset(5) + make.centerX.equalTo(icon) + } + } + } +} diff --git a/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingCell.swift b/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingCell.swift deleted file mode 100644 index c5a651c..0000000 --- a/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingCell.swift +++ /dev/null @@ -1,134 +0,0 @@ -// -// Fi.swift -// ShenYin -// -// Created by liangshi on 2025/8/26. -// - -import UIKit - -/// Ai回应模型 -public class UBAiResponse { - /// 类型, - /// 0:AI录音解析错误(只发类型即可,后面字节均不发) - /// 1:AI录音解析内容 - /// 2:AI回应内容 - /// 3:AI回应错误(只发类型即可,后面字节均不发) - /// 4:AI回应结束(只发类型即可,后面字节均不发) - public var type: Int = 0 - /// 类型 start middle end - public var state:String = "" - - /// 回复id - public var reponseId: String = "" - /// 内容 - public var content: String = "" - /// 累积内容 - public var totalContent: String = "" - - - init(_ reponseId:String) { - self.reponseId = reponseId - } - - public var description: String { - return "UBAiResponse(type: \(type), state:\(state), content:\(content))" - } -} - - -class FieldRecordingCell:BaseTableViewCell{ - let bgView = UIView() - let line = BrokenLineView() - let originalLabel = UILabel() - let translationLabel = UILabel() - - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - override func setupViews() { - contentView.backgroundColor = .rgb(0xF6F6F6) - - bgView.do { v in - v.yc.setCornerRadius(12) - v.backgroundColor = .white - } - originalLabel.do { v in - v.text = "你好,欢迎使用AI翻译,点击下方按钮立即开始咱们的对话吧" - v.font = .regular(14) - v.textColor = .hexString("#606D80") - v.numberOfLines = 0 - v.textAlignment = .left - } - translationLabel.do { v in - v.text = "Hello, welcome to AI translation, click the button below now Let's start our conversation" - v.font = .regular(14) - v.textColor = .hexString("#121212") - v.numberOfLines = 0 - v.textAlignment = .left - } - line.do { v in -// v.backgroundColor = .hexString("#93C6EC") - } - contentView.addSubview(bgView) - bgView.addSubviews([originalLabel,translationLabel,line]) - - -// let brokenLineView = BrokenLineView(frame: CGRect(x: 0, y: 0, width: 300, height:100)) -// addSubview(brokenLineView) - } - - override func setupLayout() { - bgView.snp.makeConstraints { make in - make.top.bottom.equalToSuperview().inset(10) - make.width.lessThanOrEqualTo(kScreenWid - 36) - make.left.equalToSuperview().inset(18) - } - - originalLabel.snp.makeConstraints { make in - make.top.equalToSuperview().inset(14) - make.left.equalToSuperview().inset(10) - make.width.lessThanOrEqualTo(kScreenWid - 60) - } - line.snp.makeConstraints { make in - make.left.right.equalToSuperview().inset(10) - make.height.equalTo(10) - make.top.equalTo(originalLabel.snp.bottom).offset(18) - } - - translationLabel.snp.makeConstraints { make in - make.top.equalTo(line.snp.bottom).offset(18) - make.left.equalToSuperview().inset(10) - make.width.lessThanOrEqualTo(kScreenWid - 60) - make.bottom.equalToSuperview().inset(10) - } - } - -// var data:UBAiResponse!{ -// didSet{ -// if data.type == 1 { -// bgView.snp.remakeConstraints { make in -// make.top.bottom.equalToSuperview().inset(10) -// make.right.equalToSuperview().inset(20) -// } -// } -// else{ -// -// bgView.snp.remakeConstraints { make in -// make.top.bottom.equalToSuperview().inset(10) -// make.left.equalToSuperview().inset(20) -// } -// } -// msgLabel.text = data.totalContent -// } -// } -} - - - diff --git a/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingVC.swift b/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingVC.swift index c85d261..e1e7e83 100644 --- a/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingVC.swift +++ b/ShenYin/ShenYin/UI/Home/FieldRecording/FieldRecordingVC.swift @@ -8,66 +8,46 @@ import UIKit class FieldRecordingVC:BaseVC{ - let toolBar = SendToolBar() - let tableView = UITableView(frame: CGRectZero, style: .plain) - var dataList = [1,2,3] + let toolBar = FieldRecordBar() + let textView = UITextView() + let rhythView = RhythView() override func viewDidLoad() { super.viewDidLoad() } override func setupViews() { - self.navBar.title = "现场录音" - tableView.backgroundColor = .clear - tableView.delegate = self - tableView.dataSource = self - tableView.estimatedRowHeight = 60 - tableView.separatorStyle = .none - tableView.register(FieldRecordingCell.self, forCellReuseIdentifier: FieldRecordingCell.reuseID) - view.addSubview(tableView) + navBar.title = "现场录音" + navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) + textView.do { v in + v.text = "好优美的一篇文章,山花落尽,我心犹青|||记得春日时分,山花绽放得那样热烈,鲜红的、明黄的、洁白的,仿佛将整片山野染成了一幅画。那时的心也如山花般明亮,轻快地跳跃在生活的每一个角落。然而,繁华易逝,花朵终会飘落。花落的那天,我站在同一片山坡上,听着风带走它们的碎影。那种空落感从心底涌起,像极了许多未能言说的遗憾,带着些许酸涩。" + v.font = .regular(14) + v.textColor = .hexString("#121212") + v.contentInset = UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18) + } + view.addSubviews([rhythView,textView,toolBar]) - toolBar.textField.text = "" - toolBar.delegate = self - view.addSubview(toolBar) - } override func setupLayout() { + rhythView.snp.makeConstraints { make in + make.width.centerX.equalToSuperview() + make.height.equalTo(100) + make.top.equalToSuperview().inset(kNavBtm) + } toolBar.snp.makeConstraints { make in make.width.centerX.equalToSuperview() - make.height.equalTo(52) + make.height.equalTo(120) make.bottom.equalToSuperview().inset(20) } - tableView.snp.makeConstraints { make in - make.top.equalToSuperview().inset(80) + textView.snp.makeConstraints { make in + make.top.equalTo(rhythView.snp.bottom) make.left.right.equalToSuperview() make.bottom.equalTo(toolBar.snp.top) } } - func scrollToBottom(){ - if dataList.count > 0 { - tableView.scrollToRow(at: IndexPath(row: dataList.count - 1, section: 0), at: .none, animated: true) - } - } -} -extension FieldRecordingVC:UITableViewDelegate,UITableViewDataSource { - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return dataList.count - } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = FieldRecordingCell.cell(withTableView: tableView, indexPath: indexPath) -// cell.data = dataList[indexPath.row] - return cell - } - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + override func navRightViewTapped() { } -} -extension FieldRecordingVC:SendToolBarDelegate{ - func sendToolBar(_ toolBar: SendToolBar, _ text: String) { - toolBar.textField.resignFirstResponder() -// list.append(ChatCellModel(isSend:true,content:text)) -// tableView.reloadData() -// scrollToBottom() -// StartburstGlassesSdk.shared().chat.fireText(text) + func scrollToBottom(){ + } } diff --git a/ShenYin/ShenYin/UI/Home/FieldRecording/RecordBar.swift b/ShenYin/ShenYin/UI/Home/FieldRecording/RecordBar.swift new file mode 100644 index 0000000..03c9012 --- /dev/null +++ b/ShenYin/ShenYin/UI/Home/FieldRecording/RecordBar.swift @@ -0,0 +1,92 @@ +// +// RecordBar.swift +// ShenYin +// +// Created by liangshi on 2025/8/27. +// + +class RecordBar: BaseView { + let recordBtn = UIButton() + let leftItem = RecordBarItem() + let rightItem = RecordBarItem() + + + override func setupViews() { + backgroundColor = .white + addSubviews([leftItem,rightItem,recordBtn]) + + recordBtn.do { v in + v.setImage(UIImage(named: "btn_record_normal"), for: .normal) + v.setImage(UIImage(named: "btn_record_stop"), for: .selected) + v.addTarget(self, action: #selector(recordBtnAction), for: .touchUpInside) + } + leftItem.do {v in +// v.backgroundColor = .green + } + rightItem.do {v in +// v.backgroundColor = .yellow + } + } + + override func setupLayout() { + recordBtn.snp.makeConstraints { make in + make.size.equalTo(56) + make.center.equalToSuperview() + } + leftItem.snp.makeConstraints { make in + make.size.equalTo(56) + make.centerY.equalTo(recordBtn) + make.right.equalToSuperview().offset(-(kScreenWid/2 + 60)) + } + rightItem.snp.makeConstraints { make in + make.size.equalTo(56) + make.centerY.equalTo(recordBtn) + make.left.equalToSuperview().offset(kScreenWid/2 + 60) + } + } + + @objc func recordBtnAction(){ + recordBtn.isSelected = !recordBtn.isSelected + } + + class RecordBarItem: BaseView { + let icon = UIImageView() + let titleLabel = UILabel() + let valueLabel = UILabel() + + override func setupViews() { +// backgroundColor = .red + addSubviews([titleLabel,valueLabel,icon]) + icon.do { v in + v.image = UIImage(named: "") + v.backgroundColor = .black + } + titleLabel.do { v in + v.textColor = .rgb(0x121212) + v.font = .bold(16) + v.text = "中文" + } + valueLabel.do { v in + v.textColor = .rgb(0x666666) + v.font = .regular(10) + v.text = "耳机" + } + } + + override func setupLayout() { + icon.snp.makeConstraints { make in + make.size.equalTo(12) + make.top.equalToSuperview().inset(10) + make.right.equalToSuperview() + } + titleLabel.snp.makeConstraints { make in + make.right.equalTo(icon.snp.left).offset(-5) + make.centerY.equalTo(icon) + } + valueLabel.snp.makeConstraints { make in + make.right.equalTo(titleLabel) + make.top.equalTo(titleLabel.snp.bottom).offset(5) + } + } + } +} diff --git a/ShenYin/ShenYin/UI/Home/FieldRecording/RhythView.swift b/ShenYin/ShenYin/UI/Home/FieldRecording/RhythView.swift new file mode 100644 index 0000000..55b95a7 --- /dev/null +++ b/ShenYin/ShenYin/UI/Home/FieldRecording/RhythView.swift @@ -0,0 +1,20 @@ +// +// Untitled.swift +// ShenYin +// +// Created by liangshi on 2025/8/27. +// + +class RhythView: BaseView { + + + override func setupViews() { + backgroundColor = .red + + } + + override func setupLayout() { + + } + +} diff --git a/ShenYin/ShenYin/UI/Home/HistoryRecord/HistoryRecordCell.swift b/ShenYin/ShenYin/UI/Home/HistoryRecord/HistoryRecordCell.swift index da7c364..5cb7669 100644 --- a/ShenYin/ShenYin/UI/Home/HistoryRecord/HistoryRecordCell.swift +++ b/ShenYin/ShenYin/UI/Home/HistoryRecord/HistoryRecordCell.swift @@ -66,7 +66,7 @@ class HistoryRecordCell: BaseTableViewCell { } collectionIcon.image = UIImage(named: "collection_selected") playIcon.do { v in - v.backgroundColor = .lightGray + v.image = UIImage(named: "play_icon") } } @@ -79,14 +79,13 @@ class HistoryRecordCell: BaseTableViewCell { } playIcon.snp.makeConstraints { (m) in - m.width.equalTo(30) - m.height.equalTo(30) + m.width.size.equalTo(34) m.left.equalToSuperview().inset(14) m.centerY.equalToSuperview() } titleLabel.snp.makeConstraints { (m) in m.top.equalTo(16) - m.left.equalToSuperview().offset(52) + m.left.equalTo(playIcon.snp.right).offset(6) } collectionIcon.snp.makeConstraints { (m) in m.size.equalTo(16) diff --git a/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift b/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift index cd0e7e1..1d0e619 100644 --- a/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift +++ b/ShenYin/ShenYin/UI/Home/RecordTranslateVC.swift @@ -9,17 +9,59 @@ import UIKit class RecordTranslateVC:BaseVC{ - + let toolBar = RecordBar() + let tableView = UITableView(frame: CGRectZero, style: .plain) + var dataList = [1,2,3] override func viewDidLoad() { super.viewDidLoad() - - } override func setupViews() { - self.navBar.title = "同声传译" + navBar.title = "同声传译" + navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) + + + tableView.backgroundColor = .clear + tableView.delegate = self + tableView.dataSource = self + tableView.estimatedRowHeight = 60 + tableView.separatorStyle = .none + tableView.register(TranslateCell.self, forCellReuseIdentifier: TranslateCell.reuseID) + view.addSubview(tableView) + view.addSubview(toolBar) + } override func setupLayout() { + toolBar.snp.makeConstraints { make in + make.width.centerX.equalToSuperview() + make.height.equalTo(120) + make.bottom.equalToSuperview().inset(20) + } + tableView.snp.makeConstraints { make in + make.top.equalToSuperview().inset(80) + make.left.right.equalToSuperview() + make.bottom.equalTo(toolBar.snp.top) + } + } + override func navRightViewTapped() { } + func scrollToBottom(){ + if dataList.count > 0 { + tableView.scrollToRow(at: IndexPath(row: dataList.count - 1, section: 0), at: .none, animated: true) + } + } +} +extension RecordTranslateVC:UITableViewDelegate,UITableViewDataSource { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return dataList.count + } + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = TranslateCell.cell(withTableView: tableView, indexPath: indexPath) + // cell.data = dataList[indexPath.row] + return cell + } + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + + } } diff --git a/ShenYin/ShenYin/UI/Home/Root/HomeFunctionView.swift b/ShenYin/ShenYin/UI/Home/Root/HomeFunctionView.swift index 0c2ebb8..dde9a4a 100644 --- a/ShenYin/ShenYin/UI/Home/Root/HomeFunctionView.swift +++ b/ShenYin/ShenYin/UI/Home/Root/HomeFunctionView.swift @@ -165,7 +165,7 @@ class HomeCell: BaseView { case .recordTranslate: App.shared.goToPage(RecordTranslateVC()) case .dialogTranslate: - App.shared.goToPage(ChatVC()) + App.shared.goToPage(DialogTranlateVC()) case .textTranslate: App.shared.goToPage(TextTranlateVC()) } diff --git a/ShenYin/ShenYin/UI/Home/Root/HomeHeadView.swift b/ShenYin/ShenYin/UI/Home/Root/HomeHeadView.swift index 594526f..655a7d1 100644 --- a/ShenYin/ShenYin/UI/Home/Root/HomeHeadView.swift +++ b/ShenYin/ShenYin/UI/Home/Root/HomeHeadView.swift @@ -24,6 +24,7 @@ class HomeHeadView: BaseView { bottonView.do { v in v.backgroundColor = .rgb(0xFAFAFA) v.yc.setCornerRadius(30) + v.yc.addTap(target: self, action: #selector(chatAction)) } tipsIcon.do { v in v.image = UIImage(named: "home_chat") @@ -64,6 +65,9 @@ class HomeHeadView: BaseView { make.centerY.equalToSuperview() } } + @objc func chatAction(){ + App.shared.goToPage(ChatVC()) + } } diff --git a/ShenYin/ShenYin/UI/Home/Root/HomeVC.swift b/ShenYin/ShenYin/UI/Home/Root/HomeVC.swift index 9bb7fe2..0608d3f 100644 --- a/ShenYin/ShenYin/UI/Home/Root/HomeVC.swift +++ b/ShenYin/ShenYin/UI/Home/Root/HomeVC.swift @@ -56,13 +56,7 @@ class HomeVC:BaseVC{ // v.selectedIndex(4) // v.show(animate: true) - let v = CustomPicker(title: "tishi", list: ["2","3","4","5","6","7","8"]) - v.selectedIndex = 2 - v.show() - v.didSelected = { (index,value) in - print(index,value) - } - return + } @objc func addDeviceAction(){ diff --git a/ShenYin/ShenYin/UI/Home/textTranslateVC/TextTranslateVC.swift b/ShenYin/ShenYin/UI/Home/textTranslateVC/TextTranslateVC.swift index 86b897f..c775aae 100644 --- a/ShenYin/ShenYin/UI/Home/textTranslateVC/TextTranslateVC.swift +++ b/ShenYin/ShenYin/UI/Home/textTranslateVC/TextTranslateVC.swift @@ -16,6 +16,9 @@ class TextTranlateVC:BaseVC{ } override func setupViews() { self.navBar.title = "文本翻译" + navBar.rightView.setImage(UIImage(named: "help_icon"), for: .normal) + + tableView.backgroundColor = .clear tableView.delegate = self tableView.dataSource = self @@ -41,6 +44,9 @@ class TextTranlateVC:BaseVC{ make.left.right.equalToSuperview() make.bottom.equalTo(toolBar.snp.top) } + } + override func navRightViewTapped() { + } func scrollToBottom(){ if dataList.count > 0 { diff --git a/ShenYin/ShenYin/UI/Home/textTranslateVC/TranslateCell.swift b/ShenYin/ShenYin/UI/Home/textTranslateVC/TranslateCell.swift index 6d455c5..95c5876 100644 --- a/ShenYin/ShenYin/UI/Home/textTranslateVC/TranslateCell.swift +++ b/ShenYin/ShenYin/UI/Home/textTranslateVC/TranslateCell.swift @@ -5,6 +5,7 @@ // Created by liangshi on 2025/8/26. // + class TranslateCell:BaseTableViewCell{ let bgView = UIView() let line = BrokenLineView() diff --git a/ShenYin/ShenYin/UI/Mine/Root/MineBannerView.swift b/ShenYin/ShenYin/UI/Mine/Root/MineBannerView.swift index 1e99d12..4137a3a 100644 --- a/ShenYin/ShenYin/UI/Mine/Root/MineBannerView.swift +++ b/ShenYin/ShenYin/UI/Mine/Root/MineBannerView.swift @@ -42,7 +42,7 @@ final class MineBannerView: BaseView { pageControl.snp.makeConstraints { (m) in m.width.equalToSuperview() m.height.equalTo(25) - m.bottom.equalToSuperview().inset(10) + m.bottom.equalToSuperview().inset(5) m.centerX.equalToSuperview() } } diff --git a/ShenYin/ShenYin/UI/common/CustomPicker.swift b/ShenYin/ShenYin/UI/common/CustomPicker.swift index ba59023..b08cef7 100644 --- a/ShenYin/ShenYin/UI/common/CustomPicker.swift +++ b/ShenYin/ShenYin/UI/common/CustomPicker.swift @@ -60,7 +60,7 @@ class CustomPicker: BasePresentView { v.textColor = .rgb(0x333333) v.font = .semiBold(16) v.textAlignment = .center - v.text = "标题" + v.text = title } btn.do { v in v.setImage(UIImage(named: "close_icon"), for: .normal)