Commit efaebc22 authored by Alex朱枝文's avatar Alex朱枝文

直播UI调整

parent 64661dfc
...@@ -293,12 +293,14 @@ ...@@ -293,12 +293,14 @@
04564D4B2CF389DD004456E4 /* YHLivePlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D4A2CF389DD004456E4 /* YHLivePlayerViewController.swift */; }; 04564D4B2CF389DD004456E4 /* YHLivePlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D4A2CF389DD004456E4 /* YHLivePlayerViewController.swift */; };
04564D4D2CF38D16004456E4 /* YHLiveMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D4C2CF38D16004456E4 /* YHLiveMessageCell.swift */; }; 04564D4D2CF38D16004456E4 /* YHLiveMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D4C2CF38D16004456E4 /* YHLiveMessageCell.swift */; };
04564D4F2CF38E20004456E4 /* YHLiveMessageListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D4E2CF38E20004456E4 /* YHLiveMessageListView.swift */; }; 04564D4F2CF38E20004456E4 /* YHLiveMessageListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D4E2CF38E20004456E4 /* YHLiveMessageListView.swift */; };
04564D512CF38EA4004456E4 /* YHMessageInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D502CF38EA4004456E4 /* YHMessageInputView.swift */; };
04564D532CF38FE2004456E4 /* YHVODPlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D522CF38FE2004456E4 /* YHVODPlayerViewController.swift */; }; 04564D532CF38FE2004456E4 /* YHVODPlayerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D522CF38FE2004456E4 /* YHVODPlayerViewController.swift */; };
04564D562CF4467B004456E4 /* YHPlayerTopBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D552CF4467B004456E4 /* YHPlayerTopBarView.swift */; }; 04564D562CF4467B004456E4 /* YHPlayerTopBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D552CF4467B004456E4 /* YHPlayerTopBarView.swift */; };
04564D592CF470B2004456E4 /* YHIncomeRecordCompanyTipsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D582CF470B2004456E4 /* YHIncomeRecordCompanyTipsCell.swift */; }; 04564D592CF470B2004456E4 /* YHIncomeRecordCompanyTipsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D582CF470B2004456E4 /* YHIncomeRecordCompanyTipsCell.swift */; };
04564D5D2CF49F0A004456E4 /* live_room_test_bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 04564D5C2CF49F0A004456E4 /* live_room_test_bg.png */; }; 04564D5D2CF49F0A004456E4 /* live_room_test_bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 04564D5C2CF49F0A004456E4 /* live_room_test_bg.png */; };
04564D5F2CF565C7004456E4 /* YHInputBottomBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D5E2CF565C7004456E4 /* YHInputBottomBar.swift */; }; 04564D5F2CF565C7004456E4 /* YHInputBottomBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D5E2CF565C7004456E4 /* YHInputBottomBar.swift */; };
04564D612CF59835004456E4 /* YHMessageInputViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D602CF59835004456E4 /* YHMessageInputViewController.swift */; };
04564D632CF60222004456E4 /* YHGradientView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D622CF60222004456E4 /* YHGradientView.swift */; };
04564D652CF6065D004456E4 /* YHFadeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04564D642CF6065D004456E4 /* YHFadeView.swift */; };
0457920B2CBCE7B200EBD99B /* YHResignUploadTravelCardViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0457920A2CBCE7B200EBD99B /* YHResignUploadTravelCardViewModel.swift */; }; 0457920B2CBCE7B200EBD99B /* YHResignUploadTravelCardViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0457920A2CBCE7B200EBD99B /* YHResignUploadTravelCardViewModel.swift */; };
0457920D2CBCE8A800EBD99B /* YHResignUploadTravelCardListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0457920C2CBCE8A800EBD99B /* YHResignUploadTravelCardListModel.swift */; }; 0457920D2CBCE8A800EBD99B /* YHResignUploadTravelCardListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0457920C2CBCE8A800EBD99B /* YHResignUploadTravelCardListModel.swift */; };
0457920F2CBCE9D000EBD99B /* YHResignUploadTravelCardListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0457920E2CBCE9D000EBD99B /* YHResignUploadTravelCardListTableViewCell.swift */; }; 0457920F2CBCE9D000EBD99B /* YHResignUploadTravelCardListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0457920E2CBCE9D000EBD99B /* YHResignUploadTravelCardListTableViewCell.swift */; };
...@@ -1344,12 +1346,14 @@ ...@@ -1344,12 +1346,14 @@
04564D4A2CF389DD004456E4 /* YHLivePlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLivePlayerViewController.swift; sourceTree = "<group>"; }; 04564D4A2CF389DD004456E4 /* YHLivePlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLivePlayerViewController.swift; sourceTree = "<group>"; };
04564D4C2CF38D16004456E4 /* YHLiveMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLiveMessageCell.swift; sourceTree = "<group>"; }; 04564D4C2CF38D16004456E4 /* YHLiveMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLiveMessageCell.swift; sourceTree = "<group>"; };
04564D4E2CF38E20004456E4 /* YHLiveMessageListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLiveMessageListView.swift; sourceTree = "<group>"; }; 04564D4E2CF38E20004456E4 /* YHLiveMessageListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLiveMessageListView.swift; sourceTree = "<group>"; };
04564D502CF38EA4004456E4 /* YHMessageInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMessageInputView.swift; sourceTree = "<group>"; };
04564D522CF38FE2004456E4 /* YHVODPlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHVODPlayerViewController.swift; sourceTree = "<group>"; }; 04564D522CF38FE2004456E4 /* YHVODPlayerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHVODPlayerViewController.swift; sourceTree = "<group>"; };
04564D552CF4467B004456E4 /* YHPlayerTopBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPlayerTopBarView.swift; sourceTree = "<group>"; }; 04564D552CF4467B004456E4 /* YHPlayerTopBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHPlayerTopBarView.swift; sourceTree = "<group>"; };
04564D582CF470B2004456E4 /* YHIncomeRecordCompanyTipsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHIncomeRecordCompanyTipsCell.swift; sourceTree = "<group>"; }; 04564D582CF470B2004456E4 /* YHIncomeRecordCompanyTipsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHIncomeRecordCompanyTipsCell.swift; sourceTree = "<group>"; };
04564D5C2CF49F0A004456E4 /* live_room_test_bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = live_room_test_bg.png; sourceTree = "<group>"; }; 04564D5C2CF49F0A004456E4 /* live_room_test_bg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = live_room_test_bg.png; sourceTree = "<group>"; };
04564D5E2CF565C7004456E4 /* YHInputBottomBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInputBottomBar.swift; sourceTree = "<group>"; }; 04564D5E2CF565C7004456E4 /* YHInputBottomBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInputBottomBar.swift; sourceTree = "<group>"; };
04564D602CF59835004456E4 /* YHMessageInputViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMessageInputViewController.swift; sourceTree = "<group>"; };
04564D622CF60222004456E4 /* YHGradientView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHGradientView.swift; sourceTree = "<group>"; };
04564D642CF6065D004456E4 /* YHFadeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFadeView.swift; sourceTree = "<group>"; };
0457920A2CBCE7B200EBD99B /* YHResignUploadTravelCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignUploadTravelCardViewModel.swift; sourceTree = "<group>"; }; 0457920A2CBCE7B200EBD99B /* YHResignUploadTravelCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignUploadTravelCardViewModel.swift; sourceTree = "<group>"; };
0457920C2CBCE8A800EBD99B /* YHResignUploadTravelCardListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignUploadTravelCardListModel.swift; sourceTree = "<group>"; }; 0457920C2CBCE8A800EBD99B /* YHResignUploadTravelCardListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignUploadTravelCardListModel.swift; sourceTree = "<group>"; };
0457920E2CBCE9D000EBD99B /* YHResignUploadTravelCardListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignUploadTravelCardListTableViewCell.swift; sourceTree = "<group>"; }; 0457920E2CBCE9D000EBD99B /* YHResignUploadTravelCardListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHResignUploadTravelCardListTableViewCell.swift; sourceTree = "<group>"; };
...@@ -2931,6 +2935,7 @@ ...@@ -2931,6 +2935,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
04564D482CF385D9004456E4 /* YHBasePlayerViewController.swift */, 04564D482CF385D9004456E4 /* YHBasePlayerViewController.swift */,
04564D602CF59835004456E4 /* YHMessageInputViewController.swift */,
04564D4A2CF389DD004456E4 /* YHLivePlayerViewController.swift */, 04564D4A2CF389DD004456E4 /* YHLivePlayerViewController.swift */,
04564D522CF38FE2004456E4 /* YHVODPlayerViewController.swift */, 04564D522CF38FE2004456E4 /* YHVODPlayerViewController.swift */,
); );
...@@ -2944,7 +2949,8 @@ ...@@ -2944,7 +2949,8 @@
04564D462CF3851D004456E4 /* YHPlayerControlView.swift */, 04564D462CF3851D004456E4 /* YHPlayerControlView.swift */,
04564D4C2CF38D16004456E4 /* YHLiveMessageCell.swift */, 04564D4C2CF38D16004456E4 /* YHLiveMessageCell.swift */,
04564D4E2CF38E20004456E4 /* YHLiveMessageListView.swift */, 04564D4E2CF38E20004456E4 /* YHLiveMessageListView.swift */,
04564D502CF38EA4004456E4 /* YHMessageInputView.swift */, 04564D622CF60222004456E4 /* YHGradientView.swift */,
04564D642CF6065D004456E4 /* YHFadeView.swift */,
04564D552CF4467B004456E4 /* YHPlayerTopBarView.swift */, 04564D552CF4467B004456E4 /* YHPlayerTopBarView.swift */,
04564D5E2CF565C7004456E4 /* YHInputBottomBar.swift */, 04564D5E2CF565C7004456E4 /* YHInputBottomBar.swift */,
); );
...@@ -6225,6 +6231,7 @@ ...@@ -6225,6 +6231,7 @@
04A671602BA0280800C1FB91 /* YHFileRenameInputView.swift in Sources */, 04A671602BA0280800C1FB91 /* YHFileRenameInputView.swift in Sources */,
04CA2BF42CB7B33500F36DE7 /* YHResignUploadTravelGuideView.swift in Sources */, 04CA2BF42CB7B33500F36DE7 /* YHResignUploadTravelGuideView.swift in Sources */,
A5ACE93F2B4564F7002C94D2 /* UIViewController+Extension.swift in Sources */, A5ACE93F2B4564F7002C94D2 /* UIViewController+Extension.swift in Sources */,
04564D612CF59835004456E4 /* YHMessageInputViewController.swift in Sources */,
A53B61192BB3C9960010B573 /* YHMyDocListHeaderView.swift in Sources */, A53B61192BB3C9960010B573 /* YHMyDocListHeaderView.swift in Sources */,
042B20D22CEADBD800655093 /* YHImproveHKView.swift in Sources */, 042B20D22CEADBD800655093 /* YHImproveHKView.swift in Sources */,
04F243662C9D5CB200DF2C74 /* YHResignDocumentViewModel.swift in Sources */, 04F243662C9D5CB200DF2C74 /* YHResignDocumentViewModel.swift in Sources */,
...@@ -6347,6 +6354,7 @@ ...@@ -6347,6 +6354,7 @@
042B20DA2CEB337100655093 /* YHImproveSchemeTemplateListCell.swift in Sources */, 042B20DA2CEB337100655093 /* YHImproveSchemeTemplateListCell.swift in Sources */,
0445E6AF2BE9CFF6003C52F9 /* YHAppVersionForceUpdateView.swift in Sources */, 0445E6AF2BE9CFF6003C52F9 /* YHAppVersionForceUpdateView.swift in Sources */,
040AE9882CEB6DAC00310241 /* YHWorkExperiencePositionModel.swift in Sources */, 040AE9882CEB6DAC00310241 /* YHWorkExperiencePositionModel.swift in Sources */,
04564D652CF6065D004456E4 /* YHFadeView.swift in Sources */,
04213B272C48C95E00797900 /* YHHomeIdentityCell.swift in Sources */, 04213B272C48C95E00797900 /* YHHomeIdentityCell.swift in Sources */,
041892262C91BDF500B9FB94 /* YHResignDocumentHeaderCell.swift in Sources */, 041892262C91BDF500B9FB94 /* YHResignDocumentHeaderCell.swift in Sources */,
0449EEE92C8EEB1E00A397FD /* YHResinMaterialManageContainerVC.swift in Sources */, 0449EEE92C8EEB1E00A397FD /* YHResinMaterialManageContainerVC.swift in Sources */,
...@@ -6379,6 +6387,7 @@ ...@@ -6379,6 +6387,7 @@
04F243532C9C434100DF2C74 /* YHHKRecordsCustomerItemCell.swift in Sources */, 04F243532C9C434100DF2C74 /* YHHKRecordsCustomerItemCell.swift in Sources */,
A58A8C8F2BA6978100632765 /* YHMineCertificateEntryViewController.swift in Sources */, A58A8C8F2BA6978100632765 /* YHMineCertificateEntryViewController.swift in Sources */,
045EEF1B2B9F171A0022A143 /* YHAddressPickViewTableViewCell.swift in Sources */, 045EEF1B2B9F171A0022A143 /* YHAddressPickViewTableViewCell.swift in Sources */,
04564D632CF60222004456E4 /* YHGradientView.swift in Sources */,
04213B2F2C49154900797900 /* YHHomeInfoDetailContainerViewController.swift in Sources */, 04213B2F2C49154900797900 /* YHHomeInfoDetailContainerViewController.swift in Sources */,
047AA3FA2C60739E009C4554 /* YHInvitationWithGiftsSelectItemView.swift in Sources */, 047AA3FA2C60739E009C4554 /* YHInvitationWithGiftsSelectItemView.swift in Sources */,
A567E5A42BD7643D00D5D5A0 /* YHSearchInfoCell.swift in Sources */, A567E5A42BD7643D00D5D5A0 /* YHSearchInfoCell.swift in Sources */,
...@@ -6448,7 +6457,6 @@ ...@@ -6448,7 +6457,6 @@
0414BDAB2BC7E9C200225367 /* YHMyPermissionCell.swift in Sources */, 0414BDAB2BC7E9C200225367 /* YHMyPermissionCell.swift in Sources */,
045792152CBD041F00EBD99B /* YHResignUploadTravelHKTableViewCell.swift in Sources */, 045792152CBD041F00EBD99B /* YHResignUploadTravelHKTableViewCell.swift in Sources */,
04C8F4832B7216D800ADF59B /* YHUserInfoHeaderView.swift in Sources */, 04C8F4832B7216D800ADF59B /* YHUserInfoHeaderView.swift in Sources */,
04564D512CF38EA4004456E4 /* YHMessageInputView.swift in Sources */,
045EEEAF2B9F171A0022A143 /* YHWorkExperienceTextItemView.swift in Sources */, 045EEEAF2B9F171A0022A143 /* YHWorkExperienceTextItemView.swift in Sources */,
A5ACE9492B4564F7002C94D2 /* YHHUDSuccessView.swift in Sources */, A5ACE9492B4564F7002C94D2 /* YHHUDSuccessView.swift in Sources */,
04B360EF2C620975001EB053 /* YHPrincipleUploadStatusCell.swift in Sources */, 04B360EF2C620975001EB053 /* YHPrincipleUploadStatusCell.swift in Sources */,
......
...@@ -12,10 +12,35 @@ import UIKit ...@@ -12,10 +12,35 @@ import UIKit
class YHLivePlayerViewController: YHBasePlayerViewController { class YHLivePlayerViewController: YHBasePlayerViewController {
// MARK: - Properties // MARK: - Properties
private var roomInfo: YHLiveRoomInfo private var roomInfo: YHLiveRoomInfo
private lazy var messageListView: YHLiveMessageListView = YHLiveMessageListView()
private var listMaxWidth: CGFloat {
return KScreenWidth * 248.0 / 375.0
}
private lazy var bottomInputBar: YHInputBottomBar = { private lazy var bottomInputBar: YHInputBottomBar = {
let view = YHInputBottomBar() let view = YHInputBottomBar()
view.textViewTappedEvent = { [weak self] in
guard let self = self else {
return
}
self.present(self.inputVC, animated: false)
}
return view
}()
private lazy var inputVC: YHMessageInputViewController = {
let ctl = YHMessageInputViewController()
ctl.closeCallbcak = {
//
}
ctl.inputCallback = { [weak self] controller, text in
//
}
return ctl
}()
private lazy var messageListView: YHLiveMessageListView = {
let view = YHLiveMessageListView(frame: CGRect.init(x: 0, y: 0, width: listMaxWidth, height: listMaxWidth))
return view return view
}() }()
...@@ -40,18 +65,18 @@ class YHLivePlayerViewController: YHBasePlayerViewController { ...@@ -40,18 +65,18 @@ class YHLivePlayerViewController: YHBasePlayerViewController {
private func setupUI() { private func setupUI() {
containerView.addSubview(bottomInputBar) containerView.addSubview(bottomInputBar)
// containerView.addSubview(messageListView) containerView.addSubview(messageListView)
bottomInputBar.snp.makeConstraints { make in bottomInputBar.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview() make.left.right.bottom.equalToSuperview()
make.top.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-YHInputBottomBar.inputActionHeight) make.top.equalTo(view.safeAreaLayoutGuide.snp.bottom).offset(-YHInputBottomBar.inputActionHeight)
} }
// messageListView.snp.makeConstraints { make in messageListView.snp.makeConstraints { make in
// make.left.right.equalToSuperview() make.left.equalToSuperview().offset(16)
// make.bottom.equalTo(bottomInputBar.snp.top) make.bottom.equalTo(bottomInputBar.snp.top).offset(-14)
// make.height.equalTo(view.snp.height).multipliedBy(0.3) make.height.width.equalTo(listMaxWidth)
// } }
} }
private func startLive() { private func startLive() {
......
//
// YHMessageInputViewController.swift
// galaxy
//
// Created by alexzzw on 2024/11/26.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import IQKeyboardManagerSwift
class YHMessageInputViewController: UIViewController {
private let maxCount = 40
private let overMaxCountTips = "评论字数限制40字以下"
private let nullInputTips = "请输入内容"
private let failTips = "发送失败"
private var keyboardHeight = 0.0
private let textContainerToTop = 8.0
private var lastMessage: String = ""
private let textViewMinHeight: CGFloat = 18
private let textViewMaxHeight: CGFloat = 54
var inputCallback: ((YHMessageInputViewController, String) -> Void)?
var closeCallbcak: (() -> Void)?
private lazy var inputMainView: UIView = {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 54))
view.backgroundColor = .white
return view
}()
private lazy var textContainer: YHBaseDynamicCornerRadiusView = {
let view = YHBaseDynamicCornerRadiusView(cornerRadius: 2, corner: .allCorners)
view.backgroundColor = .contentBkgColor
return view
}()
private lazy var textView: UITextView = {
let view = UITextView()
view.backgroundColor = .clear
view.textColor = .mainTextColor
view.tintColor = .brandMainColor
view.font = .PFSC_R(ofSize: 13)
view.returnKeyType = .send
view.enablesReturnKeyAutomatically = true
view.delegate = self
view.textContainerInset = .zero
view.textContainer.lineFragmentPadding = 0
return view
}()
private lazy var editTipsLabel: UILabel = {
let label = UILabel()
label.isHidden = true
label.text = "说点什么..."
label.font = .PFSC_R(ofSize: 13)
label.textColor = UIColor(hexString: "#8993A2")
return label
}()
private lazy var sendButton: UIButton = {
let button = UIButton(type: .custom)
button.setTitle("发送", for: .normal)
button.titleLabel?.font = .PFSC_M(ofSize: 12)
button.setTitleColor(.white, for: .normal)
button.backgroundColor = .brandMainColor
button.layer.cornerRadius = 3
button.clipsToBounds = true
button.addTarget(self, action: #selector(sendButtonTapped), for: .touchUpInside)
return button
}()
init() {
super.init(nibName: nil, bundle: nil)
modalPresentationStyle = .overFullScreen
modalTransitionStyle = .crossDissolve
}
@MainActor required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
addObserver()
// 关闭点击事件
let ges = UITapGestureRecognizer(target: self, action: #selector(closeKeyboard(_:)))
view.addGestureRecognizer(ges)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
IQKeyboardManager.shared.enable = false
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
IQKeyboardManager.shared.enable = true
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
// 显示上次编辑记录
showLastRecord()
guard textView.canBecomeFirstResponder else {
return
}
textView.becomeFirstResponder()
}
func updateText(_ text: String) {
textView.text = text
textViewDidChange(textView)
}
deinit {
NotificationCenter.default.removeObserver(self)
}
}
extension YHMessageInputViewController {
// MARK: - Actions
@objc func keyboardWillShow(_ sender: Notification) {
guard let userInfo = sender.userInfo else {
return
}
guard let keyboardRect = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? CGRect else {
return
}
// 获取动画执行的时间
var duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double ?? 0.25
if duration == 0 {
duration = 0.25
}
// 获取键盘弹起的高度
let keyboardHeight = keyboardRect.height
self.keyboardHeight = keyboardHeight
self.inputMainView.snp.remakeConstraints { make in
make.bottom.equalToSuperview().offset(-keyboardHeight)
make.left.right.equalToSuperview()
}
UIView.animateKeyframes(withDuration: duration, delay: 0, options: UIView.KeyframeAnimationOptions(rawValue: 0)) {
self.view.layoutIfNeeded()
}
}
@objc func keyboardWillHide(_ sender: Notification) {
guard let userInfo = sender.userInfo else {
return
}
// 获取动画执行的时间
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? Double ?? 0.25
let height = self.inputMainView.bounds.height
self.inputMainView.snp.remakeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(height)
}
UIView.animateKeyframes(withDuration: duration, delay: 0, options: UIView.KeyframeAnimationOptions(rawValue: 0)) {
self.view.layoutIfNeeded()
}
}
@objc private func sendButtonTapped() {
let text = textView.text ?? ""
let currentText = text.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
guard currentText.count > 0 else {
// nullInputTips
return
}
inputCallback?(self, currentText)
}
@objc func closeKeyboard(_ sender: UIGestureRecognizer?) {
DispatchQueue.main.async {
// 保存这次编辑的内容
self.lastMessage = self.textView.text
self.textView.snp.updateConstraints { make in
make.height.equalTo(self.textViewMinHeight)
}
self.textView.endEditing(true)
self.dismiss(animated: false) { [weak self] in
self?.closeCallbcak?()
}
}
}
// 显示上次编辑记录
private func showLastRecord() {
guard lastMessage.count > 0 else {
return
}
textView.text = lastMessage
textViewDidChange(textView)
}
private func setupUI() {
view.backgroundColor = .black.withAlphaComponent(0.1)
view.addSubview(inputMainView)
inputMainView.addSubview(textContainer)
textContainer.addSubview(textView)
textContainer.addSubview(editTipsLabel)
inputMainView.addSubview(sendButton)
inputMainView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.bottom.equalToSuperview().offset(54)
}
textContainer.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16)
make.top.equalToSuperview().offset(textContainerToTop)
make.bottom.equalToSuperview().offset(-textContainerToTop)
}
sendButton.snp.makeConstraints { make in
make.left.equalTo(textContainer.snp.right).offset(16)
make.right.equalToSuperview().offset(-16)
make.centerY.equalTo(textContainer)
make.height.equalTo(32)
make.width.equalTo(56)
}
textView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(12)
make.right.equalToSuperview().offset(-12)
make.top.equalToSuperview().offset(10)
make.bottom.equalToSuperview().offset(-10)
make.height.equalTo(textViewMinHeight)
}
editTipsLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(12)
make.centerY.equalToSuperview()
}
}
/// 事件监听
private func addObserver() {
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
}
extension YHMessageInputViewController: UITextViewDelegate {
func textViewDidChange(_ textView: UITextView) {
editTipsLabel.isHidden = textView.text.count > 0
var text = textView.text.replacingOccurrences(of: " ", with: "")
text = text.replacingOccurrences(of: "\n", with: "")
// 储存原textView的大小
let oldSize = textView.frame.size
// 预设textView的大小,宽度设为固定宽度,高度设为CGFloat的最大值
let presetSize = CGSize(width: textView.frame.size.width, height: CGFloat.greatestFiniteMagnitude)
// 重新计算textView的实际大小
let newSize = textView.sizeThatFits(presetSize)
// 当高度变化时,刷新tableview(beginUpdates和endUpdates必须成对使用)
if newSize.height != oldSize.height {
var height = newSize.height >= textViewMaxHeight ? textViewMaxHeight : newSize.height
height = height < textViewMinHeight ? textViewMinHeight : height
self.textView.snp.updateConstraints { make in
make.height.equalTo(height)
}
}
}
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
guard textView == self.textView else {
return true
}
/// 输入删除
if text == "" {
return true
}
if text == "\n" { // 检测回车键
sendButtonTapped()
return false // 不插入换行符
}
let count = (textView.text?.utf16.count ?? 0) - range.length + text.utf16.count
if count > maxCount {
// overMaxCountTips
return false
}
return true
}
}
//
// YHFadeView.swift
// galaxy
//
// Created by alexzzw on 2024/11/26.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHFadeView: UIView {
private let maskLayer = CAGradientLayer()
override init(frame: CGRect) {
super.init(frame: frame)
setupMask()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupMask()
}
private func setupMask() {
// 使用黑色渐变作为mask
maskLayer.colors = [
UIColor.white.cgColor,
UIColor.clear.cgColor,
]
maskLayer.startPoint = CGPoint(x: 0.5, y: 0)
maskLayer.endPoint = CGPoint(x: 0.5, y: 1)
// 重要:将渐变层设置为mask
layer.mask = maskLayer
}
override func layoutSubviews() {
super.layoutSubviews()
// 确保mask大小与视图相同
maskLayer.frame = bounds
}
}
//
// YHGradientView.swift
// galaxy
//
// Created by alexzzw on 2024/11/26.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHGradientView: UIView {
override class var layerClass: AnyClass {
return CAGradientLayer.self
}
init() {
super.init(frame: .zero)
setupGradient()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupGradient()
}
private func setupGradient() {
guard let gradientLayer = layer as? CAGradientLayer else {
return
}
gradientLayer.colors = [
UIColor(white: 1, alpha: 1).cgColor, // 顶部 100% 不透明
UIColor(white: 1, alpha: 0).cgColor // 底部 0% 完全透明
]
gradientLayer.startPoint = CGPoint(x: 0.5, y: 0) // 上边中点
gradientLayer.endPoint = CGPoint(x: 0.5, y: 1) // 下边中点
}
}
...@@ -6,45 +6,30 @@ ...@@ -6,45 +6,30 @@
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved. // Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
// //
import AttributedString
import UIKit import UIKit
class YHLiveMessageCell: UITableViewCell { class YHLiveMessageCell: UITableViewCell {
static let reuseIdentifier = "YHLiveMessageCell" static let reuseIdentifier = "YHLiveMessageCell"
// MARK: - UI Components // MARK: - UI Components
private let containerView: UIView = {
let view = UIView() private let containerView: YHBaseDynamicCornerRadiusView = {
view.backgroundColor = UIColor.black.withAlphaComponent(0.4) let view = YHBaseDynamicCornerRadiusView(cornerRadius: 8, corner: .allCorners)
view.backgroundColor = UIColor.black.withAlphaComponent(0.3)
view.layer.cornerRadius = 8 view.layer.cornerRadius = 8
return view return view
}() }()
private let levelLabel: YHPaddedLabel = {
let label = YHPaddedLabel(padding: UIEdgeInsets(top: 2, left: 4, bottom: 2, right: 4))
label.font = .systemFont(ofSize: 10)
label.textColor = .white
label.backgroundColor = .systemBlue
label.layer.cornerRadius = 4
label.layer.masksToBounds = true
return label
}()
private let nicknameLabel: UILabel = {
let label = UILabel()
label.font = .systemFont(ofSize: 14, weight: .medium)
label.textColor = .systemYellow
return label
}()
private let contentLabel: UILabel = { private let contentLabel: UILabel = {
let label = UILabel() let label = UILabel()
label.font = .systemFont(ofSize: 14)
label.textColor = .white
label.numberOfLines = 0 label.numberOfLines = 0
label.lineBreakMode = .byCharWrapping
return label return label
}() }()
// MARK: - Initialization // MARK: - Initialization
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI() setupUI()
...@@ -57,91 +42,29 @@ class YHLiveMessageCell: UITableViewCell { ...@@ -57,91 +42,29 @@ class YHLiveMessageCell: UITableViewCell {
private func setupUI() { private func setupUI() {
backgroundColor = .clear backgroundColor = .clear
selectionStyle = .none selectionStyle = .none
contentView.addSubview(containerView) contentView.addSubview(containerView)
containerView.addSubview(levelLabel)
containerView.addSubview(nicknameLabel)
containerView.addSubview(contentLabel) containerView.addSubview(contentLabel)
setupConstraints() setupConstraints()
} }
private func setupConstraints() { private func setupConstraints() {
containerView.snp.makeConstraints { make in containerView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(8) make.left.equalToSuperview()
make.right.lessThanOrEqualToSuperview().offset(-8) make.right.lessThanOrEqualToSuperview()
make.top.equalToSuperview().offset(4) make.top.equalToSuperview().offset(2)
make.bottom.equalToSuperview().offset(-4) make.bottom.equalToSuperview().offset(-2)
}
levelLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(8)
make.centerY.equalTo(nicknameLabel)
}
nicknameLabel.snp.makeConstraints { make in
make.left.equalTo(levelLabel.snp.right).offset(8)
make.top.equalToSuperview().offset(8)
} }
contentLabel.snp.makeConstraints { make in contentLabel.snp.makeConstraints { make in
make.left.equalToSuperview().offset(8) make.left.equalToSuperview().offset(8)
make.right.equalToSuperview().offset(-8) make.right.equalToSuperview().offset(-8)
make.top.equalTo(nicknameLabel.snp.bottom).offset(4) make.top.equalToSuperview().offset(4)
make.bottom.equalToSuperview().offset(-8) make.bottom.equalToSuperview().offset(-4)
}
}
// MARK: - Configuration
func configure(with message: YHLiveMessage) {
levelLabel.text = "Lv.\(message.sender.level)"
nicknameLabel.text = message.sender.nickname
switch message.type {
case .normal:
configureNormalMessage(message)
case .system:
configureSystemMessage(message)
case .gift:
configureGiftMessage(message)
case .enter:
configureEnterMessage(message)
case .like:
configureLikeMessage(message)
}
}
private func configureNormalMessage(_ message: YHLiveMessage) {
contentLabel.text = message.content
contentLabel.textColor = .white
if message.sender.isAdmin {
nicknameLabel.textColor = .systemRed
} else {
nicknameLabel.textColor = .systemYellow
}
}
private func configureSystemMessage(_ message: YHLiveMessage) {
levelLabel.isHidden = true
nicknameLabel.isHidden = true
contentLabel.text = message.content
contentLabel.textColor = .systemGray
contentLabel.textAlignment = .center
}
private func configureGiftMessage(_ message: YHLiveMessage) {
contentLabel.text = message.content
contentLabel.textColor = .systemPink
} }
private func configureEnterMessage(_ message: YHLiveMessage) {
contentLabel.text = "进入了直播间"
contentLabel.textColor = .systemGreen
} }
private func configureLikeMessage(_ message: YHLiveMessage) { func configureNormalMessage(_ nickname: String, _ content: String) {
contentLabel.text = "点了赞" let nickAtt = ASAttributedString(string: nickname + ":", .foreground(UIColor.white.withAlphaComponent(0.65)), .font(UIFont.PFSC_R(ofSize: 13)))
contentLabel.textColor = .systemPink let contentAtt = ASAttributedString(string: content, .foreground(UIColor.white), .font(UIFont.PFSC_R(ofSize: 13)))
contentLabel.attributed.text = nickAtt + contentAtt
} }
} }
...@@ -9,118 +9,106 @@ ...@@ -9,118 +9,106 @@
import UIKit import UIKit
class YHLiveMessageListView: UIView { class YHLiveMessageListView: UIView {
// MARK: - Properties
private var messages: [YHLiveMessage] = [] private var messages: [YHLiveMessage] = []
private let maxMessageCount = 200
// MARK: - UI Components // MARK: - UI Components
private lazy var tableView: UITableView = {
let tableView = UITableView() private lazy var topFadeView: YHFadeView = {
tableView.backgroundColor = .clear let view = YHFadeView()
tableView.separatorStyle = .none view.backgroundColor = .clear.withAlphaComponent(0.1)
tableView.showsVerticalScrollIndicator = false return view
tableView.allowsSelection = false
tableView.delegate = self
tableView.dataSource = self
tableView.register(YHLiveMessageCell.self, forCellReuseIdentifier: YHLiveMessageCell.reuseIdentifier)
return tableView
}() }()
private lazy var messageInputView: YHMessageInputView = { private lazy var tableView: UITableView = {
let view = YHMessageInputView(frame: CGRect.zero) let view = UITableView()
view.backgroundColor = .clear
view.separatorStyle = .none
view.showsVerticalScrollIndicator = false
view.allowsSelection = false
view.delegate = self view.delegate = self
view.dataSource = self
view.transform = CGAffineTransform(rotationAngle: .pi)
view.register(YHLiveMessageCell.self, forCellReuseIdentifier: YHLiveMessageCell.reuseIdentifier)
return view return view
}() }()
// MARK: - Initialization // MARK: - Initialization
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
setupUI() setupUI()
setupData()
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
private func setupData() {
let message6 = YHLiveMessage.init(type: .normal, sender: YHLiveUser.init(userId: "1233", nickname: "MAKESIBIB", level: 0, isAdmin: false), content: "优才今年政策", timestamp: Date())
let message5 = YHLiveMessage.init(type: .normal, sender: YHLiveUser.init(userId: "1233", nickname: "MAKESIBIB", level: 0, isAdmin: false), content: "😊", timestamp: Date())
let message4 = YHLiveMessage.init(type: .normal, sender: YHLiveUser.init(userId: "1233", nickname: "姑息可", level: 0, isAdmin: false), content: "优才申请时间有什么限制吗", timestamp: Date())
let message3 = YHLiveMessage.init(type: .normal, sender: YHLiveUser.init(userId: "1233", nickname: "侯米儿", level: 0, isAdmin: false), content: "我来了", timestamp: Date())
let message2 = YHLiveMessage.init(type: .normal, sender: YHLiveUser.init(userId: "1233", nickname: "奇思幻想牛先生", level: 0, isAdmin: false), content: "可以帮忙介绍一下香港优秀人才计划吗?", timestamp: Date())
let message1 = YHLiveMessage.init(type: .normal, sender: YHLiveUser.init(userId: "1233", nickname: "侯米儿", level: 0, isAdmin: false), content: "我工作5年,香港高才怎么申请更快获批啊", timestamp: Date())
let message0 = YHLiveMessage.init(type: .normal, sender: YHLiveUser.init(userId: "1233", nickname: "谷溪", level: 0, isAdmin: false), content: "想了解香港教育有什么优势", timestamp: Date())
messages = [message0, message1, message2, message3, message4, message5, message6]
// messages = [message6]
tableView.reloadData()
}
private func setupUI() { private func setupUI() {
backgroundColor = .clear backgroundColor = .clear
addSubview(tableView) addSubview(tableView)
addSubview(messageInputView) addSubview(topFadeView)
bringSubviewToFront(topFadeView)
setupConstraints() topFadeView.snp.makeConstraints { make in
}
private func setupConstraints() {
tableView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview() make.top.left.right.equalToSuperview()
make.bottom.equalTo(messageInputView.snp.top) make.height.equalTo(26)
} }
messageInputView.snp.makeConstraints { make in tableView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview() make.top.equalToSuperview()
make.height.equalTo(44) make.left.bottom.right.equalToSuperview()
} }
} }
// MARK: - Public Methods // MARK: - Public Methods
func addMessage(_ message: YHLiveMessage) {
messages.append(message)
if messages.count > maxMessageCount {
messages.removeFirst(messages.count - maxMessageCount)
}
let indexPath = IndexPath(row: messages.count - 1, section: 0) func addMessage(_ message: YHLiveMessage) {
tableView.insertRows(at: [indexPath], with: .fade) messages.insert(message, at: 0)
scrollToBottom(animated: true) let indexPath = IndexPath(row: 0, section: 0)
tableView.insertRows(at: [indexPath], with: .bottom)
} }
func clearMessages() { func clearMessages() {
messages.removeAll() messages.removeAll()
tableView.reloadData() tableView.reloadData()
} }
private func scrollToBottom(animated: Bool) {
guard !messages.isEmpty else { return }
let lastIndex = IndexPath(row: messages.count - 1, section: 0)
tableView.scrollToRow(at: lastIndex, at: .bottom, animated: animated)
}
} }
// MARK: - UITableViewDelegate & UITableViewDataSource // MARK: - UITableViewDelegate & UITableViewDataSource
extension YHLiveMessageListView: UITableViewDelegate, UITableViewDataSource { extension YHLiveMessageListView: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return messages.count return messages.count
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard messages.count > indexPath.row else {
return UITableViewCell()
}
guard let cell = tableView.dequeueReusableCell( guard let cell = tableView.dequeueReusableCell(
withIdentifier: YHLiveMessageCell.reuseIdentifier, withIdentifier: YHLiveMessageCell.reuseIdentifier) as? YHLiveMessageCell else {
for: indexPath) as? YHLiveMessageCell else {
return UITableViewCell() return UITableViewCell()
} }
let message = messages[indexPath.row] let message = messages[indexPath.row]
cell.configure(with: message) // cell 也需要旋转
cell.contentView.transform = CGAffineTransform(rotationAngle: .pi)
cell.configureNormalMessage(message.sender.nickname, message.content)
return cell return cell
} }
} }
// MARK: - MessageInputViewDelegate
extension YHLiveMessageListView: YHMessageInputViewDelegate {
func messageInputView(_ inputView: YHMessageInputView, didSendMessage text: String) {
// 创建当前用户
let currentUser = YHLiveUser(userId: "current_user",
nickname: "我",
level: 1,
isAdmin: false)
// 创建消息
let message = YHLiveMessage.createNormalMessage(sender: currentUser,
content: text)
// 添加消息到列表
addMessage(message)
}
}
//
// YHMessageInputView.swift
// galaxy
//
// Created by alexzzw on 2024/11/25.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
protocol YHMessageInputViewDelegate: AnyObject {
func messageInputView(_ inputView: YHMessageInputView, didSendMessage text: String)
}
enum YHMessageInputViewState {
case normalWithGift(_ count: Int)
case inputState
}
class YHMessageInputView: UIView {
// MARK: - Properties
weak var delegate: YHMessageInputViewDelegate?
// MARK: - UI Components
private lazy var textField: UITextField = {
let textField = UITextField()
textField.placeholder = "说点什么..."
textField.textColor = .white
textField.backgroundColor = UIColor.white.withAlphaComponent(0.2)
textField.layer.cornerRadius = 17
textField.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 34))
textField.leftViewMode = .always
textField.returnKeyType = .send
textField.delegate = self
return textField
}()
private lazy var giftButton: UIButton = {
let button = UIButton(type: .custom)
button.setBackgroundImage(UIImage(named: "live_room_msg_gift"), for: .normal)
button.setTitle("2", for: .normal)
button.setTitleColor(UIColor.white, for: .normal)
button.titleLabel?.font = .PFSC_M(ofSize: 10)
button.addTarget(self, action: #selector(giftButtonTapped), for: .touchUpInside)
return button
}()
private lazy var sendButton: UIButton = {
let button = UIButton(type: .custom)
button.setTitle("发送", for: .normal)
button.titleLabel?.font = .PFSC_M(ofSize: 12)
button.setTitleColor(.white, for: .normal)
button.backgroundColor = .brandMainColor
button.layer.cornerRadius = 3
button.clipsToBounds = true
button.addTarget(self, action: #selector(sendButtonTapped), for: .touchUpInside)
return button
}()
var state: YHMessageInputViewState = .normalWithGift(2) {
didSet {
updateState(state)
}
}
// MARK: - Initialization
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
updateState(state)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
addSubview(textField)
addSubview(sendButton)
addSubview(giftButton)
}
private func updateState(_ state: YHMessageInputViewState) {
// switch state {
// case let .normalWithGift(count):
// <#code#>
// case .inputState:
// <#code#>
// }
textField.snp.makeConstraints { make in
make.left.equalToSuperview().offset(8)
make.centerY.equalToSuperview()
make.right.equalTo(sendButton.snp.left).offset(-8)
make.height.equalTo(34)
}
sendButton.snp.makeConstraints { make in
make.right.equalToSuperview().offset(-8)
make.centerY.equalToSuperview()
make.width.equalTo(50)
}
}
@objc private func sendButtonTapped() {
sendMessage()
}
@objc private func giftButtonTapped() {
//
}
private func sendMessage() {
guard let text = textField.text?.trimmingCharacters(in: .whitespacesAndNewlines),
!text.isEmpty else {
return
}
delegate?.messageInputView(self, didSendMessage: text)
textField.text = ""
}
}
// MARK: - UITextFieldDelegate
extension YHMessageInputView: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
sendMessage()
textField.resignFirstResponder()
return true
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment