diff --git a/NEChatUIKit/NEKitChatUI.podspec b/NEChatUIKit/NEKitChatUI.podspec index 4d74f8ff..704bc4ab 100644 --- a/NEChatUIKit/NEKitChatUI.podspec +++ b/NEChatUIKit/NEKitChatUI.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "NEKitChatUI" - spec.version = "9.2.7" + spec.version = "9.2.8" spec.summary = "Chat Module of IM." # This description is used to generate tags and improve search results. @@ -38,7 +38,6 @@ TODO: Add long description of the pod here. 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' } spec.user_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' } - spec.resource_bundles = { 'NEKitChatUI' => ['NEKitChatUI/Assets/*.png'] } diff --git a/NEChatUIKit/NEKitChatUI/Assets/en.lproj/Localizable.strings b/NEChatUIKit/NEKitChatUI/Assets/en.lproj/Localizable.strings index ca96635f..03544b99 100644 --- a/NEChatUIKit/NEKitChatUI/Assets/en.lproj/Localizable.strings +++ b/NEChatUIKit/NEKitChatUI/Assets/en.lproj/Localizable.strings @@ -4,98 +4,111 @@ // found in the LICENSE file. //MAKR:common -"ok"="ok"; -"send_to"="To "; - +"ok"="OK"; +"send_to"="send to"; //MAKR:message -"发来了一张图片"="Send an image to you"; -"发来了一段语音"="Send an audio to you"; -"发来了一段视频"="Send an video to you"; -"按住说话"="Hold down the talk"; -"send_after_let_go"="Release to send, press and hold to swipe to an empty area to cancel"; -"录音时间太短"="Recording time is too short"; -"没有麦克风权限"="No microphone access"; +"send_picture"="get a picture"; +"send_voice"="get a audio"; +"send_video"="get a video"; +"press_speak"="Hold to talk"; +"send_after_let_go"="Release to send, Slide to the blank area to cancel"; +"record_too_short"="Time is too short"; +"no_microphone_permission"="no micro permission"; +"choose"="select"; +"take_photo"="camera"; +"select_from_album"="album"; +"editing"="typing"; +"read"="read"; +"unread"="unread"; +"network_unavailable"="No internet, Please check your setting"; + //MARK: tips //MARK: team -"invite"="invite "; -"humans"="humans "; -"enter"="enter "; -"unknown_system_message"="Unknown System Message"; -"You"="You "; -"discussion_group"="discussion group"; +"invite"="Invite"; +"humans"="member"; +"enter"="enter"; +"unknown_system_message"="Unknown message"; +"You"="you"; +"discussion_group"="temp group"; "group"="group"; -"dissolve"="dissolved "; -"kick"="kick "; -"out"="out "; -"has_updated" = "has updated "; -"team_name" = " team name "; -"team_intro" = " introduce "; -"team_anouncement" = " anouncement "; -"team_avatar" = " avatar "; -"team_join_mode" = " join mode "; -"team_be_invited_mode" = " invited mode "; -"team_be_invited_permission" = " invited permission "; -"team_update_info_permission" = " permission of update info "; -"team_be_invited_author" = "Whether the invitee is required to agree permission"; -"team_update_client_custom"="permission of update client custom text"; -"team_custom_info" = "custom info "; -"not_mute" = " was unmuted "; -"mute" = " was muted "; -"team_has_been_removed" = " team has been removed "; -"join"=" join "; -"pass"=" pass "; -"leave"="leave "; -"transfer"=" transfer manager to "; -"added_manager"=" was as group manager "; -"removed_manager"=" group admin was revoked "; -"accept"=" has accepted group invitation from "; -"team_mute"="The group owner is set to mute"; -"team_all_mute"="The group was muted"; -"team_all_no_mute"="The group was unmuted"; -"session_set_top"="聊天置顶"; -"message_remind"="开启消息提醒"; -"pin_text"=" has pined this message"; +"dissolve"="dissolved"; +"kick"="将 "; +"out"="remove"; +"has_updated" = "updated"; + +"team_name" = "name"; +"team_intro" = "Info"; +"team_anouncement" = "Notice"; +"team_avatar" = "Avatar"; +"team_join_mode" = "join mode"; +"team_be_invited_mode" = "invite mode"; +"team_be_invited_permission" = "invite permission"; +"team_be_invited_author" = "是否需要被邀请者同意权限"; +"team_update_info_permission" = "update info permission"; +"team_update_client_custom"="update custom permission"; + +"team_custom_info" = "custom info"; +"not_mute" = "unmute"; +"mute" = "mute"; +"team_has_been_removed" = "This group was removed"; +"join"="joined"; +"pass"="Passed"; +"leave"="leave"; +"transfer"="Transferred the group leader identity to"; +"added_manager"="add to be Group administrator"; +"removed_manager"="Group administrator identity revoked"; +"accept"="Accept the group invitation from"; +"team_mute"=" Group owner set muting"; +"team_all_mute"="Mute all"; +"team_all_no_mute"="Unmute"; + +"pin_text"="pinned this message for both"; + +"session_set_top"="sticky to top"; +"message_remind"="open notification"; + +"open_soon"="Not open"; -"open_soon"="暂未开放"; //MARK: operation -"operation_copy"="Copy"; -"operation_replay"="Replay"; -"operation_forward"="Forward"; -"operation_pin"="Pin"; -"operation_select"="Select"; -"operation_collection"="Collection"; -"operation_delete"="Delete"; -"operation_recall"="Recall"; -"message_has_be_withdrawn" = "Message has be withdrawn"; -"message_reedit" = "Reedit message"; -"message_revoke_confim" = "Are you sure?"; -"message_delete_comfirm"="Are you sure?"; +"operation_copy"="copy"; +"operation_replay"="reply"; +"operation_forward"="forward"; +"operation_pin"="pin"; +"operation_cancel_pin"="unpin"; +"operation_select"="multi-select"; +"operation_collection"="favorite"; +"operation_delete"="delete"; +"operation_recall"="recall"; +"message_has_be_withdrawn" = "message recalled"; +"message_reedit" = "reedit"; +"message_revoke_confim" = "Wether to recall this message"; +"message_delete_comfirm"="Wether to delete this message"; -//MARK: toast -"copy_success"="Copy succeeded"; -"collection_success"="Collection Success"; -"no_permession"="No permession"; -"msg_reply"="Reply"; -"msg_image"="Image"; -"msg_audio"="Audio"; -"msg_video"="Video"; -"msg_file"="File"; -"msg_custom"="Custom"; -"msg_unknown"="Unknown"; -"message_read"="Read status"; -"message_all_unread"="No body has readed"; -"user_select"="Select Users"; -"user_select_all"="All"; +//MARK: toast +"copy_success"="Copy successfully"; +"collection_success"="Favorite"; +"no_permession"="No Permission"; +"msg_reply"="reply"; +"msg_image"="picture"; +"msg_audio"="audio"; +"msg_video"="video"; +"msg_file"="file"; +"msg_custom"="custom message"; +"msg_unknown"="Unknown message type"; +"message_read"="Reading Status"; +"message_all_unread"="all unread"; +"user_select"="notification"; +"user_select_all"="all"; -"contact_user"="个人"; -"team"="群组"; -"cancel"="取消"; -"send_to"="发送给"; +"contact_user"="contacts"; +"team"="group"; +"cancel"="cancel"; +"send_to"="send to"; +"send"="send"; +"confirm"="yes"; -"contact_user"="好友"; -"team"="群聊"; -"cancel"="取消"; -"send_to"="发送给"; +"mdhm"="MM.dd HH:mm"; +"ymdhm"="yyyy.MM.dd HH:mm"; diff --git a/NEChatUIKit/NEKitChatUI/Assets/zh-Hans.lproj/Localizable.strings b/NEChatUIKit/NEKitChatUI/Assets/zh-Hans.lproj/Localizable.strings index 8a836d25..933ad4ff 100644 --- a/NEChatUIKit/NEKitChatUI/Assets/zh-Hans.lproj/Localizable.strings +++ b/NEChatUIKit/NEKitChatUI/Assets/zh-Hans.lproj/Localizable.strings @@ -7,13 +7,27 @@ "ok"="确认"; "send_to"="发送给 "; //MAKR:message -"发来了一张图片"="发来了一张图"; -"发来了一段语音"="发来了一段语音"; -"发来了一段视频"="发来了一段视频"; -"按住说话"="按住说话"; +"send_picture"="发来了一张图片"; +"send_voice"="发来了一段语音"; +"send_video"="发来了一段视频"; +"press_speak"="按住说话"; "send_after_let_go"="松开发送,按住滑到空白区域取消"; -"录音时间太短"="录音时间太短"; -"没有麦克风权限"="没有麦克风权限"; +"record_too_short"="录音时间太短"; +"no_microphone_permission"="没有麦克风权限"; +"choose"="请选择"; +"take_photo"="拍照"; +"select_from_album"="从相册选择"; +"editing"="正在输入中..."; +"read"="已读(0)"; +"unread"="未读(0)"; +"network_unavailable"="当前网络不可用,请检查你当网络设置。"; + + + + + + + //MARK: tips //MARK: team @@ -54,12 +68,9 @@ "team_mute"="当前群主设置为禁言"; "team_all_mute"="群全体禁言"; "team_all_no_mute"="取消群全体禁言"; - "pin_text"="标记了这条信息,对话内容双方均可见"; - "session_set_top"="聊天置顶"; "message_remind"="开启消息提醒"; - "open_soon"="暂未开放"; //MARK: operation @@ -98,3 +109,9 @@ "team"="群聊"; "cancel"="取消"; "send_to"="发送给"; +"send"="发送"; +"confirm"="确定"; + + +"mdhm"="MM月dd日 HH:mm"; +"ymdhm"="yyyy年MM月dd日 HH:mm"; diff --git a/NEChatUIKit/NEKitChatUI/Classes/Base/BaseView/ChatImageTextCell.swift b/NEChatUIKit/NEKitChatUI/Classes/Base/BaseView/ChatImageTextCell.swift index 0fe2fe59..38f74bf2 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Base/BaseView/ChatImageTextCell.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Base/BaseView/ChatImageTextCell.swift @@ -67,7 +67,6 @@ class ChatImageTextCell: ChatStateCell { name.textColor = .white name.textAlignment = .center name.font = UIFont.systemFont(ofSize: 14.0) - name.text = "果冻" return name }() diff --git a/NEChatUIKit/NEKitChatUI/Classes/Base/BaseView/ChatTextCell.swift b/NEChatUIKit/NEKitChatUI/Classes/Base/BaseView/ChatTextCell.swift index 1c386288..d1446571 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Base/BaseView/ChatTextCell.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Base/BaseView/ChatTextCell.swift @@ -31,7 +31,7 @@ class ChatTextCell: ChatStateCell { titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor), titleLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), ]) - titleLabel.text = "删除" + titleLabel.text = localizable("operation_delete") detailLabel.font = UIFont.systemFont(ofSize: 16) detailLabel.translatesAutoresizingMaskIntoConstraints = false diff --git a/NEChatUIKit/NEKitChatUI/Classes/Base/BaseViewController/ChatBaseViewController.swift b/NEChatUIKit/NEKitChatUI/Classes/Base/BaseViewController/ChatBaseViewController.swift index c74ac360..9d98bc7c 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Base/BaseViewController/ChatBaseViewController.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Base/BaseViewController/ChatBaseViewController.swift @@ -6,18 +6,24 @@ import UIKit import NEKitCore -class ChatBaseViewController: NEBaseViewController { - override func viewDidLoad() { +@objc open class ChatBaseViewController: UIViewController { + override open func viewDidLoad() { super.viewDidLoad() + view.backgroundColor = .white + setupBackUI() } - /* - // MARK: - Navigation + private func setupBackUI() { + let image = UIImage.ne_imageNamed(name: "backArrow")?.withRenderingMode(.alwaysOriginal) + navigationItem.leftBarButtonItem = UIBarButtonItem( + image: image, + style: .plain, + target: self, + action: #selector(backEvent) + ) + } - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destination. - // Pass the selected object to the new view controller. - } - */ + @objc func backEvent() { + navigationController?.popViewController(animated: true) + } } diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/ChatViewController.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/ChatViewController.swift index 1e6e071e..59e3f02e 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/ChatViewController.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/ChatViewController.swift @@ -15,9 +15,10 @@ import NEKitCommonUI import WebKit @objcMembers -open class ChatViewController: NEBaseViewController, UINavigationControllerDelegate, +open class ChatViewController: ChatBaseViewController, UINavigationControllerDelegate, ChatInputViewDelegate, ChatViewModelDelegate, NIMMediaManagerDelegate, - MessageOperationViewDelegate, UIGestureRecognizerDelegate,UITableViewDataSource, UITableViewDelegate { + MessageOperationViewDelegate, UIGestureRecognizerDelegate, UITableViewDataSource, + UITableViewDelegate { private let tag = "ChatViewController" public var viewmodel: ChatViewModel private var inputViewTopConstraint: NSLayoutConstraint? @@ -178,7 +179,7 @@ open class ChatViewController: NEBaseViewController, UINavigationControllerDeleg } public func remoteUserEditing() { - title = "正在输入中..." + title = localizable("editing") trigerEndTimer() } @@ -216,650 +217,652 @@ open class ChatViewController: NEBaseViewController, UINavigationControllerDeleg deinit { print("will deinit") } - - - //MARK: objc 方法 - @objc func toSetting() { - if viewmodel.session.sessionType == .team { - Router.shared.use( - TeamSettingViewRouter, - parameters: ["nav": navigationController as Any, - "teamid": viewmodel.session.sessionId], - closure: nil - ) - } else if viewmodel.session.sessionType == .P2P { - let userSetting = UserSettingViewController() - userSetting.userId = viewmodel.session.sessionId - navigationController?.pushViewController(userSetting, animated: true) - } - } - //MARK: private 方法 - open func commonUI() { - title = viewmodel.session.sessionId - view.addSubview(tableView) - tableViewBottomConstraint = tableView.bottomAnchor.constraint( - equalTo: view.bottomAnchor, - constant: -100 - ) - tableViewBottomConstraint?.isActive = true - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint( - equalTo: view.topAnchor, - constant: kNavigationHeight + KStatusBarHeight - ), - tableView.leftAnchor.constraint(equalTo: view.leftAnchor), - tableView.rightAnchor.constraint(equalTo: view.rightAnchor), - ]) - tableView.register( - ChatTimeTableViewCell.self, - forCellReuseIdentifier: "\(ChatTimeTableViewCell.self)" - ) - tableView.register( - ChatBaseLeftCell.self, - forCellReuseIdentifier: "\(ChatBaseLeftCell.self)" - ) - tableView.register( - ChatBaseRightCell.self, - forCellReuseIdentifier: "\(ChatBaseRightCell.self)" - ) - tableView.register( - ChatTextRightCell.self, - forCellReuseIdentifier: "\(ChatTextRightCell.self)" - ) - tableView.register( - ChatTextLeftCell.self, - forCellReuseIdentifier: "\(ChatTextLeftCell.self)" - ) - tableView.register( - ChatAudioLeftCell.self, - forCellReuseIdentifier: "\(ChatAudioLeftCell.self)" - ) - tableView.register( - ChatAudioRightCell.self, - forCellReuseIdentifier: "\(ChatAudioRightCell.self)" - ) - tableView.register( - ChatImageLeftCell.self, - forCellReuseIdentifier: "\(ChatImageLeftCell.self)" - ) - tableView.register( - ChatImageRightCell.self, - forCellReuseIdentifier: "\(ChatImageRightCell.self)" - ) + // MARK: objc 方法 - tableView.register( - ChatRevokeLeftCell.self, - forCellReuseIdentifier: "\(ChatRevokeLeftCell.self)" - ) - tableView.register( - ChatRevokeRightCell.self, - forCellReuseIdentifier: "\(ChatRevokeRightCell.self)" + func toSetting() { + if viewmodel.session.sessionType == .team { + Router.shared.use( + TeamSettingViewRouter, + parameters: ["nav": navigationController as Any, + "teamid": viewmodel.session.sessionId], + closure: nil ) + } else if viewmodel.session.sessionType == .P2P { + let userSetting = UserSettingViewController() + userSetting.userId = viewmodel.session.sessionId + navigationController?.pushViewController(userSetting, animated: true) + } + } - tableView.register( - ChatVideoLeftCell.self, - forCellReuseIdentifier: "\(ChatVideoLeftCell.self)" - ) - tableView.register( - ChatVideoRightCell.self, - forCellReuseIdentifier: "\(ChatVideoRightCell.self)" - ) + // MARK: private 方法 - tableView.register( - ChatReplyRightCell.self, - forCellReuseIdentifier: "\(ChatReplyRightCell.self)" - ) - tableView.register( - ChatReplyLeftCell.self, - forCellReuseIdentifier: "\(ChatReplyLeftCell.self)" - ) + open func commonUI() { + title = viewmodel.session.sessionId + view.addSubview(tableView) + tableViewBottomConstraint = tableView.bottomAnchor.constraint( + equalTo: view.bottomAnchor, + constant: -100 + ) + tableViewBottomConstraint?.isActive = true + NSLayoutConstraint.activate([ + tableView.topAnchor.constraint( + equalTo: view.topAnchor, + constant: kNavigationHeight + KStatusBarHeight + ), + tableView.leftAnchor.constraint(equalTo: view.leftAnchor), + tableView.rightAnchor.constraint(equalTo: view.rightAnchor), + ]) + tableView.register( + ChatTimeTableViewCell.self, + forCellReuseIdentifier: "\(ChatTimeTableViewCell.self)" + ) - menuView.translatesAutoresizingMaskIntoConstraints = false - menuView.delegate = self - view.addSubview(menuView) + tableView.register( + ChatBaseLeftCell.self, + forCellReuseIdentifier: "\(ChatBaseLeftCell.self)" + ) + tableView.register( + ChatBaseRightCell.self, + forCellReuseIdentifier: "\(ChatBaseRightCell.self)" + ) + tableView.register( + ChatTextRightCell.self, + forCellReuseIdentifier: "\(ChatTextRightCell.self)" + ) + tableView.register( + ChatTextLeftCell.self, + forCellReuseIdentifier: "\(ChatTextLeftCell.self)" + ) + tableView.register( + ChatAudioLeftCell.self, + forCellReuseIdentifier: "\(ChatAudioLeftCell.self)" + ) + tableView.register( + ChatAudioRightCell.self, + forCellReuseIdentifier: "\(ChatAudioRightCell.self)" + ) + tableView.register( + ChatImageLeftCell.self, + forCellReuseIdentifier: "\(ChatImageLeftCell.self)" + ) + tableView.register( + ChatImageRightCell.self, + forCellReuseIdentifier: "\(ChatImageRightCell.self)" + ) - inputViewTopConstraint = menuView.topAnchor.constraint( - equalTo: view.bottomAnchor, - constant: -100 - ) - NSLayoutConstraint.activate([ - menuView.leftAnchor.constraint(equalTo: view.leftAnchor), - menuView.rightAnchor.constraint(equalTo: view.rightAnchor), - menuView.heightAnchor.constraint(equalToConstant: 304), - ]) - inputViewTopConstraint?.isActive = true + tableView.register( + ChatRevokeLeftCell.self, + forCellReuseIdentifier: "\(ChatRevokeLeftCell.self)" + ) + tableView.register( + ChatRevokeRightCell.self, + forCellReuseIdentifier: "\(ChatRevokeRightCell.self)" + ) - weak var weakSelf = self - NEChatDetectNetworkTool.shareInstance.netWorkReachability { status in - if status == .notReachable, let networkView = weakSelf?.brokenNetworkView { - weakSelf?.view.addSubview(networkView) - } else { - weakSelf?.brokenNetworkView.removeFromSuperview() - } + tableView.register( + ChatVideoLeftCell.self, + forCellReuseIdentifier: "\(ChatVideoLeftCell.self)" + ) + tableView.register( + ChatVideoRightCell.self, + forCellReuseIdentifier: "\(ChatVideoRightCell.self)" + ) + + tableView.register( + ChatReplyRightCell.self, + forCellReuseIdentifier: "\(ChatReplyRightCell.self)" + ) + tableView.register( + ChatReplyLeftCell.self, + forCellReuseIdentifier: "\(ChatReplyLeftCell.self)" + ) + + menuView.translatesAutoresizingMaskIntoConstraints = false + menuView.delegate = self + view.addSubview(menuView) + + inputViewTopConstraint = menuView.topAnchor.constraint( + equalTo: view.bottomAnchor, + constant: -100 + ) + NSLayoutConstraint.activate([ + menuView.leftAnchor.constraint(equalTo: view.leftAnchor), + menuView.rightAnchor.constraint(equalTo: view.rightAnchor), + menuView.heightAnchor.constraint(equalToConstant: 304), + ]) + inputViewTopConstraint?.isActive = true + + weak var weakSelf = self + NEChatDetectNetworkTool.shareInstance.netWorkReachability { status in + if status == .notReachable, let networkView = weakSelf?.brokenNetworkView { + weakSelf?.view.addSubview(networkView) + } else { + weakSelf?.brokenNetworkView.removeFromSuperview() } - addRightAction(UIImage.ne_imageNamed(name: "three_point"), #selector(toSetting), self) } + addRightAction(UIImage.ne_imageNamed(name: "three_point"), #selector(toSetting), self) + } - func loadData() { - // title - getSessionInfo(session: viewmodel.session) - weak var weakSelf = self - - viewmodel.queryRoamMsgHasMoreTime_v2 { error, historyEnd, newEnd, models, index in - if let ms = models, ms.count > 0 { - if let messages = weakSelf?.viewmodel.messages { - for index in 0 ..< messages.count { - let message = messages[index] - if message.message?.messageId == weakSelf?.viewmodel.anchor?.messageId { - print("messages real index : ", index) - print("messages text : ", message.message?.text as Any) - } + func loadData() { + // title + getSessionInfo(session: viewmodel.session) + weak var weakSelf = self + + viewmodel.queryRoamMsgHasMoreTime_v2 { error, historyEnd, newEnd, models, index in + if let ms = models, ms.count > 0 { + if let messages = weakSelf?.viewmodel.messages { + for index in 0 ..< messages.count { + let message = messages[index] + if message.message?.messageId == weakSelf?.viewmodel.anchor?.messageId { + print("messages real index : ", index) + print("messages text : ", message.message?.text as Any) } } - weakSelf?.tableView.reloadData() - if weakSelf?.viewmodel.isHistoryChat == true { - let indexPath = IndexPath(row: index, section: 0) - print("queryRoamMsgHasMoreTime_v2 index : ", index) - weakSelf?.tableView.scrollToRow(at: indexPath, at: .none, animated: false) - if newEnd <= 0 { - weakSelf?.addBottomLoadMore() - } - } else { - if let tempArray = weakSelf?.viewmodel.messages, tempArray.count > 0 { - weakSelf?.tableView.reloadData() - weakSelf?.tableView.scrollToRow( - at: IndexPath(row: tempArray.count - 1, section: 0), - at: .bottom, - animated: false - ) - } + } + weakSelf?.tableView.reloadData() + if weakSelf?.viewmodel.isHistoryChat == true { + let indexPath = IndexPath(row: index, section: 0) + print("queryRoamMsgHasMoreTime_v2 index : ", index) + weakSelf?.tableView.scrollToRow(at: indexPath, at: .none, animated: false) + if newEnd <= 0 { + weakSelf?.addBottomLoadMore() + } + } else { + if let tempArray = weakSelf?.viewmodel.messages, tempArray.count > 0 { + weakSelf?.tableView.reloadData() + weakSelf?.tableView.scrollToRow( + at: IndexPath(row: tempArray.count - 1, section: 0), + at: .bottom, + animated: false + ) } - - } else if let err = error { - weakSelf?.showToast(err.localizedDescription) } - } - // if viewmodel.isHistoryChat == false { - // viewmodel.getMessageHistory({[weak self] error,isEmpty,messages in - // if let err = error { - // NELog.errorLog(self?.tag ?? "ChatViewController", desc: "❌getMessageHistory error, error:\(err)") - // }else { - // if let tempArray = weakSelf?.viewmodel.messages,tempArray.count > 0 { - // weakSelf?.tableView.reloadData() - // weakSelf?.tableView.scrollToRow(at: IndexPath(row: tempArray.count - 1, section: 0), at: .bottom, animated: false) - // } - // } - // }) - // }else { - // print("queryRoamMsgHasMoreTime") - // viewmodel.queryRoamMsgHasMoreTime_v2 { error, historyEnd, newEnd, models, index in - // if let ms = models, ms.count > 0 { - // if let messages = weakSelf?.viewmodel.messages { - // for index in 0.. 0 { + // weakSelf?.tableView.reloadData() + // weakSelf?.tableView.scrollToRow(at: IndexPath(row: tempArray.count - 1, section: 0), at: .bottom, animated: false) + // } + // } + // }) + // }else { + // print("queryRoamMsgHasMoreTime") + // viewmodel.queryRoamMsgHasMoreTime_v2 { error, historyEnd, newEnd, models, index in + // if let ms = models, ms.count > 0 { + // if let messages = weakSelf?.viewmodel.messages { + // for index in 0.. 0 { - weakSelf?.tableView.scrollToRow( - at: IndexPath(row: count, section: 0), - at: .top, - animated: false - ) - } - weakSelf?.tableView.mj_header?.endRefreshing() - } + func loadMoreData() { + weak var weakSelf = self + viewmodel.dropDownRemoteRefresh { error, count, messages in + print("dropDownRemoteRefresh messages count ", messages?.count as Any) - // viewmodel.getMoreMessageHistory { error, isEmpty, messageFrames in - // weakSelf?.tableView.reloadData() - // weakSelf?.tableView.mj_header?.endRefreshing() - // } + weakSelf?.tableView.reloadData() + if count > 0 { + weakSelf?.tableView.scrollToRow( + at: IndexPath(row: count, section: 0), + at: .top, + animated: false + ) + } + weakSelf?.tableView.mj_header?.endRefreshing() } - @objc func loadFartherToNowData() {} + // viewmodel.getMoreMessageHistory { error, isEmpty, messageFrames in + // weakSelf?.tableView.reloadData() + // weakSelf?.tableView.mj_header?.endRefreshing() + // } + } - @objc func loadCloserToNowData() { - weak var weakSelf = self - viewmodel.pullRemoteRefresh { error, end, datas in - if end > 0 { - weakSelf?.removeBottomLoadMore() - } else { - weakSelf?.tableView.mj_footer?.endRefreshing() - weakSelf?.tableView.reloadData() - } + func loadFartherToNowData() {} + + func loadCloserToNowData() { + weak var weakSelf = self + viewmodel.pullRemoteRefresh { error, end, datas in + if end > 0 { + weakSelf?.removeBottomLoadMore() + } else { + weakSelf?.tableView.mj_footer?.endRefreshing() + weakSelf?.tableView.reloadData() } } + } - func addObseve() { - NotificationCenter.default.addObserver(self, - selector: #selector(keyBoardWillShow(_:)), - name: UIResponder.keyboardWillShowNotification, - object: nil) - - NotificationCenter.default.addObserver(self, - selector: #selector(keyBoardWillHide(_:)), - name: UIResponder.keyboardWillHideNotification, - object: nil) - // let tap = UITapGestureRecognizer(target: self, action: #selector(viewTap)) - // tap.delegate = self - // self.view.addGestureRecognizer(tap) - } + func addObseve() { + NotificationCenter.default.addObserver(self, + selector: #selector(keyBoardWillShow(_:)), + name: UIResponder.keyboardWillShowNotification, + object: nil) + + NotificationCenter.default.addObserver(self, + selector: #selector(keyBoardWillHide(_:)), + name: UIResponder.keyboardWillHideNotification, + object: nil) + // let tap = UITapGestureRecognizer(target: self, action: #selector(viewTap)) + // tap.delegate = self + // self.view.addGestureRecognizer(tap) + } - func addBottomLoadMore() { - tableView.mj_footer = MJRefreshBackNormalFooter( - refreshingTarget: self, - refreshingAction: #selector(loadCloserToNowData) - ) - } + func addBottomLoadMore() { + tableView.mj_footer = MJRefreshBackNormalFooter( + refreshingTarget: self, + refreshingAction: #selector(loadCloserToNowData) + ) + } - func removeBottomLoadMore() { - tableView.mj_footer?.endRefreshingWithNoMoreData() - tableView.mj_footer = nil - viewmodel.isHistoryChat = false // 转为普通聊天页面 - } + func removeBottomLoadMore() { + tableView.mj_footer?.endRefreshingWithNoMoreData() + tableView.mj_footer = nil + viewmodel.isHistoryChat = false // 转为普通聊天页面 + } // MARK: 键盘通知相关操作 - @objc func keyBoardWillShow(_ notification: Notification) { - if menuView.currentType != .text { - return - } - let keyboardRect = (notification - .userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue - layoutInputView(offset: keyboardRect.size.height) - - UIView.animate(withDuration: 0.25, animations: { - self.view.layoutIfNeeded() - }) - scrollTableViewToBottom() + func keyBoardWillShow(_ notification: Notification) { + if menuView.currentType != .text { + return } + let keyboardRect = (notification + .userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue + layoutInputView(offset: keyboardRect.size.height) - @objc func keyBoardWillHide(_ notification: Notification) { - if menuView.currentType != .text { - return - } - if operationView?.superview != nil { - operationView?.removeFromSuperview() - } - layoutInputView(offset: 0) - scrollTableViewToBottom() + UIView.animate(withDuration: 0.25, animations: { + self.view.layoutIfNeeded() + }) + scrollTableViewToBottom() + } + + func keyBoardWillHide(_ notification: Notification) { + if menuView.currentType != .text { + return } + // 解决点击operation点击无效问题 +// if operationView?.superview != nil { +// operationView?.removeFromSuperview() +// } + layoutInputView(offset: 0) + scrollTableViewToBottom() + } - private func scrollTableViewToBottom() { - print("self.viewmodel.messages.count\(viewmodel.messages.count)") - print("self.tableView.numberOfRows(inSection: 0)\(tableView.numberOfRows(inSection: 0))") - if viewmodel.messages.count > 0 { - let indexPath = IndexPath(row: viewmodel.messages.count - 1, section: 0) - tableView.scrollToRow(at: indexPath, at: .bottom, animated: true) - } + private func scrollTableViewToBottom() { + print("self.viewmodel.messages.count\(viewmodel.messages.count)") + print("self.tableView.numberOfRows(inSection: 0)\(tableView.numberOfRows(inSection: 0))") + if viewmodel.messages.count > 0 { + let indexPath = IndexPath(row: viewmodel.messages.count - 1, section: 0) + tableView.scrollToRow(at: indexPath, at: .bottom, animated: true) } + } // offset:value which from self.view.bottom to inputView.bottom - private func layoutInputView(offset: CGFloat) { - inputViewTopConstraint?.constant = -100 - offset - tableViewBottomConstraint?.constant = -100 - offset - UIView.animate(withDuration: 0.25, animations: { - self.view.layoutIfNeeded() - }) - } + private func layoutInputView(offset: CGFloat) { + inputViewTopConstraint?.constant = -100 - offset + tableViewBottomConstraint?.constant = -100 - offset + UIView.animate(withDuration: 0.25, animations: { + self.view.layoutIfNeeded() + }) + } // MARK: ChatInputViewDelegate - public func sendText(text: String?) { - guard let content = text, content.count > 0 else { - showToast(localizable("text_is_nil")) - return - } - if viewmodel.isReplying, let msg = viewmodel.operationModel?.message { - viewmodel - .replyMessage(MessageUtils.textMessage(text: content), msg) { [weak self] error in - if error != nil { - self?.view.makeToast(error?.localizedDescription) - } else { - self?.viewmodel.isReplying = false - self?.replyView.removeFromSuperview() - } - } - - } else { - viewmodel.sendTextMessage(text: content) { [weak self] error in + public func sendText(text: String?) { + guard let content = text, content.count > 0 else { + return + } + if viewmodel.isReplying, let msg = viewmodel.operationModel?.message { + viewmodel + .replyMessage(MessageUtils.textMessage(text: content), msg) { [weak self] error in if error != nil { self?.view.makeToast(error?.localizedDescription) + } else { + self?.viewmodel.isReplying = false + self?.replyView.removeFromSuperview() } } - } - } - public func textChanged(text: String) -> Bool { - if text == "@" { - // 做p2p类型判断 - if viewmodel.session.sessionType == .P2P { - return true - } else { - showUserSelectVC(text: text) - return false + } else { + viewmodel.sendTextMessage(text: content) { [weak self] error in + if error != nil { + self?.view.makeToast(error?.localizedDescription) } - - } else { - return true } } + } - public func textDelete(range: NSRange, text: String) -> Bool { - var index = -1 - var removeRange: NSRange? - for (i, r) in atUsers.enumerated() { - let rightIndex = r.location + r.length - 1 - if rightIndex == range.location { - index = i - removeRange = r - break - } - } - if index >= 0 { - atUsers.remove(at: index) - if let text = menuView.textField.text { - menuView.textField.text = text - .substring(to: text.index(text.startIndex, offsetBy: removeRange!.location)) - } + public func textChanged(text: String) -> Bool { + if text == "@" { + // 做p2p类型判断 + if viewmodel.session.sessionType == .P2P { + return true + } else { + showUserSelectVC(text: text) return false } + + } else { return true } + } - public func textFieldDidChange(_ textField: UITextView) { - if let text = textField.text { - if text.count > 0 { - viewmodel.sendInputTypingState() - } else { - viewmodel.sendInputTypingEndState() - } + public func textDelete(range: NSRange, text: String) -> Bool { + var index = -1 + var removeRange: NSRange? + for (i, r) in atUsers.enumerated() { + let rightIndex = r.location + r.length - 1 + if rightIndex == range.location { + index = i + removeRange = r + break } } - - public func textFieldDidEndEditing(_ textField: UITextView) { - viewmodel.sendInputTypingEndState() - } - - public func textFieldDidBeginEditing(_ textField: UITextView) { - if let count = textField.text?.count, count > 0 { - viewmodel.sendInputTypingState() + if index >= 0 { + atUsers.remove(at: index) + if let text = menuView.textField.text { + menuView.textField.text = text + .substring(to: text.index(text.startIndex, offsetBy: removeRange!.location)) } + return false } + return true + } - public func willSelectItem(button: UIButton, index: Int) { - if index == 0 { - layoutInputView(offset: 204) - scrollTableViewToBottom() - } else if index == 1 { - layoutInputView(offset: 204) - scrollTableViewToBottom() - } else if index == 2 { - // showMenue(sourceView: view) - // showBottomAlert(self, false) - goPhotoAlbumWithVideo(self) - } else if index == 3 { - showBottomVideoAction(self, false) + public func textFieldDidChange(_ textField: UITextView) { + if let text = textField.text { + if text.count > 0 { + viewmodel.sendInputTypingState() } else { - showToast(localizable("open_soon")) + viewmodel.sendInputTypingEndState() } } + } - func showMenue(sourceView: UIView) { - let alert = UIAlertController( - title: localizable("请选择"), - message: nil, - preferredStyle: .actionSheet - ) - alert.modalPresentationStyle = .popover - let camera = UIAlertAction(title: localizable("拍照"), style: .default) { action in - self.takePhoto() - } - let photo = UIAlertAction(title: localizable("从相册选择"), style: .default) { action in - self.willSelectImage() - } + public func textFieldDidEndEditing(_ textField: UITextView) { + viewmodel.sendInputTypingEndState() + } - let cancel = UIAlertAction(title: "取消", style: .cancel) { action in - } + public func textFieldDidBeginEditing(_ textField: UITextView) { + if let count = textField.text?.count, count > 0 { + viewmodel.sendInputTypingState() + } + } - alert.addAction(camera) - alert.addAction(photo) - alert.addAction(cancel) - let popover = alert.popoverPresentationController - if popover != nil { - popover?.sourceView = sourceView - popover?.permittedArrowDirections = .any - } - present(alert, animated: true, completion: nil) + public func willSelectItem(button: UIButton, index: Int) { + if index == 0 { + layoutInputView(offset: 204) + scrollTableViewToBottom() + } else if index == 1 { + layoutInputView(offset: 204) + scrollTableViewToBottom() + } else if index == 2 { + // showMenue(sourceView: view) + // showBottomAlert(self, false) + goPhotoAlbumWithVideo(self) + } else if index == 3 { + showBottomVideoAction(self, false) + } else { + showToast(localizable("open_soon")) } + } - func willSelectImage() { - let imagePickerVC = UIImagePickerController() - imagePickerVC.delegate = self - imagePickerVC.allowsEditing = false - imagePickerVC.sourceType = .photoLibrary - present(imagePickerVC, animated: true) {} + func showMenue(sourceView: UIView) { + let alert = UIAlertController( + title: localizable("choose"), + message: nil, + preferredStyle: .actionSheet + ) + alert.modalPresentationStyle = .popover + let camera = UIAlertAction(title: localizable("take_photo"), style: .default) { action in + self.takePhoto() + } + let photo = UIAlertAction(title: localizable("select_from_album"), style: .default) { action in + self.willSelectImage() } - func takePhoto() { - let imagePickerVC = UIImagePickerController() - imagePickerVC.delegate = self - imagePickerVC.allowsEditing = false - imagePickerVC.sourceType = .camera - present(imagePickerVC, animated: true) {} + let cancel = UIAlertAction(title: localizable("cancel"), style: .cancel) { action in } + alert.addAction(camera) + alert.addAction(photo) + alert.addAction(cancel) + let popover = alert.popoverPresentationController + if popover != nil { + popover?.sourceView = sourceView + popover?.permittedArrowDirections = .any + } + present(alert, animated: true, completion: nil) + } + + func willSelectImage() { + let imagePickerVC = UIImagePickerController() + imagePickerVC.delegate = self + imagePickerVC.allowsEditing = false + imagePickerVC.sourceType = .photoLibrary + present(imagePickerVC, animated: true) {} + } + + func takePhoto() { + let imagePickerVC = UIImagePickerController() + imagePickerVC.delegate = self + imagePickerVC.allowsEditing = false + imagePickerVC.sourceType = .camera + present(imagePickerVC, animated: true) {} + } + // MARK: UIImagePickerControllerDelegate - public func imagePickerController(_ picker: UIImagePickerController, - didFinishPickingMediaWithInfo info: [UIImagePickerController - .InfoKey: Any]) { - // send message + public func imagePickerController(_ picker: UIImagePickerController, + didFinishPickingMediaWithInfo info: [UIImagePickerController + .InfoKey: Any]) { + // send message - picker.dismiss(animated: true, completion: nil) + picker.dismiss(animated: true, completion: nil) - if let url = info[.mediaURL] as? URL { - // video - print("image picker video : url", url) - // NELog.infoLog("send video message", desc: error?.localizedDescription ?? "no error") - weak var weakSelf = self - viewmodel.sendVideoMessage(url: url) { error in + if let url = info[.mediaURL] as? URL { + // video + print("image picker video : url", url) + // NELog.infoLog("send video message", desc: error?.localizedDescription ?? "no error") + weak var weakSelf = self + viewmodel.sendVideoMessage(url: url) { error in - if let err = error { - NELog.errorLog("send video message", desc: err.localizedDescription) - weakSelf?.showToast(err.localizedDescription) - } + if let err = error { + NELog.errorLog("send video message", desc: err.localizedDescription) + weakSelf?.showToast(err.localizedDescription) } - return } + return + } - guard let image = info[.originalImage] as? UIImage else { - showToast(localizable("image_is_nil")) - return - } - viewmodel.sendImageMessage(image: image) { [weak self] error in - NELog.infoLog("send image message", desc: error?.localizedDescription ?? "no error") - if error != nil { - self?.view.makeToast(error?.localizedDescription) - } else {} - } + guard let image = info[.originalImage] as? UIImage else { + showToast(localizable("image_is_nil")) + return + } + viewmodel.sendImageMessage(image: image) { [weak self] error in + NELog.infoLog("send image message", desc: error?.localizedDescription ?? "no error") + if error != nil { + self?.view.makeToast(error?.localizedDescription) + } else {} } + } // MARK: ChatViewModelDelegate - public func onRecvMessages(_ messages: [NIMMessage]) { - insertRows() - viewmodel.markRead(messages: messages) { error in - print("mark read \(error?.localizedDescription)") - } + public func onRecvMessages(_ messages: [NIMMessage]) { + insertRows() + viewmodel.markRead(messages: messages) { error in + print("mark read \(error?.localizedDescription)") } + } - public func willSend(_ message: NIMMessage) { - insertRows() - } + public func willSend(_ message: NIMMessage) { + insertRows() + } - public func send(_ message: NIMMessage, progress: Float) {} + public func send(_ message: NIMMessage, progress: Float) {} - public func send(_ message: NIMMessage, didCompleteWithError error: Error?) { - if indexPathsWithMessags([message]).count > 0 { - tableViewReloadIndexs(indexPathsWithMessags([message])) - } + public func send(_ message: NIMMessage, didCompleteWithError error: Error?) { + if indexPathsWithMessags([message]).count > 0 { + tableViewReloadIndexs(indexPathsWithMessags([message])) } + } - private func indexPathsWithMessags(_ messages: [NIMMessage]) -> [IndexPath] { - var indexPaths = [IndexPath]() - for messageModel in messages { - for (i, model) in viewmodel.messages.enumerated() { - if model.message?.messageId == messageModel.messageId { - indexPaths.append(IndexPath(row: i, section: 0)) - } + private func indexPathsWithMessags(_ messages: [NIMMessage]) -> [IndexPath] { + var indexPaths = [IndexPath]() + for messageModel in messages { + for (i, model) in viewmodel.messages.enumerated() { + if model.message?.messageId == messageModel.messageId { + indexPaths.append(IndexPath(row: i, section: 0)) } } - return indexPaths - } - - public func onDeleteMessage(_ message: NIMMessage, atIndexs: [IndexPath]) { - if atIndexs.isEmpty { - return - } - // self.tableView.reloadData() - tableViewDeleteIndexs(atIndexs) } + return indexPaths + } - public func updateDownloadProgress(_ message: NIMMessage, atIndex: IndexPath, progress: Float) { - tableViewUpdateDownload(atIndex) + public func onDeleteMessage(_ message: NIMMessage, atIndexs: [IndexPath]) { + if atIndexs.isEmpty { + return } + // self.tableView.reloadData() + tableViewDeleteIndexs(atIndexs) + } - public func onRevokeMessage(_ message: NIMMessage, atIndexs: [IndexPath]) { - if atIndexs.isEmpty { - return - } - tableViewReloadIndexs(atIndexs) - } + public func updateDownloadProgress(_ message: NIMMessage, atIndex: IndexPath, progress: Float) { + tableViewUpdateDownload(atIndex) + } - public func onAddMessagePin(_ message: NIMMessage, atIndexs: [IndexPath]) { - tableViewReloadIndexs(atIndexs) + public func onRevokeMessage(_ message: NIMMessage, atIndexs: [IndexPath]) { + if atIndexs.isEmpty { + return } + tableViewReloadIndexs(atIndexs) + } - public func onRemoveMessagePin(_ message: NIMMessage, atIndexs: [IndexPath]) { - tableViewReloadIndexs(atIndexs) - } + public func onAddMessagePin(_ message: NIMMessage, atIndexs: [IndexPath]) { + tableViewReloadIndexs(atIndexs) + } - public func tableViewDeleteIndexs(_ indexs: [IndexPath]) { - tableView.beginUpdates() - tableView.deleteRows(at: indexs, with: .none) - tableView.endUpdates() - } + public func onRemoveMessagePin(_ message: NIMMessage, atIndexs: [IndexPath]) { + tableViewReloadIndexs(atIndexs) + } - public func tableViewReloadIndexs(_ indexs: [IndexPath]) { - tableView.beginUpdates() - tableView.reloadRows(at: indexs, with: .none) - tableView.endUpdates() - } + public func tableViewDeleteIndexs(_ indexs: [IndexPath]) { + tableView.beginUpdates() + tableView.deleteRows(at: indexs, with: .none) + tableView.endUpdates() + } - public func didReadedMessageIndexs() { - if let indexPaths = tableView.indexPathsForVisibleRows, indexPaths.count > 0 { - tableView.beginUpdates() - // self.tableView.reloadRows(at: indexs, with: .none) - tableView.reloadRows(at: indexPaths, with: .none) - tableView.endUpdates() - } - } + public func tableViewReloadIndexs(_ indexs: [IndexPath]) { + tableView.beginUpdates() + tableView.reloadRows(at: indexs, with: .none) + tableView.endUpdates() + } - public func tableViewUpdateDownload(_ index: IndexPath) { + public func didReadedMessageIndexs() { + if let indexPaths = tableView.indexPathsForVisibleRows, indexPaths.count > 0 { tableView.beginUpdates() - tableView.reloadRows(at: [index], with: .none) + // self.tableView.reloadRows(at: indexs, with: .none) + tableView.reloadRows(at: indexPaths, with: .none) tableView.endUpdates() } + } - // record audio - public func startRecord() { - let dur = 60.0 - if NEAuthManager.hasAudioAuthoriztion() { - NIMSDK.shared().mediaManager.record(forDuration: dur) - } else { - NEAuthManager.requestAudioAuthorization { granted in - if granted { - } else { - DispatchQueue.main.async { - self.showToast(localizable("没有麦克风权限")) - } + public func tableViewUpdateDownload(_ index: IndexPath) { + tableView.beginUpdates() + tableView.reloadRows(at: [index], with: .none) + tableView.endUpdates() + } + + // record audio + public func startRecord() { + let dur = 60.0 + if NEAuthManager.hasAudioAuthoriztion() { + NIMSDK.shared().mediaManager.record(forDuration: dur) + } else { + NEAuthManager.requestAudioAuthorization { granted in + if granted { + } else { + DispatchQueue.main.async { + self.showToast(localizable("no_microphone_permission")) } } } } + } - public func moveOutView() {} + public func moveOutView() {} - public func moveInView() {} + public func moveInView() {} - public func endRecord(insideView: Bool) { - print("[record] stop:\(insideView)") - if insideView { - // send - NIMSDK.shared().mediaManager.stopRecord() - } else { - // cancel - NIMSDK.shared().mediaManager.cancelRecord() - } + public func endRecord(insideView: Bool) { + print("[record] stop:\(insideView)") + if insideView { + // send + NIMSDK.shared().mediaManager.stopRecord() + } else { + // cancel + NIMSDK.shared().mediaManager.cancelRecord() } + } - @objc func viewTap(tap: UITapGestureRecognizer) { - operationView?.removeFromSuperview() - if menuView.textField.isFirstResponder { - menuView.textField.resignFirstResponder() - } else { - layoutInputView(offset: 0) - } + func viewTap(tap: UITapGestureRecognizer) { + operationView?.removeFromSuperview() + if menuView.textField.isFirstResponder { + menuView.textField.resignFirstResponder() + } else { + layoutInputView(offset: 0) } + } - // MARK: audio play + // MARK: audio play - private func startPlay(cell: ChatAudioCell?, audio: NIMAudioObject) { - if cell?.isPlaying == true { - stopPlay() - } else { - stopPlay() - playingCell = cell - playingCell?.startAnimation() - if let url = audio.path { - NIMSDK.shared().mediaManager.switch(.speaker) - NIMSDK.shared().mediaManager.play(url) - } + private func startPlay(cell: ChatAudioCell?, audio: NIMAudioObject) { + if cell?.isPlaying == true { + stopPlay() + } else { + stopPlay() + playingCell = cell + playingCell?.startAnimation() + if let url = audio.path { + NIMSDK.shared().mediaManager.switch(.speaker) + NIMSDK.shared().mediaManager.play(url) } } + } - private func stopPlay() { - if NIMSDK.shared().mediaManager.isPlaying() { - playingCell?.startAnimation() - NIMSDK.shared().mediaManager.stopPlay() - } + private func stopPlay() { + if NIMSDK.shared().mediaManager.isPlaying() { + playingCell?.startAnimation() + NIMSDK.shared().mediaManager.stopPlay() } + } // private func startPlay() { // if NIMSDK.shared().mediaManager.isPlaying() { @@ -871,470 +874,468 @@ open class ChatViewController: NEBaseViewController, UINavigationControllerDeleg // MARK: NIMMediaManagerDelegate // play - public func playAudio(_ filePath: String, didBeganWithError error: Error?) { - print(#function + "\(error)") - if let e = error { - showToast(e.localizedDescription) - // stop - playingCell?.stopAnimation() - } - } - - public func playAudio(_ filePath: String, didCompletedWithError error: Error?) { - print(#function + "\(error)") - if let e = error { - showToast(e.localizedDescription) - } + public func playAudio(_ filePath: String, didBeganWithError error: Error?) { + print(#function + "\(error)") + if let e = error { + showToast(e.localizedDescription) // stop playingCell?.stopAnimation() } + } - public func stopPlayAudio(_ filePath: String, didCompletedWithError error: Error?) { - print(#function + "\(error)") - if let e = error { - showToast(e.localizedDescription) - } - playingCell?.stopAnimation() + public func playAudio(_ filePath: String, didCompletedWithError error: Error?) { + print(#function + "\(error)") + if let e = error { + showToast(e.localizedDescription) } + // stop + playingCell?.stopAnimation() + } - public func playAudio(_ filePath: String, progress value: Float) {} - - public func playAudioInterruptionEnd() { - print(#function) + public func stopPlayAudio(_ filePath: String, didCompletedWithError error: Error?) { + print(#function + "\(error)") + if let e = error { + showToast(e.localizedDescription) } + playingCell?.stopAnimation() + } - public func playAudioInterruptionBegin() { - print(#function) - // stop play - playingCell?.stopAnimation() - } + public func playAudio(_ filePath: String, progress value: Float) {} + + public func playAudioInterruptionEnd() { + print(#function) + } + + public func playAudioInterruptionBegin() { + print(#function) + // stop play + playingCell?.stopAnimation() + } // record - public func recordAudio(_ filePath: String?, didBeganWithError error: Error?) { - print("[record] sdk Began error:\(error)") + public func recordAudio(_ filePath: String?, didBeganWithError error: Error?) { + print("[record] sdk Began error:\(error)") + } + + public func recordAudio(_ filePath: String?, didCompletedWithError error: Error?) { + print("[record] sdk Completed error:\(error)") + menuView.stopRecordAnimation() + guard let fp = filePath else { + showToast(error?.localizedDescription ?? "") + return } + let dur = recordDuration(filePath: fp) - public func recordAudio(_ filePath: String?, didCompletedWithError error: Error?) { - print("[record] sdk Completed error:\(error)") - menuView.stopRecordAnimation() - guard let fp = filePath else { - showToast(error?.localizedDescription ?? "") - return - } - let dur = recordDuration(filePath: fp) - - print("dur:\(dur)") - if dur > 1 { - viewmodel.sendAudioMessage(filePath: fp) { error in - if let e = error { - self.showToast(e.localizedDescription) - } else {} - } - } else { - showToast(localizable("录音时间太短")) + print("dur:\(dur)") + if dur > 1 { + viewmodel.sendAudioMessage(filePath: fp) { error in + if let e = error { + self.showToast(e.localizedDescription) + } else {} } + } else { + showToast(localizable("record_too_short")) } + } - public func recordAudioDidCancelled() { - print("[record] sdk cancel") - } + public func recordAudioDidCancelled() { + print("[record] sdk cancel") + } - public func recordAudioProgress(_ currentTime: TimeInterval) {} + public func recordAudioProgress(_ currentTime: TimeInterval) {} - public func recordAudioInterruptionBegin() { - print(#function) - } + public func recordAudioInterruptionBegin() { + print(#function) + } // MARK: Private Method - private func recordDuration(filePath: String) -> Float64 { - let avAsset = AVURLAsset(url: URL(fileURLWithPath: filePath)) - return CMTimeGetSeconds(avAsset.duration) - } + private func recordDuration(filePath: String) -> Float64 { + let avAsset = AVURLAsset(url: URL(fileURLWithPath: filePath)) + return CMTimeGetSeconds(avAsset.duration) + } - private func insertRows() { - let oldRows = tableView.numberOfRows(inSection: 0) - if oldRows == 0 { - tableView.reloadData() - return - } - if oldRows == viewmodel.messages.count { - tableView.reloadData() - return - } - var indexs = [IndexPath]() - for (i, model) in viewmodel.messages.enumerated() { - if i >= oldRows { - indexs.append(IndexPath(row: i, section: 0)) - } + private func insertRows() { + let oldRows = tableView.numberOfRows(inSection: 0) + if oldRows == 0 { + tableView.reloadData() + return + } + if oldRows == viewmodel.messages.count { + tableView.reloadData() + return + } + var indexs = [IndexPath]() + for (i, model) in viewmodel.messages.enumerated() { + if i >= oldRows { + indexs.append(IndexPath(row: i, section: 0)) } + } - print("oo indexs:\(indexs)") - print("oo:\(viewmodel.messages.count)") - if !indexs.isEmpty { - tableView.insertRows(at: indexs, with: .none) - tableView.scrollToRow( - at: IndexPath(row: viewmodel.messages.count - 1, section: 0), - at: .bottom, - animated: false - ) - } + if !indexs.isEmpty { + tableView.insertRows(at: indexs, with: .none) + tableView.scrollToRow( + at: IndexPath(row: viewmodel.messages.count - 1, section: 0), + at: .bottom, + animated: false + ) } + } - private func showUserSelectVC(text: String) { - let selectVC = SelectUserViewController(sessionId: viewmodel.session.sessionId) - selectVC.modalPresentationStyle = .formSheet - selectVC.selectedBlock = { [weak self] index, model in - var resultText = "" - var location = 0 - var length = 0 - if let t = self?.menuView.textField.text, t.count > 0 { - resultText = t - location = t.count - } - if index == 0 { - let addText = text + localizable("user_select_all") + " " + private func showUserSelectVC(text: String) { + let selectVC = SelectUserViewController(sessionId: viewmodel.session.sessionId) + selectVC.modalPresentationStyle = .formSheet + selectVC.selectedBlock = { [weak self] index, model in + var resultText = "" + var location = 0 + var length = 0 + if let t = self?.menuView.textField.text, t.count > 0 { + resultText = t + location = t.count + } + if index == 0 { + let addText = text + localizable("user_select_all") + " " + resultText = resultText + addText + length = addText.count + let range = NSRange(location: location, length: length) + self?.atUsers.append(range) + } else { + if let m = model { + let addText = text + m.atNameInTeam() + " " resultText = resultText + addText length = addText.count let range = NSRange(location: location, length: length) self?.atUsers.append(range) - } else { - if let m = model { - let addText = text + m.atNameInTeam() + " " - resultText = resultText + addText - length = addText.count - let range = NSRange(location: location, length: length) - self?.atUsers.append(range) - } } - self?.menuView.textField.text = resultText } - present(selectVC, animated: true, completion: nil) + self?.menuView.textField.text = resultText } + present(selectVC, animated: true, completion: nil) + } // MARK: MessageOperationViewDelegate - public func didSelectedItem(item: OperationItem) { - switch item.type { - case .copy: - copyMessage() - case .delete: - deleteMessage() - case .reply: - showReplyMessageView() - case .recall: - recallMessage() - case .collection: - collectionMessage() - case .forward: - forwardMessage() - case .pin: - pinMessage() - case .removePin: - removePinMessage() - default: - doNothing() - } + public func didSelectedItem(item: OperationItem) { + switch item.type { + case .copy: + copyMessage() + case .delete: + deleteMessage() + case .reply: + showReplyMessageView() + case .recall: + recallMessage() + case .collection: + collectionMessage() + case .forward: + forwardMessage() + case .pin: + pinMessage() + case .removePin: + removePinMessage() + default: + doNothing() } + } - private func doNothing() {} + private func doNothing() {} - private func copyMessage() { - if let model = viewmodel.operationModel as? MessageTextModel, - let text = model.attributeStr { - let pasteboard = UIPasteboard.general - pasteboard.string = text.string - showToast(localizable("copy_success")) - } + private func copyMessage() { + if let model = viewmodel.operationModel as? MessageTextModel, + let text = model.attributeStr { + let pasteboard = UIPasteboard.general + pasteboard.string = text.string + showToast(localizable("copy_success")) } + } - private func deleteMessage() { - showAlert(message: localizable("message_delete_comfirm")) { - if let message = self.viewmodel.operationModel?.message { - self.viewmodel.deleteMessage(message: message) - } + private func deleteMessage() { + showAlert(message: localizable("message_delete_comfirm")) { + if let message = self.viewmodel.operationModel?.message { + self.viewmodel.deleteMessage(message: message) } } + } - private func showReplyMessageView() { - viewmodel.isReplying = true - view.addSubview(replyView) - replyView.closeButton.addTarget(self, action: #selector(cancelReply), for: .touchUpInside) - replyView.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([ - replyView.leadingAnchor.constraint(equalTo: menuView.leadingAnchor), - replyView.trailingAnchor.constraint(equalTo: menuView.trailingAnchor), - replyView.bottomAnchor.constraint(equalTo: menuView.topAnchor), - replyView.heightAnchor.constraint(equalToConstant: 36), - ]) - if let message = viewmodel.operationModel?.message { - var text = localizable("msg_reply") - if let name = viewmodel.operationModel?.shortName { - text = text + name - } - text = text + ":" - switch message.messageType { - case .text: - if let t = message.text { - text = text + t - } - case .image: - text = text + localizable("msg_image") - case .audio: - text = text + localizable("msg_audio") - case .video: - text = text + localizable("msg_video") - default: - text = text + "" - } - replyView.textLabel.text = text + private func showReplyMessageView() { + viewmodel.isReplying = true + view.addSubview(replyView) + replyView.closeButton.addTarget(self, action: #selector(cancelReply), for: .touchUpInside) + replyView.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + replyView.leadingAnchor.constraint(equalTo: menuView.leadingAnchor), + replyView.trailingAnchor.constraint(equalTo: menuView.trailingAnchor), + replyView.bottomAnchor.constraint(equalTo: menuView.topAnchor), + replyView.heightAnchor.constraint(equalToConstant: 36), + ]) + if let message = viewmodel.operationModel?.message { + var text = localizable("msg_reply") + if let name = viewmodel.operationModel?.shortName { + text = text + name } - } - - @objc private func cancelReply(button: UIButton) { - replyView.removeFromSuperview() - viewmodel.isReplying = false - } - - private func recallMessage() { - showAlert(message: localizable("message_revoke_confim")) { - if let message = self.viewmodel.operationModel?.message { - self.viewmodel.revokeMessage(message: message) { error in - if error != nil { - self.showToast(error!.localizedDescription) - } else { - // 自己撤回成功 & 收到对方撤回 都会走回调方法 onRevokeMessage - // 撤回成功的逻辑统一在代理方法中处理 onRevokeMessage - } - } + text = text + ":" + switch message.messageType { + case .text: + if let t = message.text { + text = text + t } + case .image: + text = text + localizable("msg_image") + case .audio: + text = text + localizable("msg_audio") + case .video: + text = text + localizable("msg_video") + default: + text = text + "" } + replyView.textLabel.text = text } + } - private func collectionMessage() { - if let message = viewmodel.operationModel?.message { - viewmodel.addColletion(message) { error, info in + @objc private func cancelReply(button: UIButton) { + replyView.removeFromSuperview() + viewmodel.isReplying = false + } + + private func recallMessage() { + showAlert(message: localizable("message_revoke_confim")) { + if let message = self.viewmodel.operationModel?.message { + self.viewmodel.revokeMessage(message: message) { error in if error != nil { self.showToast(error!.localizedDescription) } else { - self.showToast(localizable("collection_success")) + // 自己撤回成功 & 收到对方撤回 都会走回调方法 onRevokeMessage + // 撤回成功的逻辑统一在代理方法中处理 onRevokeMessage } } } } + } - private func forwardMessage() { - if let message = viewmodel.operationModel?.message { - weak var weakSelf = self - let userAction = UIAlertAction(title: localizable("contact_user"), - style: .default) { action in - - Router.shared.register(ContactSelectedUsersRouter) { param in - print("user setting accids : ", param) - var items = [ForwardItem]() - - if let users = param["im_user"] as? [NIMUser] { - users.forEach { user in - let item = ForwardItem() - item.uid = user.userId - item.avatar = user.userInfo?.avatarUrl - item.name = user.userInfo?.nickName - items.append(item) - } - - let forwardAlert = ForwardAlertViewController() - forwardAlert.setItems(items) - if let senderName = message.senderName { - forwardAlert.context = senderName - } - weakSelf?.addChild(forwardAlert) - weakSelf?.view.addSubview(forwardAlert.view) - - forwardAlert.sureBlock = { - print("sure click ") - weakSelf?.viewmodel.forwardUserMessage(message, users) - } - } - } - var param = [String: Any]() - param["nav"] = weakSelf?.navigationController as Any - param["limit"] = 6 - if let session = weakSelf?.viewmodel.session, session.sessionType == .P2P { - var filters = Set() - filters.insert(session.sessionId) - param["filters"] = filters - } - Router.shared.use(ContactUserSelectRouter, parameters: param, closure: nil) + private func collectionMessage() { + if let message = viewmodel.operationModel?.message { + viewmodel.addColletion(message) { error, info in + if error != nil { + self.showToast(error!.localizedDescription) + } else { + self.showToast(localizable("collection_success")) } + } + } + } + + private func forwardMessage() { + if let message = viewmodel.operationModel?.message { + weak var weakSelf = self + let userAction = UIAlertAction(title: localizable("contact_user"), + style: .default) { action in - let teamAction = UIAlertAction(title: localizable("team"), style: .default) { action in + Router.shared.register(ContactSelectedUsersRouter) { param in + print("user setting accids : ", param) + var items = [ForwardItem]() - Router.shared.register(ContactTeamDataRouter) { param in - if let team = param["team"] as? NIMTeam { + if let users = param["im_user"] as? [NIMUser] { + users.forEach { user in let item = ForwardItem() - item.avatar = team.avatarUrl - item.name = team.getShowName() - item.uid = team.teamId - - let forwardAlert = ForwardAlertViewController() - forwardAlert.setItems([item]) - if let senderName = message.senderName { - forwardAlert.context = senderName - } - weakSelf?.addChild(forwardAlert) - weakSelf?.view.addSubview(forwardAlert.view) - weakSelf?.viewmodel.forwardTeamMessage(message, team) + item.uid = user.userId + item.avatar = user.userInfo?.avatarUrl + item.name = user.userInfo?.nickName + items.append(item) } - } - Router.shared.use( - ContactTeamListRouter, - parameters: ["nav": weakSelf?.navigationController as Any], - closure: nil - ) - } + let forwardAlert = ForwardAlertViewController() + forwardAlert.setItems(items) + if let senderName = message.senderName { + forwardAlert.context = senderName + } + weakSelf?.addChild(forwardAlert) + weakSelf?.view.addSubview(forwardAlert.view) - let cancelAction = UIAlertAction(title: localizable("cancel"), - style: .cancel) { action in + forwardAlert.sureBlock = { + print("sure click ") + weakSelf?.viewmodel.forwardUserMessage(message, users) + } + } } - - showActionSheet([userAction, teamAction, cancelAction]) + var param = [String: Any]() + param["nav"] = weakSelf?.navigationController as Any + param["limit"] = 6 + if let session = weakSelf?.viewmodel.session, session.sessionType == .P2P { + var filters = Set() + filters.insert(session.sessionId) + param["filters"] = filters + } + Router.shared.use(ContactUserSelectRouter, parameters: param, closure: nil) } - } - private func pinMessage() { - if let message = viewmodel.operationModel?.message { - viewmodel.pinMessage(message) { [weak self] error, pinItem, index in - if error != nil { - self?.view.makeToast(error?.localizedDescription) - } else { - // update UI - if index >= 0 { - self?.tableViewReloadIndexs([IndexPath(row: index, section: 0)]) + let teamAction = UIAlertAction(title: localizable("team"), style: .default) { action in + + Router.shared.register(ContactTeamDataRouter) { param in + if let team = param["team"] as? NIMTeam { + let item = ForwardItem() + item.avatar = team.avatarUrl + item.name = team.getShowName() + item.uid = team.teamId + + let forwardAlert = ForwardAlertViewController() + forwardAlert.setItems([item]) + if let senderName = message.senderName { + forwardAlert.context = senderName } + weakSelf?.addChild(forwardAlert) + weakSelf?.view.addSubview(forwardAlert.view) + weakSelf?.viewmodel.forwardTeamMessage(message, team) } } + + Router.shared.use( + ContactTeamListRouter, + parameters: ["nav": weakSelf?.navigationController as Any], + closure: nil + ) + } + + let cancelAction = UIAlertAction(title: localizable("cancel"), + style: .cancel) { action in } + + showActionSheet([userAction, teamAction, cancelAction]) } + } - private func removePinMessage() { - if let message = viewmodel.operationModel?.message { - viewmodel.removePinMessage(message) { [weak self] error, pinItem, index in - if error != nil { - self?.view.makeToast(error?.localizedDescription) - } else { - // update UI - if index >= 0 { - self?.tableViewReloadIndexs([IndexPath(row: index, section: 0)]) - } + private func pinMessage() { + if let message = viewmodel.operationModel?.message { + viewmodel.pinMessage(message) { [weak self] error, pinItem, index in + if error != nil { + self?.view.makeToast(error?.localizedDescription) + } else { + // update UI + if index >= 0 { + self?.tableViewReloadIndexs([IndexPath(row: index, section: 0)]) } } } } - - //MARK: UITableViewDataSource, UITableViewDelegate - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - viewmodel.messages.count ?? 0 - } + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let model = viewmodel.messages[indexPath.row] - var reuseId = "" - if let isSend = model.message?.isOutgoingMsg, isSend { - if model.replyedModel != nil { - reuseId = "\(ChatReplyRightCell.self)" + private func removePinMessage() { + if let message = viewmodel.operationModel?.message { + viewmodel.removePinMessage(message) { [weak self] error, pinItem, index in + if error != nil { + self?.view.makeToast(error?.localizedDescription) } else { - switch model.type { - case .text: - reuseId = "\(ChatTextRightCell.self)" - case .image: - reuseId = "\(ChatImageRightCell.self)" - case .audio: - reuseId = "\(ChatAudioRightCell.self)" - case .video: - reuseId = "\(ChatVideoRightCell.self)" - case .time, .tip, .notification: - reuseId = "\(ChatTimeTableViewCell.self)" - case .revoke: - reuseId = "\(ChatRevokeRightCell.self)" - default: - reuseId = "\(ChatBaseRightCell.self)" + // update UI + if index >= 0 { + self?.tableViewReloadIndexs([IndexPath(row: index, section: 0)]) } } + } + } + } - let cell = tableView.dequeueReusableCell(withIdentifier: reuseId, for: indexPath) - if let c = cell as? ChatTimeTableViewCell { - if let m = model as? MessageTipsModel { - c.setModel(m) - } - return c - } else if let c = cell as? ChatBaseRightCell { - c.delegate = self - if let m = model as? MessageContentModel { - c.setModel(m) - } - return c - } else { - return ChatBaseRightCell() - } + // MARK: UITableViewDataSource, UITableViewDelegate + + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + viewmodel.messages.count ?? 0 + } + + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewmodel.messages[indexPath.row] + var reuseId = "" + if let isSend = model.message?.isOutgoingMsg, isSend { + if model.replyedModel != nil { + reuseId = "\(ChatReplyRightCell.self)" } else { - if model.replyedModel != nil { - reuseId = "\(ChatReplyLeftCell.self)" - } else { - switch model.type { - case .text: - reuseId = "\(ChatTextLeftCell.self)" - case .image: - reuseId = "\(ChatImageLeftCell.self)" - case .audio: - reuseId = "\(ChatAudioLeftCell.self)" - case .video: - reuseId = "\(ChatVideoLeftCell.self)" - case .time, .tip, .notification: - reuseId = "\(ChatTimeTableViewCell.self)" - case .revoke: - reuseId = "\(ChatRevokeLeftCell.self)" - default: - reuseId = "\(ChatBaseLeftCell.self)" - } + switch model.type { + case .text: + reuseId = "\(ChatTextRightCell.self)" + case .image: + reuseId = "\(ChatImageRightCell.self)" + case .audio: + reuseId = "\(ChatAudioRightCell.self)" + case .video: + reuseId = "\(ChatVideoRightCell.self)" + case .time, .tip, .notification: + reuseId = "\(ChatTimeTableViewCell.self)" + case .revoke: + reuseId = "\(ChatRevokeRightCell.self)" + default: + reuseId = "\(ChatBaseRightCell.self)" } + } - let cell = tableView.dequeueReusableCell(withIdentifier: reuseId, for: indexPath) - if let c = cell as? ChatTimeTableViewCell { - if let m = model as? MessageTipsModel { - c.setModel(m) - } - return c - } else if let c = cell as? ChatBaseLeftCell { - c.delegate = self - if let m = model as? MessageContentModel { - c.setModel(m) - } - return c - } else { - return ChatBaseLeftCell() + let cell = tableView.dequeueReusableCell(withIdentifier: reuseId, for: indexPath) + if let c = cell as? ChatTimeTableViewCell { + if let m = model as? MessageTipsModel { + c.setModel(m) + } + return c + } else if let c = cell as? ChatBaseRightCell { + c.delegate = self + if let m = model as? MessageContentModel { + c.setModel(m) + } + return c + } else { + return ChatBaseRightCell() + } + } else { + if model.replyedModel != nil { + reuseId = "\(ChatReplyLeftCell.self)" + } else { + switch model.type { + case .text: + reuseId = "\(ChatTextLeftCell.self)" + case .image: + reuseId = "\(ChatImageLeftCell.self)" + case .audio: + reuseId = "\(ChatAudioLeftCell.self)" + case .video: + reuseId = "\(ChatVideoLeftCell.self)" + case .time, .tip, .notification: + reuseId = "\(ChatTimeTableViewCell.self)" + case .revoke: + reuseId = "\(ChatRevokeLeftCell.self)" + default: + reuseId = "\(ChatBaseLeftCell.self)" } } - } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - print("did select row ") - operationView?.removeFromSuperview() - if menuView.textField.isFirstResponder { - menuView.textField.resignFirstResponder() + let cell = tableView.dequeueReusableCell(withIdentifier: reuseId, for: indexPath) + if let c = cell as? ChatTimeTableViewCell { + if let m = model as? MessageTipsModel { + c.setModel(m) + } + return c + } else if let c = cell as? ChatBaseLeftCell { + c.delegate = self + if let m = model as? MessageContentModel { + c.setModel(m) + } + return c } else { - layoutInputView(offset: 0) + return ChatBaseLeftCell() } } + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - let m = viewmodel.messages[indexPath.row] - print("text:\(m.message?.text) height:\(m.height)") - return CGFloat(m.height) + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + print("did select row ") + operationView?.removeFromSuperview() + if menuView.textField.isFirstResponder { + menuView.textField.resignFirstResponder() + } else { + layoutInputView(offset: 0) } - + } + + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + let m = viewmodel.messages[indexPath.row] + print("text:\(m.message?.text) height:\(m.height)") + return CGFloat(m.height) + } } // MARK: ChatBaseCellDelegate @@ -1460,7 +1461,3 @@ extension ChatViewController: ChatBaseCellDelegate { } } } - - - - diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/GroupChatViewController.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/GroupChatViewController.swift index 1e23898e..76db717f 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/GroupChatViewController.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/GroupChatViewController.swift @@ -56,7 +56,7 @@ open class GroupChatViewController: ChatViewController, TeamChatViewModelDelegat public func onTeamRemoved(team: NIMTeam) { // 只有群创建者 才弹弹窗 - if team.owner == IMKitLoginManager.instance.imAccid { + if team.owner == IMKitEngine.instance.imAccid { showSingleAlert(message: localizable("team_has_been_removed")) { self.navigationController?.popViewController(animated: true) } diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/P2PChatViewController.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/P2PChatViewController.swift index 17e13540..e16e38cd 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/P2PChatViewController.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/P2PChatViewController.swift @@ -20,7 +20,6 @@ open class P2PChatViewController: ChatViewController { let title = user?.showName() ?? "" self.title = title titleContent = title - // self.menuView.textField.placeholder = localizable("send_to") + title menuView.textField.placeholder = localizable("send_to") + title as NSString } diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/ReadViewController.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/ReadViewController.swift index 3d1da908..dbb8b596 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/ReadViewController.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/ReadViewController.swift @@ -8,7 +8,7 @@ import NIMSDK import NEKitCoreIM import NEKitCommonUI -public class ReadViewController: NEBaseViewController, UIScrollViewDelegate, UITableViewDelegate, +public class ReadViewController: ChatBaseViewController, UIScrollViewDelegate, UITableViewDelegate, UITableViewDataSource { public var read: Bool = true public var line: UIView = .init() @@ -37,7 +37,7 @@ public class ReadViewController: NEBaseViewController, UIScrollViewDelegate, UIT func commonUI() { title = localizable("message_read") readButton.titleLabel?.font = UIFont.systemFont(ofSize: 14) - readButton.setTitle("已读(0)", for: .normal) + readButton.setTitle(localizable("read"), for: .normal) readButton.setTitleColor(UIColor.ne_darkText, for: .normal) readButton.translatesAutoresizingMaskIntoConstraints = false readButton.addTarget(self, action: #selector(readButtonEvent), for: .touchUpInside) @@ -45,7 +45,7 @@ public class ReadViewController: NEBaseViewController, UIScrollViewDelegate, UIT unreadButton.titleLabel?.font = UIFont.systemFont(ofSize: 14) unreadButton.setTitleColor(UIColor.ne_darkText, for: .normal) - unreadButton.setTitle("未读(0)", for: .normal) + unreadButton.setTitle(localizable("unread"), for: .normal) unreadButton.translatesAutoresizingMaskIntoConstraints = false unreadButton.addTarget(self, action: #selector(unreadButtonEvent), for: .touchUpInside) diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/SelectUserViewController.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/SelectUserViewController.swift index 721ce48e..80be5a1d 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/SelectUserViewController.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/SelectUserViewController.swift @@ -8,7 +8,7 @@ import NEKitChat public typealias didSelectedAtRow = (_ index: Int, _ model: ChatTeamMemberInfoModel?) -> Void -public class SelectUserViewController: NEBaseViewController, UITableViewDelegate, +public class SelectUserViewController: ChatBaseViewController, UITableViewDelegate, UITableViewDataSource { public var tableView = UITableView(frame: .zero, style: .plain) public var sessionId: String diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/UserSettingViewController.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/UserSettingViewController.swift index 56bbc010..af0763a3 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/UserSettingViewController.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/Controller/UserSettingViewController.swift @@ -7,7 +7,8 @@ import UIKit import NEKitCommon import NIMSDK -public class UserSettingViewController: NEBaseViewController, UserSettingViewModelDelegate,UITableViewDataSource, UITableViewDelegate{ +public class UserSettingViewController: ChatBaseViewController, UserSettingViewModelDelegate, + UITableViewDataSource, UITableViewDelegate { var userId: String? let viewmodel = UserSettingViewModel() @@ -157,7 +158,12 @@ public class UserSettingViewController: NEBaseViewController, UserSettingViewMod Router.shared.use( ContactUserSelectRouter, - parameters: ["nav": navigationController as Any, "filters": filters, "limit": 199], + parameters: [ + "nav": navigationController as Any, + "filters": filters, + "limit": 199, + "uid": userId ?? "", + ], closure: nil ) @@ -209,27 +215,26 @@ public class UserSettingViewController: NEBaseViewController, UserSettingViewMod showToast(error.localizedDescription) } - //MARK: UITableViewDataSource, UITableViewDelegate - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - viewmodel.cellDatas.count - } + // MARK: UITableViewDataSource, UITableViewDelegate - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let model = viewmodel.cellDatas[indexPath.row] - if let cell = tableView.dequeueReusableCell( - withIdentifier: "\(UserSettingSwitchCell.self)", - for: indexPath - ) as? UserSettingBaseCell { - cell.configure(model) - return cell - } - return UITableViewCell() - } + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + viewmodel.cellDatas.count + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - // let model = viewmodel.cellDatas[indexPath.row] + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewmodel.cellDatas[indexPath.row] + if let cell = tableView.dequeueReusableCell( + withIdentifier: "\(UserSettingSwitchCell.self)", + for: indexPath + ) as? UserSettingBaseCell { + cell.configure(model) + return cell } -} - + return UITableViewCell() + } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + // let model = viewmodel.cellDatas[indexPath.row] + } +} diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/Emoji/InputEmoticonTabView.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/Emoji/InputEmoticonTabView.swift index 398168de..b1aa08a1 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/Emoji/InputEmoticonTabView.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/Emoji/InputEmoticonTabView.swift @@ -82,7 +82,7 @@ public class InputEmoticonTabView: UIControl { public lazy var sendButton: UIButton = { let button = UIButton() button.translatesAutoresizingMaskIntoConstraints = false - button.setTitle("发送", for: .normal) + button.setTitle(localizable("send"), for: .normal) button.titleLabel?.textColor = .white button.backgroundColor = UIColor.ne_blueText button.titleLabel?.font = DefaultTextFont(14) diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/Helper/MessageUtils.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/Helper/MessageUtils.swift index 4d745f29..6e7030eb 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/Helper/MessageUtils.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/Helper/MessageUtils.swift @@ -29,7 +29,7 @@ public class MessageUtils { option.compressQuality = 0.8 imageObject.option = option message.messageObject = imageObject - message.apnsContent = localizable("发来了一张图片") + message.apnsContent = localizable("send_picture") message.setting = messageSetting() return message } @@ -38,7 +38,7 @@ public class MessageUtils { let messageObject = NIMAudioObject(sourcePath: filePath) let message = NIMMessage() message.messageObject = messageObject - message.apnsContent = localizable("发来了一段语音") + message.apnsContent = localizable("send_voice") message.setting = messageSetting() return message } @@ -47,7 +47,7 @@ public class MessageUtils { let messageObject = NIMVideoObject(sourcePath: filePath) let message = NIMMessage() message.messageObject = messageObject - message.apnsContent = localizable("发来了一段视频") + message.apnsContent = localizable("send_video") message.setting = messageSetting() return message } diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/Model/MessageContentModel.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/Model/MessageContentModel.swift index 6e7d4b6a..e987a1a8 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/Model/MessageContentModel.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/Model/MessageContentModel.swift @@ -78,7 +78,7 @@ public class MessageContentModel: MessageModel { self.message = message contentSize = CGSize(width: 32.0, height: qChat_min_h) if message?.session?.sessionType == .team, - !IMKitLoginManager.instance.isMySelf(message?.from) { + !IMKitEngine.instance.isMySelf(message?.from) { fullNameHeight = 20 } print("self.fullNameHeight\(fullNameHeight)") diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/Cell/ChatVideoLeftCell.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/Cell/ChatVideoLeftCell.swift index 46063252..81432f4d 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/Cell/ChatVideoLeftCell.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/Cell/ChatVideoLeftCell.swift @@ -81,9 +81,9 @@ class ChatVideoLeftCell: ChatImageLeftCell { override func setModel(_ model: MessageContentModel) { super.setModel(model) if let videoObject = model.message?.messageObject as? NIMVideoObject { - if let path = videoObject.coverPath { + if let path = videoObject.coverUrl { contentImageView.sd_setImage( - with: URL(fileURLWithPath: path), + with: URL(string: path), placeholderImage: nil, options: .retryFailed, progress: nil, diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatBrokenNetworkView.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatBrokenNetworkView.swift index dd489a16..59a20c4e 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatBrokenNetworkView.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatBrokenNetworkView.swift @@ -31,7 +31,7 @@ public class ChatBrokenNetworkView: UIView { label.font = DefaultTextFont(14) label.textColor = HexRGB(0xFC596A) label.textAlignment = .center - label.text = "当前网络不可用,请检查你当网络设置。" + label.text = localizable("network_unavailable") return label }() } diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatInputView.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatInputView.swift index 4bba0287..3e53b34e 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatInputView.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatInputView.swift @@ -236,18 +236,10 @@ public class ChatInputView: UIView, UITextFieldDelegate, ChatRecordViewDelegate, delegate?.textFieldDidEndEditing(textView) } - public func textFieldDidEndEditing(_ textField: UITextField) { - // delegate?.textFieldDidEndEditing(textField) - } - public func textViewDidBeginEditing(_ textView: UITextView) { delegate?.textFieldDidBeginEditing(textView) } - public func textFieldDidBeginEditing(_ textField: UITextField) { - // delegate?.textFieldDidBeginEditing(textField) - } - public func textViewShouldBeginEditing(_ textView: UITextView) -> Bool { currentType = .text return true diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatRecordView.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatRecordView.swift index 07a39aa8..10211abc 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatRecordView.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ChatRecordView.swift @@ -63,7 +63,7 @@ class ChatRecordView: UIView, UIGestureRecognizerDelegate { recordImageView.addGestureRecognizer(guesture) tipLabel.translatesAutoresizingMaskIntoConstraints = false - tipLabel.text = localizable("按住说话") + tipLabel.text = localizable("press_speak") tipLabel.font = UIFont.systemFont(ofSize: 12) tipLabel.textColor = .ne_lightText tipLabel.textAlignment = .center diff --git a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ForwardAlertViewController.swift b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ForwardAlertViewController.swift index e34457a1..210aa989 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ForwardAlertViewController.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Chat/View/ForwardAlertViewController.swift @@ -201,13 +201,13 @@ public class ForwardAlertViewController: UIViewController { let canceBtn = UIButton() canceBtn.translatesAutoresizingMaskIntoConstraints = false canceBtn.addTarget(self, action: #selector(cancelClick), for: .touchUpInside) - canceBtn.setTitle("取消", for: .normal) + canceBtn.setTitle(localizable("cancel"), for: .normal) canceBtn.setTitleColor(.ne_greyText, for: .normal) let sureBtn = UIButton() sureBtn.translatesAutoresizingMaskIntoConstraints = false sureBtn.addTarget(self, action: #selector(sureClick), for: .touchUpInside) - sureBtn.setTitle("确定", for: .normal) + sureBtn.setTitle(localizable("confirm"), for: .normal) sureBtn.setTitleColor(.ne_blueText, for: .normal) contentView.addSubview(canceBtn) diff --git a/NEChatUIKit/NEKitChatUI/Classes/ChatRouter/ChatRouter.swift b/NEChatUIKit/NEKitChatUI/Classes/ChatRouter/ChatRouter.swift index ad31045d..9bd036b3 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/ChatRouter/ChatRouter.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/ChatRouter/ChatRouter.swift @@ -7,7 +7,8 @@ import Foundation import NIMSDK import NEKitCommon -public enum ChatRouter { +@objcMembers +public class ChatRouter:NSObject { public static func register() { // p2p Router.shared.register(PushP2pChatVCRouter) { param in diff --git a/NEChatUIKit/NEKitChatUI/Classes/Common/NSBundleExtension.swift b/NEChatUIKit/NEKitChatUI/Classes/Common/NSBundleExtension.swift index c3932ff2..c3bbb7f5 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Common/NSBundleExtension.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Common/NSBundleExtension.swift @@ -4,6 +4,7 @@ // found in the LICENSE file. import Foundation +import NEKitCommon public extension Bundle { class func nim_defaultEmojiBundle() -> Bundle? { @@ -18,8 +19,10 @@ public extension Bundle { class func nim_EmojiPlistFile() -> String? { let bundle = Bundle.nim_defaultEmojiBundle() + + let resource = (CommonTool.getCurrentLanguage() == "cn") ?"emoji_ios_cn" : "emoji_ios_en" let filepath = bundle?.path( - forResource: "emoji_ios_new", + forResource: resource, ofType: "plist", inDirectory: NIMKit_EmojiPath ) diff --git a/NEChatUIKit/NEKitChatUI/Classes/Extension/ChatStringExtension.swift b/NEChatUIKit/NEKitChatUI/Classes/Extension/ChatStringExtension.swift index f8d0a42e..bb73c625 100644 --- a/NEChatUIKit/NEKitChatUI/Classes/Extension/ChatStringExtension.swift +++ b/NEChatUIKit/NEKitChatUI/Classes/Extension/ChatStringExtension.swift @@ -23,12 +23,12 @@ extension String { if let firstDayYear = firstDayInYear() { let dur = date.timeIntervalSince(firstDayYear) if dur > 0 { - fmt.dateFormat = "MM月dd日 HH:mm" + fmt.dateFormat = localizable("mdhm") } else { - fmt.dateFormat = "yyyy年MM月dd日 HH:mm" + fmt.dateFormat = localizable("ymdhm") } } else { - fmt.dateFormat = "yyyy年MM月dd日 HH:mm" + fmt.dateFormat = localizable("ymdhm") } } return fmt.string(from: date) diff --git a/NEContactUIKit/NEKitContactUI.podspec b/NEContactUIKit/NEKitContactUI.podspec index 5517d963..7c4090cb 100644 --- a/NEContactUIKit/NEKitContactUI.podspec +++ b/NEContactUIKit/NEKitContactUI.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'NEKitContactUI' - s.version = '9.2.7' + s.version = '9.2.8' s.summary = 'Netease XKit' # This description is used to generate tags and improve search results. @@ -23,12 +23,10 @@ Pod::Spec.new do |s| s.source = { :git => 'ssh://git@g.hz.netease.com:22222/yunxin-app/xkit-ios.git', :tag => s.version.to_s } # s.source = { :git => 'https://github.com/chenyu-home/ContactKitUI.git', :tag => s.version.to_s } - # s.social_media_url = 'https://twitter.com/' s.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' } s.user_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' } - s.ios.deployment_target = '9.0' s.source_files = 'NEKitContactUI/Classes/**/*' diff --git a/NEContactUIKit/NEKitContactUI/Assets/en.lproj/Localizable.strings b/NEContactUIKit/NEKitContactUI/Assets/en.lproj/Localizable.strings index a75d7def..076ea47c 100644 --- a/NEContactUIKit/NEKitContactUI/Assets/en.lproj/Localizable.strings +++ b/NEContactUIKit/NEKitContactUI/Assets/en.lproj/Localizable.strings @@ -3,13 +3,39 @@ // Use of this source code is governed by a MIT license that can be // found in the LICENSE file. -"验证消息"="验证消息"; -"alert_tip"="提示"; -"alert_sure"="确定"; -"alert_cancel"="取消"; -"备注名"="备注名"; -"remove_black" = "解除"; +"alert_tip"="tip"; +"alert_sure"="ok"; +"alert_cancel"="cancel"; +"noteName"="Nick Name"; +"remove_black" = "Remove"; + +"blacklist"="Blacklist"; +"mine_groupchat"="My Group"; +"save"="Save"; +"input_noteName"="Please enter nick name"; +"phone"="mobile"; +"email"="e-mail"; +"sign"="What's Up"; +"delete_friend"="Delete Contact"; +"add_friend"="Add Contact"; +"add_blackList"="block"; +"send_friend_apply"="Contact request sent"; +"validation_message"="Verify message"; +"clear"="Clear"; +"agreed"="Added"; +"refused"="Rejected"; +"expired"="Expired"; +"refuse"="Reject"; +"agree"="Agree"; +"select"="Select"; +"select_contact"="Please select Contact"; +"user_not_exist"="No contact"; +"chat"="Chat"; +"message_remind"="Message notification"; +"clear_all_validate_message"="Wether to clear all verification"; +"sure_delte_friend"="Wether to delete Contact?"; + diff --git a/NEContactUIKit/NEKitContactUI/Assets/zh-Hans.lproj/Localizable.strings b/NEContactUIKit/NEKitContactUI/Assets/zh-Hans.lproj/Localizable.strings index a6a97b9c..72e4333e 100644 --- a/NEContactUIKit/NEKitContactUI/Assets/zh-Hans.lproj/Localizable.strings +++ b/NEContactUIKit/NEKitContactUI/Assets/zh-Hans.lproj/Localizable.strings @@ -3,10 +3,35 @@ // Use of this source code is governed by a MIT license that can be // found in the LICENSE file. -"验证消息"="验证消息"; "alert_tip"="提示"; "alert_sure"="确定"; "alert_cancel"="取消"; -"备注名"="备注名"; +"noteName"="备注名"; "remove_black" = "解除"; + +"blacklist"="黑名单"; +"mine_groupchat"="我的群聊"; +"save"="保存"; +"input_noteName"="请输入备注名"; +"phone"="手机"; +"email"="邮箱"; +"sign"="个性签名"; +"delete_friend"="删除好友"; +"add_friend"="添加好友"; +"add_blackList"="加入黑名单"; +"send_friend_apply"="好友申请已发送"; +"validation_message"="验证消息"; +"clear"="清空"; +"agreed"="已同意"; +"refused"="已拒绝"; +"expired"="已过期"; +"refuse"="拒绝"; +"agree"="同意"; +"select"="选择"; +"select_contact"="请选择联系人"; +"user_not_exist"="该用户不存在"; +"chat"="聊天"; +"message_remind"="消息提醒"; +"clear_all_validate_message"="是否要清除所有验证消息?"; +"sure_delte_friend"="是否确定删除好友?"; diff --git a/NEContactUIKit/NEKitContactUI/Classes/BlackList/ViewController/BlackListViewController.swift b/NEContactUIKit/NEKitContactUI/Classes/BlackList/ViewController/BlackListViewController.swift index 4d6579d1..67357f1f 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/BlackList/ViewController/BlackListViewController.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/BlackList/ViewController/BlackListViewController.swift @@ -19,7 +19,7 @@ public class BlackListViewController: UIViewController, UITableViewDelegate, UIT } func commonUI() { - title = "黑名单" + title = localizable("blacklist") let image = UIImage.ne_imageNamed(name: "backArrow")?.withRenderingMode(.alwaysOriginal) navigationItem.leftBarButtonItem = UIBarButtonItem( image: image, diff --git a/NEContactUIKit/NEKitContactUI/Classes/Common/ContactRouter.swift b/NEContactUIKit/NEKitContactUI/Classes/Common/ContactRouter.swift index a003a280..9e97dece 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/Common/ContactRouter.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/Common/ContactRouter.swift @@ -8,7 +8,8 @@ import NEKitCore import NEKitCoreIM import NIMSDK -public enum ContactRouter { +@objcMembers +public class ContactRouter:NSObject { public static func register() { Router.shared.register(ContactUserSelectRouter) { param in print("param:\(param)") @@ -20,6 +21,9 @@ public enum ContactRouter { if let limit = param["limit"] as? Int, limit > 0 { contactSelectVC.limit = limit } + if let uid = param["uid"] as? String { + contactSelectVC.userId = uid + } nav?.pushViewController(contactSelectVC, animated: true) } diff --git a/NEContactUIKit/NEKitContactUI/Classes/Team/ViewController/TeamListViewController.swift b/NEContactUIKit/NEKitContactUI/Classes/Team/ViewController/TeamListViewController.swift index e7478f9f..927056b8 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/Team/ViewController/TeamListViewController.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/Team/ViewController/TeamListViewController.swift @@ -19,7 +19,7 @@ public class TeamListViewController: UIViewController, UITableViewDelegate, UITa } func commonUI() { - title = "我的群聊" + title = localizable("mine_groupchat") let image = UIImage.ne_imageNamed(name: "backArrow")?.withRenderingMode(.alwaysOriginal) navigationItem.leftBarButtonItem = UIBarButtonItem( image: image, diff --git a/NEContactUIKit/NEKitContactUI/Classes/UserInfo/ViewController/ContactRemakNameViewController.swift b/NEContactUIKit/NEKitContactUI/Classes/UserInfo/ViewController/ContactRemakNameViewController.swift index a3188ed2..e8d9b481 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/UserInfo/ViewController/ContactRemakNameViewController.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/UserInfo/ViewController/ContactRemakNameViewController.swift @@ -37,16 +37,16 @@ public class ContactRemakNameViewController: ContactBaseViewController, UITextFi func setupUI() { view.backgroundColor = UIColor(hexString: "F2F4F5") let clearItem = UIBarButtonItem( - title: "保存", + title: localizable("save"), style: .done, target: self, action: #selector(saveAlias) ) clearItem.tintColor = UIColor(hexString: "337EFF") navigationItem.rightBarButtonItem = clearItem - title = localizable("备注名") + title = localizable("noteName") view.addSubview(aliasInput) - aliasInput.placeholder = "输入备注名" + aliasInput.placeholder = localizable("input_noteName") NSLayoutConstraint.activate([ aliasInput.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20), aliasInput.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20), diff --git a/NEContactUIKit/NEKitContactUI/Classes/UserInfo/ViewController/ContactUserViewController.swift b/NEContactUIKit/NEKitContactUI/Classes/UserInfo/ViewController/ContactUserViewController.swift index 057ca4da..c112da0e 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/UserInfo/ViewController/ContactUserViewController.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/UserInfo/ViewController/ContactUserViewController.swift @@ -105,44 +105,44 @@ public class ContactUserViewController: ContactBaseViewController, UITableViewDe if isFriend { data = [ [UserItem( - title: localizable("备注名"), + title: localizable("noteName"), detailTitle: user?.alias, value: false, textColor: UIColor.darkText, cellClass: TextWithRightArrowCell.self )], [ - UserItem(title: localizable("手机"), detailTitle: user?.userInfo?.mobile, + UserItem(title: localizable("phone"), detailTitle: user?.userInfo?.mobile, value: false, textColor: UIColor.darkText, cellClass: TextWithDetailTextCell.self), UserItem( - title: localizable("邮箱"), + title: localizable("email"), detailTitle: user?.userInfo?.email, value: false, textColor: UIColor.darkText, cellClass: TextWithDetailTextCell.self ), UserItem( - title: localizable("个性签名"), + title: localizable("sign"), detailTitle: user?.userInfo?.sign, value: false, textColor: UIColor.darkText, cellClass: TextWithDetailTextCell.self ), ], - // UserItem(title: localizable("消息提醒"), detailTitle: "", value: false, textColor: UIColor.darkText, cellClass: TextWithSwitchCell.self) 隐藏消息提醒 + [UserItem( - title: localizable("加入黑名单"), + title: localizable("add_blackList"), detailTitle: "", value: isBlack, textColor: UIColor.darkText, cellClass: TextWithSwitchCell.self )], [ - UserItem(title: localizable("聊天"), detailTitle: "", value: false, + UserItem(title: localizable("chat"), detailTitle: "", value: false, textColor: UIColor(hexString: "#337EFF"), cellClass: CenterTextCell.self), UserItem( - title: localizable("删除好友"), + title: localizable("delete_friend"), detailTitle: "", value: false, textColor: UIColor.red, @@ -152,7 +152,7 @@ public class ContactUserViewController: ContactBaseViewController, UITableViewDe ] } else { data = [[UserItem( - title: localizable("添加好友"), + title: localizable("add_friend"), detailTitle: user?.alias, value: false, textColor: UIColor(hexString: "#337EFF"), @@ -194,9 +194,9 @@ public class ContactUserViewController: ContactBaseViewController, UITableViewDe c.switchButton.isOn = item.value c.block = { [weak self] title, value in print("title:\(title) value\(value)") - if title == localizable("加入黑名单") { + if title == localizable("add_blackList") { self?.blackList(isBlack: value) - } else if title == localizable("消息提醒") {} + } else if title == localizable("message_remind") {} } return c @@ -212,7 +212,7 @@ public class ContactUserViewController: ContactBaseViewController, UITableViewDe public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let item = data[indexPath.section][indexPath.row] - if item.title == localizable("备注名") { + if item.title == localizable("noteName") { toEditRemarks() } // if item.title == localizable("消息提醒") { @@ -221,13 +221,13 @@ public class ContactUserViewController: ContactBaseViewController, UITableViewDe // if item.title == localizable("加入黑名单") { // blackList(isBlack: item.value) // } - if item.title == localizable("聊天") { + if item.title == localizable("chat") { chat(user: user) } - if item.title == localizable("删除好友") { + if item.title == localizable("delete_friend") { deleteFriend(user: user) } - if item.title == localizable("添加好友") { + if item.title == localizable("add_friend") { addFriend() } } @@ -293,16 +293,22 @@ public class ContactUserViewController: ContactBaseViewController, UITableViewDe } func deleteFriend(user: User?) { - print("edit remarks") - if let userId = user?.userId { - viewModel.deleteFriend(account: userId) { error in - if error != nil { - self.showToast(error?.localizedDescription ?? "") - } else { - self.navigationController?.popViewController(animated: true) + showAlert( + title: localizable("sure_delte_friend"), + message: "", + sureText: localizable("alert_sure"), + cancelText: localizable("alert_cancel") + ) { [self] in + if let userId = user?.userId { + viewModel.deleteFriend(account: userId) { error in + if error != nil { + self.showToast(error?.localizedDescription ?? "") + } else { + self.navigationController?.popViewController(animated: true) + } } } - } + } cancelBack: {} } @objc func addFriend() { @@ -312,7 +318,7 @@ public class ContactUserViewController: ContactBaseViewController, UITableViewDe if let err = error { NELog.errorLog("ContactUserViewController", desc: "❌add friend failed :\(err)") } else { - weakSelf?.showToast("好友申请已发送") + weakSelf?.showToast(localizable("send_friend_apply")) } } } diff --git a/NEContactUIKit/NEKitContactUI/Classes/Validation/ViewController/ValidationMessageViewController.swift b/NEContactUIKit/NEKitContactUI/Classes/Validation/ViewController/ValidationMessageViewController.swift index 2f3cb736..fd2c614d 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/Validation/ViewController/ValidationMessageViewController.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/Validation/ViewController/ValidationMessageViewController.swift @@ -19,7 +19,7 @@ public class ValidationMessageViewController: ContactBaseViewController { super.viewDidLoad() // Do any additional setup after loading the view. - title = localizable("验证消息") + title = localizable("validation_message") // viewModel.getValidationMessage() setupUI() weak var weakSelf = self @@ -34,7 +34,7 @@ public class ValidationMessageViewController: ContactBaseViewController { func setupUI() { let clearItem = UIBarButtonItem( - title: "清空", + title: localizable("clear"), style: .done, target: self, action: #selector(clearMessage) @@ -63,7 +63,7 @@ public class ValidationMessageViewController: ContactBaseViewController { @objc func clearMessage() { weak var weakSelf = self - showAlert(message: "是否要清除所有验证消息?") { + showAlert(message: localizable("clear_all_validate_message")) { weakSelf?.viewModel.clearAllNoti { weakSelf?.tableView.reloadData() } diff --git a/NEContactUIKit/NEKitContactUI/Classes/Validation/Views/SystemNotificationCell.swift b/NEContactUIKit/NEKitContactUI/Classes/Validation/Views/SystemNotificationCell.swift index 11638cd3..4584497f 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/Validation/Views/SystemNotificationCell.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/Validation/Views/SystemNotificationCell.swift @@ -85,11 +85,11 @@ class SystemNotificationCell: BaseValidationCell { switch notifModel?.handleStatus { case .HandleTypeOk: - resultLabel.text = "已同意" + resultLabel.text = localizable("agreed") case .HandleTypeNo: - resultLabel.text = "已拒绝" + resultLabel.text = localizable("refused") case .HandleTypeOutOfDate: - resultLabel.text = "已过期" + resultLabel.text = localizable("expired") default: resultLabel.text = "" } @@ -137,7 +137,7 @@ class SystemNotificationCell: BaseValidationCell { var rejectBtn: ExpandButton = { let button = ExpandButton() button.translatesAutoresizingMaskIntoConstraints = false - button.setTitle("拒绝", for: .normal) + button.setTitle(localizable("refuse"), for: .normal) button.setTitleColor(UIColor(hexString: "333333"), for: .normal) button.titleLabel?.font = UIFont.systemFont(ofSize: 14.0) button.clipsToBounds = false @@ -150,7 +150,7 @@ class SystemNotificationCell: BaseValidationCell { var agreeBtn: ExpandButton = { let button = ExpandButton() button.translatesAutoresizingMaskIntoConstraints = false - button.setTitle("同意", for: .normal) + button.setTitle(localizable("agree"), for: .normal) let blue = UIColor(hexString: "337EFF") button.setTitleColor(blue, for: .normal) button.titleLabel?.font = UIFont.systemFont(ofSize: 14) diff --git a/NEContactUIKit/NEKitContactUI/Classes/Views/ContactsSelectedViewController.swift b/NEContactUIKit/NEKitContactUI/Classes/Views/ContactsSelectedViewController.swift index 3ed22f17..480c29bf 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/Views/ContactsSelectedViewController.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/Views/ContactsSelectedViewController.swift @@ -15,6 +15,9 @@ open class ContactsSelectedViewController: ContactBaseViewController { public var limit = 10 // max select count + // 单聊中对方的userId + public var userId: String? + var selectArray = [ContactInfo]() let selectDic = [String: ContactInfo]() lazy var collection: UICollectionView = { @@ -42,7 +45,7 @@ open class ContactsSelectedViewController: ContactBaseViewController { super.viewDidLoad() // Do any additional setup after loading the view. - title = "选择" + title = localizable("select") setupUI() setupNavRightItem() @@ -108,7 +111,7 @@ open class ContactsSelectedViewController: ContactBaseViewController { let rightItem = UIBarButtonItem(customView: sureBtn) navigationItem.rightBarButtonItem = rightItem sureBtn.addTarget(self, action: #selector(sureClick(_:)), for: .touchUpInside) - sureBtn.setTitle("确定", for: .normal) + sureBtn.setTitle(localizable("alert_sure"), for: .normal) sureBtn.setTitleColor(UIColor(hexString: "337EFF"), for: .normal) sureBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16.0) sureBtn.contentHorizontalAlignment = .right @@ -129,7 +132,7 @@ open class ContactsSelectedViewController: ContactBaseViewController { extension ContactsSelectedViewController { @objc func sureClick(_ sender: UIButton) { if selectArray.count <= 0 { - view.makeToast("请选择联系人") + view.makeToast(localizable("select_contact")) return } if let completion = callBack { @@ -153,6 +156,9 @@ extension ContactsSelectedViewController { } } + if let uid = userId { + accids.append(uid) + } let nameString = names.joined(separator: "、") print("name string : ", nameString) Router.shared.use( @@ -293,7 +299,7 @@ extension ContactsSelectedViewController: UICollectionViewDelegate, UICollection if selectArray.count > 0 { sureBtn.setTitle("确定(\(selectArray.count))", for: .normal) } else { - sureBtn.setTitle("确定", for: .normal) + sureBtn.setTitle(localizable("alert_sure"), for: .normal) } } } diff --git a/NEContactUIKit/NEKitContactUI/Classes/Views/ContactsViewController.swift b/NEContactUIKit/NEKitContactUI/Classes/Views/ContactsViewController.swift index e282266f..51f083d4 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/Views/ContactsViewController.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/Views/ContactsViewController.swift @@ -19,19 +19,19 @@ open class ContactsViewController: UIViewController, UITableViewDelegate, UITabl var tableView = UITableView(frame: .zero, style: .grouped) var viewModel = ContactViewModel(contactHeaders: [ ContactHeadItem( - name: "验证消息", + name: localizable("validation_message"), imageName: "valid", router: ValidationMessageRouter, color: UIColor(hexString: "#60CFA7") ), ContactHeadItem( - name: "黑名单", + name: localizable("blacklist"), imageName: "blackName", router: ContactBlackListRouter, color: UIColor(hexString: "#53C3F3") ), ContactHeadItem( - name: "我的群聊", + name: localizable("mine_groupchat"), imageName: "group", router: ContactGroupRouter, color: UIColor(hexString: "#BE65D9") diff --git a/NEContactUIKit/NEKitContactUI/Classes/Views/FindFriendViewController.swift b/NEContactUIKit/NEKitContactUI/Classes/Views/FindFriendViewController.swift index 606dbbb1..a8d02210 100644 --- a/NEContactUIKit/NEKitContactUI/Classes/Views/FindFriendViewController.swift +++ b/NEContactUIKit/NEKitContactUI/Classes/Views/FindFriendViewController.swift @@ -22,7 +22,7 @@ public class FindFriendViewController: ContactBaseViewController, UITextFieldDel lazy var userLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false - label.text = "该用户不存在" + label.text = localizable("user_not_exist") label.textColor = .ne_emptyTitleColor label.font = UIFont.systemFont(ofSize: 14.0) return label @@ -30,7 +30,7 @@ public class FindFriendViewController: ContactBaseViewController, UITextFieldDel override public func viewDidLoad() { super.viewDidLoad() - title = "添加好友" + title = localizable("add_friend") setupUI() } diff --git a/NEConversationUIKit/NEKitConversationUI.podspec b/NEConversationUIKit/NEKitConversationUI.podspec index e3a18ef4..c3bf309d 100644 --- a/NEConversationUIKit/NEKitConversationUI.podspec +++ b/NEConversationUIKit/NEKitConversationUI.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'NEKitConversationUI' - s.version = '9.2.7' + s.version = '9.2.8' s.summary = 'Netease XKit' # This description is used to generate tags and improve search results. @@ -22,7 +22,6 @@ TODO: Add long description of the pod here. DESC s.homepage = 'http://netease.im' - # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' s.license = { :'type' => 'Copyright', :'text' => ' Copyright 2022 Netease '} s.author = 'yunxin engineering department' s.source = { :git => 'ssh://git@g.hz.netease.com:22222/yunxin-app/xkit-ios.git', :tag => s.version.to_s } @@ -33,11 +32,11 @@ TODO: Add long description of the pod here. s.source_files = 'NEKitConversationUI/Classes/**/*' s.resource = 'NEKitConversationUI/Assets/**/*' # s.public_header_files = 'Pod/Classes/**/*.h' - s.pod_target_xcconfig = { - 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' - } + 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' + } s.user_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' } + s.dependency 'NECommonUIKit' s.dependency 'NEConversationKit' diff --git a/NEConversationUIKit/NEKitConversationUI/Assets/en.lproj/Localizable.strings b/NEConversationUIKit/NEKitConversationUI/Assets/en.lproj/Localizable.strings index eec66e03..c0dd9841 100644 --- a/NEConversationUIKit/NEKitConversationUI/Assets/en.lproj/Localizable.strings +++ b/NEConversationUIKit/NEKitConversationUI/Assets/en.lproj/Localizable.strings @@ -4,12 +4,31 @@ // found in the LICENSE file. //MAKR:common - -"add_friend"="添加好友"; -"create_discussion_group"="创建讨论组"; -"create_senior_group"="创建高级群"; - - +"add_friend"="Add Contacts"; +"create_discussion_group"="Create Temp Group"; +"create_senior_group"="Create Group"; +"cancel_stickTop"="Cancel topping"; +"stickTop"="Sticky on Top"; +"delete"="Cancel"; +"friend"="Contact"; +"discussion_group"="Temp Group"; +"senior_group"="Group"; +"search"="Search"; +"search_keyword"="Enter the key words"; +"user_not_exist"="Not Exist"; +"hm"="HH:mm"; +"mdhm"="MM.dd HH:mm"; +"ymdhm"="yyyy.MM.dd HH:mm"; +"voice"="[aduio]"; +"picture"="[picture]"; +"video"="[Video]"; +"location"="[Loaction]"; +"notification"="[Tip]"; +"file"="[File]"; +"internet_phone"="[Audio_Chat]"; +"video_chat"="[Video_Chat]"; +"unknown"="[Unknown Message]"; +"appName"="CommsEase IM"; diff --git a/NEConversationUIKit/NEKitConversationUI/Assets/zh-Hans.lproj/Localizable.strings b/NEConversationUIKit/NEKitConversationUI/Assets/zh-Hans.lproj/Localizable.strings index e2514171..bf369508 100644 --- a/NEConversationUIKit/NEKitConversationUI/Assets/zh-Hans.lproj/Localizable.strings +++ b/NEConversationUIKit/NEKitConversationUI/Assets/zh-Hans.lproj/Localizable.strings @@ -7,3 +7,25 @@ "add_friend"="添加好友"; "create_discussion_group"="创建讨论组"; "create_senior_group"="创建高级群"; +"cancel_stickTop"="取消置顶"; +"stickTop"="置顶"; +"delete"="删除"; +"friend"="好友"; +"discussion_group"="讨论组"; +"senior_group"="高级群"; +"search"="搜索"; +"search_keyword"="请输入你要搜索的关键字"; +"user_not_exist"="该用户不存在"; +"hm"="HH:mm"; +"mdhm"="MM月dd日 HH:mm"; +"ymdhm"="yyyy年MM月dd日 HH:mm"; +"voice"="[语音]"; +"picture"="[图片]"; +"video"="[视频]"; +"location"="[位置]"; +"notification"="[通知]"; +"file"="[文件]"; +"internet_phone"="[网络通话]"; +"video_chat"="[视频聊天]"; +"unknown"="[未知消息]"; +"appName"="云信IM"; diff --git a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/Controller/ConversationListViewController.swift b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/Controller/ConversationListViewController.swift index 63fe16ec..d17ca1c8 100644 --- a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/Controller/ConversationListViewController.swift +++ b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/Controller/ConversationListViewController.swift @@ -197,7 +197,7 @@ extension ConversationListViewController: UITableViewDelegate, UITableViewDataSo } let deleteAction = UITableViewRowAction(style: .destructive, - title: "删除") { action, indexPath in + title: localizable("delete")) { action, indexPath in weakSelf?.viewModel.deleteRecentSession(recentSession: recentSession) weakSelf?.didDeleteConversationCell( @@ -224,7 +224,8 @@ extension ConversationListViewController: UITableViewDelegate, UITableViewDataSo // 置顶和取消置顶 let isTop = viewModel.stickTopInfos[session] != nil let topAction = UITableViewRowAction(style: .destructive, - title: isTop ? "取消置顶" : "置顶") { action, indexPath in + title: isTop ? localizable("cancel_stickTop") : + localizable("stickTop")) { action, indexPath in if let recentSesstion = conversationModel?.recentSession { weakSelf?.onTopRecentAtIndexPath( rencent: recentSesstion, diff --git a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/Controller/ConversationSearchController.swift b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/Controller/ConversationSearchController.swift index 64a5ceb5..08769a95 100644 --- a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/Controller/ConversationSearchController.swift +++ b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/Controller/ConversationSearchController.swift @@ -53,11 +53,16 @@ open class SearchSessionHeaderView: UITableViewHeaderFooterView { }() } -public class ConversationSearchController: NEBaseViewController,UITableViewDelegate, UITableViewDataSource { +public class ConversationSearchController: NEBaseViewController, UITableViewDelegate, + UITableViewDataSource { private var viewModel = ConversationSearchViewModel() private let tag = "ConversationSearchController" private var searchStr = "" - private let headTitleArr = ["好友", "讨论组", "高级群"] + private let headTitleArr = [ + localizable("friend"), + localizable("discussion_group"), + localizable("senior_group"), + ] override public func viewDidLoad() { super.viewDidLoad() @@ -101,7 +106,7 @@ public class ConversationSearchController: NEBaseViewController,UITableViewDeleg } func initialConfig() { - title = "搜索" + title = localizable("search") } // MARK: private method @@ -170,7 +175,7 @@ public class ConversationSearchController: NEBaseViewController,UITableViewDeleg textField.contentMode = .center textField.leftView = leftImageView textField.leftViewMode = .always - textField.placeholder = localizable("搜索") + textField.placeholder = localizable("search") textField.font = UIFont.systemFont(ofSize: 14) textField.textColor = UIColor.ne_greyText textField.translatesAutoresizingMaskIntoConstraints = false @@ -179,112 +184,116 @@ public class ConversationSearchController: NEBaseViewController,UITableViewDeleg textField.clearButtonMode = .whileEditing textField.returnKeyType = .search textField.addTarget(self, action: #selector(searchTextFieldChange), for: .editingChanged) - textField.placeholder = "请输入你要搜索的关键字" + textField.placeholder = localizable("search_keyword") return textField }() private lazy var emptyView: NEEmptyDataView = { - let view = NEEmptyDataView(imageName: "user_empty", content: "该用户不存在", frame: CGRect.zero) + let view = NEEmptyDataView( + imageName: "user_empty", + content: localizable("user_not_exist"), + frame: CGRect.zero + ) view.translatesAutoresizingMaskIntoConstraints = false view.isHidden = true return view }() - - //MARK: UITableViewDelegate, UITableViewDataSource - public func numberOfSections(in tableView: UITableView) -> Int { - return 3 - } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if let friend = viewModel.searchResult?.friend, section == 0 { - return friend.count - } else if let contactGroup = viewModel.searchResult?.contactGroup, section == 1 { - return contactGroup.count - } else if let seniorGroup = viewModel.searchResult?.seniorGroup, section == 2 { - return seniorGroup.count - } else { - return 0 - } + // MARK: UITableViewDelegate, UITableViewDataSource + + public func numberOfSections(in tableView: UITableView) -> Int { + 3 + } + + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if let friend = viewModel.searchResult?.friend, section == 0 { + return friend.count + } else if let contactGroup = viewModel.searchResult?.contactGroup, section == 1 { + return contactGroup.count + } else if let seniorGroup = viewModel.searchResult?.seniorGroup, section == 2 { + return seniorGroup.count + } else { + return 0 } + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell( - withIdentifier: "\(NSStringFromClass(ConversationSearchCell.self))", - for: indexPath - ) as! ConversationSearchCell - if indexPath.section == 0 { - cell.searchModel = viewModel.searchResult?.friend[indexPath.row] - } else if indexPath.section == 1 { - cell.searchModel = viewModel.searchResult?.contactGroup[indexPath.row] - } else { - cell.searchModel = viewModel.searchResult?.seniorGroup[indexPath.row] - } - cell.searchText = searchStr - return cell + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell( + withIdentifier: "\(NSStringFromClass(ConversationSearchCell.self))", + for: indexPath + ) as! ConversationSearchCell + if indexPath.section == 0 { + cell.searchModel = viewModel.searchResult?.friend[indexPath.row] + } else if indexPath.section == 1 { + cell.searchModel = viewModel.searchResult?.contactGroup[indexPath.row] + } else { + cell.searchModel = viewModel.searchResult?.seniorGroup[indexPath.row] } + cell.searchText = searchStr + return cell + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.section == 0 { - let searchModel = viewModel.searchResult?.friend[indexPath.row] - if let userId = searchModel?.userInfo?.userId { - let session = NIMSession(userId, type: .P2P) - Router.shared.use( - PushP2pChatVCRouter, - parameters: ["nav": navigationController as Any, "session": session as Any], - closure: nil - ) - } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.section == 0 { + let searchModel = viewModel.searchResult?.friend[indexPath.row] + if let userId = searchModel?.userInfo?.userId { + let session = NIMSession(userId, type: .P2P) + Router.shared.use( + PushP2pChatVCRouter, + parameters: ["nav": navigationController as Any, "session": session as Any], + closure: nil + ) + } - } else if indexPath.section == 1 { - let searchModel = viewModel.searchResult?.contactGroup[indexPath.row] - if let teamId = searchModel?.teamInfo?.teamId { - let session = NIMSession(teamId, type: .team) - Router.shared.use( - PushTeamChatVCRouter, - parameters: ["nav": navigationController as Any, "session": session as Any], - closure: nil - ) - } - } else { - let searchModel = viewModel.searchResult?.seniorGroup[indexPath.row] - if let teamId = searchModel?.teamInfo?.teamId { - let session = NIMSession(teamId, type: .team) - Router.shared.use( - PushTeamChatVCRouter, - parameters: ["nav": navigationController as Any, "session": session as Any], - closure: nil - ) - } + } else if indexPath.section == 1 { + let searchModel = viewModel.searchResult?.contactGroup[indexPath.row] + if let teamId = searchModel?.teamInfo?.teamId { + let session = NIMSession(teamId, type: .team) + Router.shared.use( + PushTeamChatVCRouter, + parameters: ["nav": navigationController as Any, "session": session as Any], + closure: nil + ) + } + } else { + let searchModel = viewModel.searchResult?.seniorGroup[indexPath.row] + if let teamId = searchModel?.teamInfo?.teamId { + let session = NIMSession(teamId, type: .team) + Router.shared.use( + PushTeamChatVCRouter, + parameters: ["nav": navigationController as Any, "session": session as Any], + closure: nil + ) } } + } - public func tableView(_ tableView: UITableView, - viewForHeaderInSection section: Int) -> UIView? { - let sectionView = tableView - .dequeueReusableHeaderFooterView( - withIdentifier: "\(NSStringFromClass(SearchSessionHeaderView.self))" - ) as! SearchSessionHeaderView - sectionView.setUpTitle(title: headTitleArr[section]) - sectionView.backgroundView = UIView() - return sectionView - } + public func tableView(_ tableView: UITableView, + viewForHeaderInSection section: Int) -> UIView? { + let sectionView = tableView + .dequeueReusableHeaderFooterView( + withIdentifier: "\(NSStringFromClass(SearchSessionHeaderView.self))" + ) as! SearchSessionHeaderView + sectionView.setUpTitle(title: headTitleArr[section]) + sectionView.backgroundView = UIView() + return sectionView + } - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - if let friend = viewModel.searchResult?.friend, friend.count > 0, section == 0 { - return 30 - - } else if let contactGroup = viewModel.searchResult?.contactGroup, contactGroup.count > 0, - section == 1 { - return 30 - } else if let seniorGroup = viewModel.searchResult?.seniorGroup, seniorGroup.count > 0, - section == 2 { - return 30 - } else { - return 0 - } + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + if let friend = viewModel.searchResult?.friend, friend.count > 0, section == 0 { + return 30 + + } else if let contactGroup = viewModel.searchResult?.contactGroup, contactGroup.count > 0, + section == 1 { + return 30 + } else if let seniorGroup = viewModel.searchResult?.seniorGroup, seniorGroup.count > 0, + section == 2 { + return 30 + } else { + return 0 } + } } - diff --git a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/ConversationRouter/ConversationRouter.swift b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/ConversationRouter/ConversationRouter.swift index 31a1b4f2..6dcfd0c0 100644 --- a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/ConversationRouter/ConversationRouter.swift +++ b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/ConversationRouter/ConversationRouter.swift @@ -5,7 +5,9 @@ import Foundation -public enum ConversationRouter { +@objcMembers +public class ConversationRouter:NSObject { + public static func register() { Router.shared.register(SearchContactPageRouter) { param in let nav = param["nav"] as? UINavigationController @@ -19,4 +21,5 @@ public enum ConversationRouter { nav?.pushViewController(conversation, animated: true) } } + } diff --git a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/View/ConversationListCell.swift b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/View/ConversationListCell.swift index 41ed31be..1cc1bcb7 100644 --- a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/View/ConversationListCell.swift +++ b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/View/ConversationListCell.swift @@ -184,16 +184,16 @@ open class ConversationListCell: UITableViewCell { let fmt = DateFormatter() if targetDate.isToday() { - fmt.dateFormat = "HH:mm" + fmt.dateFormat = localizable("hm") return fmt.string(from: targetDate) } else { if targetDate.isThisYear() { - fmt.dateFormat = "MM月dd日 HH:mm" + fmt.dateFormat = localizable("mdhm") return fmt.string(from: targetDate) } else { - fmt.dateFormat = "yyyy年MM月dd日 HH:mm" + fmt.dateFormat = localizable("ymdhm") return fmt.string(from: targetDate) } } diff --git a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/View/ConversationNavView.swift b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/View/ConversationNavView.swift index e2492e0a..5af9686d 100644 --- a/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/View/ConversationNavView.swift +++ b/NEConversationUIKit/NEKitConversationUI/Classes/Conversation/View/ConversationNavView.swift @@ -81,7 +81,7 @@ class ConversationNavView: UIView { private lazy var brandBtn: UIButton = { let button = UIButton() - button.setTitle(localizable("云信IM"), for: .normal) + button.setTitle(localizable("appName"), for: .normal) button.setImage(UIImage.ne_imageNamed(name: "brand_yunxin"), for: .normal) button.layoutButtonImage(style: .left, space: 12) button.translatesAutoresizingMaskIntoConstraints = false diff --git a/NEConversationUIKit/NEKitConversationUI/Classes/Util/NEMessageUtil.swift b/NEConversationUIKit/NEKitConversationUI/Classes/Util/NEMessageUtil.swift index 0562b989..ece6b873 100644 --- a/NEConversationUIKit/NEKitConversationUI/Classes/Util/NEMessageUtil.swift +++ b/NEConversationUIKit/NEKitConversationUI/Classes/Util/NEMessageUtil.swift @@ -17,26 +17,27 @@ public class NEMessageUtil { text = messageText } case .audio: - text = "[语音]" + text = localizable("voice") case .image: - text = "[图片]" + text = localizable("picture") case .video: - text = "[视频]" + text = localizable("video") case .location: - text = "[位置]" + text = localizable("location") case .notification: - text = "[通知]" + text = localizable("notification") case .file: - text = "[文件]" + text = localizable("file") case .tip: if let messageText = message.text { text = messageText } case .rtcCallRecord: let record = message.messageObject as? NIMRtcCallRecordObject - text = (record?.callType == .audio) ? "[网络通话]" : "[视频聊天]" + text = (record?.callType == .audio) ? localizable("internet_phone") : + localizable("video_chat") default: - text = "[未知消息]" + text = localizable("unknown") } return text diff --git a/NEQChatUIKit/NEKitQChatUI.podspec b/NEQChatUIKit/NEKitQChatUI.podspec index 78f14b2e..00c61aac 100644 --- a/NEQChatUIKit/NEKitQChatUI.podspec +++ b/NEQChatUIKit/NEKitQChatUI.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'NEKitQChatUI' - s.version = '9.2.7' + s.version = '9.2.8' s.summary = 'Netease XKit' # This description is used to generate tags and improve search results. @@ -35,7 +35,6 @@ TODO: Add long description of the pod here. s.resource_bundles = { 'NEKitQChatUI' => ['NEKitQChatUI/Assets/*.png'] } - s.resource = 'NEKitQChatUI/Assets/**/*' s.dependency 'NECommonUIKit' s.dependency 'NEQChatKit' diff --git a/NEQChatUIKit/NEKitQChatUI/Assets/en.lproj/Localizable.strings b/NEQChatUIKit/NEKitQChatUI/Assets/en.lproj/Localizable.strings index 3f93e4d3..844efdbd 100644 --- a/NEQChatUIKit/NEKitQChatUI/Assets/en.lproj/Localizable.strings +++ b/NEQChatUIKit/NEKitQChatUI/Assets/en.lproj/Localizable.strings @@ -4,192 +4,163 @@ // found in the LICENSE file. //MAKR:common -"ok"="ok"; -"exceed"="超出"; -"person"="人"; -"limit"="限制"; +"ok"="Ok"; +"exceed"="Exceed"; +"person"="Member"; +"limit"="Limit"; + //MARK: Server -"qchat_setting"="服务器设置"; -"close"="关闭"; -"qchat_delete_server"="删除服务器"; -"qchat_leave_server"="退出服务器"; -"qchat_permisssion"="权限"; -"qchat_server_theme"="服务器主题"; -"qchat_server_name"="服务器名称"; -"qchat_id_group"="身份组"; -"qchat_group_default_permission"="所有服务器成员默认权限"; -"qchat_sort"="排序"; +"qchat_setting"="Server Settings"; +"qchat_delete_server"="Delete Server"; +"qchat_leave_server"="Exit Server"; +"qchat_permisssion"="Permission"; +"qchat_server_theme"="Server Theme"; +"qchat_server_name"="Server Name"; +"qchat_id_group"="Role"; +"qchat_group_default_permission"="Default Permission for everyone"; +"qchat_sort"="sort"; +"qchat_create_new_id_group"="Create new Role"; +"qchat_group_name"="Role Name"; +"qchat_manager_member"="Role management"; +"qchat_edit"="Edit"; +"qchat_save"="Save"; +"qchat_nickname"="Nick Name"; +"qcaht_edit_nickname"="Edit Nick Name"; +"qchat_kick_out"="Kick out"; +"qchat_prohibit"="Prohibit"; +"qchat_manager_server"="Manage Server"; +"qchat_manager_channel"="Manage all cannel info"; +"qchat_manager_role"="Manage Role"; +"qchat_send_message"="Send Message"; +"qchat_delete_message"="Delete other's message in Server"; +"qchat_recall_message"="Recall other's message in Server"; +"qchat_at_any"="@ anyone"; +"qchat_at_all"="@ everyone"; +"qchat_modify_own_server"="Edit my info in Server"; +"qchat_modify_other_server"="Edit other's Server info"; +"qchat_invite_member"="Invite Permission"; +"qchat_kickout_member"="Kick out"; +"qchat_manager_channel_list"="Manage channel members"; +"qchat_common_permission"="Common Permission"; +"qchat_message_permission"="Message Permission"; +"qchat_member_permission"="Member Permission"; +"qchat_member"="Member"; +"qchat_id_group_sort"="Role Sort"; +"qchat_sure"="Ok"; +"qchat_cancel"="cancel"; +"qchat_tip"="Tip"; +"qchat_select"="Select"; +"qchat_please_input_topic"="Please enter the theme"; +"qchat_not_empty_servername"="Please Name the server"; +"qchat_not_empty_header_url"="Please upload Avator"; +"qchat_not_empty_select_memeber"="Please Select member"; +"qchat_please_input_role_name"="Please set the role name"; +"qchat_sure_delete_user"="wether to delete this member"; +"qchat_delete_success"="Delete successfully"; +"qchat_add_success"="Add successfully"; +"qchat_add_Server"="create Server"; +"qchat_mine_add"="create"; +"qchat_join_otherServer"="Join other Server"; -"qchat_create_new_id_group"="创建新身份组"; -"qchat_add_member"="添加成员"; -"qchat_group_name"="身份组名称"; -"qchat_manager_member"="成员管理"; -"qchat_edit"="编辑"; -"qchat_save"="保存"; -"qchat_nickname"="昵称"; -"qcaht_edit_nickname"="编辑昵称"; -"qchat_kick_out"="踢除"; -"qchat_prohibit"="封禁"; -"qchat_manager_server"="管理服务器"; -"qchat_manager_channel"="管理所有频道属性"; -"qchat_manager_role"="管理角色"; -"qchat_send_message"="发送消息"; -"qchat_delete_message"="所有频道中删除他人消息"; -"qchat_recall_message"="所有频道撤回他人消息"; -"qchat_at_any"="@任意人的权限"; -"qchat_at_all"="@所有人的权限"; -"qchat_modify_own_server"="修改自己服务器成员信息"; -"qchat_modify_other_server"="修改他人服务器成员信息"; -"qchat_invite_member"="邀请他人进入server权限"; -"qchat_kickout_member"="踢人"; -"qchat_manager_channel_list"="管理频道名单"; -"qchat_common_permission"="通用权限"; -"qchat_message_permission"="消息权限"; -"qchat_member_permission"="成员权限"; -"qchat_member"="成员"; -"qchat_id_group_sort"="身份组排序"; -"qchat_sure"="确定"; -"qchat_cancel"="取消"; -"qchat_tip"="提示"; -"qchat_select"="选择"; -"qchat_please_input_topic"="请输入主题"; -"qchat_not_empty_servername"="服务器名不能为空"; -"qchat_not_empty_header_url"="请先上传头像"; -"qchat_not_empty_select_memeber"="请选择用户"; -"qchat_please_input_role_name"="请输入身份组名称"; -"qchat_sure_delete_user"="确定删除当前用户?"; -"qchat_delete_success"="删除成功"; -"qchat_add_success"="添加成功"; -"qchat_add_Server"="创建服务器"; -"qchat_mine_add"="自己创建"; -"qchat_join_otherServer"="加入别人服务器"; +//MARK: Channel +"create_channel"="Create New Channel"; +"delete_channel"="Delete Channel"; +"confirm_delete_channel"="Sure to Remove ?"; + +"create"="Creat"; +"cancel"="Cancel"; +"channel_name"="Channel Name"; +"channel_topic"="Channel Theme"; +"channel_type"="Channel Type"; +"input_channel_name"="Enter Name"; +"input_channel_topic"="Enter Theme"; +"public"="Public"; +"private"="Private"; +"online"="Online"; +"offline"="Offline"; +"first_channel"="Channel 1"; +"second_channel"="channel 2"; +"more"="More"; +"has_no_role"="No more role"; +"send_to"="Send to"; +"image_is_nil"= "No picture"; -////MARK: Channel -//"create_channel"="Create Channel"; -//"delete_channel"="Delete Channel"; -//"confirm_delete_channel"="Would you like to delete "; -// -//"create"="Create"; -//"cancel"="Cancel"; -//"channel_name"="Channel Name"; -//"channel_topic"="Channel Topic"; -//"channel_type"="Channel Type"; -//"input_channel_name"="Please enter name of channel"; -//"input_channel_topic"="Please enter topic of channel"; -//"public"="Public"; -//"private"="Private"; -//"online"="Online"; -//"offline"="Offline"; -//"first_channel"="频道1"; -//"second_channel"="频道2"; -// -//"more"="more"; -// -// -////MARK:toast -//"update_channel_suscess"="Update Channel Suscess"; -//"delete_channel_suscess"="Delete Channel Suscess"; -// -// -////MARK: channel_setting -//"channel_setting"="Setting"; -//"save_setting"="Save"; -//"close"="Close"; -//"authority"="Authority"; -//"authority_setting"="Authority setting"; -//"list"="List"; -//"white_list"="White List"; -//"black_list"="Black List"; -//"channel_member"="Members"; -//"delete_channel"="Delete Channel"; -//"authority_setting"="Authority Setting"; -// -//"add_group"="Add Authority Group"; -//"add_member"="Add Member"; -//"member_permission_setting"="Member Permission Setting"; -//"group_permission_setting"="Permission Setting"; -//"finish"="Finished"; -//"removeMember"="Remove Member"; -//MARK: Channel -"create_channel"="创建新频道"; -"delete_channel"="删除频道"; -"confirm_delete_channel"="确认要移除"; -"create"="创建"; -"cancel"="取消"; -"channel_name"="频道名称"; -"channel_topic"="频道主题"; -"channel_type"="频道类型"; -"input_channel_name"="请输入名称"; -"input_channel_topic"="请输入主题"; -"public"="公开"; -"private"="私密"; -"online"="在线"; -"offline"="离线"; -"first_channel"="频道1"; -"second_channel"="频道2"; -"more"="更多"; -"has_no_role"="无身份组可添加"; -"send_to"="发送给"; -"image_is_nil"= "图片为空"; -"text_is_nil"="内容为空"; //MARK:toast -"update_channel_suscess"="保存成功"; -"delete_channel_suscess"="删除成功"; -"open_soon"="暂未开放"; - +"update_channel_suscess"="Save Successfully"; +"delete_channel_suscess"="Delete Successfully"; +"open_soon"="Not Open"; //MARK: channel_setting -"channel_setting"="频道设置"; -"save"="保存"; -"close"="关闭"; -"authority"="权限"; -"authority_setting"="权限设置"; -"list"="名单"; -"white_list"="白名单"; -"black_list"="黑名单"; -"channel_member"="频道成员"; -"delete_channel"="删除频道"; -"authority_setting"="权限设置"; +"channel_setting"="Channel Setting"; +"save"="Save"; +"close"="Close"; +"authority"="Permission"; +"authority_setting"="Permission Setting"; +"list"="List"; +"white_list"="whitelist"; +"black_list"="blacklist"; +"channel_member"="Channel Member"; +"delete_channel"="Delete Channel"; + +"add_group"="Add Role"; +"add_member"="Add member"; +"member_permission_setting"="Member Permission Setting"; +"finish"="Finish"; +"removeMember"="Remove Memebr"; +"removeRole"="Remove Role"; -"add_group"="添加身份组"; -"add_member"="添加成员"; -"member_permission_setting"="成员权限设置"; -"group_permission_setting"="权限设置"; -"finish"="完成"; -"removeMember"="移除成员"; -"removeRole"="移除身份组"; //MARK:身份组权限设置 "auth1"="ManageServer"; -"auth2"="管理频道属性"; -"auth3"="管理频道权限"; -"auth4"="发送消息"; +"auth2"="Manage Channel Info"; +"auth3"="Manage Channel Permission"; +"auth4"="Send Message"; "auth5"="ModifySelfInfo"; "auth6"="InviteToServer"; "auth7"="KickOthersInServer"; "auth8"="ModifyOthersInfoInServer"; -"auth9"="频道中撤回他人消息"; -"auth10"="频道中删除他人消息"; +"auth9"="Recall other's Message"; +"auth10"="Delete other's Message"; "auth11"="RemindOther"; "auth12"="RemindAll"; -"auth13"="管理频道名单"; +"auth13"="Manage Channel Memeber"; + +//supplement +"delete"="delete"; +"share_thoughts"="Share Thoughts"; +"noMember_add"="No member to add"; +"search_serverId"="Search ServerID"; +"no_serverId"="Not Found"; +"know"="ok"; +"upload_headImage"="Upload Avator"; +"enter_serverName"="Please enter server name"; +"request_sended"="invit sent"; +"message_channel"="Message Channel"; +"server_nochannel"="No Channel"; +"applied"="Applied"; +"join"="Join"; +"modify_nickname"="Click to edit nick name"; +"sure_exit_server"="wether to exit server?"; +"sure_delete_server"="wether to delete server?"; +"serverId_notbe_empty"="Cannot be empty "; +"enter_name"="Enter Name"; +"kick_currentMember"="Wether to kick out this member?"; +"sure_delete"=" Wether to delete?"; +"current_identity"="Current Identity Group"; +"hm"="HH:mm"; +"mdhm"="MM.dd HH:mm"; +"ymdhm"="yyyy.MM.dd HH:mm"; //MARK:error toast "param_error"="Parameter error"; -"no_Permession"="暂无权限在该频道发言"; - - - - - - - - - - - - - - +"no_Permession"="No permission to send message"; +"channelName_cannot_be_empty"="Cannot be empty"; +"network_error"="No internet"; +"cant_join"="Cannot join?"; +"blocked_from_server_cant_join"="You are blocked by this server and cannot join"; +"serverName_limit"="Cannot exceed 50 characters"; +"add_favorite_service"="No Server, Let's join or create one"; +"nickName_not_empty"="Cannot be empty "; +"accid_not_empty"="Cannot be empty"; diff --git a/NEQChatUIKit/NEKitQChatUI/Assets/zh-Hans.lproj/Localizable.strings b/NEQChatUIKit/NEKitQChatUI/Assets/zh-Hans.lproj/Localizable.strings index 76f672f2..05b5e4a9 100644 --- a/NEQChatUIKit/NEKitQChatUI/Assets/zh-Hans.lproj/Localizable.strings +++ b/NEQChatUIKit/NEKitQChatUI/Assets/zh-Hans.lproj/Localizable.strings @@ -21,7 +21,6 @@ "qchat_group_default_permission"="所有服务器成员默认权限"; "qchat_sort"="排序"; "qchat_create_new_id_group"="创建新身份组"; -"qchat_add_member"="添加成员"; "qchat_group_name"="身份组名称"; "qchat_manager_member"="成员管理"; "qchat_edit"="编辑"; @@ -86,7 +85,7 @@ "has_no_role"="无身份组可添加"; "send_to"="发送给"; "image_is_nil"= "图片为空"; -"text_is_nil"="内容为空"; + //MARK:toast @@ -105,12 +104,12 @@ "black_list"="黑名单"; "channel_member"="频道成员"; "delete_channel"="删除频道"; -"authority_setting"="权限设置"; + "add_group"="添加身份组"; "add_member"="添加成员"; "member_permission_setting"="成员权限设置"; -"group_permission_setting"="权限设置"; + "finish"="完成"; "removeMember"="移除成员"; "removeRole"="移除身份组"; @@ -130,7 +129,40 @@ "auth12"="RemindAll"; "auth13"="管理频道名单"; +//supplement +"delete"="删除"; +"share_thoughts"="分享心得"; +"noMember_add"="无成员可添加"; +"search_serverId"="搜索服务器ID"; +"no_serverId"="暂无你要的服务器ID"; +"know"="知道了"; +"upload_headImage"="上传头像"; +"enter_serverName"=" 请输入服务器名称"; +"request_sended"="请求已发送"; +"message_channel"="消息频道"; +"server_nochannel"="该服务器下暂无频道"; +"applied"="已申请"; +"join"="加入"; +"modify_nickname"="请点击编辑后修改昵称"; +"sure_exit_server"="确定退出当前服务器?"; +"sure_delete_server"="确定删除当前服务器?"; +"serverId_notbe_empty"="服务器id不能为空"; +"enter_name"="输入名称"; +"kick_currentMember"="确定踢出当前成员?"; +"sure_delete"="确定删除"; +"current_identity"="当前身份组"; +"hm"="HH:mm"; +"mdhm"="MM月dd日 HH:mm"; +"ymdhm"="yyyy年MM月dd日 HH:mm"; + //MARK:error toast "param_error"="Parameter error"; "no_Permession"="暂无权限在该频道发言"; - +"channelName_cannot_be_empty"="频道名称不能为空"; +"network_error"="当前网络错误"; +"cant_join"="无法加入?"; +"blocked_from_server_cant_join"="你被该服务器封禁,无法加入。"; +"serverName_limit"="服务器命名不超过50个字符"; +"add_favorite_service"="暂无服务器,\n赶紧去添加心仪的服务器吧"; +"nickName_not_empty"="昵称不能为空"; +"accid_not_empty"="accid 不能为空"; diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Base/BaseView/QChatImageTextCell.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Base/BaseView/QChatImageTextCell.swift index bbd832b0..914d115d 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Base/BaseView/QChatImageTextCell.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Base/BaseView/QChatImageTextCell.swift @@ -67,7 +67,6 @@ class QChatImageTextCell: QChatStateCell { name.textColor = .white name.textAlignment = .center name.font = UIFont.systemFont(ofSize: 14.0) - name.text = "果冻" return name }() diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Base/BaseView/QChatTextCell.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Base/BaseView/QChatTextCell.swift index 731a2465..baf04109 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Base/BaseView/QChatTextCell.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Base/BaseView/QChatTextCell.swift @@ -31,7 +31,7 @@ class QChatTextCell: QChatStateCell { titleLabel.topAnchor.constraint(equalTo: contentView.topAnchor), titleLabel.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), ]) - titleLabel.text = "删除" + titleLabel.text = localizable("delete") detailLabel.font = UIFont.systemFont(ofSize: 16) detailLabel.translatesAutoresizingMaskIntoConstraints = false diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/ChannelHeaderView.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/ChannelHeaderView.swift index c0125df6..a9a39a57 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/ChannelHeaderView.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/ChannelHeaderView.swift @@ -27,7 +27,7 @@ class ChannelHeaderView: UIView { titleLabel.font = .systemFont(ofSize: 18) titleLabel.textColor = .ne_darkText - titleLabel.text = "频道1" + titleLabel.text = localizable("first_channel") titleLabel.translatesAutoresizingMaskIntoConstraints = false addSubview(titleLabel) NSLayoutConstraint.activate([ @@ -39,7 +39,7 @@ class ChannelHeaderView: UIView { detailLabel.textColor = .ne_greyText detailLabel.font = .systemFont(ofSize: 14) - detailLabel.text = "分享心得" + detailLabel.text = localizable("share_thoughts") detailLabel.translatesAutoresizingMaskIntoConstraints = false addSubview(detailLabel) NSLayoutConstraint.activate([ diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/QChatPermissionSettingCell.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/QChatPermissionSettingCell.swift index 976fb3f5..c8b9a430 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/QChatPermissionSettingCell.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/QChatPermissionSettingCell.swift @@ -45,7 +45,7 @@ class QChatPermissionSettingCell: QChatCornerCell { titleLabel.font = UIFont.systemFont(ofSize: 16) titleLabel.translatesAutoresizingMaskIntoConstraints = false titleLabel.textColor = .ne_darkText - titleLabel.text = "删除" + titleLabel.text = localizable("delete") contentView.addSubview(titleLabel) NSLayoutConstraint.activate([ titleLabel.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 35), diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/QChatTextEditCell.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/QChatTextEditCell.swift index 588a376b..341ae5a0 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/QChatTextEditCell.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/View/QChatTextEditCell.swift @@ -5,13 +5,12 @@ import UIKit -@objc protocol QChatTextEditCellDelegate:AnyObject { +@objc protocol QChatTextEditCellDelegate: AnyObject { // @objc optional func textFieldDidChangeSelection(cell: QChatTextEditCell, // _ textField: UITextField) @objc optional func textDidChange(_ textField: UITextField) } - class QChatTextEditCell: QChatCornerCell, UITextFieldDelegate { var limit: Int? var canEdit = true diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatAddMemberVC.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatAddMemberVC.swift index d1a23325..1191cc8a 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatAddMemberVC.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatAddMemberVC.swift @@ -219,7 +219,7 @@ public class QChatAddMemberVC: QChatSearchVC { private lazy var emptyView: EmptyDataView = { let view = EmptyDataView( imageName: "memberPlaceholder", - content: "无成员可添加", + content: localizable("noMember_add"), frame: CGRect( x: 0, y: 60, diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatChannelMembersVC.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatChannelMembersVC.swift index 4f250781..e7c96d1a 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatChannelMembersVC.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatChannelMembersVC.swift @@ -168,7 +168,7 @@ public class QChatChannelMembersVC: QChatTableViewController, QChatMemberInfoVie func didClickUserHeader(_ accid: String?) { if let uid = accid { - if IMKitLoginManager.instance.isMySelf(uid) { + if IMKitEngine.instance.isMySelf(uid) { Router.shared.use( MeSettingRouter, parameters: ["nav": navigationController as Any], diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatChannelViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatChannelViewController.swift index fcea1056..cbac7902 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatChannelViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatChannelViewController.swift @@ -143,12 +143,11 @@ public class QChatChannelViewController: QChatTableViewController, QChatTextEdit // MARK: event @objc func createChannel() { - - guard let name = viewModel?.name,name.count > 0 else { - self.showToast("频道名称不能为空") - return - } - + guard let name = viewModel?.name, name.count > 0 else { + showToast(localizable("channelName_cannot_be_empty")) + return + } + if !isCreatedChannel { isCreatedChannel = true viewModel?.createChannel { error, channel in diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatWhiteBlackListVC.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatWhiteBlackListVC.swift index b9824d1c..20842dce 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatWhiteBlackListVC.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Channel/ViewController/QChatWhiteBlackListVC.swift @@ -73,7 +73,7 @@ public class QChatWhiteBlackListVC: QChatTableViewController, QChatMemberSelectC ) as! QChatTextCell cell.backgroundColor = .white cell.rightStyle = .indicate - cell.titleLabel.text = localizable("qchat_add_member") + cell.titleLabel.text = localizable("add_member") return cell } else { let cell = tableView.dequeueReusableCell( @@ -87,7 +87,7 @@ public class QChatWhiteBlackListVC: QChatTableViewController, QChatMemberSelectC // if CoreKitEngine.instance.imAccid == member?.accid, self.type == .white { // cell.rightStyle = .none // } - if IMKitLoginManager.instance.imAccid == member?.accid, type == .white { + if IMKitEngine.instance.imAccid == member?.accid, type == .white { cell.rightStyle = .none } return cell @@ -103,7 +103,6 @@ public class QChatWhiteBlackListVC: QChatTableViewController, QChatMemberSelectC memberSelect.delegate = self memberSelect.completion = { [weak self] datas in // 选中成员 - print("选中成员:datas:\(datas)") if datas.count > 0 { var seletedMembers = [ServerMemeber]() for data in datas { @@ -135,7 +134,7 @@ public class QChatWhiteBlackListVC: QChatTableViewController, QChatMemberSelectC // return // } - if IMKitLoginManager.instance.imAccid == member.accid, type == .white { + if IMKitEngine.instance.imAccid == member.accid, type == .white { return } diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Chat/Controller/QChatViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Chat/Controller/QChatViewController.swift index 1a1284a1..0d11dd7f 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Chat/Controller/QChatViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Chat/Controller/QChatViewController.swift @@ -13,7 +13,7 @@ import NEKitCommon import NEKitCore public class QChatViewController: NEBaseViewController, UINavigationControllerDelegate, - QChatInputViewDelegate, QChatViewModelDelegate,UITableViewDataSource, UITableViewDelegate { + QChatInputViewDelegate, QChatViewModelDelegate, UITableViewDataSource, UITableViewDelegate { private let tag = "QChatViewController" private var viewmodel: QChatViewModel? private var inputViewBottomConstraint: NSLayoutConstraint? @@ -62,169 +62,169 @@ public class QChatViewController: NEBaseViewController, UINavigationControllerDe deinit { NELog.infoLog(className(), desc: "✅ QChatViewController release") } - - func commonUI() { - title = viewmodel?.channel?.name - addLeftAction(UIImage.ne_imageNamed(name: "server_menu"), #selector(enterServerVC), self) - addRightAction( - UIImage.ne_imageNamed(name: "channel_member"), - #selector(enterChannelMemberVC), - self - ) - view.addSubview(tableView) + func commonUI() { + title = viewmodel?.channel?.name + addLeftAction(UIImage.ne_imageNamed(name: "server_menu"), #selector(enterServerVC), self) + addRightAction( + UIImage.ne_imageNamed(name: "channel_member"), + #selector(enterChannelMemberVC), + self + ) + + view.addSubview(tableView) + NSLayoutConstraint.activate([ + tableView.topAnchor.constraint( + equalTo: view.topAnchor, + constant: kNavigationHeight + KStatusBarHeight + ), + tableView.leftAnchor.constraint(equalTo: view.leftAnchor), + tableView.rightAnchor.constraint(equalTo: view.rightAnchor), + tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -130), + ]) + + tableView.register( + QChatBaseTableViewCell.self, + forCellReuseIdentifier: "\(QChatBaseTableViewCell.self)" + ) + tableView.register( + QChatTextTableViewCell.self, + forCellReuseIdentifier: "\(QChatTextTableViewCell.self)" + ) + tableView.register( + QChatImageTableViewCell.self, + forCellReuseIdentifier: "\(QChatImageTableViewCell.self)" + ) + tableView.register( + QChatTimeTableViewCell.self, + forCellReuseIdentifier: "\(QChatTimeTableViewCell.self)" + ) + + // IQKeyboardManager.shared.enable = false + IQKeyboardManager.shared.keyboardDistanceFromTextField = 60 + IQKeyboardManager.shared.enable = true + IQKeyboardManager.shared.enableAutoToolbar = false + let inputView = QChatInputView() + var tip = localizable("send_to") + if let cName = viewmodel?.channel?.name { + tip = tip + cName + } + inputView.textField.placeholder = tip + + inputView.translatesAutoresizingMaskIntoConstraints = false + inputView.delegate = self + view.addSubview(inputView) + if #available(iOS 11.0, *) { + self.inputViewBottomConstraint = inputView.bottomAnchor + .constraint(equalTo: self.view.bottomAnchor) + // self.inputViewBottomConstraint = inputView.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor) NSLayoutConstraint.activate([ - tableView.topAnchor.constraint( - equalTo: view.topAnchor, - constant: kNavigationHeight + KStatusBarHeight - ), - tableView.leftAnchor.constraint(equalTo: view.leftAnchor), - tableView.rightAnchor.constraint(equalTo: view.rightAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -130), + inputView.leftAnchor.constraint(equalTo: self.view.leftAnchor), + inputView.rightAnchor.constraint(equalTo: self.view.rightAnchor), + inputView.heightAnchor.constraint(equalToConstant: 100), ]) + } else { + // Fallback on earlier versions + inputViewBottomConstraint = inputView.bottomAnchor + .constraint(equalTo: view.bottomAnchor) + NSLayoutConstraint.activate([ + inputView.leftAnchor.constraint(equalTo: view.leftAnchor), + inputView.rightAnchor.constraint(equalTo: view.rightAnchor), + inputView.heightAnchor.constraint(equalToConstant: 100), + ]) + } + inputViewBottomConstraint?.isActive = true - tableView.register( - QChatBaseTableViewCell.self, - forCellReuseIdentifier: "\(QChatBaseTableViewCell.self)" - ) - tableView.register( - QChatTextTableViewCell.self, - forCellReuseIdentifier: "\(QChatTextTableViewCell.self)" - ) - tableView.register( - QChatImageTableViewCell.self, - forCellReuseIdentifier: "\(QChatImageTableViewCell.self)" - ) - tableView.register( - QChatTimeTableViewCell.self, - forCellReuseIdentifier: "\(QChatTimeTableViewCell.self)" - ) - - // IQKeyboardManager.shared.enable = false - IQKeyboardManager.shared.keyboardDistanceFromTextField = 60 - IQKeyboardManager.shared.enable = true - IQKeyboardManager.shared.enableAutoToolbar = false - let inputView = QChatInputView() - var tip = localizable("send_to") - if let cName = viewmodel?.channel?.name { - tip = tip + cName - } - inputView.textField.placeholder = tip - - inputView.translatesAutoresizingMaskIntoConstraints = false - inputView.delegate = self - view.addSubview(inputView) - if #available(iOS 11.0, *) { - self.inputViewBottomConstraint = inputView.bottomAnchor - .constraint(equalTo: self.view.bottomAnchor) - // self.inputViewBottomConstraint = inputView.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor) - NSLayoutConstraint.activate([ - inputView.leftAnchor.constraint(equalTo: self.view.leftAnchor), - inputView.rightAnchor.constraint(equalTo: self.view.rightAnchor), - inputView.heightAnchor.constraint(equalToConstant: 100), - ]) + weak var weakSelf = self + NEChatDetectNetworkTool.shareInstance.netWorkReachability { status in + if status == .notReachable, let networkView = weakSelf?.brokenNetworkView { + weakSelf?.view.addSubview(networkView) } else { - // Fallback on earlier versions - inputViewBottomConstraint = inputView.bottomAnchor - .constraint(equalTo: view.bottomAnchor) - NSLayoutConstraint.activate([ - inputView.leftAnchor.constraint(equalTo: view.leftAnchor), - inputView.rightAnchor.constraint(equalTo: view.rightAnchor), - inputView.heightAnchor.constraint(equalToConstant: 100), - ]) - } - inputViewBottomConstraint?.isActive = true - - weak var weakSelf = self - NEChatDetectNetworkTool.shareInstance.netWorkReachability { status in - if status == .notReachable, let networkView = weakSelf?.brokenNetworkView { - weakSelf?.view.addSubview(networkView) - } else { - weakSelf?.brokenNetworkView.removeFromSuperview() - } + weakSelf?.brokenNetworkView.removeFromSuperview() } } + } // MARK: event - @objc func enterChannelMemberVC() { - let memberVC = QChatChannelMembersVC() - memberVC.channel = viewmodel?.channel - navigationController?.pushViewController(memberVC, animated: true) - } + @objc func enterChannelMemberVC() { + let memberVC = QChatChannelMembersVC() + memberVC.channel = viewmodel?.channel + navigationController?.pushViewController(memberVC, animated: true) + } - @objc func enterServerVC() { - navigationController?.popViewController(animated: true) - } + @objc func enterServerVC() { + navigationController?.popViewController(animated: true) + } - func loadData() { - weak var weakSelf = self - viewmodel?.getMessageHistory { error, messages in - - if let err = error { - NELog.errorLog(self.tag, desc: "❌getMessageHistory error, error:\(err)") - } else { - if let tempArray = weakSelf?.viewmodel?.messages, tempArray.count > 0 { - weakSelf?.tableView.reloadData() - weakSelf?.tableView.scrollToRow( - at: IndexPath(row: tempArray.count - 1, section: 0), - at: .bottom, - animated: false - ) - if let time = messages?.first?.message?.timestamp { - weakSelf?.viewmodel?.markMessageRead(time: time) - } + func loadData() { + weak var weakSelf = self + viewmodel?.getMessageHistory { error, messages in + + if let err = error { + NELog.errorLog(self.tag, desc: "❌getMessageHistory error, error:\(err)") + } else { + if let tempArray = weakSelf?.viewmodel?.messages, tempArray.count > 0 { + weakSelf?.tableView.reloadData() + weakSelf?.tableView.scrollToRow( + at: IndexPath(row: tempArray.count - 1, section: 0), + at: .bottom, + animated: false + ) + if let time = messages?.first?.message?.timestamp { + weakSelf?.viewmodel?.markMessageRead(time: time) } } } } + } - @objc func loadMoreData() { - weak var weakSelf = self - viewmodel?.getMoreMessageHistory { error, messageFrames in - weakSelf?.tableView.reloadData() - weakSelf?.tableView.mj_header?.endRefreshing() - } + @objc func loadMoreData() { + weak var weakSelf = self + viewmodel?.getMoreMessageHistory { error, messageFrames in + weakSelf?.tableView.reloadData() + weakSelf?.tableView.mj_header?.endRefreshing() } + } - func addObseve() { - NotificationCenter.default.addObserver( - self, - selector: #selector(onUpdateChannel), - name: NotificationName.updateChannel, - object: nil - ) - NotificationCenter.default.addObserver( - self, - selector: #selector(onDeleteChannel), - name: NotificationName.deleteChannel, - object: nil - ) - // NotificationCenter.default.addObserver(self, - // selector: #selector(keyBoardWillShow(_ :)), - // name: UIResponder.keyboardWillShowNotification, - // object: nil) - // - // NotificationCenter.default.addObserver(self, - // selector: #selector(keyBoardWillHide(_ :)), - // name: UIResponder.keyboardWillHideNotification, - // object: nil) - } + func addObseve() { + NotificationCenter.default.addObserver( + self, + selector: #selector(onUpdateChannel), + name: NotificationName.updateChannel, + object: nil + ) + NotificationCenter.default.addObserver( + self, + selector: #selector(onDeleteChannel), + name: NotificationName.deleteChannel, + object: nil + ) + // NotificationCenter.default.addObserver(self, + // selector: #selector(keyBoardWillShow(_ :)), + // name: UIResponder.keyboardWillShowNotification, + // object: nil) + // + // NotificationCenter.default.addObserver(self, + // selector: #selector(keyBoardWillHide(_ :)), + // name: UIResponder.keyboardWillHideNotification, + // object: nil) + } - @objc func onUpdateChannel(noti: Notification) { - // enter ChatVC - guard let channel = noti.object as? ChatChannel else { - return - } - viewmodel?.channel = channel - title = viewmodel?.channel?.name + @objc func onUpdateChannel(noti: Notification) { + // enter ChatVC + guard let channel = noti.object as? ChatChannel else { + return } + viewmodel?.channel = channel + title = viewmodel?.channel?.name + } - @objc func onDeleteChannel(noti: Notification) { - navigationController?.popToRootViewController(animated: true) - } + @objc func onDeleteChannel(noti: Notification) { + navigationController?.popToRootViewController(animated: true) + } - // MARK: 键盘通知相关操作 + // MARK: 键盘通知相关操作 // @objc func keyBoardWillShow(_ notification:Notification) { // let keyboardRect = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue @@ -241,144 +241,143 @@ public class QChatViewController: NEBaseViewController, UINavigationControllerDe // }) // } - // MARK: QChatInputViewDelegate - - func sendText(text: String?) { - NELog.infoLog(tag, desc: "sendText:\(text ?? "")") - guard let content = text, content.count > 0 else { - showToast(localizable("text_is_nil")) + // MARK: QChatInputViewDelegate - return - } - viewmodel?.sendTextMessage(text: content) { [weak self] error in - if error != nil { - self?.view.makeToast(error?.localizedDescription) - } else {} - } + func sendText(text: String?) { + NELog.infoLog(tag, desc: "sendText:\(text ?? "")") + guard let content = text, content.count > 0 else { + return + } + viewmodel?.sendTextMessage(text: content) { [weak self] error in + if error != nil { + self?.view.makeToast(error?.localizedDescription) + } else {} } + } - func willSelectItem(button: UIButton, index: Int) { - if index == 2 { - showBottomAlert(self, false) - } else { - showToast(localizable("open_soon")) - } + func willSelectItem(button: UIButton, index: Int) { + if index == 2 { + showBottomAlert(self, false) + } else { + showToast(localizable("open_soon")) } + } // MARK: UIImagePickerControllerDelegate - public func imagePickerController(_ picker: UIImagePickerController, - didFinishPickingMediaWithInfo info: [UIImagePickerController - .InfoKey: Any]) { - picker.dismiss(animated: true, completion: nil) - guard let image = info[.originalImage] as? UIImage else { - showToast(localizable("image_is_nil")) - return - } - // 发送消息 - viewmodel?.sendImageMessage(image: image) { [weak self] error in - if error != nil { - self?.view.makeToast(error?.localizedDescription) - } + public func imagePickerController(_ picker: UIImagePickerController, + didFinishPickingMediaWithInfo info: [UIImagePickerController + .InfoKey: Any]) { + picker.dismiss(animated: true, completion: nil) + guard let image = info[.originalImage] as? UIImage else { + showToast(localizable("image_is_nil")) + return + } + // 发送消息 + viewmodel?.sendImageMessage(image: image) { [weak self] error in + if error != nil { + self?.view.makeToast(error?.localizedDescription) } } + } // MARK: QChatViewModelDelegate - public func onRecvMessages(_ messages: [NIMQChatMessage]) { - tableView.reloadData() - if let messageCount = viewmodel?.messages.count, messageCount > 1 { - tableView.scrollToRow( - at: IndexPath(row: messageCount - 1, section: 0), - at: .bottom, - animated: false - ) - if let time = viewmodel?.messages.last?.message?.timestamp { - viewmodel?.markMessageRead(time: time) - } + public func onRecvMessages(_ messages: [NIMQChatMessage]) { + tableView.reloadData() + if let messageCount = viewmodel?.messages.count, messageCount > 1 { + tableView.scrollToRow( + at: IndexPath(row: messageCount - 1, section: 0), + at: .bottom, + animated: false + ) + if let time = viewmodel?.messages.last?.message?.timestamp { + viewmodel?.markMessageRead(time: time) } } + } - public func send(_ message: NIMQChatMessage, progress: Float) {} + public func send(_ message: NIMQChatMessage, progress: Float) {} - public func send(_ message: NIMQChatMessage, didCompleteWithError error: Error?) { - if let e = error as NSError? { - if e.code == 403 { - showAlert(message: localizable("no_Permession")) {} - } - } - tableView.reloadData() - if let messageCount = viewmodel?.messages.count, messageCount > 1 { - tableView.scrollToRow( - at: IndexPath(row: messageCount - 1, section: 0), - at: .bottom, - animated: false - ) + public func send(_ message: NIMQChatMessage, didCompleteWithError error: Error?) { + if let e = error as NSError? { + if e.code == 403 { + showAlert(message: localizable("no_Permession")) {} } } - - public func willSend(_ message: NIMQChatMessage) { - tableView.reloadData() - if let messageCount = viewmodel?.messages.count, messageCount > 1 { - tableView.scrollToRow( - at: IndexPath(row: messageCount - 1, section: 0), - at: .bottom, - animated: false - ) - } + tableView.reloadData() + if let messageCount = viewmodel?.messages.count, messageCount > 1 { + tableView.scrollToRow( + at: IndexPath(row: messageCount - 1, section: 0), + at: .bottom, + animated: false + ) } - - //MARK: UITableViewDataSource, UITableViewDelegate - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - viewmodel?.messages.count ?? 0 + } + + public func willSend(_ message: NIMQChatMessage) { + tableView.reloadData() + if let messageCount = viewmodel?.messages.count, messageCount > 1 { + tableView.scrollToRow( + at: IndexPath(row: messageCount - 1, section: 0), + at: .bottom, + animated: false + ) } + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let messageFrame = viewmodel?.messages[indexPath.row] - var reuseIdentifier = "\(QChatBaseTableViewCell.self)" + // MARK: UITableViewDataSource, UITableViewDelegate - guard let msgFrame = messageFrame else { - return tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) - } + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + viewmodel?.messages.count ?? 0 + } - if msgFrame.showTime { - reuseIdentifier = "\(QChatTimeTableViewCell.self)" - } else { - // 根据cell类型区分identify - switch msgFrame.message?.messageType { - case .text: - reuseIdentifier = "\(QChatTextTableViewCell.self)" - case .image: - reuseIdentifier = "\(QChatImageTableViewCell.self)" - default: - reuseIdentifier = "\(QChatBaseTableViewCell.self)" - } - } + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let messageFrame = viewmodel?.messages[indexPath.row] + var reuseIdentifier = "\(QChatBaseTableViewCell.self)" - if msgFrame.showTime { - let cell = tableView.dequeueReusableCell( - withIdentifier: reuseIdentifier, - for: indexPath - ) as! QChatTimeTableViewCell - cell.messageFrame = messageFrame - return cell - } else { - let cell = tableView.dequeueReusableCell( - withIdentifier: reuseIdentifier, - for: indexPath - ) as! QChatBaseTableViewCell - cell.messageFrame = messageFrame - cell.delegate = self - return cell + guard let msgFrame = messageFrame else { + return tableView.dequeueReusableCell(withIdentifier: reuseIdentifier, for: indexPath) + } + + if msgFrame.showTime { + reuseIdentifier = "\(QChatTimeTableViewCell.self)" + } else { + // 根据cell类型区分identify + switch msgFrame.message?.messageType { + case .text: + reuseIdentifier = "\(QChatTextTableViewCell.self)" + case .image: + reuseIdentifier = "\(QChatImageTableViewCell.self)" + default: + reuseIdentifier = "\(QChatBaseTableViewCell.self)" } } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - let messageFrame = viewmodel?.messages[indexPath.row] - return messageFrame?.cellHeight ?? 0 + if msgFrame.showTime { + let cell = tableView.dequeueReusableCell( + withIdentifier: reuseIdentifier, + for: indexPath + ) as! QChatTimeTableViewCell + cell.messageFrame = messageFrame + return cell + } else { + let cell = tableView.dequeueReusableCell( + withIdentifier: reuseIdentifier, + for: indexPath + ) as! QChatBaseTableViewCell + cell.messageFrame = messageFrame + cell.delegate = self + return cell } + } + + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + let messageFrame = viewmodel?.messages[indexPath.row] + return messageFrame?.cellHeight ?? 0 + } } // MARK: =============== QChatBaseCellDelegate ================ @@ -392,7 +391,7 @@ extension QChatViewController: QChatBaseCellDelegate { } func didClickHeader(_ message: NIMQChatMessage) { - if IMKitLoginManager.instance.isMySelf(message.from) == true { + if IMKitEngine.instance.isMySelf(message.from) == true { Router.shared.use( MeSettingRouter, parameters: ["nav": navigationController as Any], @@ -420,4 +419,3 @@ extension QChatViewController: QChatBaseCellDelegate { } else if messgae.messageType == .audio {} } } - diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Chat/ViewModel/QChatViewModel.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Chat/ViewModel/QChatViewModel.swift index 846fd9e0..825ee0ea 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Chat/ViewModel/QChatViewModel.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Chat/ViewModel/QChatViewModel.swift @@ -34,7 +34,7 @@ public class QChatViewModel: NSObject, NIMQChatMessageManagerDelegate { if let cid = channel?.channelId, let sid = channel?.serverId { let message = NIMQChatMessage() message.text = text - message.from = IMKitLoginManager.instance.imAccid + message.from = IMKitEngine.instance.imAccid QChatSystemMessageProvider.shared.sendMessage( message: message, session: NIMSession(forQChat: Int64(cid), qchatServerId: Int64(sid)) @@ -49,7 +49,7 @@ public class QChatViewModel: NSObject, NIMQChatMessageManagerDelegate { if let cid = channel?.channelId, let sid = channel?.serverId { let message = NIMQChatMessage() message.messageObject = NIMImageObject(image: image) - message.from = IMKitLoginManager.instance.imAccid + message.from = IMKitEngine.instance.imAccid QChatSystemMessageProvider.shared.sendMessage( message: message, session: NIMSession(forQChat: Int64(cid), qchatServerId: Int64(sid)) diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Extension/QChatStringExtension.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Extension/QChatStringExtension.swift index f8d0a42e..e2801047 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Extension/QChatStringExtension.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Extension/QChatStringExtension.swift @@ -18,17 +18,17 @@ extension String { static func stringFromDate(date: Date) -> String { let fmt = DateFormatter() if Calendar.current.isDateInToday(date) { - fmt.dateFormat = "HH:mm" + fmt.dateFormat = localizable("hm") } else { if let firstDayYear = firstDayInYear() { let dur = date.timeIntervalSince(firstDayYear) if dur > 0 { - fmt.dateFormat = "MM月dd日 HH:mm" + fmt.dateFormat = localizable("mdhm") } else { - fmt.dateFormat = "yyyy年MM月dd日 HH:mm" + fmt.dateFormat = localizable("ymdhm") } } else { - fmt.dateFormat = "yyyy年MM月dd日 HH:mm" + fmt.dateFormat = localizable("ymdhm") } } return fmt.string(from: date) diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/CreateServerViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/CreateServerViewController.swift index 99b4ad8c..dc0b4968 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/CreateServerViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/CreateServerViewController.swift @@ -5,7 +5,8 @@ import UIKit -public class CreateServerViewController: NEBaseViewController,UITableViewDelegate, UITableViewDataSource { +public class CreateServerViewController: NEBaseViewController, UITableViewDelegate, + UITableViewDataSource { public var serverViewModel = CreateServerViewModel() override public func viewDidLoad() { @@ -46,44 +47,40 @@ public class CreateServerViewController: NEBaseViewController,UITableViewDelegat tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 0.1)) return tableView }() - - @objc func closeAction(sender: UIButton) { - navigationController?.dismiss(animated: true, completion: nil) - } - - - //MARK: UITableViewDelegate, UITableViewDataSource - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - serverViewModel.dataArray.count - } - - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell( - withIdentifier: "\(NSStringFromClass(NECreateServerCell.self))", - for: indexPath - ) as! NECreateServerCell - let model = serverViewModel.dataArray[indexPath.row] - cell.model = model - return cell - } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.row == 0 { - let mineCreateCtrl = MineCreateServerController() - navigationController?.pushViewController(mineCreateCtrl, animated: true) - } else if indexPath.row == 1 { - let otherCtrl = JoinOtherServiceController() - navigationController?.pushViewController(otherCtrl, animated: true) - } - } + @objc func closeAction(sender: UIButton) { + navigationController?.dismiss(animated: true, completion: nil) + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - 76 - } -} + // MARK: UITableViewDelegate, UITableViewDataSource + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + serverViewModel.dataArray.count + } + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell( + withIdentifier: "\(NSStringFromClass(NECreateServerCell.self))", + for: indexPath + ) as! NECreateServerCell + let model = serverViewModel.dataArray[indexPath.row] + cell.model = model + return cell + } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.row == 0 { + let mineCreateCtrl = MineCreateServerController() + navigationController?.pushViewController(mineCreateCtrl, animated: true) + } else if indexPath.row == 1 { + let otherCtrl = JoinOtherServiceController() + navigationController?.pushViewController(otherCtrl, animated: true) + } + } + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + 76 + } +} diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/JoinOtherServiceController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/JoinOtherServiceController.swift index 9fd1c86d..5438b0d6 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/JoinOtherServiceController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/JoinOtherServiceController.swift @@ -9,7 +9,8 @@ import NEKitCoreIM import NEKitCommon import IQKeyboardManagerSwift -public class JoinOtherServiceController: NEBaseViewController,UITableViewDelegate, UITableViewDataSource { +public class JoinOtherServiceController: NEBaseViewController, UITableViewDelegate, + UITableViewDataSource { private let tag = "JoinOtherServiceController" public var serversArray = [QChatServer]() public var serverViewModel = CreateServerViewModel() @@ -65,7 +66,7 @@ public class JoinOtherServiceController: NEBaseViewController,UITableViewDelegat textField.contentMode = .center textField.leftView = leftImageView textField.leftViewMode = .always - textField.placeholder = localizable("搜索服务器ID") + textField.placeholder = localizable("search_serverId") textField.font = DefaultTextFont(14) textField.textColor = TextNormalColor textField.translatesAutoresizingMaskIntoConstraints = false @@ -95,99 +96,99 @@ public class JoinOtherServiceController: NEBaseViewController,UITableViewDelegat private lazy var emptyView: EmptyDataView = { let view = EmptyDataView( imageName: "searchServer_noMoreData", - content: "暂无你要的服务器ID", + content: localizable("no_serverId"), frame: tableView.bounds ) return view }() - - @objc func searchTextFieldChange(textfield: SearchTextField) { - // 选择高亮文本在进行搜索 - // let textRange = textfield.markedTextRange - // if textRange == nil || ((textRange?.isEmpty) == nil) { - // print("111") - // } - - if !NEChatDetectNetworkTool.shareInstance.isNetworkRecahability() { - showToast("当前网络错误") - return - } - guard let content = textfield.text else { - return - } - // 空字符串判断 - if content.isBlank { - emptyView.removeFromSuperview() - return - } + @objc func searchTextFieldChange(textfield: SearchTextField) { + // 选择高亮文本在进行搜索 + // let textRange = textfield.markedTextRange + // if textRange == nil || ((textRange?.isEmpty) == nil) { + // print("111") + // } + + if !NEChatDetectNetworkTool.shareInstance.isNetworkRecahability() { + showToast(localizable("network_error")) + return + } - let param = QChatGetServersParam(serverIds: [NSNumber(value: UInt64(content)!)]) - serverViewModel.getServers(parameter: param) { error, serversArray in - if error == nil { - self.serversArray = serversArray?.servers ?? Array() - if self.serversArray.isEmpty { - self.tableView.addSubview(self.emptyView) - return - } else { - self.emptyView.removeFromSuperview() - } - self.tableView.reloadData() + guard let content = textfield.text else { + return + } + // 空字符串判断 + if content.isBlank { + emptyView.removeFromSuperview() + return + } + + let param = QChatGetServersParam(serverIds: [NSNumber(value: UInt64(content)!)]) + serverViewModel.getServers(parameter: param) { error, serversArray in + if error == nil { + self.serversArray = serversArray?.servers ?? Array() + if self.serversArray.isEmpty { + self.tableView.addSubview(self.emptyView) + return } else { - NELog.errorLog(self.tag, desc: "❌getServers failed,error = \(error!)") + self.emptyView.removeFromSuperview() } + self.tableView.reloadData() + } else { + NELog.errorLog(self.tag, desc: "❌getServers failed,error = \(error!)") } } - - // MARK: UITableViewDelegate UITableViewDataSource - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - serversArray.count - } + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell( - withIdentifier: "\(NSStringFromClass(NESearchServerCell.self))", - for: indexPath - ) as! NESearchServerCell - cell.serverModel = serversArray[indexPath.row] - weak var weakSelf = self - cell.joinServerCallBack = { - let successView = - InviteMemberView(frame: CGRect(x: (kScreenWidth - 176) / 2, y: KStatusBarHeight, - width: 176, height: 55)) - successView.showSuccessView() - } - return cell + // MARK: UITableViewDelegate UITableViewDataSource + + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + serversArray.count + } + + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell( + withIdentifier: "\(NSStringFromClass(NESearchServerCell.self))", + for: indexPath + ) as! NESearchServerCell + cell.serverModel = serversArray[indexPath.row] + weak var weakSelf = self + cell.joinServerCallBack = { + let successView = + InviteMemberView(frame: CGRect(x: (kScreenWidth - 176) / 2, y: KStatusBarHeight, + width: 176, height: 55)) + successView.showSuccessView() } + return cell + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - guard let serverId = serversArray[indexPath.row].serverId else { return } - let param = QChatGetChannelsByPageParam(timeTag: 0, serverId: serverId) - weak var weakSelf = self - channelViewModel.getChannelsByPage(parameter: param) { error, result in - if error == nil { - guard let dataArray = result?.channels else { return } - let chatVC = QChatViewController(channel: dataArray.first) - weakSelf?.navigationController?.pushViewController(chatVC, animated: true) - } else { - print("getChannelsByPage failed,error = \(error!)") - } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + guard let serverId = serversArray[indexPath.row].serverId else { return } + let param = QChatGetChannelsByPageParam(timeTag: 0, serverId: serverId) + weak var weakSelf = self + channelViewModel.getChannelsByPage(parameter: param) { error, result in + if error == nil { + guard let dataArray = result?.channels else { return } + let chatVC = QChatViewController(channel: dataArray.first) + weakSelf?.navigationController?.pushViewController(chatVC, animated: true) + } else { + print("getChannelsByPage failed,error = \(error!)") } } + } } - // MARK: private Method extension JoinOtherServiceController { func showAlert() { let alertCtrl = UIAlertController( - title: localizable("无法加入?"), - message: localizable("你被该服务器封禁,无法加入。"), + title: localizable("cant_join"), + message: localizable("blocked_from_server_cant_join"), preferredStyle: .alert ) - let okAction = UIAlertAction(title: localizable("知道了"), style: .default, handler: nil) + let okAction = UIAlertAction(title: localizable("know"), style: .default, handler: nil) alertCtrl.addAction(okAction) present(alertCtrl, animated: true, completion: nil) } diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/MemberListViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/MemberListViewController.swift index d5ccf03d..d403f482 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/MemberListViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/MemberListViewController.swift @@ -6,7 +6,8 @@ import UIKit import NEKitCoreIM import NEKitCore -public class MemberListViewController: NEBaseViewController,UITableViewDelegate, UITableViewDataSource { +public class MemberListViewController: NEBaseViewController, UITableViewDelegate, + UITableViewDataSource { public var serverViewModel = CreateServerViewModel() public var memberViewModel = MemberListViewModel() @@ -37,7 +38,7 @@ public class MemberListViewController: NEBaseViewController,UITableViewDelegate, } func initializeConfig() { - title = "成员" + title = localizable("qchat_member") addRightAction(UIImage.ne_imageNamed(name: "sign_add"), #selector(addMemberClick), self) } @@ -67,78 +68,76 @@ public class MemberListViewController: NEBaseViewController,UITableViewDelegate, tableView.estimatedRowHeight = 125 return tableView }() - - //MAKR: UITableViewDelegate, UITableViewDataSource - @objc func addMemberClick(sender: UIButton) { - Router.shared.register(ContactSelectedUsersRouter) { [weak self] param in - print("param\(param)") - if let userIds = param["accids"] as? [String] { - print("userIds:\(userIds)") - guard let serverId = self?.serverId else { return } - self?.serverViewModel - .inviteMembersToServer(serverId: serverId, accids: userIds) { error in - if error == nil { - self?.requestData() - } + + // MAKR: UITableViewDelegate, UITableViewDataSource + @objc func addMemberClick(sender: UIButton) { + Router.shared.register(ContactSelectedUsersRouter) { [weak self] param in + print("param\(param)") + if let userIds = param["accids"] as? [String] { + print("userIds:\(userIds)") + guard let serverId = self?.serverId else { return } + self?.serverViewModel + .inviteMembersToServer(serverId: serverId, accids: userIds) { error in + if error == nil { + self?.requestData() } - } + } } + } - Router.shared - .use(ContactUserSelectRouter, - parameters: ["nav": navigationController]) { obj, routerState, str in - print("obj:\(obj) routerState:\(routerState) str:\(str)") - } + Router.shared + .use(ContactUserSelectRouter, + parameters: ["nav": navigationController]) { obj, routerState, str in + print("obj:\(obj) routerState:\(routerState) str:\(str)") + } - // FIXME: router - // let contactCtrl = ContactsSelectedViewController() - // self.navigationController?.pushViewController(contactCtrl, animated: true) - // weak var weakSelf = self - // - // contactCtrl.callBack = {(selectMemberarray)->Void in - // - // guard let serverId = weakSelf?.serverId else { return } - // var accidArray = [String]() - // selectMemberarray.forEach { memberInfo in - // accidArray.append(memberInfo.user?.userId ?? "") - // } - // weakSelf?.serverViewModel.inviteMembersToServer(serverId: serverId, accids: accidArray) { error in - // if error == nil{ - // weakSelf?.requestData() - // } - // } - // } - } + // FIXME: router + // let contactCtrl = ContactsSelectedViewController() + // self.navigationController?.pushViewController(contactCtrl, animated: true) + // weak var weakSelf = self + // + // contactCtrl.callBack = {(selectMemberarray)->Void in + // + // guard let serverId = weakSelf?.serverId else { return } + // var accidArray = [String]() + // selectMemberarray.forEach { memberInfo in + // accidArray.append(memberInfo.user?.userId ?? "") + // } + // weakSelf?.serverViewModel.inviteMembersToServer(serverId: serverId, accids: accidArray) { error in + // if error == nil{ + // weakSelf?.requestData() + // } + // } + // } + } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - dataArray?.count ?? 0 - } + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + dataArray?.count ?? 0 + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell( - withIdentifier: "\(NSStringFromClass(NEGroupIdentityMemberCell.self))", - for: indexPath - ) as! NEGroupIdentityMemberCell - cell.memberModel = dataArray?[indexPath.row] - return cell - } + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell( + withIdentifier: "\(NSStringFromClass(NEGroupIdentityMemberCell.self))", + for: indexPath + ) as! NEGroupIdentityMemberCell + cell.memberModel = dataArray?[indexPath.row] + return cell + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - // let user = viewModel.limitUsers[indexPath.row] - if let member = dataArray?[indexPath.row] { - let editMember = QChatEditMemberViewController() - editMember.deleteCompletion = { - self.requestData() - } - editMember.changeCompletion = { - self.requestData() - } - let user = UserInfo(member) - editMember.user = user - navigationController?.pushViewController(editMember, animated: true) + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + // let user = viewModel.limitUsers[indexPath.row] + if let member = dataArray?[indexPath.row] { + let editMember = QChatEditMemberViewController() + editMember.deleteCompletion = { + self.requestData() + } + editMember.changeCompletion = { + self.requestData() } + let user = UserInfo(member) + editMember.user = user + navigationController?.pushViewController(editMember, animated: true) } + } } - - diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/MineCreateServerController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/MineCreateServerController.swift index c1169132..b774e8b1 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/MineCreateServerController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/MineCreateServerController.swift @@ -9,7 +9,8 @@ import NEKitCoreIM import NIMSDK import NEKitCommon -public class MineCreateServerController: NEBaseViewController, UINavigationControllerDelegate,UITextFieldDelegate { +public class MineCreateServerController: NEBaseViewController, UINavigationControllerDelegate, + UITextFieldDelegate { private let tag = "MineCreateServerController" public var serverViewModel = CreateServerViewModel() var headImageUrl: String? @@ -108,7 +109,7 @@ public class MineCreateServerController: NEBaseViewController, UINavigationContr private lazy var uploadDesLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false - label.text = localizable("上传头像") + label.text = localizable("upload_headImage") label.textColor = HexRGB(0x656A72) label.font = DefaultTextFont(12) return label @@ -117,7 +118,7 @@ public class MineCreateServerController: NEBaseViewController, UINavigationContr private lazy var textField: UITextField = { let textField = UITextField() textField.setValue(NSNumber(value: 10), forKey: "paddingLeft") - textField.placeholder = localizable(" 请输入服务器名称") + textField.placeholder = localizable("enter_serverName") textField.font = DefaultTextFont(16) textField.textColor = TextNormalColor textField.translatesAutoresizingMaskIntoConstraints = false @@ -140,102 +141,101 @@ public class MineCreateServerController: NEBaseViewController, UINavigationContr button.addTarget(self, action: #selector(createServerBtnClick), for: .touchUpInside) return button }() - - - @objc func createServerBtnClick(sender: UIButton) { - guard let serverName = textField.text, serverName.count > 0 else { return } - if NEChatDetectNetworkTool.shareInstance.isNetworkRecahability() { - sender.isEnabled = false - } else { - showToast("当前网络错误") - return - } + @objc func createServerBtnClick(sender: UIButton) { + guard let serverName = textField.text, serverName.count > 0 else { return } + + if NEChatDetectNetworkTool.shareInstance.isNetworkRecahability() { + sender.isEnabled = false + } else { + showToast(localizable("network_error")) + return + } - let param = CreateServerParam(name: textField.text!, icon: headImageUrl ?? "") - serverViewModel.createServer(parameter: param) { error, result in + let param = CreateServerParam(name: textField.text!, icon: headImageUrl ?? "") + serverViewModel.createServer(parameter: param) { error, result in - if error != nil { - NELog.errorLog(self.tag, desc: "❌createServer failed,error = \(error!)") + if error != nil { + NELog.errorLog(self.tag, desc: "❌createServer failed,error = \(error!)") + } else { + // 创建服务器成功后,默认创建好两个频道 + if let serverId = result?.server?.serverId { + NotificationCenter.default.post( + name: NotificationName.createServer, + object: serverId + ) + self.navigationController?.dismiss(animated: true, completion: nil) } else { - // 创建服务器成功后,默认创建好两个频道 - if let serverId = result?.server?.serverId { - NotificationCenter.default.post( - name: NotificationName.createServer, - object: serverId - ) - self.navigationController?.dismiss(animated: true, completion: nil) - } else { - print("serverId is nil") - return - } + print("serverId is nil") + return } } - // 应对wifi切换4G请求没有回调的处理结果 - DispatchQueue.main.asyncAfter(deadline: .now() + 1) { - sender.isEnabled = true - } } - - //MARK : UITextFieldDelegate - public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, - replacementString string: String) -> Bool { - let text = "\(textField.text ?? "")\(string)" - if text.count > 50 { - showToast("服务器命名不超过50个字符") - return false - } - - return true + // 应对wifi切换4G请求没有回调的处理结果 + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + sender.isEnabled = true } + } - // Upload the picture - @objc func uploadBgViewClick(sender: UIButton) { - showBottomAlert(self) - } + // MARK: UITextFieldDelegate - @objc func textContentChanged() { - if textField.text?.count != 0 { - bottomBtn.isEnabled = true - bottomBtn.backgroundColor = HexRGB(0x337EFF) - } else { - bottomBtn.isEnabled = false - bottomBtn.backgroundColor = HexRGBAlpha(0x337EFF, 0.5) - } + public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, + replacementString string: String) -> Bool { + let text = "\(textField.text ?? "")\(string)" + if text.count > 50 { + showToast(localizable("serverName_limit")) + return false } - // MARK: UIImagePickerControllerDelegate + return true + } + + // Upload the picture + @objc func uploadBgViewClick(sender: UIButton) { + showBottomAlert(self) + } - func imagePickerController(_ picker: UIImagePickerController, - didFinishPickingMediaWithInfo info: [UIImagePickerController - .InfoKey: Any]) { - let image: UIImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage - uploadHeadImage(image: image) - dismiss(animated: true, completion: nil) + @objc func textContentChanged() { + if textField.text?.count != 0 { + bottomBtn.isEnabled = true + bottomBtn.backgroundColor = HexRGB(0x337EFF) + } else { + bottomBtn.isEnabled = false + bottomBtn.backgroundColor = HexRGBAlpha(0x337EFF, 0.5) } + } + + // MARK: UIImagePickerControllerDelegate - public func uploadHeadImage(image: UIImage) { - view.makeToastActivity(.center) - if let imageData = image.jpegData(compressionQuality: 0.6) as NSData? { - let filePath = NSHomeDirectory().appending("/Documents/") - .appending(IMKitLoginManager.instance.imAccid) - let succcess = imageData.write(toFile: filePath, atomically: true) - - if succcess { - NIMSDK.shared().resourceManager - .upload(filePath, progress: nil) { urlString, error in - if error == nil { - // 显示设置的照片 - self.selectHeadImage.image = image - self.headImageUrl = urlString - print("upload image success") - } else { - print("upload image failed,error = \(error!)") - } - self.view.hideToastActivity() + func imagePickerController(_ picker: UIImagePickerController, + didFinishPickingMediaWithInfo info: [UIImagePickerController + .InfoKey: Any]) { + let image: UIImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage + uploadHeadImage(image: image) + dismiss(animated: true, completion: nil) + } + + public func uploadHeadImage(image: UIImage) { + view.makeToastActivity(.center) + if let imageData = image.jpegData(compressionQuality: 0.6) as NSData? { + let filePath = NSHomeDirectory().appending("/Documents/") + .appending(IMKitEngine.instance.imAccid) + let succcess = imageData.write(toFile: filePath, atomically: true) + + if succcess { + NIMSDK.shared().resourceManager + .upload(filePath, progress: nil) { urlString, error in + if error == nil { + // 显示设置的照片 + self.selectHeadImage.image = image + self.headImageUrl = urlString + print("upload image success") + } else { + print("upload image failed,error = \(error!)") } - } + self.view.hideToastActivity() + } } } + } } - diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/QChatHomeViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/QChatHomeViewController.swift index 87ce1cef..c1b20546 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/QChatHomeViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/Controller/QChatHomeViewController.swift @@ -143,7 +143,6 @@ public class QChatHomeViewController: UIViewController, ViewModelDelegate { weak var weakSelf = self view.viewmodel = serverViewModel view.setUpBlock = { () in - print("设置服务器") if weakSelf?.serverListArray.count == 0 { return } @@ -315,8 +314,8 @@ extension QChatHomeViewController: NIMQChatMessageManagerDelegate { self.channelChange(notificationInfo: systemNotification) case .serverMemberKick, .serverMemberInviteDone: - if systemNotification.fromAccount != IMKitLoginManager.instance.imAccid, - (systemNotification.toAccids?.contains(IMKitLoginManager.instance.imAccid)) != + if systemNotification.fromAccount != IMKitEngine.instance.imAccid, + (systemNotification.toAccids?.contains(IMKitEngine.instance.imAccid)) != nil { self.requestData(timeTag: 0) } @@ -326,7 +325,7 @@ extension QChatHomeViewController: NIMQChatMessageManagerDelegate { selectIndex = 0 self.requestData(timeTag: 0) } else { - if systemNotification.fromAccount == IMKitLoginManager.instance.imAccid { + if systemNotification.fromAccount == IMKitEngine.instance.imAccid { selectIndex = 0 self.requestData(timeTag: 0) } diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/InviteMemberView.swift b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/InviteMemberView.swift index 17def387..9795bead 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/InviteMemberView.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/InviteMemberView.swift @@ -46,7 +46,7 @@ class InviteMemberView: UIView { private lazy var content: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false - label.text = localizable("请求已发送") + label.text = localizable("request_sended") label.font = DefaultTextFont(16) label.textColor = UIColor.ne_darkText return label diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/NEHomeChannelView.swift b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/NEHomeChannelView.swift index 3d7987c9..cd32fda3 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/NEHomeChannelView.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/NEHomeChannelView.swift @@ -113,7 +113,7 @@ class NEHomeChannelView: UIView { } case .updateChannelCategoryBlackWhiteRole: if noticeInfo.serverId == qchatServerModel?.serverId, - (noticeInfo.toAccids?.contains(IMKitLoginManager.instance.imAccid)) != nil { + (noticeInfo.toAccids?.contains(IMKitEngine.instance.imAccid)) != nil { requestData(timeTag: 0) } @@ -151,7 +151,7 @@ class NEHomeChannelView: UIView { private lazy var subTitleLable: UILabel = { let title = UILabel() title.translatesAutoresizingMaskIntoConstraints = false - title.text = "消息频道" + title.text = localizable("message_channel") title.textColor = PlaceholderTextColor title.font = DefaultTextFont(14) return title @@ -189,7 +189,7 @@ class NEHomeChannelView: UIView { private lazy var emptyView: EmptyDataView = { let view = EmptyDataView( imageName: "channel_noMoreData", - content: "该服务器下暂无频道", + content: localizable("server_nochannel"), frame: tableView.bounds ) view.translatesAutoresizingMaskIntoConstraints = false @@ -231,7 +231,7 @@ extension NEHomeChannelView { self.channelArray.removeAll() self.channelArray = dataArray if dataArray.isEmpty { - emptyView.setttingContent(content: "该服务器下暂无频道") + emptyView.setttingContent(content: localizable("server_nochannel")) emptyView.setEmptyImage(name: "channel_noMoreData") emptyView.isHidden = false } else { @@ -257,7 +257,7 @@ extension NEHomeChannelView { subTitleLable.isHidden = true addChannelBtn.isHidden = true emptyView.isHidden = false - emptyView.setttingContent(content: "暂无服务器,\n赶紧去添加心仪的服务器吧") + emptyView.setttingContent(content: localizable("add_favorite_service")) emptyView.setEmptyImage(name: "servers_noMore") } diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/NESearchServerCell.swift b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/NESearchServerCell.swift index 97ac73d4..8f7459a3 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/NESearchServerCell.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/QChatHomePage/View/NESearchServerCell.swift @@ -34,7 +34,7 @@ class NESearchServerCell: UITableViewCell { let item = QChatGetServerMemberItem( serverId: serverId, - accid: IMKitLoginManager.instance.imAccid + accid: IMKitEngine.instance.imAccid ) let param = QChatGetServerMembersParam(serverAccIds: [item]) @@ -178,7 +178,7 @@ class NESearchServerCell: UITableViewCell { private lazy var rightContent: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false - label.text = localizable("已申请") + label.text = localizable("applied") label.font = DefaultTextFont(12) label.textColor = UIColor.ne_emptyTitleColor label.isHidden = true @@ -195,7 +195,7 @@ class NESearchServerCell: UITableViewCell { private lazy var joinBtn: UIButton = { let button = UIButton() button.translatesAutoresizingMaskIntoConstraints = false - button.setTitle(localizable("加入"), for: .normal) + button.setTitle(localizable("join"), for: .normal) button.setTitleColor(UIColor.white, for: .normal) button.titleLabel?.font = DefaultTextFont(12) button.backgroundColor = HexRGB(0x337EFF) diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Server/Model/IdGroupModel.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Server/Model/IdGroupModel.swift index c40eaa31..2603c6d8 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Server/Model/IdGroupModel.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Server/Model/IdGroupModel.swift @@ -9,13 +9,6 @@ import NEKitCoreIM class IdGroupModel { var idName: String? var subTitle: String? -// { -// didSet { -// if let s = subTitle, s == "0人" { -// -// } -// } -// } var uid: Int? var isSelect = false var cornerType: CornerType = .none @@ -32,9 +25,5 @@ class IdGroupModel { } else if let type = serverRole.type, type == .custom { subTitle = "\(serverRole.memberCount ?? 0)人" } - -// if let s = subTitle, s == "0人" { -// -// } } } diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Server/Model/PermissionModel.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Server/Model/PermissionModel.swift index 63abac2f..4197eefa 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Server/Model/PermissionModel.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Server/Model/PermissionModel.swift @@ -74,7 +74,7 @@ class PermissionModel: NSObject { #keyPath(PermissionModel.modifyOwnServer): localizable("qchat_modify_own_server"), #keyPath(PermissionModel.modifyOthersServer): localizable("qchat_modify_other_server"), #keyPath(PermissionModel.inviteMember): localizable("qchat_invite_member"), - #keyPath(PermissionModel.kickout): localizable("qchat_kickout_member"), + #keyPath(PermissionModel.kickout): localizable("qchat_kick_out"), #keyPath(PermissionModel.managerBlackAndWhite): localizable("qchat_manager_channel_list"), ] diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatCreateGroupViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatCreateGroupViewController.swift index fbf41547..1debedbc 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatCreateGroupViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatCreateGroupViewController.swift @@ -9,7 +9,9 @@ import NEKitCoreIM typealias CreateCompletion = () -> Void public class QChatCreateGroupViewController: NEBaseTableViewController, - QChatMemberSelectControllerDelegate,UITableViewDataSource, UITableViewDelegate,ViewModelDelegate, QChatTextEditCellDelegate { + QChatMemberSelectControllerDelegate, UITableViewDataSource, UITableViewDelegate, + ViewModelDelegate, + QChatTextEditCellDelegate { let viewModel = CreateGroupViewModel() var serverId: UInt64? @@ -49,54 +51,28 @@ public class QChatCreateGroupViewController: NEBaseTableViewController, ) } - //MAKR: objc 方法 - @objc func createClick() { - if serverName.count <= 0 { - view.makeToast(localizable("qchat_please_input_role_name")) - return - } - var param = ServerRoleParam() - param.serverId = serverId - param.type = .custom - param.name = serverName - weak var weakSelf = self - print("create role param : ", param) - - viewModel.repo.createRole(param) { error, role in - print("create role : ", error as Any, role) - if let err = error { - weakSelf?.dataDidError(err) - } else { - if let rid = role.roleId, let addMemebers = weakSelf?.viewModel.allUsers, - addMemebers.count > 0 { - weakSelf?.addMember(rid) - } else { - if let block = weakSelf?.completion { - block() - } - weakSelf?.navigationController?.popViewController(animated: true) - } - } - } + // MAKR: objc 方法 + @objc func createClick() { + if serverName.count <= 0 { + view.makeToast(localizable("qchat_please_input_role_name")) + return } - - func addMember(_ roleId: UInt64) { - weak var weakSelf = self - if viewModel.allUsers.count > 0 { - var accids = [String]() - viewModel.allUsers.forEach { user in - if let accid = user.serverMember?.accid { - accids.append(accid) - } - } - var param = AddServerRoleMemberParam() - param.accountArray = accids - param.serverId = serverId - param.roleId = roleId - viewModel.repo.addRoleMember(param) { error, sAccids, fAccids in - if let err = error { - weakSelf?.showToast(err.localizedDescription) - } + var param = ServerRoleParam() + param.serverId = serverId + param.type = .custom + param.name = serverName + weak var weakSelf = self + print("create role param : ", param) + + viewModel.repo.createRole(param) { error, role in + print("create role : ", error as Any, role) + if let err = error { + weakSelf?.dataDidError(err) + } else { + if let rid = role.roleId, let addMemebers = weakSelf?.viewModel.allUsers, + addMemebers.count > 0 { + weakSelf?.addMember(rid) + } else { if let block = weakSelf?.completion { block() } @@ -104,171 +80,194 @@ public class QChatCreateGroupViewController: NEBaseTableViewController, } } } -//MARK : - public func filterMembers(accid: [String]?, _ filterMembers: @escaping ([String]?) -> Void) { - var dic = [String: String]() + } + + func addMember(_ roleId: UInt64) { + weak var weakSelf = self + if viewModel.allUsers.count > 0 { + var accids = [String]() viewModel.allUsers.forEach { user in - if let aid = user.accid { - dic[aid] = aid + if let accid = user.serverMember?.accid { + accids.append(accid) } } - var retArray = [String]() - accid?.forEach { aid in - if dic[aid] != nil { - retArray.append(aid) + var param = AddServerRoleMemberParam() + param.accountArray = accids + param.serverId = serverId + param.roleId = roleId + viewModel.repo.addRoleMember(param) { error, sAccids, fAccids in + if let err = error { + weakSelf?.showToast(err.localizedDescription) + } + if let block = weakSelf?.completion { + block() } + weakSelf?.navigationController?.popViewController(animated: true) } - filterMembers(retArray) - - // filterMembers(accid) } + } + // MARK: - func textDidChange(_ textField: UITextField) { - if let text = textField.text { - serverName = text + public func filterMembers(accid: [String]?, _ filterMembers: @escaping ([String]?) -> Void) { + var dic = [String: String]() + viewModel.allUsers.forEach { user in + if let aid = user.accid { + dic[aid] = aid } - print("text change: ", textField.text as Any) } - - public func dataDidError(_ error: Error) { - UIApplication.shared.keyWindow?.endEditing(true) - view.makeToast(error.localizedDescription) + var retArray = [String]() + accid?.forEach { aid in + if dic[aid] != nil { + retArray.append(aid) + } } + filterMembers(retArray) - public func dataDidChange() { - tableView.reloadData() - } + // filterMembers(accid) + } - public func numberOfSections(in tableView: UITableView) -> Int { - let count = 3 - // if viewModel.limitUsers.count < viewModel.allUsers.count { - // count = count + 1 - // } - return count + func textDidChange(_ textField: UITextField) { + if let text = textField.text { + serverName = text } + print("text change: ", textField.text as Any) + } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if section == 0 || section == 1 { - return 1 - } else if section == 2 { - return viewModel.allUsers.count - } else if section == 3 { - return 0 - } + public func dataDidError(_ error: Error) { + UIApplication.shared.keyWindow?.endEditing(true) + view.makeToast(error.localizedDescription) + } + + public func dataDidChange() { + tableView.reloadData() + } + + public func numberOfSections(in tableView: UITableView) -> Int { + let count = 3 + // if viewModel.limitUsers.count < viewModel.allUsers.count { + // count = count + 1 + // } + return count + } + + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if section == 0 || section == 1 { + return 1 + } else if section == 2 { + return viewModel.allUsers.count + } else if section == 3 { return 0 } + return 0 + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - if indexPath.section == 0 { - let cell: QChatTextEditCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatTextEditCell.self)", - for: indexPath - ) as! QChatTextEditCell - cell.textFied.placeholder = localizable("qchat_please_input_role_name") - cell.delegate = self - cell.limit = 20 - cell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) - .union(CornerType.topLeft).union(CornerType.topRight) - return cell - } else if indexPath.section == 1 { - let cell: QChatTextArrowCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatTextArrowCell.self)", - for: indexPath - ) as! QChatTextArrowCell - cell.titleLabel.text = localizable("qchat_add_member") - cell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) - .union(CornerType.topLeft).union(CornerType.topRight) - return cell - } else if indexPath.section == 2 { - let cell: QChatIdGroupMemberCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatIdGroupMemberCell.self)", - for: indexPath - ) as! QChatIdGroupMemberCell - let user = viewModel.allUsers[indexPath.row] - cell.cornerType = user.cornerType - cell.user = user - return cell - } else if indexPath.section == 3 { - let cell: QChatUnfoldCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatUnfoldCell.self)", - for: indexPath - ) as! QChatUnfoldCell - cell.contentLabel.text = "更多(共\(viewModel.allUsers.count))人" - cell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) - return cell - } - return UITableViewCell() + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.section == 0 { + let cell: QChatTextEditCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatTextEditCell.self)", + for: indexPath + ) as! QChatTextEditCell + cell.textFied.placeholder = localizable("qchat_please_input_role_name") + cell.delegate = self + cell.limit = 20 + cell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) + .union(CornerType.topLeft).union(CornerType.topRight) + return cell + } else if indexPath.section == 1 { + let cell: QChatTextArrowCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatTextArrowCell.self)", + for: indexPath + ) as! QChatTextArrowCell + cell.titleLabel.text = localizable("add_member") + cell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) + .union(CornerType.topLeft).union(CornerType.topRight) + return cell + } else if indexPath.section == 2 { + let cell: QChatIdGroupMemberCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatIdGroupMemberCell.self)", + for: indexPath + ) as! QChatIdGroupMemberCell + let user = viewModel.allUsers[indexPath.row] + cell.cornerType = user.cornerType + cell.user = user + return cell + } else if indexPath.section == 3 { + let cell: QChatUnfoldCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatUnfoldCell.self)", + for: indexPath + ) as! QChatUnfoldCell + cell.contentLabel.text = "更多(共\(viewModel.allUsers.count))人" + cell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) + return cell } + return UITableViewCell() + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.section == 1 { - let memberSelect = QChatMemberSelectController() - memberSelect.serverId = serverId - memberSelect.delegate = self - // memberSelect.selectType = .ServerMember - weak var weakSelf = self - memberSelect.completion = { datas in - if datas.count > 0 { - weakSelf?.viewModel.addMembers(datas) - } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.section == 1 { + let memberSelect = QChatMemberSelectController() + memberSelect.serverId = serverId + memberSelect.delegate = self + // memberSelect.selectType = .ServerMember + weak var weakSelf = self + memberSelect.completion = { datas in + if datas.count > 0 { + weakSelf?.viewModel.addMembers(datas) } - navigationController?.pushViewController(memberSelect, animated: true) + } + navigationController?.pushViewController(memberSelect, animated: true) - } else if indexPath.section == 2 { - // 编辑成员临时入口 + } else if indexPath.section == 2 { + // 编辑成员临时入口 - // let user = viewModel.limitUsers[indexPath.row] - // let editMember = QChatEditMemberViewController() - // editMember.user = user - // navigationController?.pushViewController(editMember, animated: true) + // let user = viewModel.limitUsers[indexPath.row] + // let editMember = QChatEditMemberViewController() + // editMember.user = user + // navigationController?.pushViewController(editMember, animated: true) - viewModel.removeData(indexPath.row) - } else if indexPath.section == 3 { - viewModel.loadAllData() - tableView.reloadData() - } + viewModel.removeData(indexPath.row) + } else if indexPath.section == 3 { + viewModel.loadAllData() + tableView.reloadData() } + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - 50 - } + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + 50 + } - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - if section == 0 || section == 1 { - return 40.0 - } else if section == 2 { - return 16 - } - return 0 + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + if section == 0 || section == 1 { + return 40.0 + } else if section == 2 { + return 16 } + return 0 + } - public func tableView(_ tableView: UITableView, - viewForHeaderInSection section: Int) -> UIView? { - let header = QChatHeaderView() - if section == 0 { - header.titleLabel.text = localizable("qchat_group_name") - return header - } - - if section == 1 { - header.titleLabel.text = localizable("qchat_manager_member") - return header - } - - if section == 2 { - let space = UIView() - space.backgroundColor = .clear - return space - } - - return nil + public func tableView(_ tableView: UITableView, + viewForHeaderInSection section: Int) -> UIView? { + let header = QChatHeaderView() + if section == 0 { + header.titleLabel.text = localizable("qchat_group_name") + return header } -} - + if section == 1 { + header.titleLabel.text = localizable("qchat_manager_member") + return header + } + if section == 2 { + let space = UIView() + space.backgroundColor = .clear + return space + } + return nil + } +} diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatEditMemberViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatEditMemberViewController.swift index 251cdaf9..bc0bd0e6 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatEditMemberViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatEditMemberViewController.swift @@ -13,7 +13,8 @@ typealias EditMemberChange = () -> Void typealias EditMemberDelete = () -> Void -public class QChatEditMemberViewController: NEBaseTableViewController,UITableViewDataSource, UITableViewDelegate,ViewModelDelegate, QChatTextEditCellDelegate { +public class QChatEditMemberViewController: NEBaseTableViewController, UITableViewDataSource, + UITableViewDelegate, ViewModelDelegate, QChatTextEditCellDelegate { var user: UserInfo? var editAble = false var showAll = false @@ -84,24 +85,39 @@ public class QChatEditMemberViewController: NEBaseTableViewController,UITableVie // Pass the selected object to the new view controller. } */ - //MARK: objc 方法 - @objc func rightBtnClick(_ btn: ExpandButton) { - if btn.isSelected == true { - print("to save") - if nickName.count <= 0 { - showToast("昵称不能为空") - return - } - guard let accid = user?.accid else { - showToast("accid 不能为空") - return - } + // MARK: objc 方法 + + @objc func rightBtnClick(_ btn: ExpandButton) { + if btn.isSelected == true { + print("to save") + if nickName.count <= 0 { + showToast(localizable("nickName_not_empty")) + return + } - weak var weakSelf = self + guard let accid = user?.accid else { + showToast(localizable("accid_not_empty")) + return + } - if IMKitLoginManager.instance.isMySelf(accid) == true { - viewModel.updateMyMember(user?.serverMember?.serverId, nickName) { error, member in + weak var weakSelf = self + + if IMKitEngine.instance.isMySelf(accid) == true { + viewModel.updateMyMember(user?.serverMember?.serverId, nickName) { error, member in + if let err = error { + weakSelf?.showToast(err.localizedDescription) + } else { + weakSelf?.navigationController?.popViewController(animated: true) + if let block = weakSelf?.changeCompletion { + block() + } + } + } + } else { + viewModel + .updateMember(user?.serverMember?.serverId, nickName, + user?.accid) { error, member in if let err = error { weakSelf?.showToast(err.localizedDescription) } else { @@ -111,273 +127,257 @@ public class QChatEditMemberViewController: NEBaseTableViewController,UITableVie } } } - } else { - viewModel - .updateMember(user?.serverMember?.serverId, nickName, - user?.accid) { error, member in - if let err = error { - weakSelf?.showToast(err.localizedDescription) - } else { - weakSelf?.navigationController?.popViewController(animated: true) - if let block = weakSelf?.changeCompletion { - block() - } - } - } - } - - } else { - btn.isSelected = true - editAble = true - btn.setTitle(localizable("qchat_save"), for: .normal) - viewModel.showServerData() } - } - - //MARK: UITableViewDataSource, UITableViewDelegate,ViewModelDelegate, QChatTextEditCellDelegate - func textDidChange(_ textField: UITextField) { - print("edit mebmer name change : ", textField.text as Any) - if let text = textField.text { - nickName = text - } - } - public func dataDidChange() { - tableView.reloadData() + } else { + btn.isSelected = true + editAble = true + btn.setTitle(localizable("qchat_save"), for: .normal) + viewModel.showServerData() } + } - public func dataDidError(_ error: Error) { - showToast(error.localizedDescription) - } + // MARK: UITableViewDataSource, UITableViewDelegate,ViewModelDelegate, QChatTextEditCellDelegate - public func numberOfSections(in tableView: UITableView) -> Int { - 5 + func textDidChange(_ textField: UITextField) { + print("edit mebmer name change : ", textField.text as Any) + if let text = textField.text { + nickName = text } + } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if section == 0 || section == 1 { - return 1 - } else if section == 2 { - return showAll ? viewModel.allIdGroups.count : viewModel.limitIdGroups.count - } else if section == 3 { - if viewModel.limitIdGroups.count < viewModel.allIdGroups.count { - return 1 - } - } else if section == 4 { + public func dataDidChange() { + tableView.reloadData() + } + + public func dataDidError(_ error: Error) { + showToast(error.localizedDescription) + } + + public func numberOfSections(in tableView: UITableView) -> Int { + 5 + } + + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if section == 0 || section == 1 { + return 1 + } else if section == 2 { + return showAll ? viewModel.allIdGroups.count : viewModel.limitIdGroups.count + } else if section == 3 { + if viewModel.limitIdGroups.count < viewModel.allIdGroups.count { return 1 } - return 0 + } else if section == 4 { + return 1 } + return 0 + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - if indexPath.section == 0 { - let cell: QChatHeaderCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatHeaderCell.self)", - for: indexPath - ) as! QChatHeaderCell - cell.cornerType = CornerType.topLeft.union(CornerType.topRight) - .union(CornerType.bottomLeft).union(CornerType.bottomRight) - cell.user = user - return cell - } else if indexPath.section == 1 { - let cell: QChatTextEditCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatTextEditCell.self)", - for: indexPath - ) as! QChatTextEditCell + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.section == 0 { + let cell: QChatHeaderCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatHeaderCell.self)", + for: indexPath + ) as! QChatHeaderCell + cell.cornerType = CornerType.topLeft.union(CornerType.topRight) + .union(CornerType.bottomLeft).union(CornerType.bottomRight) + cell.user = user + return cell + } else if indexPath.section == 1 { + let cell: QChatTextEditCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatTextEditCell.self)", + for: indexPath + ) as! QChatTextEditCell + cell.cornerType = CornerType.topLeft.union(CornerType.topRight) + .union(CornerType.bottomLeft).union(CornerType.bottomRight) + cell.delegate = self + cell.editTotast = localizable("modify_nickname") + cell.canEdit = editAble + if nickName.count > 0 { + cell.textFied.text = nickName + } else { + cell.textFied.text = nil + } + cell.textFied.placeholder = localizable("qcaht_edit_nickname") + return cell + } else if indexPath.section == 2 { + let cell: QChatIdGroupSelectCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatIdGroupSelectCell.self)", + for: indexPath + ) as! QChatIdGroupSelectCell + let group = showAll ? viewModel.allIdGroups[indexPath.row] : viewModel + .limitIdGroups[indexPath.row] + cell.tailImage.isHidden = !editAble + if let type = group.role?.type, type == .everyone { + cell.tailImage.isHidden = true + } + let exist = viewModel.checkoutCurrentUserRole(group.role?.roleId) + print("checkoutCurrentUserRole name : \(group.idName ?? "") exist : \(exist)") + group.isSelect = exist + cell.group = group + return cell + } else if indexPath.section == 3 { + let cell: QChatUnfoldCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatUnfoldCell.self)", + for: indexPath + ) as! QChatUnfoldCell + cell.contentLabel + .text = showAll ? "收起(共\(viewModel.allIdGroups.count)个)" : + "更多(共\(viewModel.allIdGroups.count)个)" + if showAll { + cell.changeToArrowUp() + } else { + cell.changeToArrowDown() + } + cell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) + return cell + } else if indexPath.section == 4 { + let cell: QChatDestructiveCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatDestructiveCell.self)", + for: indexPath + ) as! QChatDestructiveCell + if indexPath.row == 0 { cell.cornerType = CornerType.topLeft.union(CornerType.topRight) .union(CornerType.bottomLeft).union(CornerType.bottomRight) - cell.delegate = self - cell.editTotast = "请点击编辑后修改昵称" - cell.canEdit = editAble - if nickName.count > 0 { - cell.textFied.text = nickName - } else { - cell.textFied.text = nil - } - cell.textFied.placeholder = localizable("qcaht_edit_nickname") - return cell - } else if indexPath.section == 2 { - let cell: QChatIdGroupSelectCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatIdGroupSelectCell.self)", - for: indexPath - ) as! QChatIdGroupSelectCell - let group = showAll ? viewModel.allIdGroups[indexPath.row] : viewModel - .limitIdGroups[indexPath.row] - cell.tailImage.isHidden = !editAble - if let type = group.role?.type, type == .everyone { - cell.tailImage.isHidden = true - } - let exist = viewModel.checkoutCurrentUserRole(group.role?.roleId) - print("checkoutCurrentUserRole name : \(group.idName ?? "") exist : \(exist)") - group.isSelect = exist - cell.group = group - return cell - } else if indexPath.section == 3 { - let cell: QChatUnfoldCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatUnfoldCell.self)", - for: indexPath - ) as! QChatUnfoldCell - cell.contentLabel - .text = showAll ? "收起(共\(viewModel.allIdGroups.count)个)" : - "更多(共\(viewModel.allIdGroups.count)个)" - if showAll { - cell.changeToArrowUp() - } else { - cell.changeToArrowDown() + cell.redTextLabel.text = "\(localizable("qchat_kick_out")) \(user?.nickName ?? "")" + if getKickDisable() { + cell.changeDisableTextColor() } + } else if indexPath.row == 1 { cell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) - return cell - } else if indexPath.section == 4 { - let cell: QChatDestructiveCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatDestructiveCell.self)", - for: indexPath - ) as! QChatDestructiveCell - if indexPath.row == 0 { - cell.cornerType = CornerType.topLeft.union(CornerType.topRight) - .union(CornerType.bottomLeft).union(CornerType.bottomRight) - cell.redTextLabel.text = "\(localizable("qchat_kick_out")) \(user?.nickName ?? "")" - if getKickDisable() { - cell.changeDisableTextColor() - } - } else if indexPath.row == 1 { - cell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) - cell.redTextLabel.text = "\(localizable("qchat_prohibit")) \(user?.nickName ?? "")" - cell.changeEnableTextColor() - } - return cell + cell.redTextLabel.text = "\(localizable("qchat_prohibit")) \(user?.nickName ?? "")" + cell.changeEnableTextColor() } - - return UITableViewCell() + return cell } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - if indexPath.section == 0 { - return 92 - } - return 50 + return UITableViewCell() + } + + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.section == 0 { + return 92 } + return 50 + } - public func tableView(_ tableView: UITableView, - viewForHeaderInSection section: Int) -> UIView? { - let header = QChatHeaderView() - if section == 1 { - header.titleLabel.text = localizable("qchat_nickname") - return header - } + public func tableView(_ tableView: UITableView, + viewForHeaderInSection section: Int) -> UIView? { + let header = QChatHeaderView() + if section == 1 { + header.titleLabel.text = localizable("qchat_nickname") + return header + } - if section == 2, viewModel.allIdGroups.count > 0 { - header.titleLabel.text = localizable("qchat_id_group") - return header - } - return nil + if section == 2, viewModel.allIdGroups.count > 0 { + header.titleLabel.text = localizable("qchat_id_group") + return header } + return nil + } - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - if section == 0 { - return 22 - } + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + if section == 0 { + return 22 + } - if section == 1 { - return 38 - } + if section == 1 { + return 38 + } - if section == 2, viewModel.allIdGroups.count > 0 { - return 38 - } + if section == 2, viewModel.allIdGroups.count > 0 { + return 38 + } - if section == 4 { - return 20 - } - return 0 + if section == 4 { + return 20 } + return 0 + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.section == 1 { - // showToast("请点击编辑后修改昵称") - } else if indexPath.section == 2 { - if editAble == false { - return - } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.section == 1 { + // showToast("请点击编辑后修改昵称") + } else if indexPath.section == 2 { + if editAble == false { + return + } - let group = showAll == true ? viewModel.allIdGroups[indexPath.row] : viewModel - .limitIdGroups[indexPath.row] + let group = showAll == true ? viewModel.allIdGroups[indexPath.row] : viewModel + .limitIdGroups[indexPath.row] - if let type = group.role?.type, type == .everyone { - return - } - let select = viewModel.checkoutCurrentUserRole(group.role?.roleId) - weak var weakSelf = self - if select == false { - view.makeToastActivity(.center) - viewModel.addMembers(user?.accid, user?.serverId, group.role?.roleId) { - weakSelf?.view.hideToastActivity() - weakSelf?.didChange = true - } - } else { - view.makeToastActivity(.center) - viewModel.remove(user?.accid, user?.serverId, group.role?.roleId) { - weakSelf?.view.hideToastActivity() - weakSelf?.didChange = true - } - } - } else if indexPath.section == 3 { - showAll = !showAll - tableView.reloadData() - } else if indexPath.section == 4 { - weak var weakSelf = self - if getKickDisable() == true { - return + if let type = group.role?.type, type == .everyone { + return + } + let select = viewModel.checkoutCurrentUserRole(group.role?.roleId) + weak var weakSelf = self + if select == false { + view.makeToastActivity(.center) + viewModel.addMembers(user?.accid, user?.serverId, group.role?.roleId) { + weakSelf?.view.hideToastActivity() + weakSelf?.didChange = true } - showAlert(message: "确定踢出当前成员?") { - weakSelf?.kickOutMember() + } else { + view.makeToastActivity(.center) + viewModel.remove(user?.accid, user?.serverId, group.role?.roleId) { + weakSelf?.view.hideToastActivity() + weakSelf?.didChange = true } } + } else if indexPath.section == 3 { + showAll = !showAll + tableView.reloadData() + } else if indexPath.section == 4 { + weak var weakSelf = self + if getKickDisable() == true { + return + } + showAlert(message: localizable("kick_currentMember")) { + weakSelf?.kickOutMember() + } } + } - func didChangeRole() { - if didChange == true { - if let block = changeCompletion { - block() - } + func didChangeRole() { + if didChange == true { + if let block = changeCompletion { + block() } } + } - func getKickDisable() -> Bool { - if let accid = user?.serverMember?.accid { - // if CoreKitEngine.instance.imAccid == accid { - // return true - // } + func getKickDisable() -> Bool { + if let accid = user?.serverMember?.accid { + // if CoreKitEngine.instance.imAccid == accid { + // return true + // } - if IMKitLoginManager.instance.imAccid == accid { - return true - } - if let type = user?.serverMember?.type, type == .owner { - return true - } + if IMKitEngine.instance.imAccid == accid { + return true + } + if let type = user?.serverMember?.type, type == .owner { + return true } - return false } + return false + } - func kickOutMember() { - view.makeToastActivity(.center) - weak var weakSelf = self - viewModel.kickoutMember(user?.serverId, user?.accid) { error in - weakSelf?.view.hideToastActivity() - if let err = error { - weakSelf?.showToast(err.localizedDescription) - } else { - if let block = weakSelf?.deleteCompletion { - block() - } - weakSelf?.navigationController?.popViewController(animated: true) + func kickOutMember() { + view.makeToastActivity(.center) + weak var weakSelf = self + viewModel.kickoutMember(user?.serverId, user?.accid) { error in + weakSelf?.view.hideToastActivity() + if let err = error { + weakSelf?.showToast(err.localizedDescription) + } else { + if let block = weakSelf?.deleteCompletion { + block() } + weakSelf?.navigationController?.popViewController(animated: true) } } - - + } } - - diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatIdGroupSortController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatIdGroupSortController.swift index 725abc19..e43729b1 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatIdGroupSortController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatIdGroupSortController.swift @@ -10,7 +10,8 @@ import NEKitCoreIM typealias SortChange = () -> Void -public class QChatIdGroupSortController: NEBaseTableViewController,UITableViewDelegate, UITableViewDataSource,ViewModelDelegate { +public class QChatIdGroupSortController: NEBaseTableViewController, UITableViewDelegate, + UITableViewDataSource, ViewModelDelegate { var serverId: UInt64? var isOwer = false @@ -72,134 +73,136 @@ public class QChatIdGroupSortController: NEBaseTableViewController,UITableViewDe navigationController?.popViewController(animated: true) } - //MARK: UITableViewDelegate, UITableViewDataSource, ViewModelDelegate - public func dataDidChange() { - tableView.reloadData() - } + // MARK: UITableViewDelegate, UITableViewDataSource, ViewModelDelegate - public func dataDidError(_ error: Error) { - view.hideToastActivity() - showToast(error.localizedDescription) - } + public func dataDidChange() { + tableView.reloadData() + } - public func numberOfSections(in tableView: UITableView) -> Int { - 1 - } + public func dataDidError(_ error: Error) { + view.hideToastActivity() + showToast(error.localizedDescription) + } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - // if section == 0 { - // return viewmodel.lockData.count - // }else if section == 1 { - // return viewmodel.datas.count - // } - viewmodel.datas.count - } + public func numberOfSections(in tableView: UITableView) -> Int { + 1 + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell: QChatSortCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatSortCell.self)", - for: indexPath - ) as! QChatSortCell - // if indexPath.section == 0 { - // let model = viewmodel.lockData[indexPath.row] - // cell.configure(model) - // cell.tailImage.isHighlighted = true - // }else if indexPath.section == 1 { - // if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { - // cell.configure(model) - // cell.tailImage.isHighlighted = !model.hasPermission - // } - // } - if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { - cell.configure(model) - cell.tailImage.isHighlighted = !model.hasPermission - } + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + // if section == 0 { + // return viewmodel.lockData.count + // }else if section == 1 { + // return viewmodel.datas.count + // } + viewmodel.datas.count + } - return cell + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell: QChatSortCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatSortCell.self)", + for: indexPath + ) as! QChatSortCell + // if indexPath.section == 0 { + // let model = viewmodel.lockData[indexPath.row] + // cell.configure(model) + // cell.tailImage.isHighlighted = true + // }else if indexPath.section == 1 { + // if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { + // cell.configure(model) + // cell.tailImage.isHighlighted = !model.hasPermission + // } + // } + if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { + cell.configure(model) + cell.tailImage.isHighlighted = !model.hasPermission } - public func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, - to destinationIndexPath: IndexPath) { - print("source :", sourceIndexPath.row, " destionation :", destinationIndexPath.row) - - if sourceIndexPath.row > destinationIndexPath.row { - let src_model = viewmodel.datas.object(at: sourceIndexPath.row) - viewmodel.datas.remove(src_model) - viewmodel.datas.insert(src_model, at: destinationIndexPath.row) - } else { - let src_model = viewmodel.datas.object(at: sourceIndexPath.row) - viewmodel.datas.insert(src_model, at: destinationIndexPath.row + 1) - viewmodel.datas.removeObject(at: sourceIndexPath.row) - } + return cell + } - viewmodel.datas.forEach { user in - if let u = user as? IdGroupModel { - print("change name : ", u.idName as Any) - print("change p: ", u.role?.priority as Any) - } - } + public func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, + to destinationIndexPath: IndexPath) { + print("source :", sourceIndexPath.row, " destionation :", destinationIndexPath.row) + + if sourceIndexPath.row > destinationIndexPath.row { + let src_model = viewmodel.datas.object(at: sourceIndexPath.row) + viewmodel.datas.remove(src_model) + viewmodel.datas.insert(src_model, at: destinationIndexPath.row) + } else { + let src_model = viewmodel.datas.object(at: sourceIndexPath.row) + viewmodel.datas.insert(src_model, at: destinationIndexPath.row + 1) + viewmodel.datas.removeObject(at: sourceIndexPath.row) } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - 60 + viewmodel.datas.forEach { user in + if let u = user as? IdGroupModel { + print("change name : ", u.idName as Any) + print("change p: ", u.role?.priority as Any) + } } + } - public func tableView(_ tableView: UITableView, - shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool { - false - } + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + 60 + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { - weak var weakSelf = self - if model.hasPermission == true { - showAlert(message: "确定删除 \(model.idName ?? "当前身份组")?") { - weakSelf?.view.makeToastActivity(.center) - weakSelf?.viewmodel.removeRole(weakSelf?.serverId, model.role?.roleId, model) { - weakSelf?.didDelete = true - weakSelf?.view.hideToastActivity() - } + public func tableView(_ tableView: UITableView, + shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool { + false + } + + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { + weak var weakSelf = self + if model.hasPermission == true { + showAlert( + message: "\(localizable("sure_delete"))\(model.idName ?? localizable("current_identity"))?" + ) { + weakSelf?.view.makeToastActivity(.center) + weakSelf?.viewmodel.removeRole(weakSelf?.serverId, model.role?.roleId, model) { + weakSelf?.didDelete = true + weakSelf?.view.hideToastActivity() } } } } + } - public func tableView(_ tableView: UITableView, - targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, - toProposedIndexPath proposedDestinationIndexPath: IndexPath) - -> IndexPath { - if isOwer == true { - return proposedDestinationIndexPath - } else { - if let model = viewmodel.datas[proposedDestinationIndexPath.row] as? IdGroupModel { - if model.hasPermission == true { - return proposedDestinationIndexPath - } + public func tableView(_ tableView: UITableView, + targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, + toProposedIndexPath proposedDestinationIndexPath: IndexPath) + -> IndexPath { + if isOwer == true { + return proposedDestinationIndexPath + } else { + if let model = viewmodel.datas[proposedDestinationIndexPath.row] as? IdGroupModel { + if model.hasPermission == true { + return proposedDestinationIndexPath } } - return sourceIndexPath } + return sourceIndexPath + } - public func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { - if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { - return model.hasPermission - } - return true + public func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { + if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { + return model.hasPermission } + return true + } - public func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { - if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { - return model.hasPermission - } - return true + public func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { + if let model = viewmodel.datas[indexPath.row] as? IdGroupModel { + return model.hasPermission } + return true + } - public func tableView(_ tableView: UITableView, - editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle { - UITableViewCell.EditingStyle.none - } + public func tableView(_ tableView: UITableView, + editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell + .EditingStyle { + UITableViewCell.EditingStyle.none + } } - - diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatIdGroupViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatIdGroupViewController.swift index 89e2f36e..82c439c0 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatIdGroupViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatIdGroupViewController.swift @@ -6,7 +6,8 @@ import UIKit import MJRefresh -public class QChatIdGroupViewController: NEBaseTableViewController,UITableViewDelegate, UITableViewDataSource,ViewModelDelegate { +public class QChatIdGroupViewController: NEBaseTableViewController, UITableViewDelegate, + UITableViewDataSource, ViewModelDelegate { let viewModel = IdGroupViewModel() var isOwner = false var serverid: UInt64? @@ -75,171 +76,171 @@ public class QChatIdGroupViewController: NEBaseTableViewController,UITableViewDe // Pass the selected object to the new view controller. } */ - //MARK: UITableViewDelegate, UITableViewDataSource,ViewModelDelegate - public func dataDidError(_ error: Error) { - print("get roles error : ", error) - NELog.errorLog(className(), desc: "error : \(error)") - view.makeToast(error.localizedDescription) - } - public func dataDidChange() { - tableView.mj_footer?.endRefreshing() - tableView.reloadData() - } + // MARK: UITableViewDelegate, UITableViewDataSource,ViewModelDelegate - public func dataNoMore() { - tableView.mj_footer?.endRefreshingWithNoMoreData() - tableView.mj_footer?.isHidden = true - } + public func dataDidError(_ error: Error) { + print("get roles error : ", error) + NELog.errorLog(className(), desc: "error : \(error)") + view.makeToast(error.localizedDescription) + } - public func numberOfSections(in tableView: UITableView) -> Int { - 3 - } + public func dataDidChange() { + tableView.mj_footer?.endRefreshing() + tableView.reloadData() + } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if section == 0 { - return viewModel.topDatas.count - } else if section == 1 { - if viewModel.datas.count > 0 { - return viewModel.sortBtnCellDatas.count - } - } else if section == 2 { - return viewModel.datas.count - } - return 0 - } + public func dataNoMore() { + tableView.mj_footer?.endRefreshingWithNoMoreData() + tableView.mj_footer?.isHidden = true + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - if indexPath.section == 0 { - let model = viewModel.topDatas[indexPath.row] - let cell: QChatIdGroupTopCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatIdGroupTopCell.self)", - for: indexPath - ) as! QChatIdGroupTopCell - cell.configure(model) - return cell - } else if indexPath.section == 1 { - let model = viewModel.sortBtnCellDatas[indexPath.row] - let cell: QChatIdGroupSortButtonCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatIdGroupSortButtonCell.self)", - for: indexPath - ) as! QChatIdGroupSortButtonCell - cell.titleLabel.text = model.idName - cell.sortBtn.addTarget(self, action: #selector(toSort), for: .touchUpInside) - return cell - } else if indexPath.section == 2 { - let model = viewModel.datas[indexPath.row] - let cell: QChatIdGroupCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatIdGroupCell.self)", - for: indexPath - ) as! QChatIdGroupCell - cell.configure(model) - return cell - } - return UITableViewCell() - } + public func numberOfSections(in tableView: UITableView) -> Int { + 3 + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - if indexPath.section == 0 { - return 68 - } else if indexPath.section == 1 { - return 30 - } else if indexPath.section == 2 { - return 60 + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if section == 0 { + return viewModel.topDatas.count + } else if section == 1 { + if viewModel.datas.count > 0 { + return viewModel.sortBtnCellDatas.count } - return 0 + } else if section == 2 { + return viewModel.datas.count } + return 0 + } - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - if section == 1 { - return 6 - } - return 0 - } + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.section == 0 { + let model = viewModel.topDatas[indexPath.row] + let cell: QChatIdGroupTopCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatIdGroupTopCell.self)", + for: indexPath + ) as! QChatIdGroupTopCell + cell.configure(model) + return cell + } else if indexPath.section == 1 { + let model = viewModel.sortBtnCellDatas[indexPath.row] + let cell: QChatIdGroupSortButtonCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatIdGroupSortButtonCell.self)", + for: indexPath + ) as! QChatIdGroupSortButtonCell + cell.titleLabel.text = model.idName + cell.sortBtn.addTarget(self, action: #selector(toSort), for: .touchUpInside) + return cell + } else if indexPath.section == 2 { + let model = viewModel.datas[indexPath.row] + let cell: QChatIdGroupCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatIdGroupCell.self)", + for: indexPath + ) as! QChatIdGroupCell + cell.configure(model) + return cell + } + return UITableViewCell() + } - public func tableView(_ tableView: UITableView, - viewForHeaderInSection section: Int) -> UIView? { - if section == 1 { - let view = UIView(frame: CGRect.zero) - view.backgroundColor = UIColor(hexString: "EFF1F4") - return view - } - return nil + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.section == 0 { + return 68 + } else if indexPath.section == 1 { + return 30 + } else if indexPath.section == 2 { + return 60 } + return 0 + } - public func tableView(_ tableView: UITableView, - heightForFooterInSection section: Int) -> CGFloat { - 0 + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + if section == 1 { + return 6 } + return 0 + } - public func tableView(_ tableView: UITableView, - viewForFooterInSection section: Int) -> UIView? { - nil + public func tableView(_ tableView: UITableView, + viewForHeaderInSection section: Int) -> UIView? { + if section == 1 { + let view = UIView(frame: CGRect.zero) + view.backgroundColor = UIColor(hexString: "EFF1F4") + return view } + return nil + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.section == 1 { - return - } + public func tableView(_ tableView: UITableView, + heightForFooterInSection section: Int) -> CGFloat { + 0 + } - if indexPath.section == 0 { - let model = viewModel.topDatas[indexPath.row] - toPermission(model) - } else if indexPath.section == 2 { - let model = viewModel.datas[indexPath.row] - toPermission(model) - } - } - - //MARK: objc 方法 - @objc func addClick() { - let create = QChatCreateGroupViewController() - create.serverId = serverid - weak var weakSelf = self - create.completion = { - weakSelf?.refreshData() - } - navigationController?.pushViewController(create, animated: true) - } + public func tableView(_ tableView: UITableView, + viewForFooterInSection section: Int) -> UIView? { + nil + } - @objc func toSort() { - let sort = QChatIdGroupSortController() - sort.serverId = serverid - sort.isOwer = isOwner - weak var weakSelf = self - sort.completion = { - weakSelf?.refreshData() - // weakSelf?.viewModel.datas.removeAll() - // for index in 0.. Void -public class QChatMemberManagerController: NEBaseTableViewController,UITableViewDelegate, UITableViewDataSource,ViewModelDelegate,QChatMemberSelectControllerDelegate { +public class QChatMemberManagerController: NEBaseTableViewController, UITableViewDelegate, + UITableViewDataSource, ViewModelDelegate, QChatMemberSelectControllerDelegate { let viewmodel = MemberManagerViewModel() var memberCount = 0 @@ -69,152 +70,151 @@ public class QChatMemberManagerController: NEBaseTableViewController,UITableView // Pass the selected object to the new view controller. } */ - //MARK: UITableViewDelegate, UITableViewDataSource,ViewModelDelegate,QChatMemberSelectControllerDelegate - - public func filterMembers(accid: [String]?, _ filterMembers: @escaping ([String]?) -> Void) { - var param = GetExistingServerRoleMembersByAccidsParam() - param.serverId = serverId - param.accids = accid - param.roleId = roleId - print("param existing accid : ", accid as Any) - viewmodel.repo.getExistingServerRoleMembersByAccids(param) { error, accids in - print("getExistingServerRoleMembersByAccids : ", accids) - var dic = [String: String]() - var retAccids = [String]() - accids.forEach { aid in - dic[aid] = aid - } - accid?.forEach { aid in - if dic[aid] != nil { - retAccids.append(aid) - } + + // MARK: UITableViewDelegate, UITableViewDataSource,ViewModelDelegate,QChatMemberSelectControllerDelegate + + public func filterMembers(accid: [String]?, _ filterMembers: @escaping ([String]?) -> Void) { + var param = GetExistingServerRoleMembersByAccidsParam() + param.serverId = serverId + param.accids = accid + param.roleId = roleId + print("param existing accid : ", accid as Any) + viewmodel.repo.getExistingServerRoleMembersByAccids(param) { error, accids in + print("getExistingServerRoleMembersByAccids : ", accids) + var dic = [String: String]() + var retAccids = [String]() + accids.forEach { aid in + dic[aid] = aid + } + accid?.forEach { aid in + if dic[aid] != nil { + retAccids.append(aid) } - print("filter members : ", retAccids) - filterMembers(retAccids) } + print("filter members : ", retAccids) + filterMembers(retAccids) } + } - public func dataDidChange() { - view.hideToastActivity() - tableView.mj_footer?.endRefreshing() - tableView.reloadData() - } + public func dataDidChange() { + view.hideToastActivity() + tableView.mj_footer?.endRefreshing() + tableView.reloadData() + } - public func dataNoMore() { - view.hideToastActivity() - tableView.mj_footer?.endRefreshingWithNoMoreData() - tableView.mj_footer?.isHidden = true - } + public func dataNoMore() { + view.hideToastActivity() + tableView.mj_footer?.endRefreshingWithNoMoreData() + tableView.mj_footer?.isHidden = true + } - public func dataDidError(_ error: Error) { - showToast(error.localizedDescription) - } + public func dataDidError(_ error: Error) { + showToast(error.localizedDescription) + } - public func numberOfSections(in tableView: UITableView) -> Int { - 2 - } + public func numberOfSections(in tableView: UITableView) -> Int { + 2 + } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if section == 0 { - return 1 - } - if section == 1 { - return viewmodel.datas.count - } - return 0 + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if section == 0 { + return 1 } - - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - if indexPath.section == 0 { - let cell: QChatPlainTextArrowCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatPlainTextArrowCell.self)", - for: indexPath - ) as! QChatPlainTextArrowCell - cell.titleLabel.text = localizable("qchat_add_member") - cell.detailLabel.text = "\(memberCount)" - return cell - } - - if indexPath.section == 1 { - let cell: QChatMemberManagerCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatMemberManagerCell.self)", - for: indexPath - ) as! QChatMemberManagerCell - let user = viewmodel.datas[indexPath.row] - cell.user = user - return cell - } - - return UITableViewCell() + if section == 1 { + return viewmodel.datas.count } + return 0 + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - 50 + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.section == 0 { + let cell: QChatPlainTextArrowCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatPlainTextArrowCell.self)", + for: indexPath + ) as! QChatPlainTextArrowCell + cell.titleLabel.text = localizable("add_member") + cell.detailLabel.text = "\(memberCount)" + return cell } - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - 0 + if indexPath.section == 1 { + let cell: QChatMemberManagerCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatMemberManagerCell.self)", + for: indexPath + ) as! QChatMemberManagerCell + let user = viewmodel.datas[indexPath.row] + cell.user = user + return cell } - public func tableView(_ tableView: UITableView, - heightForFooterInSection section: Int) -> CGFloat { - 0 - } + return UITableViewCell() + } - public func tableView(_ tableView: UITableView, - viewForHeaderInSection section: Int) -> UIView? { - nil - } + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + 50 + } - public func tableView(_ tableView: UITableView, - viewForFooterInSection section: Int) -> UIView? { - nil - } + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + 0 + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - weak var weakSelf = self - if indexPath.section == 0 { - let memberSelect = QChatMemberSelectController() - memberSelect.delegate = self - memberSelect.serverId = serverId - memberSelect.completion = { users in - print("member manager select: ", users) - weakSelf?.view.makeToastActivity(.center) - weakSelf?.viewmodel - .addMembers(users, weakSelf?.serverId, weakSelf?.roleId) { successCount in - // weakSelf?.view.hideToastActivity() - weakSelf?.showToast(localizable("qchat_add_success")) - if let block = weakSelf?.countChangeBlock, var count = weakSelf?.memberCount { - count = count + successCount - weakSelf?.memberCount = count - block(count) - } + public func tableView(_ tableView: UITableView, + heightForFooterInSection section: Int) -> CGFloat { + 0 + } + + public func tableView(_ tableView: UITableView, + viewForHeaderInSection section: Int) -> UIView? { + nil + } + + public func tableView(_ tableView: UITableView, + viewForFooterInSection section: Int) -> UIView? { + nil + } + + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + weak var weakSelf = self + if indexPath.section == 0 { + let memberSelect = QChatMemberSelectController() + memberSelect.delegate = self + memberSelect.serverId = serverId + memberSelect.completion = { users in + print("member manager select: ", users) + weakSelf?.view.makeToastActivity(.center) + weakSelf?.viewmodel + .addMembers(users, weakSelf?.serverId, weakSelf?.roleId) { successCount in + // weakSelf?.view.hideToastActivity() + weakSelf?.showToast(localizable("qchat_add_success")) + if let block = weakSelf?.countChangeBlock, var count = weakSelf?.memberCount { + count = count + successCount + weakSelf?.memberCount = count + block(count) } - } - navigationController?.pushViewController(memberSelect, animated: true) - } else { - let user = viewmodel.datas[indexPath.row] - showAlert(message: localizable("qchat_sure_delete_user")) { - if let rid = weakSelf?.roleId, let sid = weakSelf?.serverId { - weakSelf?.view.makeToastActivity(.center) - weakSelf?.viewmodel.remove(user, sid, rid) { - weakSelf?.view.hideToastActivity() - weakSelf?.viewmodel.datas.remove(at: indexPath.row) - weakSelf?.tableView.reloadData() - if var count = weakSelf?.memberCount, - let block = weakSelf?.countChangeBlock { - count = count - 1 - weakSelf?.memberCount = count - block(count) - } + } + } + navigationController?.pushViewController(memberSelect, animated: true) + } else { + let user = viewmodel.datas[indexPath.row] + showAlert(message: localizable("qchat_sure_delete_user")) { + if let rid = weakSelf?.roleId, let sid = weakSelf?.serverId { + weakSelf?.view.makeToastActivity(.center) + weakSelf?.viewmodel.remove(user, sid, rid) { + weakSelf?.view.hideToastActivity() + weakSelf?.viewmodel.datas.remove(at: indexPath.row) + weakSelf?.tableView.reloadData() + if var count = weakSelf?.memberCount, + let block = weakSelf?.countChangeBlock { + count = count - 1 + weakSelf?.memberCount = count + block(count) } } } } } + } } - - diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatMemberSelectController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatMemberSelectController.swift index f7ccaaad..b0bf7847 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatMemberSelectController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatMemberSelectController.swift @@ -18,8 +18,10 @@ public protocol QChatMemberSelectControllerDelegate: AnyObject { // case ChannelMember // } -public class QChatMemberSelectController: NEBaseTableViewController, MemberSelectViewModelDelegate,UICollectionViewDelegate, UICollectionViewDataSource, - UICollectionViewDelegateFlowLayout,UITableViewDelegate,UITableViewDataSource,ViewModelDelegate { +public class QChatMemberSelectController: NEBaseTableViewController, MemberSelectViewModelDelegate, + UICollectionViewDelegate, UICollectionViewDataSource, + UICollectionViewDelegateFlowLayout, UITableViewDelegate, UITableViewDataSource, + ViewModelDelegate { let viewmodel = MemberSelectViewModel() var filterBlock: FilterMembersBlock? var completion: SelectMemeberCompletion? @@ -145,132 +147,132 @@ public class QChatMemberSelectController: NEBaseTableViewController, MemberSelec } } } - //MARK: - public func dataDidError(_ error: Error) { - view.makeToast(error.localizedDescription) - } - public func dataDidChange() { - tableView.reloadData() - } + // MARK: - public func collectionView(_ collectionView: UICollectionView, - numberOfItemsInSection section: Int) -> Int { - selectArray.count - } + public func dataDidError(_ error: Error) { + view.makeToast(error.localizedDescription) + } - public func collectionView(_ collectionView: UICollectionView, - cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - let user = selectArray[indexPath.row] - let cell = collectionView.dequeueReusableCell( - withReuseIdentifier: "\(NSStringFromClass(QChatUserUnCheckCell.self))", - for: indexPath - ) as? QChatUserUnCheckCell - cell?.configure(user) - return cell ?? UICollectionViewCell() - } + public func dataDidChange() { + tableView.reloadData() + } - public func collectionView(_ collectionView: UICollectionView, - didSelectItemAt indexPath: IndexPath) { - let user = selectArray[indexPath.row] - didUnselectContact(user) - } + public func collectionView(_ collectionView: UICollectionView, + numberOfItemsInSection section: Int) -> Int { + selectArray.count + } - public func collectionView(_ collectionView: UICollectionView, - layout collectionViewLayout: UICollectionViewLayout, - sizeForItemAt indexPath: IndexPath) -> CGSize { - CGSize(width: 46, height: 52) - } + public func collectionView(_ collectionView: UICollectionView, + cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let user = selectArray[indexPath.row] + let cell = collectionView.dequeueReusableCell( + withReuseIdentifier: "\(NSStringFromClass(QChatUserUnCheckCell.self))", + for: indexPath + ) as? QChatUserUnCheckCell + cell?.configure(user) + return cell ?? UICollectionViewCell() + } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - viewmodel.datas.count - } + public func collectionView(_ collectionView: UICollectionView, + didSelectItemAt indexPath: IndexPath) { + let user = selectArray[indexPath.row] + didUnselectContact(user) + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell: QChatSelectedCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatSelectedCell.self)", - for: indexPath - ) as! QChatSelectedCell - let user = viewmodel.datas[indexPath.row] - cell.user = user - return cell - } + public func collectionView(_ collectionView: UICollectionView, + layout collectionViewLayout: UICollectionViewLayout, + sizeForItemAt indexPath: IndexPath) -> CGSize { + CGSize(width: 46, height: 52) + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - 62 - } + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + viewmodel.datas.count + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let user = viewmodel.datas[indexPath.row] - let cell = tableView.cellForRow(at: indexPath) as? QChatSelectedCell + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell: QChatSelectedCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatSelectedCell.self)", + for: indexPath + ) as! QChatSelectedCell + let user = viewmodel.datas[indexPath.row] + cell.user = user + return cell + } - if user.select == true { - cell?.setUnselect() - didUnselectContact(user) - } else { - if selectArray.count >= limit { - // view.makeToast("超出\(limit)人限制") - showToast( - "\(localizable("exceed"))\(limit)\(localizable("person"))\(localizable("limit"))" - ) - return - } - cell?.setSelect() - didSelectContact(user) + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + 62 + } + + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let user = viewmodel.datas[indexPath.row] + let cell = tableView.cellForRow(at: indexPath) as? QChatSelectedCell + + if user.select == true { + cell?.setUnselect() + didUnselectContact(user) + } else { + if selectArray.count >= limit { + // view.makeToast("超出\(limit)人限制") + showToast( + "\(localizable("exceed"))\(limit)\(localizable("person"))\(localizable("limit"))" + ) + return } - // tableView.reloadRows(at: [indexPath], with: .none) + cell?.setSelect() + didSelectContact(user) } + // tableView.reloadRows(at: [indexPath], with: .none) + } - func didSelectContact(_ user: UserInfo) { - user.select = true - if selectArray.contains(where: { c in - user === c - }) == false { - selectArray.append(user) - if let height = collectionHeight?.constant, height <= 0 { - collectionHeight?.constant = 52 - } + func didSelectContact(_ user: UserInfo) { + user.select = true + if selectArray.contains(where: { c in + user === c + }) == false { + selectArray.append(user) + if let height = collectionHeight?.constant, height <= 0 { + collectionHeight?.constant = 52 } - collection.reloadData() - tableView.reloadData() - refreshSelectCount() } + collection.reloadData() + tableView.reloadData() + refreshSelectCount() + } - func didUnselectContact(_ user: UserInfo) { - user.select = false - selectArray.removeAll { c in - user === c - } - if selectArray.count <= 0 { - collection.reloadData() - collectionHeight?.constant = 0 - } + func didUnselectContact(_ user: UserInfo) { + user.select = false + selectArray.removeAll { c in + user === c + } + if selectArray.count <= 0 { collection.reloadData() - tableView.reloadData() - refreshSelectCount() + collectionHeight?.constant = 0 } + collection.reloadData() + tableView.reloadData() + refreshSelectCount() + } - func refreshSelectCount() { - if selectArray.count > 0 { - rightNavBtn.setTitle("\(localizable("qchat_sure"))(\(selectArray.count))", for: .normal) - } else { - rightNavBtn.setTitle(localizable("qchat_sure"), for: .normal) - } + func refreshSelectCount() { + if selectArray.count > 0 { + rightNavBtn.setTitle("\(localizable("qchat_sure"))(\(selectArray.count))", for: .normal) + } else { + rightNavBtn.setTitle(localizable("qchat_sure"), for: .normal) } + } - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - 0 - } + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + 0 + } // MARK: MemberSelectViewModelDelegate - func filterMembers(accid: [String]?, _ filterMembers: @escaping ([String]?) -> Void) { - // 查询需要筛选的用户 - delegate?.filterMembers(accid: accid, filterMembers) - } + func filterMembers(accid: [String]?, _ filterMembers: @escaping ([String]?) -> Void) { + // 查询需要筛选的用户 + delegate?.filterMembers(accid: accid, filterMembers) + } } - - diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatPermissionViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatPermissionViewController.swift index 061953d4..1eb47c7d 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatPermissionViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatPermissionViewController.swift @@ -7,7 +7,8 @@ import UIKit import NEKitCoreIM typealias RoleUpdateCompletion = (_ role: ServerRole) -> Void -public class QChatPermissionViewController: NEBaseTableViewController,UITableViewDelegate, UITableViewDataSource, QChatTextEditCellDelegate, ViewModelDelegate, QChatSwitchCellDelegate { +public class QChatPermissionViewController: NEBaseTableViewController, UITableViewDelegate, + UITableViewDataSource, QChatTextEditCellDelegate, ViewModelDelegate, QChatSwitchCellDelegate { var idGroup: IdGroupModel? let viewmodel = PermissionViewModel() @@ -62,218 +63,217 @@ public class QChatPermissionViewController: NEBaseTableViewController,UITableVie // Pass the selected object to the new view controller. } */ - //MARK: UITableViewDelegate, UITableViewDataSource, QChatTextEditCellDelegate, ViewModelDelegate, QChatSwitchCellDelegate - - func didChangeSwitchValue(_ cell: QChatSwitchCell) { - print("did change switch value : ", cell) - if let key = cell.model?.permissionKey, - let value = cell.model?.permission?.value(forKey: key) as? String, - let type = ChatPermissionType(rawValue: value) { - updatePermission(type, cell.qSwitch.isOn) { success in - if success == false { - cell.qSwitch.isOn = !cell.qSwitch.isOn - } + + // MARK: UITableViewDelegate, UITableViewDataSource, QChatTextEditCellDelegate, ViewModelDelegate, QChatSwitchCellDelegate + + func didChangeSwitchValue(_ cell: QChatSwitchCell) { + print("did change switch value : ", cell) + if let key = cell.model?.permissionKey, + let value = cell.model?.permission?.value(forKey: key) as? String, + let type = ChatPermissionType(rawValue: value) { + updatePermission(type, cell.qSwitch.isOn) { success in + if success == false { + cell.qSwitch.isOn = !cell.qSwitch.isOn } } } + } + + public func dataDidChange() { + tableView.reloadData() + } + + public func dataDidError(_ error: Error) { + showToast(error.localizedDescription) + } - public func dataDidChange() { - tableView.reloadData() + func textDidChange(_ textField: UITextField) { + if let text = textField.text { + serverName = text } + } - public func dataDidError(_ error: Error) { - showToast(error.localizedDescription) + public func numberOfSections(in tableView: UITableView) -> Int { + 5 + } + + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if section == 0 { + return 1 + } + if section == 1 { + if let type = idGroup?.role?.type, type == .everyone { + return 0 + } + return 1 + } + if section == 2 { + return viewmodel.commons.count + } + if section == 3 { + return viewmodel.messages.count } + if section == 4 { + return viewmodel.members.count + } + return 0 + } - func textDidChange(_ textField: UITextField) { - if let text = textField.text { - serverName = text + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.section == 0 { + let cell: QChatTextEditCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatTextEditCell.self)", + for: indexPath + ) as! QChatTextEditCell + if serverName.count > 0 { + cell.textFied.text = serverName + } else { + cell.textFied.text = nil } + cell.textFied.placeholder = localizable("qchat_please_input_role_name") + cell.delegate = self + cell.limit = 20 + cell.cornerType = CornerType.topLeft.union(CornerType.topRight) + .union(CornerType.bottomLeft).union(CornerType.bottomRight) + return cell } - public func numberOfSections(in tableView: UITableView) -> Int { - 5 + if indexPath.section == 1 { + let cell: QChatTextArrowCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatTextArrowCell.self)", + for: indexPath + ) as! QChatTextArrowCell + cell.titleLabel.text = localizable("qchat_member") + cell.detailLabel.text = "\(idGroup?.role?.memberCount ?? 0)" + cell.cornerType = CornerType.topLeft.union(CornerType.topRight) + .union(CornerType.bottomLeft).union(CornerType.bottomRight) + return cell } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if section == 0 { - return 1 - } - if section == 1 { - if let type = idGroup?.role?.type, type == .everyone { - return 0 - } - return 1 - } - if section == 2 { - return viewmodel.commons.count - } - if section == 3 { - return viewmodel.messages.count - } - if section == 4 { - return viewmodel.members.count + if indexPath.section == 2 || indexPath.section == 3 || indexPath.section == 4 { + let cell: QChatSwitchCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatSwitchCell.self)", + for: indexPath + ) as! QChatSwitchCell + var model: PermissionCellModel? + if indexPath.section == 2 { + model = viewmodel.commons[indexPath.row] + } else if indexPath.section == 3 { + model = viewmodel.messages[indexPath.row] + } else if indexPath.section == 4 { + model = viewmodel.members[indexPath.row] } - return 0 + cell.delegate = self + cell.model = model + return cell } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - if indexPath.section == 0 { - let cell: QChatTextEditCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatTextEditCell.self)", - for: indexPath - ) as! QChatTextEditCell - if serverName.count > 0 { - cell.textFied.text = serverName - } else { - cell.textFied.text = nil - } - cell.textFied.placeholder = localizable("qchat_please_input_role_name") - cell.delegate = self - cell.limit = 20 - cell.cornerType = CornerType.topLeft.union(CornerType.topRight) - .union(CornerType.bottomLeft).union(CornerType.bottomRight) - return cell - } + return UITableViewCell() + } - if indexPath.section == 1 { - let cell: QChatTextArrowCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatTextArrowCell.self)", - for: indexPath - ) as! QChatTextArrowCell - cell.titleLabel.text = localizable("qchat_member") - cell.detailLabel.text = "\(idGroup?.role?.memberCount ?? 0)" - cell.cornerType = CornerType.topLeft.union(CornerType.topRight) - .union(CornerType.bottomLeft).union(CornerType.bottomRight) - return cell - } + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + 50 + } - if indexPath.section == 2 || indexPath.section == 3 || indexPath.section == 4 { - let cell: QChatSwitchCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatSwitchCell.self)", - for: indexPath - ) as! QChatSwitchCell - var model: PermissionCellModel? - if indexPath.section == 2 { - model = viewmodel.commons[indexPath.row] - } else if indexPath.section == 3 { - model = viewmodel.messages[indexPath.row] - } else if indexPath.section == 4 { - model = viewmodel.members[indexPath.row] - } - cell.delegate = self - cell.model = model - return cell + public func tableView(_ tableView: UITableView, + viewForHeaderInSection section: Int) -> UIView? { + let header = QChatHeaderView() + switch section { + case 0: + header.titleLabel.text = localizable("qchat_group_name") + case 1: + if let type = idGroup?.role?.type, type == .everyone { + return nil } - - return UITableViewCell() + header.titleLabel.text = localizable("qchat_manager_member") + case 2: + header.titleLabel.text = localizable("qchat_common_permission") + case 3: + header.titleLabel.text = localizable("qchat_message_permission") + case 4: + header.titleLabel.text = localizable("qchat_member_permission") + default: + break } + return header + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - 50 + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + if let type = idGroup?.role?.type, type == .everyone, section == 1 { + return 0 } + return 40 + } - public func tableView(_ tableView: UITableView, - viewForHeaderInSection section: Int) -> UIView? { - let header = QChatHeaderView() - switch section { - case 0: - header.titleLabel.text = localizable("qchat_group_name") - case 1: - if let type = idGroup?.role?.type, type == .everyone { - return nil + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.section == 1 { + let memberManager = QChatMemberManagerController() + memberManager.serverId = idGroup?.role?.serverId + memberManager.roleId = idGroup?.role?.roleId + memberManager.memberCount = idGroup?.role?.memberCount ?? 0 + weak var weakSelf = self + memberManager.countChangeBlock = { count in + weakSelf?.idGroup?.role?.memberCount = count + if let role = weakSelf?.idGroup?.role, let block = weakSelf?.completion { + block(role) } - header.titleLabel.text = localizable("qchat_manager_member") - case 2: - header.titleLabel.text = localizable("qchat_common_permission") - case 3: - header.titleLabel.text = localizable("qchat_message_permission") - case 4: - header.titleLabel.text = localizable("qchat_member_permission") - default: - break + tableView.reloadData() } - return header + navigationController?.pushViewController(memberManager, animated: true) } + } - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - if let type = idGroup?.role?.type, type == .everyone, section == 1 { - return 0 - } - return 40 + // MAKR: objc 方法 + @objc func savePermission() { + if serverName.count <= 0 { + showToast(localizable("qchat_please_input_role_name")) + return } - - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.section == 1 { - let memberManager = QChatMemberManagerController() - memberManager.serverId = idGroup?.role?.serverId - memberManager.roleId = idGroup?.role?.roleId - memberManager.memberCount = idGroup?.role?.memberCount ?? 0 - weak var weakSelf = self - memberManager.countChangeBlock = { count in - weakSelf?.idGroup?.role?.memberCount = count - if let role = weakSelf?.idGroup?.role, let block = weakSelf?.completion { - block(role) - } - tableView.reloadData() - } - navigationController?.pushViewController(memberManager, animated: true) - } + var param = UpdateServerRoleParam() + param.serverId = idGroup?.role?.serverId + if let rid = idGroup?.role?.roleId { + param.roleId = UInt64(rid) } - - //MAKR: objc 方法 - @objc func savePermission() { - if serverName.count <= 0 { - showToast(localizable("qchat_please_input_role_name")) - return - } - var param = UpdateServerRoleParam() - param.serverId = idGroup?.role?.serverId - if let rid = idGroup?.role?.roleId { - param.roleId = UInt64(rid) - } - param.name = serverName - - /* 批量逻辑,暂时不用 - let permissions = viewmodel.permission.getChangePermission() - var commonds = [StatusInfo]() - - permissions.forEach { (type: ChatPermissionType, value: Bool) in - var info = StatusInfo() - info.permissionType = type - if value == true { - info.status = .Allow - }else { - info.status = .Deny - } - commonds.append(info) - } - if commonds.count > 0 { - print("commonds : ", commonds) - print("commonds count :", commonds.count) - param.commands = commonds - } */ + param.name = serverName + + /* 批量逻辑,暂时不用 + let permissions = viewmodel.permission.getChangePermission() + var commonds = [StatusInfo]() + + permissions.forEach { (type: ChatPermissionType, value: Bool) in + var info = StatusInfo() + info.permissionType = type + if value == true { + info.status = .Allow + }else { + info.status = .Deny + } + commonds.append(info) + } + if commonds.count > 0 { + print("commonds : ", commonds) + print("commonds count :", commonds.count) + param.commands = commonds + } */ - weak var weakSelf = self - viewmodel.repo.updateRole(param) { error, role in - if let err = error { - weakSelf?.showToast(err.localizedDescription) - } else { - if let block = weakSelf?.completion { - block(role) - } - weakSelf?.showToastInWindow(localizable("update_channel_suscess")) - weakSelf?.navigationController?.popViewController(animated: true) + weak var weakSelf = self + viewmodel.repo.updateRole(param) { error, role in + if let err = error { + weakSelf?.showToast(err.localizedDescription) + } else { + if let block = weakSelf?.completion { + block(role) } + weakSelf?.showToastInWindow(localizable("update_channel_suscess")) + weakSelf?.navigationController?.popViewController(animated: true) } } + } } - - extension QChatPermissionViewController { func updatePermission(_ type: ChatPermissionType, _ open: Bool, _ completion: @escaping (Bool) -> Void) { @@ -305,6 +305,4 @@ extension QChatPermissionViewController { } } } - - } diff --git a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatServerSettingViewController.swift b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatServerSettingViewController.swift index 5af9670b..a0bc9f63 100644 --- a/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatServerSettingViewController.swift +++ b/NEQChatUIKit/NEKitQChatUI/Classes/Server/ViewController/QChatServerSettingViewController.swift @@ -10,7 +10,8 @@ import NIMSDK typealias SaveSuccessBlock = (_ server: QChatServer?) -> Void -public class QChatServerSettingViewController: NEBaseTableViewController,UITableViewDelegate, UITableViewDataSource,UITextFieldDelegate,UINavigationControllerDelegate { +public class QChatServerSettingViewController: NEBaseTableViewController, UITableViewDelegate, + UITableViewDataSource, UITextFieldDelegate, UINavigationControllerDelegate { let viewModel = SettingViewModel() var server: QChatServer? @@ -173,7 +174,7 @@ public class QChatServerSettingViewController: NEBaseTableViewController,UITable serverNameInput.topAnchor.constraint(equalTo: topView.bottomAnchor, constant: 38), serverNameInput.heightAnchor.constraint(equalToConstant: 50), ]) - serverNameInput.placeholder = "输入名称" + serverNameInput.placeholder = localizable("enter_name") serverNameInput.tag = 50 if let name = server?.name { serverNameInput.text = name @@ -241,253 +242,252 @@ public class QChatServerSettingViewController: NEBaseTableViewController,UITable textField.delegate = self return textField } - - // MARK: action - @objc func cameraClick() { - // print("camera click") - showBottomAlert(self) - } - @objc func saveClick() { - print("save click") + // MARK: action - var name = "" + @objc func cameraClick() { + // print("camera click") + showBottomAlert(self) + } - if let currentName = serverNameInput.text, currentName.count > 0 { - name = currentName - } else if let originServerName = server?.name, originServerName.count > 0 { - name = originServerName - } + @objc func saveClick() { + print("save click") - if name.count <= 0 { - showToast(localizable("qchat_not_empty_servername")) - return - } + var name = "" - if let icon = headerImageUrl { - server?.icon = icon - } + if let currentName = serverNameInput.text, currentName.count > 0 { + name = currentName + } else if let originServerName = server?.name, originServerName.count > 0 { + name = originServerName + } - var serverParam = UpdateServerParam(name: name, icon: headerImageUrl) + if name.count <= 0 { + showToast(localizable("qchat_not_empty_servername")) + return + } - guard let sid = server?.serverId else { - showToast("服务器id不能为空") - return - } - serverParam.serverId = sid + if let icon = headerImageUrl { + server?.icon = icon + } - if let topic = serverThemeInput.text, topic.count > 0 { - serverParam.custom = getJSONStringFromDictionary(["topic": topic]) + var serverParam = UpdateServerParam(name: name, icon: headerImageUrl) + + guard let sid = server?.serverId else { + showToast(localizable("serverId_notbe_empty")) + return + } + serverParam.serverId = sid + + if let topic = serverThemeInput.text, topic.count > 0 { + serverParam.custom = getJSONStringFromDictionary(["topic": topic]) + } + weak var weakSelf = self + + view.makeToastActivity(.center) + print("update param : ", serverParam) + QChatServerProvider.shared.updateServer(serverParam) { error in + print("update finish : ", error as Any) + weakSelf?.view.hideToastActivity() + if let err = error { + weakSelf?.showToast(err.localizedDescription) + } else { + weakSelf?.navigationController?.popViewController(animated: true) } - weak var weakSelf = self + } + } + func leaveServer() { + if let serverid = server?.serverId { + weak var weakSelf = self view.makeToastActivity(.center) - print("update param : ", serverParam) - QChatServerProvider.shared.updateServer(serverParam) { error in - print("update finish : ", error as Any) + let className = className() + viewModel.repo.leaveServer(serverid) { error in weakSelf?.view.hideToastActivity() if let err = error { - weakSelf?.showToast(err.localizedDescription) + NELog.errorLog(className, desc: "leave server error : \(err)") + weakSelf?.view.makeToast(err.localizedDescription) } else { weakSelf?.navigationController?.popViewController(animated: true) } } } + } - func leaveServer() { - if let serverid = server?.serverId { - weak var weakSelf = self - view.makeToastActivity(.center) - let className = className() - viewModel.repo.leaveServer(serverid) { error in - weakSelf?.view.hideToastActivity() - if let err = error { - NELog.errorLog(className, desc: "leave server error : \(err)") - weakSelf?.view.makeToast(err.localizedDescription) - } else { - weakSelf?.navigationController?.popViewController(animated: true) - } + func deleteServer() { + if let serverid = server?.serverId { + weak var weakSelf = self + view.makeToastActivity(.center) + QChatServerProvider.shared.deleteServer(serverid) { error in + print("delete result : ", error as Any) + weakSelf?.view.hideToastActivity() + if let err = error { + weakSelf?.view.makeToast(err.localizedDescription) + } else { + weakSelf?.navigationController?.popViewController(animated: true) } } } + } - func deleteServer() { - if let serverid = server?.serverId { - weak var weakSelf = self - view.makeToastActivity(.center) - QChatServerProvider.shared.deleteServer(serverid) { error in - print("delete result : ", error as Any) - weakSelf?.view.hideToastActivity() - if let err = error { - weakSelf?.view.makeToast(err.localizedDescription) - } else { - weakSelf?.navigationController?.popViewController(animated: true) - } - } - } - } - //MARK: UITableViewDelegate, UITableViewDataSource,UITextFieldDelegate - - public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, - replacementString string: String) -> Bool { - let l = textField.tag - let text = "\(textField.text ?? "")\(string)" - print("count : ", text.count) - if text.count > l { - return false - } - return true - } + // MARK: UITableViewDelegate, UITableViewDataSource,UITextFieldDelegate - public func numberOfSections(in tableView: UITableView) -> Int { - 2 + public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, + replacementString string: String) -> Bool { + let l = textField.tag + let text = "\(textField.text ?? "")\(string)" + print("count : ", text.count) + if text.count > l { + return false } + return true + } - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - print("count section : ", section) - if section == 0 { - return viewModel.permissions.count - } else if section == 1 { - return 1 - } - return 0 - } + public func numberOfSections(in tableView: UITableView) -> Int { + 2 + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - if indexPath.section == 0 { - let textCell: QChatTextArrowCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatTextArrowCell.self)", - for: indexPath - ) as! QChatTextArrowCell - let model = viewModel.permissions[indexPath.row] - textCell.titleLabel.text = model.title - textCell.backgroundColor = .clear - textCell.cornerType = model.cornerType - return textCell - } else if indexPath.section == 1 { - let destructiveCell: QChatDestructiveCell = tableView.dequeueReusableCell( - withIdentifier: "\(QChatDestructiveCell.self)", - for: indexPath - ) as! QChatDestructiveCell - - destructiveCell.redTextLabel - .text = isMyServer() ? localizable("qchat_delete_server") : - localizable("qchat_leave_server") - destructiveCell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) - .union(CornerType.topLeft).union(CornerType.topRight) - return destructiveCell - } + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + print("count section : ", section) + if section == 0 { + return viewModel.permissions.count + } else if section == 1 { + return 1 + } + return 0 + } - return UITableViewCell() + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if indexPath.section == 0 { + let textCell: QChatTextArrowCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatTextArrowCell.self)", + for: indexPath + ) as! QChatTextArrowCell + let model = viewModel.permissions[indexPath.row] + textCell.titleLabel.text = model.title + textCell.backgroundColor = .clear + textCell.cornerType = model.cornerType + return textCell + } else if indexPath.section == 1 { + let destructiveCell: QChatDestructiveCell = tableView.dequeueReusableCell( + withIdentifier: "\(QChatDestructiveCell.self)", + for: indexPath + ) as! QChatDestructiveCell + + destructiveCell.redTextLabel + .text = isMyServer() ? localizable("qchat_delete_server") : + localizable("qchat_leave_server") + destructiveCell.cornerType = CornerType.bottomLeft.union(CornerType.bottomRight) + .union(CornerType.topLeft).union(CornerType.topRight) + return destructiveCell } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.section == 0 { - if indexPath.row == 1 { - let idGroupController = QChatIdGroupViewController() - idGroupController.serverid = server?.serverId - if let owner = server?.owner, owner == IMKitLoginManager.instance.imAccid { - idGroupController.isOwner = true - } - navigationController?.pushViewController(idGroupController, animated: true) + return UITableViewCell() + } - } else if indexPath.row == 0 { - let memberCtrl = MemberListViewController() - memberCtrl.serverId = server?.serverId - navigationController?.pushViewController(memberCtrl, animated: true) + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.section == 0 { + if indexPath.row == 1 { + let idGroupController = QChatIdGroupViewController() + idGroupController.serverid = server?.serverId + if let owner = server?.owner, owner == IMKitEngine.instance.imAccid { + idGroupController.isOwner = true } + navigationController?.pushViewController(idGroupController, animated: true) - } else if indexPath.section == 1 { - print("click delete") - weak var weakSelf = self - if isMyServer() == true { - showAlert(message: "确定删除当前服务器?") { - weakSelf?.deleteServer() - } - } else { - showAlert(message: "确定退出当前服务器?") { - weakSelf?.leaveServer() - } - } + } else if indexPath.row == 0 { + let memberCtrl = MemberListViewController() + memberCtrl.serverId = server?.serverId + navigationController?.pushViewController(memberCtrl, animated: true) } - } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - if indexPath.section == 0 { - return 48 - } else if indexPath.section == 1 { - return 40 + } else if indexPath.section == 1 { + print("click delete") + weak var weakSelf = self + if isMyServer() == true { + showAlert(message: localizable("sure_delete_server")) { + weakSelf?.deleteServer() + } + } else { + showAlert(message: localizable("sure_exit_server")) { + weakSelf?.leaveServer() + } } - return 0 } + } - public func tableView(_ tableView: UITableView, - viewForHeaderInSection section: Int) -> UIView? { - if section == 1 { - return UIView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 24)) - } - return nil + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + if indexPath.section == 0 { + return 48 + } else if indexPath.section == 1 { + return 40 } + return 0 + } - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - if section == 1 { - return 24 - } - return 0 + public func tableView(_ tableView: UITableView, + viewForHeaderInSection section: Int) -> UIView? { + if section == 1 { + return UIView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 24)) } + return nil + } - public func tableView(_ tableView: UITableView, - heightForFooterInSection section: Int) -> CGFloat { - 0 + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + if section == 1 { + return 24 } + return 0 + } - func isMyServer() -> Bool { - if let owner = server?.owner { - let accid = IMKitLoginManager.instance.imAccid - if owner == accid { - return true - } + public func tableView(_ tableView: UITableView, + heightForFooterInSection section: Int) -> CGFloat { + 0 + } + + func isMyServer() -> Bool { + if let owner = server?.owner { + let accid = IMKitEngine.instance.imAccid + if owner == accid { + return true } - return false - } - - //UINavigationControllerDelegate - func imagePickerController(_ picker: UIImagePickerController, - didFinishPickingMediaWithInfo info: [UIImagePickerController - .InfoKey: Any]) { - let image: UIImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage - uploadHeadImage(image: image) - picker.dismiss(animated: true, completion: nil) } + return false + } - public func uploadHeadImage(image: UIImage) { - view.makeToastActivity(.center) - if let imageData = image.jpegData(compressionQuality: 0.6) as NSData? { - let filePath = NSHomeDirectory().appending("/Documents/") - .appending(IMKitLoginManager.instance.imAccid) - let succcess = imageData.write(toFile: filePath, atomically: true) - weak var weakSelf = self - if succcess { - NIMSDK.shared().resourceManager - .upload(filePath, progress: nil) { urlString, error in - if error == nil { - // 显示设置的照片 - weakSelf?.headerImage?.image = image - weakSelf?.headerImageUrl = urlString - weakSelf?.headerImage?.titleLabel.isHidden = true - print("upload image success") - } else { - print("upload image failed,error = \(error!)") - } - weakSelf?.view.hideToastActivity() + // UINavigationControllerDelegate + func imagePickerController(_ picker: UIImagePickerController, + didFinishPickingMediaWithInfo info: [UIImagePickerController + .InfoKey: Any]) { + let image: UIImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage + uploadHeadImage(image: image) + picker.dismiss(animated: true, completion: nil) + } + + public func uploadHeadImage(image: UIImage) { + view.makeToastActivity(.center) + if let imageData = image.jpegData(compressionQuality: 0.6) as NSData? { + let filePath = NSHomeDirectory().appending("/Documents/") + .appending(IMKitEngine.instance.imAccid) + let succcess = imageData.write(toFile: filePath, atomically: true) + weak var weakSelf = self + if succcess { + NIMSDK.shared().resourceManager + .upload(filePath, progress: nil) { urlString, error in + if error == nil { + // 显示设置的照片 + weakSelf?.headerImage?.image = image + weakSelf?.headerImageUrl = urlString + weakSelf?.headerImage?.titleLabel.isHidden = true + print("upload image success") + } else { + print("upload image failed,error = \(error!)") } - } + weakSelf?.view.hideToastActivity() + } } } + } } - - - diff --git a/NETeamUIKit/NEKitTeamUI.podspec b/NETeamUIKit/NEKitTeamUI.podspec index c82b1a6a..5de7300c 100644 --- a/NETeamUIKit/NEKitTeamUI.podspec +++ b/NETeamUIKit/NEKitTeamUI.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'NEKitTeamUI' - s.version = '9.2.7' + s.version = '9.2.8' s.summary = 'Netease XKit' # This description is used to generate tags and improve search results. @@ -41,7 +41,6 @@ TODO: Add long description of the pod here. # s.public_header_files = 'Pod/Classes/**/*.h' # s.frameworks = 'UIKit', 'MapKit' - # s.dependency 'AFNetworking', '~> 2.3' s.dependency 'NECommonUIKit' s.dependency 'NETeamKit' end diff --git a/NETeamUIKit/NEKitTeamUI/Assets/en.lproj/Localizable.strings b/NETeamUIKit/NEKitTeamUI/Assets/en.lproj/Localizable.strings index 840c4890..ec826c22 100644 --- a/NETeamUIKit/NEKitTeamUI/Assets/en.lproj/Localizable.strings +++ b/NETeamUIKit/NEKitTeamUI/Assets/en.lproj/Localizable.strings @@ -3,49 +3,48 @@ // Use of this source code is governed by a MIT license that can be // found in the LICENSE file. -"mark"="标记"; -"history"="历史记录"; -"message_remind"="开启消息提醒"; -"session_set_top"="聊天置顶"; - -"team_nick"="我在群里的昵称"; -"team_no_speak"="群禁言"; - -"invite_permission"="邀请他人权限"; -"modify_team_info_permission"="群资料修改权限"; -"agree"="是否需要被邀请者同意"; - -"setting"="设置"; - -"group_memmber"="群成员"; -"discuss_mebmer"="讨论组成员"; - -"dismiss_team"="解散群聊"; -"leave_team"="退出群聊"; -"leave_discuss"="退出讨论组"; - -"team_header"="群头像"; -"team_name"="群名称"; -"team_intr"="群介绍"; - -"default_icon"="选择默认图标"; - -"senior_team"="高级群"; -"normal_team"="讨论组"; - -"create_senior_team_noti"="成功创建高级群"; - -"team_all"="所有人"; -"team_owner"="群主"; - - - - - - - - - - - - +"mark"="pin"; +"history"="History"; +"message_remind"="Open message remind"; +"session_set_top"="Sticky on Top"; +"team_nick"="My Alias in Group"; +"team_no_speak"="Mute"; +"invite_permission"="Invite Permission"; +"modify_team_info_permission"="Group info Permission"; +"agree"="是否需要被邀请者同意";//后期能力删除 +"setting"="Setting"; +"group_memmber"="Group Member"; +"discuss_mebmer"="Temp Group Member"; +"dismiss_team"="Disband Group"; +"leave_team"="Leave Group"; +"leave_discuss"="Leave Temp Group"; +"team_header"=" Group Avator"; +"team_name"="Group Name"; +"team_intr"="Group Info"; +"default_icon"="Select Default icon"; +"senior_team"="Group"; +"normal_team"="Temp Group"; +"create_senior_team_noti"=" Create Group successfully"; +"team_all"="all"; +"team_owner"="Group Admin"; + + +"modify_headImage"="Modify Avatar"; +"save"="Save"; +"historical_record"="History"; +"search"="Search"; +"no_search_results"="No content"; +"discuss_info"="Temp Group Info"; +"group_info"="Group Info"; +"discuss_introduce"="Temp Group Introduce"; +"search_friend"="Search Contact"; +"discuss_name"="Temp Group Name"; +"dissolute_team_chat"="Wether to disband Group"; +"quit_team_chat"="Wether to leave Group"; +"quit_discuss_chat"="Wether to leave Temp Group"; +"cancel"="cancel"; +"remind"="remind"; +"discuss_avatar"="Temp Group Avator"; +"discuss_name"="Temp Group Name"; +"discuss_intro"="Temp Group Introduce"; +"invite_has_send"="Invitation sent"; diff --git a/NETeamUIKit/NEKitTeamUI/Assets/zh-Hans.lproj/Localizable.strings b/NETeamUIKit/NEKitTeamUI/Assets/zh-Hans.lproj/Localizable.strings index cf30978c..a2f371d5 100644 --- a/NETeamUIKit/NEKitTeamUI/Assets/zh-Hans.lproj/Localizable.strings +++ b/NETeamUIKit/NEKitTeamUI/Assets/zh-Hans.lproj/Localizable.strings @@ -7,33 +7,44 @@ "history"="历史记录"; "message_remind"="开启消息提醒"; "session_set_top"="聊天置顶"; - "team_nick"="我在群里的昵称"; "team_no_speak"="群禁言"; - "invite_permission"="邀请他人权限"; "modify_team_info_permission"="群资料修改权限"; "agree"="是否需要被邀请者同意"; - "setting"="设置"; - "group_memmber"="群成员"; "discuss_mebmer"="讨论组成员"; - "dismiss_team"="解散群聊"; "leave_team"="退出群聊"; "leave_discuss"="退出讨论组"; - "team_header"="群头像"; "team_name"="群名称"; "team_intr"="群介绍"; - "default_icon"="选择默认图标"; - "senior_team"="高级群"; "normal_team"="讨论组"; - "create_senior_team_noti"="成功创建高级群"; - "team_all"="所有人"; "team_owner"="群主"; + + +"modify_headImage"="修改头像"; +"save"="保存"; +"historical_record"="历史记录"; +"search"="搜索"; +"no_search_results"="暂无搜索结果"; +"discuss_info"="讨论组信息"; +"group_info"="群信息"; +"discuss_introduce"="讨论组介绍"; +"search_friend"="搜索好友"; +"discuss_name"="讨论组名称"; +"dissolute_team_chat"="是否解散群聊?"; +"quit_team_chat"="是否退出群聊?"; +"quit_discuss_chat"="是否退出讨论组?"; +"cancel"="取消"; +"remind"="提示"; +"discuss_avatar"="讨论组头像"; +"discuss_name"="讨论组名称"; +"discuss_intro"="讨论组介绍"; +"invite_has_send"="邀请已发送"; diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamAvatarViewController.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamAvatarViewController.swift index 31c112b3..b3c9b145 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamAvatarViewController.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamAvatarViewController.swift @@ -8,7 +8,8 @@ import NEKitCommonUI import NIMSDK import NEKitTeam -public class TeamAvatarViewController: NEBaseViewController,UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UINavigationControllerDelegate { +public class TeamAvatarViewController: NEBaseViewController, UICollectionViewDelegate, + UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UINavigationControllerDelegate { typealias SaveCompletion = () -> Void var block: SaveCompletion? @@ -49,8 +50,8 @@ public class TeamAvatarViewController: NEBaseViewController,UICollectionViewDele } func setupUI() { - title = "修改头像" - addRightAction("保存", #selector(savePhoto), self) + title = localizable("modify_headImage") + addRightAction(localizable("save"), #selector(savePhoto), self) view.backgroundColor = NEConstant.hexRGB(0xF1F1F6) let headerBack = UIView() @@ -166,7 +167,7 @@ public class TeamAvatarViewController: NEBaseViewController,UICollectionViewDele if let type = team?.type, type == .normal { return true } - if let ownerId = team?.owner, IMKitLoginManager.instance.isMySelf(ownerId) { + if let ownerId = team?.owner, IMKitEngine.instance.isMySelf(ownerId) { return true } if let mode = team?.updateInfoMode, mode == .all { @@ -184,108 +185,108 @@ public class TeamAvatarViewController: NEBaseViewController,UICollectionViewDele // Pass the selected object to the new view controller. } */ - //MARK: objc 方法 - - @objc func uploadPhoto() { - print("upload photo") - showBottomAlert(self) - } - @objc func savePhoto() { - print("save photo") - if let tid = team?.teamId { - view.makeToastActivity(.center) - weak var weakSelf = self - - repo.fetchNOSURL(url: headerUrl) { error, urlStr in - if error == nil { - weakSelf?.repo.updateTeamIcon(urlStr ?? "", tid) { error in - weakSelf?.view.hideToastActivity() - if let err = error { - weakSelf?.showToast(err.localizedDescription) - } else { - weakSelf?.team?.avatarUrl = weakSelf?.headerUrl - if let completion = weakSelf?.block { - completion() - } - weakSelf?.navigationController?.popViewController(animated: true) + // MARK: objc 方法 + + @objc func uploadPhoto() { + print("upload photo") + showBottomAlert(self) + } + + @objc func savePhoto() { + print("save photo") + if let tid = team?.teamId { + view.makeToastActivity(.center) + weak var weakSelf = self + + repo.fetchNOSURL(url: headerUrl) { error, urlStr in + if error == nil { + weakSelf?.repo.updateTeamIcon(urlStr ?? "", tid) { error in + weakSelf?.view.hideToastActivity() + if let err = error { + weakSelf?.showToast(err.localizedDescription) + } else { + weakSelf?.team?.avatarUrl = weakSelf?.headerUrl + if let completion = weakSelf?.block { + completion() } + weakSelf?.navigationController?.popViewController(animated: true) } } } } } - - //MAKR: UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout - public func collectionView(_ collectionView: UICollectionView, - numberOfItemsInSection section: Int) -> Int { - 5 - } + } - public func collectionView(_ collectionView: UICollectionView, - cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - if let cell = collectionView.dequeueReusableCell( - withReuseIdentifier: "\(TeamDefaultIconCell.self)", - for: indexPath - ) as? TeamDefaultIconCell { - cell.iconImage.image = coreLoader.loadImage("icon_\(indexPath.row)") + // MAKR: UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout + public func collectionView(_ collectionView: UICollectionView, + numberOfItemsInSection section: Int) -> Int { + 5 + } - return cell - } - return UICollectionViewCell() - } + public func collectionView(_ collectionView: UICollectionView, + cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + if let cell = collectionView.dequeueReusableCell( + withReuseIdentifier: "\(TeamDefaultIconCell.self)", + for: indexPath + ) as? TeamDefaultIconCell { + cell.iconImage.image = coreLoader.loadImage("icon_\(indexPath.row)") - public func collectionView(_ collectionView: UICollectionView, - layout collectionViewLayout: UICollectionViewLayout, - minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { - let space = (view.width - 297.0) / 4.0 - print("mini inter : ", space) - return space + return cell } + return UICollectionViewCell() + } - public func collectionView(_ collectionView: UICollectionView, - didSelectItemAt indexPath: IndexPath) { - if TeamRouter.iconUrls.count > indexPath.row { - headerUrl = TeamRouter.iconUrls[indexPath.row] - // headerView.image = coreLoader.loadImage("icon_\(indexPath.row)") - headerView.sd_setImage(with: URL(string: headerUrl), completed: nil) - } - } - - //MARK: UINavigationControllerDelegate - - func imagePickerController(_ picker: UIImagePickerController, - didFinishPickingMediaWithInfo info: [UIImagePickerController - .InfoKey: Any]) { - let image: UIImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage - uploadHeadImage(image: image) - picker.dismiss(animated: true, completion: nil) + public func collectionView(_ collectionView: UICollectionView, + layout collectionViewLayout: UICollectionViewLayout, + minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { + let space = (view.width - 297.0) / 4.0 + print("mini inter : ", space) + return space + } + + public func collectionView(_ collectionView: UICollectionView, + didSelectItemAt indexPath: IndexPath) { + if TeamRouter.iconUrls.count > indexPath.row { + headerUrl = TeamRouter.iconUrls[indexPath.row] + // headerView.image = coreLoader.loadImage("icon_\(indexPath.row)") + headerView.sd_setImage(with: URL(string: headerUrl), completed: nil) } + } - public func uploadHeadImage(image: UIImage) { - view.makeToastActivity(.center) - if let imageData = image.jpegData(compressionQuality: 0.6) as NSData? { - let filePath = NSHomeDirectory().appending("/Documents/") - .appending(IMKitLoginManager.instance.imAccid) - let succcess = imageData.write(toFile: filePath, atomically: true) - weak var weakSelf = self - if succcess { - NIMSDK.shared().resourceManager - .upload(filePath, progress: nil) { urlString, error in - if error == nil { - // 显示设置的照片 - weakSelf?.headerView.image = image - if let url = urlString { - weakSelf?.headerUrl = url - } - print("upload image success") - } else { - print("upload image failed,error = \(error!)") + // MARK: UINavigationControllerDelegate + + func imagePickerController(_ picker: UIImagePickerController, + didFinishPickingMediaWithInfo info: [UIImagePickerController + .InfoKey: Any]) { + let image: UIImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage + uploadHeadImage(image: image) + picker.dismiss(animated: true, completion: nil) + } + + public func uploadHeadImage(image: UIImage) { + view.makeToastActivity(.center) + if let imageData = image.jpegData(compressionQuality: 0.6) as NSData? { + let filePath = NSHomeDirectory().appending("/Documents/") + .appending(IMKitEngine.instance.imAccid) + let succcess = imageData.write(toFile: filePath, atomically: true) + weak var weakSelf = self + if succcess { + NIMSDK.shared().resourceManager + .upload(filePath, progress: nil) { urlString, error in + if error == nil { + // 显示设置的照片 + weakSelf?.headerView.image = image + if let url = urlString { + weakSelf?.headerUrl = url } - weakSelf?.view.hideToastActivity() + print("upload image success") + } else { + print("upload image failed,error = \(error!)") } - } + weakSelf?.view.hideToastActivity() + } } } + } } - diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamHistoryMessageController.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamHistoryMessageController.swift index 4d144958..ec76925e 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamHistoryMessageController.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamHistoryMessageController.swift @@ -6,7 +6,8 @@ import UIKit import NIMSDK -public class TeamHistoryMessageController: NEBaseViewController,UITextFieldDelegate,UITableViewDelegate, UITableViewDataSource { +public class TeamHistoryMessageController: NEBaseViewController, UITextFieldDelegate, + UITableViewDelegate, UITableViewDataSource { private let viewmodel = TeamSettingViewModel() private var teamSession: NIMSession? private var searchStr = "" @@ -58,7 +59,7 @@ public class TeamHistoryMessageController: NEBaseViewController,UITextFieldDeleg } func initialConfig() { - title = "历史记录" + title = localizable("historical_record") } // MARK: lazy method @@ -86,7 +87,7 @@ public class TeamHistoryMessageController: NEBaseViewController,UITextFieldDeleg textField.contentMode = .center textField.leftView = leftImageView textField.leftViewMode = .always - textField.placeholder = localizable("搜索") + textField.placeholder = localizable("search") textField.font = UIFont.systemFont(ofSize: 14) textField.textColor = UIColor.ne_greyText textField.translatesAutoresizingMaskIntoConstraints = false @@ -101,7 +102,11 @@ public class TeamHistoryMessageController: NEBaseViewController,UITextFieldDeleg }() private lazy var emptyView: NEEmptyDataView = { - let view = NEEmptyDataView(imageName: "emptyView", content: "暂无搜索结果", frame: CGRect.zero) + let view = NEEmptyDataView( + imageName: "emptyView", + content: localizable("no_search_results"), + frame: CGRect.zero + ) view.translatesAutoresizingMaskIntoConstraints = false view.isHidden = true return view @@ -116,75 +121,73 @@ public class TeamHistoryMessageController: NEBaseViewController,UITextFieldDeleg tableView.reloadData() } } - - //MARK: UITextFieldDelegate - public func textFieldShouldReturn(_ textField: UITextField) -> Bool { - guard let searchText = textField.text else { - return false - } - if searchText.count <= 0 { - return false - } - guard let session = teamSession else { - return false - } - weak var weakSelf = self - searchStr = searchText - let option = NIMMessageSearchOption() - option.searchContent = searchText - weakSelf?.viewmodel.searchMessages(session, option: option) { error, messages in - if error == nil { - if let msg = messages, msg.count > 0 { - weakSelf?.emptyView.isHidden = true - } else { - weakSelf?.emptyView.isHidden = false - } - weakSelf?.tableView.reloadData() - } else { - NELog.errorLog( - weakSelf?.tag ?? "TeamHistoryMessageController", - desc: "❌searchMessages failed, error = \(error!)" - ) - } - } - return true + // MARK: UITextFieldDelegate + + public func textFieldShouldReturn(_ textField: UITextField) -> Bool { + guard let searchText = textField.text else { + return false } - - //MARK: UITableViewDelegate, UITableViewDataSource - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - viewmodel.searchResultInfos?.count ?? 0 + if searchText.count <= 0 { + return false } - - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell( - withIdentifier: "\(NSStringFromClass(HistoryMessageCell.self))", - for: indexPath - ) as! HistoryMessageCell - let cellModel = viewmodel.searchResultInfos?[indexPath.row] - cell.searchText = searchStr - cell.configData(message: cellModel) - return cell + guard let session = teamSession else { + return false } - - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let cellModel = viewmodel.searchResultInfos?[indexPath.row] - if cellModel?.imMessage?.session?.sessionType == .team { - if let sid = cellModel?.imMessage?.session?.sessionId, - let message = cellModel?.imMessage { - let session = NIMSession(sid, type: .team) - Router.shared.use( - PushTeamChatVCRouter, - parameters: ["nav": navigationController as Any, "session": session as Any, - "anchor": message], - closure: nil - ) + weak var weakSelf = self + searchStr = searchText + let option = NIMMessageSearchOption() + option.searchContent = searchText + weakSelf?.viewmodel.searchMessages(session, option: option) { error, messages in + if error == nil { + if let msg = messages, msg.count > 0 { + weakSelf?.emptyView.isHidden = true + } else { + weakSelf?.emptyView.isHidden = false } + weakSelf?.tableView.reloadData() + } else { + NELog.errorLog( + weakSelf?.tag ?? "TeamHistoryMessageController", + desc: "❌searchMessages failed, error = \(error!)" + ) } } -} + return true + } + // MARK: UITableViewDelegate, UITableViewDataSource + + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + viewmodel.searchResultInfos?.count ?? 0 + } + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell( + withIdentifier: "\(NSStringFromClass(HistoryMessageCell.self))", + for: indexPath + ) as! HistoryMessageCell + let cellModel = viewmodel.searchResultInfos?[indexPath.row] + cell.searchText = searchStr + cell.configData(message: cellModel) + return cell + } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let cellModel = viewmodel.searchResultInfos?[indexPath.row] + if cellModel?.imMessage?.session?.sessionType == .team { + if let sid = cellModel?.imMessage?.session?.sessionId, + let message = cellModel?.imMessage { + let session = NIMSession(sid, type: .team) + Router.shared.use( + PushTeamChatVCRouter, + parameters: ["nav": navigationController as Any, "session": session as Any, + "anchor": message], + closure: nil + ) + } + } + } +} diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamInfoViewController.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamInfoViewController.swift index b8fbfa6e..5e452ca0 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamInfoViewController.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamInfoViewController.swift @@ -6,7 +6,8 @@ import UIKit import NIMSDK -public class TeamInfoViewController: NEBaseViewController,UITableViewDelegate, UITableViewDataSource { +public class TeamInfoViewController: NEBaseViewController, UITableViewDelegate, + UITableViewDataSource { let viewmodel = TeamInfoViewModel() var team: NIMTeam? @@ -36,9 +37,9 @@ public class TeamInfoViewController: NEBaseViewController,UITableViewDelegate, U // Do any additional setup after loading the view. if let type = team?.type, type == .normal { - title = "讨论组信息" + title = localizable("discuss_info") } else { - title = "群信息" + title = localizable("group_info") } viewmodel.getData(team) setupUI() @@ -67,58 +68,58 @@ public class TeamInfoViewController: NEBaseViewController,UITableViewDelegate, U // Pass the selected object to the new view controller. } */ - //MARK: UITableViewDelegate, UITableViewDataSource - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - viewmodel.cellDatas.count - } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let model = viewmodel.cellDatas[indexPath.row] - if let cell = tableView.dequeueReusableCell( - withIdentifier: "\(model.type)", - for: indexPath - ) as? BaseTeamSettingCell { - cell.configure(model) - return cell - } - return UITableViewCell() + // MARK: UITableViewDelegate, UITableViewDataSource + + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + viewmodel.cellDatas.count + } + + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewmodel.cellDatas[indexPath.row] + if let cell = tableView.dequeueReusableCell( + withIdentifier: "\(model.type)", + for: indexPath + ) as? BaseTeamSettingCell { + cell.configure(model) + return cell } + return UITableViewCell() + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.row == 0 { - let avatar = TeamAvatarViewController() - avatar.team = team - weak var weakSelf = self - avatar.block = { - if let t = weakSelf?.team { - weakSelf?.viewmodel.getData(t) - weakSelf?.contentTable.reloadData() - } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.row == 0 { + let avatar = TeamAvatarViewController() + avatar.team = team + weak var weakSelf = self + avatar.block = { + if let t = weakSelf?.team { + weakSelf?.viewmodel.getData(t) + weakSelf?.contentTable.reloadData() } - navigationController?.pushViewController(avatar, animated: true) - - } else if indexPath.row == 1 { - let nameController = TeamNameViewController() - nameController.team = team - navigationController?.pushViewController(nameController, animated: true) - } else if indexPath.row == 2 { - let intr = TeamIntroduceViewController() - intr.team = team - navigationController?.pushViewController(intr, animated: true) } + navigationController?.pushViewController(avatar, animated: true) + + } else if indexPath.row == 1 { + let nameController = TeamNameViewController() + nameController.team = team + navigationController?.pushViewController(nameController, animated: true) + } else if indexPath.row == 2 { + let intr = TeamIntroduceViewController() + intr.team = team + navigationController?.pushViewController(intr, animated: true) } + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - let model = viewmodel.cellDatas[indexPath.row] - return model.rowHeight - } + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + let model = viewmodel.cellDatas[indexPath.row] + return model.rowHeight + } - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - 12.0 - } - + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + 12.0 + } } - diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamIntroduceViewController.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamIntroduceViewController.swift index cd5e7473..e0cbcd5a 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamIntroduceViewController.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamIntroduceViewController.swift @@ -8,7 +8,7 @@ import NEKitCommon import NIMSDK import NEKitTeam -public class TeamIntroduceViewController: NEBaseViewController,UITextViewDelegate { +public class TeamIntroduceViewController: NEBaseViewController, UITextViewDelegate { // typealias SaveCompletion = () -> Void // // var block: SaveCompletion? @@ -44,12 +44,12 @@ public class TeamIntroduceViewController: NEBaseViewController,UITextViewDelegat } func setupUI() { - addRightAction("保存", #selector(saveIntr), self) + addRightAction(localizable("save"), #selector(saveIntr), self) if let type = team?.type, type == .advanced { - title = "群介绍" + title = localizable("team_intr") } else { - title = "讨论组介绍" + title = localizable("discuss_introduce") } view.backgroundColor = NEConstant.hexRGB(0xF1F1F6) @@ -127,7 +127,7 @@ public class TeamIntroduceViewController: NEBaseViewController,UITextViewDelegat */ func changePermission() -> Bool { - if let ownerId = team?.owner, IMKitLoginManager.instance.isMySelf(ownerId) { + if let ownerId = team?.owner, IMKitEngine.instance.isMySelf(ownerId) { return true } if let mode = team?.updateInfoMode, mode == .all { @@ -135,49 +135,50 @@ public class TeamIntroduceViewController: NEBaseViewController,UITextViewDelegat } return false } - - @objc func saveIntr() { - textView.resignFirstResponder() - if let teamid = team?.teamId { - let text = textView.text ?? "" - weak var weakSelf = self - view.makeToastActivity(.center) - repo.updateTeamIntroduce(text, teamid) { error in - weakSelf?.view.hideToastActivity() - if let err = error { - weakSelf?.showToast(err.localizedDescription) - } else { - weakSelf?.team?.intro = text - weakSelf?.navigationController?.popViewController(animated: true) - } + + @objc func saveIntr() { + textView.resignFirstResponder() + if let teamid = team?.teamId { + let text = textView.text ?? "" + weak var weakSelf = self + view.makeToastActivity(.center) + repo.updateTeamIntroduce(text, teamid) { error in + weakSelf?.view.hideToastActivity() + if let err = error { + weakSelf?.showToast(err.localizedDescription) + } else { + weakSelf?.team?.intro = text + weakSelf?.navigationController?.popViewController(animated: true) } } } - //MARK: UITextViewDelegate - public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, - replacementText text: String) -> Bool { - let currentText = textView.text ?? "" - guard let stringRange = Range(range, in: currentText) else { return false } - let updatedText = currentText.replacingCharacters(in: stringRange, with: text) - return updatedText.count <= 100 - } + } + + // MARK: UITextViewDelegate - public func textViewDidChange(_ textView: UITextView) { - if var text = textView.text { - if let lang = textView.textInputMode?.primaryLanguage, lang == "zh-Hans", - let selectRange = textView.markedTextRange { - let position = textView.position(from: selectRange.start, offset: 0) - if position == nil { - if text.count > 30 { - text = String(text.prefix(30)) - textView.text = String(text.prefix(30)) - } - countLabel.text = "\(text.count)/100" + public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, + replacementText text: String) -> Bool { + let currentText = textView.text ?? "" + guard let stringRange = Range(range, in: currentText) else { return false } + let updatedText = currentText.replacingCharacters(in: stringRange, with: text) + return updatedText.count <= 100 + } + + public func textViewDidChange(_ textView: UITextView) { + if var text = textView.text { + if let lang = textView.textInputMode?.primaryLanguage, lang == "zh-Hans", + let selectRange = textView.markedTextRange { + let position = textView.position(from: selectRange.start, offset: 0) + if position == nil { + if text.count > 30 { + text = String(text.prefix(30)) + textView.text = String(text.prefix(30)) } - } else { countLabel.text = "\(text.count)/100" } + } else { + countLabel.text = "\(text.count)/100" } } + } } - diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamMembersController.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamMembersController.swift index 058e85f0..a003f96b 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamMembersController.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamMembersController.swift @@ -8,7 +8,8 @@ import NEKitTeam import NEKitCore // -public class TeamMembersController: NEBaseViewController,UITableViewDelegate, UITableViewDataSource { +public class TeamMembersController: NEBaseViewController, UITableViewDelegate, + UITableViewDataSource { var datas: [TeamMemberInfoModel]? var ownerId: String? @@ -20,7 +21,7 @@ public class TeamMembersController: NEBaseViewController,UITableViewDelegate, UI lazy var searchTextField: UITextField = { let field = UITextField() field.translatesAutoresizingMaskIntoConstraints = false - field.placeholder = "搜索好友" + field.placeholder = localizable("search_friend") field.textColor = .ne_greyText field.font = UIFont.systemFont(ofSize: 14.0) field.backgroundColor = UIColor.ne_backcolor @@ -57,9 +58,9 @@ public class TeamMembersController: NEBaseViewController,UITableViewDelegate, UI func setupUI() { if isSenior { - title = "群成员" + title = localizable("group_memmber") } else { - title = "讨论组成员" + title = localizable("discuss_mebmer") } let back = UIView() @@ -162,63 +163,62 @@ public class TeamMembersController: NEBaseViewController,UITableViewDelegate, UI } contentTable.reloadData() } - func getRealModel(_ index: Int) -> TeamMemberInfoModel? { - if let text = searchTextField.text, text.count > 0 { - return searchDatas[index] - } - return datas?[index] + + func getRealModel(_ index: Int) -> TeamMemberInfoModel? { + if let text = searchTextField.text, text.count > 0 { + return searchDatas[index] } - - + return datas?[index] + } + deinit { NotificationCenter.default.removeObserver(self) } - - - //MARK: UITableViewDelegate, UITableViewDataSource - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if let text = searchTextField.text, text.count > 0 { - return searchDatas.count - } - return datas?.count ?? 0 + // MARK: UITableViewDelegate, UITableViewDataSource + + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if let text = searchTextField.text, text.count > 0 { + return searchDatas.count } + return datas?.count ?? 0 + } - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - if let cell = tableView.dequeueReusableCell( - withIdentifier: "\(TeamMemberCell.self)", - for: indexPath - ) as? TeamMemberCell { - if let model = getRealModel(indexPath.row) { - cell.configure(model) - cell.ownerLabel.isHidden = !isOwner(model.nimUser?.userId) - } - return cell + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if let cell = tableView.dequeueReusableCell( + withIdentifier: "\(TeamMemberCell.self)", + for: indexPath + ) as? TeamMemberCell { + if let model = getRealModel(indexPath.row) { + cell.configure(model) + cell.ownerLabel.isHidden = !isOwner(model.nimUser?.userId) } - return UITableViewCell() + return cell } + return UITableViewCell() + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - 62.0 - } + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + 62.0 + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if let model = getRealModel(indexPath.row), let user = model.nimUser { - if IMKitLoginManager.instance.isMySelf(user.userId) { - Router.shared.use( - MeSettingRouter, - parameters: ["nav": navigationController as Any], - closure: nil - ) - } else { - Router.shared.use( - ContactUserInfoPageRouter, - parameters: ["nav": navigationController as Any, "nim_user": user], - closure: nil - ) - } + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if let model = getRealModel(indexPath.row), let user = model.nimUser { + if IMKitEngine.instance.isMySelf(user.userId) { + Router.shared.use( + MeSettingRouter, + parameters: ["nav": navigationController as Any], + closure: nil + ) + } else { + Router.shared.use( + ContactUserInfoPageRouter, + parameters: ["nav": navigationController as Any, "nim_user": user], + closure: nil + ) } } + } } diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamNameViewController.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamNameViewController.swift index 2d253601..9dc72afe 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamNameViewController.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamNameViewController.swift @@ -13,7 +13,7 @@ enum ChangeType { case NickName } -public class TeamNameViewController: NEBaseViewController,UITextFieldDelegate { +public class TeamNameViewController: NEBaseViewController, UITextFieldDelegate { var team: NIMTeam? // var user: NIMUser? var type = ChangeType.TeamName @@ -97,13 +97,13 @@ public class TeamNameViewController: NEBaseViewController,UITextFieldDelegate { textField.isEnabled = false } if let teamType = team?.type, teamType == .normal { - title = "讨论组名称" + title = localizable("discuss_name") } else { - title = "群名称" + title = localizable("team_name") } } else if type == .NickName, let n = teamMember?.nickname { - title = "我在群里的昵称" + title = localizable("team_nick") name = n } @@ -121,7 +121,7 @@ public class TeamNameViewController: NEBaseViewController,UITextFieldDelegate { object: textField ) - addRightAction("保存", #selector(saveName), self) + addRightAction(localizable("save"), #selector(saveName), self) } /* @@ -139,7 +139,7 @@ public class TeamNameViewController: NEBaseViewController,UITextFieldDelegate { return true } - if let ownerId = team?.owner, IMKitLoginManager.instance.isMySelf(ownerId) { + if let ownerId = team?.owner, IMKitEngine.instance.isMySelf(ownerId) { return true } if let mode = team?.updateInfoMode, mode == .all { @@ -157,70 +157,69 @@ public class TeamNameViewController: NEBaseViewController,UITextFieldDelegate { rightNavBtn.setTitleColor(NEConstant.hexRGB(0x337EFF), for: .normal) rightNavBtn.isEnabled = true } - - - //MARK: objc 方法 - @objc func textFieldChange() { - if var text = textField.text { - if let lang = textField.textInputMode?.primaryLanguage, lang == "zh-Hans", - let selectRange = textField.markedTextRange { - let position = textField.position(from: selectRange.start, offset: 0) - if position == nil { - if text.count > 30 { - text = String(text.prefix(30)) - textField.text = String(text.prefix(30)) - } - figureTextCount(text) + + // MARK: objc 方法 + + @objc func textFieldChange() { + if var text = textField.text { + if let lang = textField.textInputMode?.primaryLanguage, lang == "zh-Hans", + let selectRange = textField.markedTextRange { + let position = textField.position(from: selectRange.start, offset: 0) + if position == nil { + if text.count > 30 { + text = String(text.prefix(30)) + textField.text = String(text.prefix(30)) } - } else { figureTextCount(text) } + } else { + figureTextCount(text) } } - - @objc func saveName() { - weak var weakSelf = self - textField.resignFirstResponder() - if type == .TeamName, let tid = team?.teamId { - let n = textField.text ?? "" - view.makeToastActivity(.center) - repo.updateTeamName(n, tid) { error in - weakSelf?.view.hideToastActivity() - if let err = error { - weakSelf?.showToast(err.localizedDescription) - } else { - weakSelf?.team?.teamName = n - weakSelf?.navigationController?.popViewController(animated: true) - } + } + + @objc func saveName() { + weak var weakSelf = self + textField.resignFirstResponder() + if type == .TeamName, let tid = team?.teamId { + let n = textField.text ?? "" + view.makeToastActivity(.center) + repo.updateTeamName(n, tid) { error in + weakSelf?.view.hideToastActivity() + if let err = error { + weakSelf?.showToast(err.localizedDescription) + } else { + weakSelf?.team?.teamName = n + weakSelf?.navigationController?.popViewController(animated: true) } - } else if type == .NickName, let tid = team?.teamId, let uid = teamMember?.userId { - let n = textField.text ?? "" - view.makeToastActivity(.center) - repo.updateMemberNick(uid, n, tid) { error in - - weakSelf?.view.hideToastActivity() - if let err = error { - weakSelf?.showToast(err.localizedDescription) - } else { - weakSelf?.navigationController?.popViewController(animated: true) - } + } + } else if type == .NickName, let tid = team?.teamId, let uid = teamMember?.userId { + let n = textField.text ?? "" + view.makeToastActivity(.center) + repo.updateMemberNick(uid, n, tid) { error in + + weakSelf?.view.hideToastActivity() + if let err = error { + weakSelf?.showToast(err.localizedDescription) + } else { + weakSelf?.navigationController?.popViewController(animated: true) } } } - //MAKR: UITextFieldDelegate - public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, - replacementString string: String) -> Bool { - if let text = (textField.text as NSString?)?.replacingCharacters(in: range, with: string), - text.count > 30 { - return false - } - return true + } + + // MAKR: UITextFieldDelegate + public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, + replacementString string: String) -> Bool { + if let text = (textField.text as NSString?)?.replacingCharacters(in: range, with: string), + text.count > 30 { + return false } - + return true + } } extension TeamNameViewController { - func figureTextCount(_ text: String) { countLabel.text = "\(text.count)/30" if type == .NickName { @@ -232,6 +231,4 @@ extension TeamNameViewController { disableSubmit() } } - - } diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamSettingViewController.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamSettingViewController.swift index b170c709..b1d02b2b 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamSettingViewController.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/TeamSettingViewController.swift @@ -8,7 +8,9 @@ import NEKitCommonUI import NEKitCoreIM import NIMSDK -public class TeamSettingViewController: NEBaseViewController,UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UITableViewDataSource, UITableViewDelegate { +public class TeamSettingViewController: NEBaseViewController, UICollectionViewDelegate, + UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, UITableViewDataSource, + UITableViewDelegate { let viewmodel = TeamSettingViewModel() var teamId: String? @@ -321,189 +323,191 @@ public class TeamSettingViewController: NEBaseViewController,UICollectionViewDel forCellWithReuseIdentifier: "\(TeamUserCell.self)" ) } -//MARK: objc 方法 - @objc func addUser() { - weak var weakSelf = self - Router.shared.register(ContactSelectedUsersRouter) { param in - print("addUser weak self ", weakSelf as Any) - if let accids = param["accids"] as? [String], - let tid = self.viewmodel.teamInfoModel?.team?.teamId, - let beInviteMode = self.viewmodel.teamInfoModel?.team?.beInviteMode, - let type = self.viewmodel.teamInfoModel?.team?.type { - if beInviteMode == .noAuth || type == .normal { - self.didAddUserAndRefreshUI(accids, tid) - } else { - self.didAddUser(accids, tid) - } - } - } - var param = [String: Any]() - param["nav"] = navigationController as Any - var filters = Set() - viewmodel.teamInfoModel?.users.forEach { model in - if let uid = model.nimUser?.userId { - filters.insert(uid) - } - } - if filters.count > 0 { - param["filters"] = filters - } - param["limit"] = 200 - filters.count - Router.shared.use(ContactUserSelectRouter, parameters: param, closure: nil) - } + // MARK: objc 方法 - @objc func removeTeamForMyself() { - weak var weakSelf = self - if viewmodel.isOwner(), let type = viewmodel.teamInfoModel?.team?.type, type == .advanced { - showAlert(message: "是否解散群聊?") { - weakSelf?.dismissTeam() - } - } else { - if let type = viewmodel.teamInfoModel?.team?.type { - if type == .advanced { - showAlert(message: "是否退出群聊?") { - weakSelf?.leveaTeam() - } - } else if type == .normal { - showAlert(message: "是否退出讨论组?") { - weakSelf?.leveaTeam() - } - } + @objc func addUser() { + weak var weakSelf = self + Router.shared.register(ContactSelectedUsersRouter) { param in + print("addUser weak self ", weakSelf as Any) + if let accids = param["accids"] as? [String], + let tid = self.viewmodel.teamInfoModel?.team?.teamId, + let beInviteMode = self.viewmodel.teamInfoModel?.team?.beInviteMode, + let type = self.viewmodel.teamInfoModel?.team?.type { + if beInviteMode == .noAuth || type == .normal { + self.didAddUserAndRefreshUI(accids, tid) + } else { + self.didAddUser(accids, tid) } } } - - @objc func toInfoView() { - let info = TeamInfoViewController() - info.team = viewmodel.teamInfoModel?.team - navigationController?.pushViewController(info, animated: true) + var param = [String: Any]() + param["nav"] = navigationController as Any + var filters = Set() + viewmodel.teamInfoModel?.users.forEach { model in + if let uid = model.nimUser?.userId { + filters.insert(uid) + } + } + if filters.count > 0 { + param["filters"] = filters } - @objc func toMemberList() { - let memberController = TeamMembersController() - memberController.datas = viewmodel.teamInfoModel?.users - if let type = viewmodel.teamInfoModel?.team?.type, type == .advanced { - memberController.isSenior = true - } - memberController.ownerId = viewmodel.teamInfoModel?.team?.owner - navigationController?.pushViewController(memberController, animated: true) - } - - - //MARK: UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout - public func collectionView(_ collectionView: UICollectionView, - numberOfItemsInSection section: Int) -> Int { - print("numberOfItemsInSection ", viewmodel.teamInfoModel?.users.count as Any) - return viewmodel.teamInfoModel?.users.count ?? 0 - } - - public func collectionView(_ collectionView: UICollectionView, - cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - if let cell = collectionView.dequeueReusableCell( - withReuseIdentifier: "\(TeamUserCell.self)", - for: indexPath - ) as? TeamUserCell { - if let user = viewmodel.teamInfoModel?.users[indexPath.row] { - cell.user = user - } - return cell + param["limit"] = 200 - filters.count + Router.shared.use(ContactUserSelectRouter, parameters: param, closure: nil) + } + + @objc func removeTeamForMyself() { + weak var weakSelf = self + if viewmodel.isOwner(), let type = viewmodel.teamInfoModel?.team?.type, type == .advanced { + showAlert(message: localizable("dissolute_team_chat")) { + weakSelf?.dismissTeam() } - return UICollectionViewCell() - } - - public func collectionView(_ collectionView: UICollectionView, - layout collectionViewLayout: UICollectionViewLayout, - sizeForItemAt indexPath: IndexPath) -> CGSize { - CGSize(width: 47.0, height: 32) - } - - public func collectionView(_ collectionView: UICollectionView, - didSelectItemAt indexPath: IndexPath) { - if let member = viewmodel.teamInfoModel?.users[indexPath.row], - let nimUser = member.nimUser { - let user = User(user: nimUser) - if IMKitLoginManager.instance.isMySelf(user.userId) { - Router.shared.use( - MeSettingRouter, - parameters: ["nav": navigationController as Any], - closure: nil - ) - } else { - Router.shared.use( - ContactUserInfoPageRouter, - parameters: ["nav": navigationController as Any, "user": user], - closure: nil - ) + } else { + if let type = viewmodel.teamInfoModel?.team?.type { + if type == .advanced { + showAlert(message: localizable("quit_team_chat")) { + weakSelf?.leveaTeam() + } + } else if type == .normal { + showAlert(message: localizable("quit_discuss_chat")) { + weakSelf?.leveaTeam() + } } } } - - //MARK: UITableViewDataSource, UITableViewDelegate - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if viewmodel.sectionData.count > section { - let model = viewmodel.sectionData[section] - return model.cellModels.count - } - return 0 - } + } - public func numberOfSections(in tableView: UITableView) -> Int { - viewmodel.sectionData.count + @objc func toInfoView() { + let info = TeamInfoViewController() + info.team = viewmodel.teamInfoModel?.team + navigationController?.pushViewController(info, animated: true) + } + + @objc func toMemberList() { + let memberController = TeamMembersController() + memberController.datas = viewmodel.teamInfoModel?.users + if let type = viewmodel.teamInfoModel?.team?.type, type == .advanced { + memberController.isSenior = true } + memberController.ownerId = viewmodel.teamInfoModel?.team?.owner + navigationController?.pushViewController(memberController, animated: true) + } + + // MARK: UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout - public func tableView(_ tableView: UITableView, - cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let model = viewmodel.sectionData[indexPath.section].cellModels[indexPath.row] - if let cell = tableView.dequeueReusableCell( - withIdentifier: "\(model.type)", - for: indexPath - ) as? BaseTeamSettingCell { - cell.configure(model) - return cell + public func collectionView(_ collectionView: UICollectionView, + numberOfItemsInSection section: Int) -> Int { + print("numberOfItemsInSection ", viewmodel.teamInfoModel?.users.count as Any) + return viewmodel.teamInfoModel?.users.count ?? 0 + } + + public func collectionView(_ collectionView: UICollectionView, + cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + if let cell = collectionView.dequeueReusableCell( + withReuseIdentifier: "\(TeamUserCell.self)", + for: indexPath + ) as? TeamUserCell { + if let user = viewmodel.teamInfoModel?.users[indexPath.row] { + cell.user = user } - return UITableViewCell() + return cell } + return UICollectionViewCell() + } + + public func collectionView(_ collectionView: UICollectionView, + layout collectionViewLayout: UICollectionViewLayout, + sizeForItemAt indexPath: IndexPath) -> CGSize { + CGSize(width: 47.0, height: 32) + } - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let model = viewmodel.sectionData[indexPath.section].cellModels[indexPath.row] - if let block = model.cellClick { - block() + public func collectionView(_ collectionView: UICollectionView, + didSelectItemAt indexPath: IndexPath) { + if let member = viewmodel.teamInfoModel?.users[indexPath.row], + let nimUser = member.nimUser { + let user = User(user: nimUser) + if IMKitEngine.instance.isMySelf(user.userId) { + Router.shared.use( + MeSettingRouter, + parameters: ["nav": navigationController as Any], + closure: nil + ) + } else { + Router.shared.use( + ContactUserInfoPageRouter, + parameters: ["nav": navigationController as Any, "user": user], + closure: nil + ) } } + } - public func tableView(_ tableView: UITableView, - heightForRowAt indexPath: IndexPath) -> CGFloat { - let model = viewmodel.sectionData[indexPath.section].cellModels[indexPath.row] - return model.rowHeight - } + // MARK: UITableViewDataSource, UITableViewDelegate - public func tableView(_ tableView: UITableView, - heightForHeaderInSection section: Int) -> CGFloat { - if viewmodel.sectionData.count > section { - let model = viewmodel.sectionData[section] - if model.cellModels.count > 0 { - return 12.0 - } - } - return 0 + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if viewmodel.sectionData.count > section { + let model = viewmodel.sectionData[section] + return model.cellModels.count } + return 0 + } - public func tableView(_ tableView: UITableView, - viewForHeaderInSection section: Int) -> UIView? { - let header = UIView() - header.backgroundColor = NEConstant.hexRGB(0xF1F1F6) - return header + public func numberOfSections(in tableView: UITableView) -> Int { + viewmodel.sectionData.count + } + + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewmodel.sectionData[indexPath.section].cellModels[indexPath.row] + if let cell = tableView.dequeueReusableCell( + withIdentifier: "\(model.type)", + for: indexPath + ) as? BaseTeamSettingCell { + cell.configure(model) + return cell + } + return UITableViewCell() + } + + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let model = viewmodel.sectionData[indexPath.section].cellModels[indexPath.row] + if let block = model.cellClick { + block() } + } - public func tableView(_ tableView: UITableView, - heightForFooterInSection section: Int) -> CGFloat { - if section == viewmodel.sectionData.count - 1 { + public func tableView(_ tableView: UITableView, + heightForRowAt indexPath: IndexPath) -> CGFloat { + let model = viewmodel.sectionData[indexPath.section].cellModels[indexPath.row] + return model.rowHeight + } + + public func tableView(_ tableView: UITableView, + heightForHeaderInSection section: Int) -> CGFloat { + if viewmodel.sectionData.count > section { + let model = viewmodel.sectionData[section] + if model.cellModels.count > 0 { return 12.0 } - return 0 } - + return 0 + } + + public func tableView(_ tableView: UITableView, + viewForHeaderInSection section: Int) -> UIView? { + let header = UIView() + header.backgroundColor = NEConstant.hexRGB(0xF1F1F6) + return header + } + + public func tableView(_ tableView: UITableView, + heightForFooterInSection section: Int) -> CGFloat { + if section == viewmodel.sectionData.count - 1 { + return 12.0 + } + return 0 + } } extension TeamSettingViewController { @@ -541,13 +545,11 @@ extension TeamSettingViewController { if let err = error { weakSelf?.showToast(err.localizedDescription) } else { - weakSelf?.showToast("邀请已发送") + weakSelf?.showToast(localizable("invite_has_send")) } } } - - func dismissTeam() { if let tid = teamId { weak var weakSelf = self @@ -583,7 +585,6 @@ extension TeamSettingViewController { } } } - } extension TeamSettingViewController: TeamSettingViewModelDelegate { @@ -604,13 +605,13 @@ extension TeamSettingViewController: TeamSettingViewModelDelegate { preferredStyle: .actionSheet ) - let cancelActionButton = UIAlertAction(title: "取消", style: .cancel) { _ in + let cancelActionButton = UIAlertAction(title: localizable("cancel"), style: .cancel) { _ in print("Cancel") } cancelActionButton.setValue(UIColor.ne_darkText, forKey: "_titleTextColor") actionSheetController.addAction(cancelActionButton) - let manager = UIAlertAction(title: "群主", style: .default) { _ in + let manager = UIAlertAction(title: localizable("team_owner"), style: .default) { _ in weakSelf?.view.makeToastActivity(.center) weakSelf?.viewmodel.repo.updateInviteMode(.manager, weakSelf?.teamId ?? "") { error in weakSelf?.view.hideToastActivity() @@ -618,7 +619,7 @@ extension TeamSettingViewController: TeamSettingViewModelDelegate { weakSelf?.showToast(err.localizedDescription) } else { weakSelf?.viewmodel.teamInfoModel?.team?.inviteMode = .manager - model.subTitle = "群主" + model.subTitle = localizable("team_owner") weakSelf?.contentTable.reloadData() } } @@ -626,7 +627,7 @@ extension TeamSettingViewController: TeamSettingViewModelDelegate { manager.setValue(UIColor.ne_darkText, forKey: "_titleTextColor") actionSheetController.addAction(manager) - let deleteActionButton = UIAlertAction(title: "所有人", style: .default) { _ in + let deleteActionButton = UIAlertAction(title: localizable("team_all"), style: .default) { _ in weakSelf?.view.makeToastActivity(.center) weakSelf?.viewmodel.repo.updateInviteMode(.all, weakSelf?.teamId ?? "") { error in weakSelf?.view.hideToastActivity() @@ -634,7 +635,7 @@ extension TeamSettingViewController: TeamSettingViewModelDelegate { weakSelf?.showToast(err.localizedDescription) } else { weakSelf?.viewmodel.teamInfoModel?.team?.inviteMode = .all - model.subTitle = "所有人" + model.subTitle = localizable("team_all") weakSelf?.contentTable.reloadData() } } @@ -648,17 +649,17 @@ extension TeamSettingViewController: TeamSettingViewModelDelegate { func didUpdateTeamInfoClick(_ model: SettingCellModel) { let actionSheetController = UIAlertController( - title: "提示", + title: localizable("remind"), message: nil, preferredStyle: .actionSheet ) weak var weakSelf = self - let cancelActionButton = UIAlertAction(title: "取消", style: .cancel) { _ in + let cancelActionButton = UIAlertAction(title: localizable("cancel"), style: .cancel) { _ in print("Cancel") } actionSheetController.addAction(cancelActionButton) - let manager = UIAlertAction(title: "群主", style: .default) { _ in + let manager = UIAlertAction(title: localizable("team_owner"), style: .default) { _ in weakSelf?.view.makeToastActivity(.center) weakSelf?.viewmodel.repo .updateTeamInfoPrivilege(.manager, weakSelf?.teamId ?? "") { error in @@ -667,14 +668,14 @@ extension TeamSettingViewController: TeamSettingViewModelDelegate { weakSelf?.showToast(err.localizedDescription) } else { weakSelf?.viewmodel.teamInfoModel?.team?.updateInfoMode = .manager - model.subTitle = "群主" + model.subTitle = localizable("team_owner") weakSelf?.contentTable.reloadData() } } } actionSheetController.addAction(manager) - let all = UIAlertAction(title: "所有人", style: .default) { _ in + let all = UIAlertAction(title: localizable("team_all"), style: .default) { _ in weakSelf?.view.makeToastActivity(.center) weakSelf?.viewmodel.repo .updateTeamInfoPrivilege(.all, weakSelf?.teamId ?? "") { error in @@ -683,7 +684,7 @@ extension TeamSettingViewController: TeamSettingViewModelDelegate { weakSelf?.showToast(err.localizedDescription) } else { weakSelf?.viewmodel.teamInfoModel?.team?.updateInfoMode = .all - model.subTitle = "所有人" + model.subTitle = localizable("team_all") weakSelf?.contentTable.reloadData() } } diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/View/TeamMemberCell.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/View/TeamMemberCell.swift index 777bfc6b..09d57489 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/View/TeamMemberCell.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/View/TeamMemberCell.swift @@ -28,7 +28,7 @@ class TeamMemberCell: UITableViewCell { label.layer.cornerRadius = 4.0 label.layer.borderColor = NEConstant.hexRGB(0xB9D3FF).cgColor label.layer.borderWidth = 1.0 - label.text = "群主" + label.text = localizable("team_owner") label.textAlignment = .center return label }() diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/ViewModel/TeamInfoViewModel.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/ViewModel/TeamInfoViewModel.swift index 31245dd2..d5c02e2a 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/ViewModel/TeamInfoViewModel.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/ViewModel/TeamInfoViewModel.swift @@ -26,9 +26,9 @@ class TeamInfoViewModel { intrCell.cornerType = .bottomLeft.union(.bottomRight) if let type = team?.type, type == .normal { - headerCell.cellName = "讨论组头像" - nameCell.cellName = "讨论组名称" - intrCell.cellName = "讨论组介绍" + headerCell.cellName = localizable("discuss_avatar") + nameCell.cellName = localizable("discuss_name") + intrCell.cellName = localizable("discuss_intro") cellDatas.append(contentsOf: [headerCell, nameCell]) nameCell.cornerType = .bottomLeft.union(.bottomRight) } else { diff --git a/NETeamUIKit/NEKitTeamUI/Classes/Setting/ViewModel/TeamSettingViewModel.swift b/NETeamUIKit/NEKitTeamUI/Classes/Setting/ViewModel/TeamSettingViewModel.swift index 203480e3..7181b477 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/Setting/ViewModel/TeamSettingViewModel.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/Setting/ViewModel/TeamSettingViewModel.swift @@ -283,7 +283,7 @@ public class TeamSettingViewModel { if error == nil { weakSelf?.getData() - weakSelf?.getCurrentMember(IMKitLoginManager.instance.imAccid, teamId) + weakSelf?.getCurrentMember(IMKitEngine.instance.imAccid, teamId) } completion(error) } @@ -307,7 +307,7 @@ public class TeamSettingViewModel { func isOwner() -> Bool { if let accid = teamInfoModel?.team?.owner { - if IMKitLoginManager.instance.isMySelf(accid) { + if IMKitEngine.instance.isMySelf(accid) { return true } } diff --git a/NETeamUIKit/NEKitTeamUI/Classes/TeamRouter.swift b/NETeamUIKit/NEKitTeamUI/Classes/TeamRouter.swift index a5245736..4af5aa66 100644 --- a/NETeamUIKit/NEKitTeamUI/Classes/TeamRouter.swift +++ b/NETeamUIKit/NEKitTeamUI/Classes/TeamRouter.swift @@ -8,7 +8,9 @@ import NEKitTeam import NEKitCore import NEKitCoreIM import NIMSDK -public enum TeamRouter { + +@objcMembers +public class TeamRouter:NSObject { public static var iconUrls = ["https://s.netease.im/safe/ABg8YjWQWvcqO6sAAAAAAAAAAAA?_im_url=1", "https://s.netease.im/safe/ABg8YjmQWvcqO6sAAAAAAAABAAA?_im_url=1", "https://s.netease.im/safe/ABg8YjyQWvcqO6sAAAAAAAABAAA?_im_url=1", diff --git a/Podfile b/Podfile index 7ae8f3fe..55659da8 100644 --- a/Podfile +++ b/Podfile @@ -9,25 +9,25 @@ target 'app' do pod 'YXLogin', '1.0.0' #可选UI库 - pod 'NEContactUIKit', '9.2.7' - pod 'NEQChatUIKit', '9.2.7' - pod 'NEConversationUIKit', '9.2.7' - pod 'NEChatUIKit', '9.2.7' - pod 'NETeamUIKit', '9.2.7' + pod 'NEContactUIKit', '9.2.8' + pod 'NEQChatUIKit', '9.2.8' + pod 'NEConversationUIKit', '9.2.8' + pod 'NEChatUIKit', '9.2.8' + pod 'NETeamUIKit', '9.2.8' #可选Kit库(和UIKit对应) - pod 'NEContactKit', '9.2.7' - pod 'NEQChatKit', '9.2.7' - pod 'NEConversationKit', '9.2.7' - pod 'NEChatKit', '9.2.7' - pod 'NETeamKit', '9.2.7' + pod 'NEContactKit', '9.2.8' + pod 'NEQChatKit', '9.2.8' + pod 'NEConversationKit', '9.2.8' + pod 'NEChatKit', '9.2.8' + pod 'NETeamKit', '9.2.8' #基础kit库 - pod 'NECommonUIKit', '9.2.7' - pod 'NECommonKit', '9.2.7' - pod 'NECoreIMKit', '9.2.7' - pod 'NECoreKit', '9.2.7' + pod 'NECommonUIKit', '9.2.8' + pod 'NECommonKit', '9.2.8' + pod 'NECoreIMKit', '9.2.8' + pod 'NECoreKit', '9.2.8' # 如果需要查看UI部分源码请注释掉以上在线依赖,打开下面的本地依赖 diff --git a/app.xcodeproj/project.pbxproj b/app.xcodeproj/project.pbxproj index ec3d51ba..38ea292f 100644 --- a/app.xcodeproj/project.pbxproj +++ b/app.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 393759E928123E5E004F0AEC /* MessageRemindViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 393759E828123E5E004F0AEC /* MessageRemindViewModel.swift */; }; 393759EB2812951E004F0AEC /* InputPersonInfoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 393759EA2812951E004F0AEC /* InputPersonInfoController.swift */; }; 39A36F8128002CFF009B07A9 /* NETabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39A36F8028002CFF009B07A9 /* NETabBarController.swift */; }; + 39E9E27728D87E9800A11820 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 39E9E27528D87E9800A11820 /* Localizable.strings */; }; 39F793C827E20434007F63FF /* NENavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39F793C727E20434007F63FF /* NENavigationController.swift */; }; 4B3B9BDF277AFEE50091A74E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B3B9BDE277AFEE50091A74E /* AppDelegate.swift */; }; 4B3B9BE3277AFEE50091A74E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B3B9BE2277AFEE50091A74E /* ViewController.swift */; }; @@ -63,6 +64,8 @@ 393759E828123E5E004F0AEC /* MessageRemindViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageRemindViewModel.swift; sourceTree = ""; }; 393759EA2812951E004F0AEC /* InputPersonInfoController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InputPersonInfoController.swift; sourceTree = ""; }; 39A36F8028002CFF009B07A9 /* NETabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NETabBarController.swift; sourceTree = ""; }; + 39E9E27628D87E9800A11820 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; + 39E9E27828D87EA000A11820 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 39F793C727E20434007F63FF /* NENavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NENavigationController.swift; sourceTree = ""; }; 4B3B9BDB277AFEE50091A74E /* app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = app.app; sourceTree = BUILT_PRODUCTS_DIR; }; 4B3B9BDE277AFEE50091A74E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -70,7 +73,6 @@ 4B3B9BE5277AFEE50091A74E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 4B3B9BE7277AFEE70091A74E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4B3B9BEA277AFEE70091A74E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - 4B3B9BEC277AFEE70091A74E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 9E98CA4B27BCEC15008A8738 /* MeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeViewController.swift; sourceTree = ""; }; 9EA2014027BE4B4800F8BBD0 /* AppKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppKey.swift; sourceTree = ""; }; A9E4316D70F3EF2E6BD5E5CB /* Pods-app.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-app.release.xcconfig"; path = "Target Support Files/Pods-app/Pods-app.release.xcconfig"; sourceTree = ""; }; @@ -148,11 +150,11 @@ 4B3B9BDE277AFEE50091A74E /* AppDelegate.swift */, 9EA2014027BE4B4800F8BBD0 /* AppKey.swift */, 4B3B9BE2277AFEE50091A74E /* ViewController.swift */, + 39E9E27528D87E9800A11820 /* Localizable.strings */, 393759D1281033C9004F0AEC /* Mine */, 4B3B9BE4277AFEE50091A74E /* Main.storyboard */, 4B3B9BE7277AFEE70091A74E /* Assets.xcassets */, 4B3B9BE9277AFEE70091A74E /* LaunchScreen.storyboard */, - 4B3B9BEC277AFEE70091A74E /* Info.plist */, ); path = app; sourceTree = ""; @@ -230,6 +232,7 @@ buildActionMask = 2147483647; files = ( 4B3B9BEB277AFEE70091A74E /* LaunchScreen.storyboard in Resources */, + 39E9E27728D87E9800A11820 /* Localizable.strings in Resources */, 4B3B9BE8277AFEE70091A74E /* Assets.xcassets in Resources */, 4B3B9BE6277AFEE50091A74E /* Main.storyboard in Resources */, ); @@ -309,6 +312,15 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ + 39E9E27528D87E9800A11820 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 39E9E27628D87E9800A11820 /* en */, + 39E9E27828D87EA000A11820 /* zh-Hans */, + ); + name = Localizable.strings; + sourceTree = ""; + }; 4B3B9BE4277AFEE50091A74E /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( diff --git a/app/AppDelegate.swift b/app/AppDelegate.swift index dfb682fd..a4a4d760 100644 --- a/app/AppDelegate.swift +++ b/app/AppDelegate.swift @@ -54,7 +54,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD center.requestAuthorization(options: [.badge, .sound, .alert]) { grant, error in if grant == false { DispatchQueue.main.async { - UIApplication.shared.keyWindow?.makeToast("请到设置中开启推送功能") + UIApplication.shared.keyWindow?.makeToast(NSLocalizedString("open_push", comment: "")) } } } diff --git a/app/Assets.xcassets/AppIcon.appiconset/58x58-2.png b/app/Assets.xcassets/AppIcon.appiconset/58x58-2.png new file mode 100644 index 00000000..84f64125 Binary files /dev/null and b/app/Assets.xcassets/AppIcon.appiconset/58x58-2.png differ diff --git a/app/Assets.xcassets/launch_icon.imageset/Contents.json b/app/Assets.xcassets/launchIcon.imageset/Contents.json similarity index 76% rename from app/Assets.xcassets/launch_icon.imageset/Contents.json rename to app/Assets.xcassets/launchIcon.imageset/Contents.json index 1063270e..4b3f8bdc 100644 --- a/app/Assets.xcassets/launch_icon.imageset/Contents.json +++ b/app/Assets.xcassets/launchIcon.imageset/Contents.json @@ -5,12 +5,12 @@ "scale" : "1x" }, { - "filename" : "launch_icon@2x.png", + "filename" : "launchIcon@2x.png", "idiom" : "universal", "scale" : "2x" }, { - "filename" : "launch_icon@3x.png", + "filename" : "launchIcon@3x.png", "idiom" : "universal", "scale" : "3x" } diff --git a/app/Assets.xcassets/launchIcon.imageset/launchIcon@2x.png b/app/Assets.xcassets/launchIcon.imageset/launchIcon@2x.png new file mode 100644 index 00000000..3b7a373f Binary files /dev/null and b/app/Assets.xcassets/launchIcon.imageset/launchIcon@2x.png differ diff --git a/app/Assets.xcassets/launchIcon.imageset/launchIcon@3x.png b/app/Assets.xcassets/launchIcon.imageset/launchIcon@3x.png new file mode 100644 index 00000000..4ea8c4e5 Binary files /dev/null and b/app/Assets.xcassets/launchIcon.imageset/launchIcon@3x.png differ diff --git a/app/Assets.xcassets/launch_icon.imageset/launch_icon@2x.png b/app/Assets.xcassets/launch_icon.imageset/launch_icon@2x.png deleted file mode 100644 index ed120837..00000000 Binary files a/app/Assets.xcassets/launch_icon.imageset/launch_icon@2x.png and /dev/null differ diff --git a/app/Assets.xcassets/launch_icon.imageset/launch_icon@3x.png b/app/Assets.xcassets/launch_icon.imageset/launch_icon@3x.png deleted file mode 100644 index 1cb0d1bd..00000000 Binary files a/app/Assets.xcassets/launch_icon.imageset/launch_icon@3x.png and /dev/null differ diff --git a/app/Assets.xcassets/yunxin_brand.imageset/Contents.json b/app/Assets.xcassets/yunxin_brand.imageset/Contents.json new file mode 100644 index 00000000..90e0b26d --- /dev/null +++ b/app/Assets.xcassets/yunxin_brand.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "yunxin_brand@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "yunxin_brand@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app/Assets.xcassets/yunxin_brand.imageset/yunxin_brand@2x.png b/app/Assets.xcassets/yunxin_brand.imageset/yunxin_brand@2x.png new file mode 100644 index 00000000..530f576a Binary files /dev/null and b/app/Assets.xcassets/yunxin_brand.imageset/yunxin_brand@2x.png differ diff --git a/app/Assets.xcassets/yunxin_brand.imageset/yunxin_brand@3x.png b/app/Assets.xcassets/yunxin_brand.imageset/yunxin_brand@3x.png new file mode 100644 index 00000000..5089bb83 Binary files /dev/null and b/app/Assets.xcassets/yunxin_brand.imageset/yunxin_brand@3x.png differ diff --git a/app/Assets.xcassets/yunxin_logo.imageset/yunxin_logo@2x.png b/app/Assets.xcassets/yunxin_logo.imageset/yunxin_logo@2x.png index 191c4e2b..c989ac49 100644 Binary files a/app/Assets.xcassets/yunxin_logo.imageset/yunxin_logo@2x.png and b/app/Assets.xcassets/yunxin_logo.imageset/yunxin_logo@2x.png differ diff --git a/app/Assets.xcassets/yunxin_logo.imageset/yunxin_logo@3x.png b/app/Assets.xcassets/yunxin_logo.imageset/yunxin_logo@3x.png index 2ec27992..aab2bc36 100644 Binary files a/app/Assets.xcassets/yunxin_logo.imageset/yunxin_logo@3x.png and b/app/Assets.xcassets/yunxin_logo.imageset/yunxin_logo@3x.png differ diff --git a/app/Info.plist b/app/Info.plist index ee29e9a1..a856f55d 100644 --- a/app/Info.plist +++ b/app/Info.plist @@ -17,7 +17,11 @@ NSCameraUsageDescription 若不允许,你将无法拍摄照片 NSPhotoLibraryUsageDescription - 若不允许,你将无法导入照片上传头像。 + 若不允许,你将无法导入照片 + NSPhotoLibraryAddUsageDescription + 若不允许,则无法使用相册功能 + NSMicrophoneUsageDescription + 若不允许,则无法使用麦克风功能 UIApplicationSupportsMultipleScenes diff --git a/app/Mine/BirthdayDatePickerView.swift b/app/Mine/BirthdayDatePickerView.swift index 118108b0..8a6b7319 100644 --- a/app/Mine/BirthdayDatePickerView.swift +++ b/app/Mine/BirthdayDatePickerView.swift @@ -1,134 +1,127 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import UIKit +import NEKitCommonUI public class BirthdayDatePickerView: UIView { + private var selectTime: String? + public typealias SelectTimeCallBack = (String?) -> Void + public var timeCallBack: SelectTimeCallBack? - private var selectTime:String? - public typealias SelectTimeCallBack = (String?) -> Void - public var timeCallBack:SelectTimeCallBack? - - lazy var sureBtn:UIButton = { - let button = UIButton.init(type: .custom) - button.translatesAutoresizingMaskIntoConstraints = false - button.setTitle("确认", for: .normal) - button.setTitleColor(UIColor.ne_blueText, for: .normal) - button.titleLabel?.font = UIFont.systemFont(ofSize: 13) - button.addTarget(self, action: #selector(sureBtnClick), for: .touchUpInside) - return button - }() - - lazy var picker:UIDatePicker = { - let datePicker = UIDatePicker(frame: CGRect.zero) - datePicker.translatesAutoresizingMaskIntoConstraints = false - //将日期选择器区域设置为中文,则选择器日期显示为中文 - datePicker.locale = Locale(identifier: "zh_CN") - datePicker.datePickerMode = .date - //注意:action里面的方法名后面需要加个冒号“:” - datePicker.addTarget(self, action: #selector(dateChanged), - for: .valueChanged) - - return datePicker - }() - - lazy var cancelBtn:UIButton = { - let button = UIButton() - button.translatesAutoresizingMaskIntoConstraints = false - button.setTitle("取消", for: .normal) - button.setTitleColor(UIColor.ne_blueText, for: .normal) - button.titleLabel?.font = UIFont.systemFont(ofSize: 13) - button.addTarget(self, action: #selector(cancelBtnClick), for: .touchUpInside) - - return button - }() - - override init(frame: CGRect) { - super.init(frame: frame) - setupSubviews() - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - func setupSubviews(){ - //创建日期选择器 - self.addSubview(cancelBtn) - self.addSubview(sureBtn) - self.addSubview(bottomLine) - self.addSubview(picker) - - NSLayoutConstraint.activate([ - cancelBtn.leftAnchor.constraint(equalTo: self.leftAnchor,constant: 15), - cancelBtn.topAnchor.constraint(equalTo: self.topAnchor,constant: 8), - cancelBtn.widthAnchor.constraint(equalToConstant: 45) - ]) - - - NSLayoutConstraint.activate([ - sureBtn.rightAnchor.constraint(equalTo: self.rightAnchor,constant: -15), - sureBtn.topAnchor.constraint(equalTo: self.topAnchor,constant: 8), - sureBtn.widthAnchor.constraint(equalToConstant: 45) - ]) - - - NSLayoutConstraint.activate([ - bottomLine.leftAnchor.constraint(equalTo: self.leftAnchor), - bottomLine.rightAnchor.constraint(equalTo: self.rightAnchor), - bottomLine.topAnchor.constraint(equalTo: cancelBtn.bottomAnchor), - bottomLine.heightAnchor.constraint(equalToConstant: 0.5) - ]) - - - NSLayoutConstraint.activate([ - picker.leftAnchor.constraint(equalTo: self.leftAnchor), - picker.rightAnchor.constraint(equalTo: self.rightAnchor), - picker.bottomAnchor.constraint(equalTo: self.bottomAnchor), - picker.topAnchor.constraint(equalTo: bottomLine.bottomAnchor) - ]) + lazy var sureBtn: UIButton = { + let button = UIButton(type: .custom) + button.translatesAutoresizingMaskIntoConstraints = false + button.setTitle(NSLocalizedString("confirm", comment: ""), for: .normal) + button.setTitleColor(UIColor.ne_blueText, for: .normal) + button.titleLabel?.font = UIFont.systemFont(ofSize: 13) + button.addTarget(self, action: #selector(sureBtnClick), for: .touchUpInside) + return button + }() + lazy var picker: UIDatePicker = { + let datePicker = UIDatePicker(frame: CGRect.zero) + datePicker.translatesAutoresizingMaskIntoConstraints = false + // 将日期选择器区域设置为中文,则选择器日期显示为中文 + datePicker.locale = Locale(identifier: "zh_CN") + datePicker.datePickerMode = .date + // 注意:action里面的方法名后面需要加个冒号“:” + datePicker.addTarget(self, action: #selector(dateChanged), + for: .valueChanged) + + return datePicker + }() + + lazy var cancelBtn: UIButton = { + let button = UIButton() + button.translatesAutoresizingMaskIntoConstraints = false + button.setTitle(NSLocalizedString("cancel", comment: ""), for: .normal) + button.setTitleColor(UIColor.ne_blueText, for: .normal) + button.titleLabel?.font = UIFont.systemFont(ofSize: 13) + button.addTarget(self, action: #selector(cancelBtnClick), for: .touchUpInside) + + return button + }() + + override init(frame: CGRect) { + super.init(frame: frame) + setupSubviews() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func setupSubviews() { + // 创建日期选择器 + addSubview(cancelBtn) + addSubview(sureBtn) + addSubview(bottomLine) + addSubview(picker) + + NSLayoutConstraint.activate([ + cancelBtn.leftAnchor.constraint(equalTo: leftAnchor, constant: 15), + cancelBtn.topAnchor.constraint(equalTo: topAnchor, constant: 8), + cancelBtn.widthAnchor.constraint(equalToConstant: 45), + ]) + + NSLayoutConstraint.activate([ + sureBtn.rightAnchor.constraint(equalTo: rightAnchor, constant: -15), + sureBtn.topAnchor.constraint(equalTo: topAnchor, constant: 8), + sureBtn.widthAnchor.constraint(equalToConstant: 45), + ]) + + NSLayoutConstraint.activate([ + bottomLine.leftAnchor.constraint(equalTo: leftAnchor), + bottomLine.rightAnchor.constraint(equalTo: rightAnchor), + bottomLine.topAnchor.constraint(equalTo: cancelBtn.bottomAnchor), + bottomLine.heightAnchor.constraint(equalToConstant: 0.5), + ]) + + NSLayoutConstraint.activate([ + picker.leftAnchor.constraint(equalTo: leftAnchor), + picker.rightAnchor.constraint(equalTo: rightAnchor), + picker.bottomAnchor.constraint(equalTo: bottomAnchor), + picker.topAnchor.constraint(equalTo: bottomLine.bottomAnchor), + ]) + } + + @objc func dateChanged(datePicker: UIDatePicker) { + // 更新提醒时间文本框 + let formatter = DateFormatter() + // 日期样式 + formatter.dateFormat = "yyyy-MM-dd" + let time = formatter.string(from: datePicker.date) + selectTime = time + } + + @objc func sureBtnClick(sender: UIButton) { + removeFromSuperview() + weak var weakSelf = self + if let time = selectTime { + if let block = timeCallBack { + block(time) + } + } else { + let formatter = DateFormatter() + formatter.dateFormat = "yyyy-MM-dd" + selectTime = formatter.string(from: picker.date) + if let block = timeCallBack { + block(weakSelf?.selectTime) + } } - - - @objc func dateChanged(datePicker : UIDatePicker){ - //更新提醒时间文本框 - let formatter = DateFormatter() - //日期样式 - formatter.dateFormat = "yyyy-MM-dd" - let time = formatter.string(from: datePicker.date) - selectTime = time - } - - - - @objc func sureBtnClick(sender:UIButton) { - self.removeFromSuperview() - weak var weakSelf = self - if let time = selectTime { - if let block = timeCallBack { - block(time) - } - }else { - let formatter = DateFormatter() - formatter.dateFormat = "yyyy-MM-dd" - selectTime = formatter.string(from: picker.date) - if let block = timeCallBack { - block(weakSelf?.selectTime) - } - } - } - - @objc func cancelBtnClick(sender:UIButton) { - self.removeFromSuperview() - } - - private lazy var bottomLine:UIView = { - let view = UIView() - view.translatesAutoresizingMaskIntoConstraints = false - view.backgroundColor = UIColor.init(hexString: "0xDBE0E8") - return view - }() - + } + + @objc func cancelBtnClick(sender: UIButton) { + removeFromSuperview() + } + + private lazy var bottomLine: UIView = { + let view = UIView() + view.translatesAutoresizingMaskIntoConstraints = false + view.backgroundColor = UIColor(hexString: "0xDBE0E8") + return view + }() } diff --git a/app/Mine/InputPersonInfoController.swift b/app/Mine/InputPersonInfoController.swift index 73b51556..1cfb1377 100644 --- a/app/Mine/InputPersonInfoController.swift +++ b/app/Mine/InputPersonInfoController.swift @@ -14,7 +14,7 @@ public enum EditType: Int { case specialSign } -class InputPersonInfoController: NEBaseViewController,UITextFieldDelegate { +class InputPersonInfoController: NEBaseViewController, UITextFieldDelegate { typealias ResultCallBack = (String) -> Void public var contentText: String? { didSet { @@ -61,7 +61,7 @@ class InputPersonInfoController: NEBaseViewController,UITextFieldDelegate { } func initialConfig() { - addRightAction("保存", #selector(saveName), self) + addRightAction(NSLocalizedString("save", comment: ""), #selector(saveName), self) view.backgroundColor = UIColor(hexString: "0xF1F1F6") } @@ -76,16 +76,16 @@ class InputPersonInfoController: NEBaseViewController,UITextFieldDelegate { func configTitle(editType: EditType) { switch editType { case .nickName: - title = "昵称" + title = NSLocalizedString("nickname", comment: "") limitNumberCount = 30 case .cellphone: - title = "手机" + title = NSLocalizedString("phone", comment: "") limitNumberCount = 11 case .email: - title = "邮箱" + title = NSLocalizedString("email", comment: "") limitNumberCount = 30 case .specialSign: - title = "个性签名" + title = NSLocalizedString("individuality_sign", comment: "") limitNumberCount = 50 } } @@ -111,15 +111,16 @@ class InputPersonInfoController: NEBaseViewController,UITextFieldDelegate { backView.translatesAutoresizingMaskIntoConstraints = false return backView }() - //MARK: UITextFieldDelegate - func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, - replacementString string: String) -> Bool { - if let text = (textField.text as NSString?)?.replacingCharacters(in: range, with: string), - text.count > limitNumberCount { - showToast("最多只能输入\(limitNumberCount)个字符哦") - return false - } - return true + + // MARK: UITextFieldDelegate + + func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, + replacementString string: String) -> Bool { + if let text = (textField.text as NSString?)?.replacingCharacters(in: range, with: string), + text.count > limitNumberCount { + showToast("最多只能输入\(limitNumberCount)个字符哦") + return false } + return true + } } - diff --git a/app/Mine/IntroduceBrandViewController.swift b/app/Mine/IntroduceBrandViewController.swift index 7706c586..ae43f49b 100644 --- a/app/Mine/IntroduceBrandViewController.swift +++ b/app/Mine/IntroduceBrandViewController.swift @@ -8,7 +8,8 @@ import NEKitCore import NEKitTeamUI import NEKitChatUI -class IntroduceBrandViewController: NEBaseViewController,UITableViewDelegate, UITableViewDataSource { +class IntroduceBrandViewController: NEBaseViewController, UITableViewDelegate, + UITableViewDataSource { private var viewModel = IntroduceViewModel() override func viewDidLoad() { @@ -24,6 +25,8 @@ class IntroduceBrandViewController: NEBaseViewController,UITableViewDelegate, UI func setupSubviews() { view.addSubview(headImage) + view.addSubview(headLable) + view.addSubview(tableView) NSLayoutConstraint.activate([ @@ -32,9 +35,14 @@ class IntroduceBrandViewController: NEBaseViewController,UITableViewDelegate, UI equalTo: view.topAnchor, constant: kNavigationHeight + KStatusBarHeight + 20 ), - headImage.widthAnchor.constraint(equalToConstant: 94), - headImage.heightAnchor.constraint(equalToConstant: 66), + headImage.widthAnchor.constraint(equalToConstant: 72), + headImage.heightAnchor.constraint(equalToConstant: 53), + + ]) + NSLayoutConstraint.activate([ + headLable.centerXAnchor.constraint(equalTo: headImage.centerXAnchor), + headLable.topAnchor.constraint(equalTo: headImage.bottomAnchor, constant: 10), ]) NSLayoutConstraint.activate([ @@ -53,6 +61,15 @@ class IntroduceBrandViewController: NEBaseViewController,UITableViewDelegate, UI return image }() + private lazy var headLable: UILabel = { + let label = UILabel() + label.translatesAutoresizingMaskIntoConstraints = false + label.text = NSLocalizedString("brand_des", comment: "") + label.font = UIFont.systemFont(ofSize: 20.0) + label.textColor = UIColor(hexString: "333333") + return label + }() + lazy var tableView: UITableView = { let table = UITableView() table.translatesAutoresizingMaskIntoConstraints = false @@ -66,34 +83,34 @@ class IntroduceBrandViewController: NEBaseViewController,UITableViewDelegate, UI } return table }() - - //MARK: UITableViewDelegate, UITableViewDataSource - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - viewModel.sectionData.count - } - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let model = viewModel.sectionData[indexPath.row] - if let cell = tableView.dequeueReusableCell( - withIdentifier: "VersionCell", - for: indexPath - ) as? VersionCell { - cell.configData(model: model) - if indexPath.row == 0 { - cell.cellType = .version - } else { - cell.cellType = .productIntroduce - } - return cell + // MARK: UITableViewDelegate, UITableViewDataSource + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + viewModel.sectionData.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewModel.sectionData[indexPath.row] + if let cell = tableView.dequeueReusableCell( + withIdentifier: "VersionCell", + for: indexPath + ) as? VersionCell { + cell.configData(model: model) + if indexPath.row == 0 { + cell.cellType = .version + } else { + cell.cellType = .productIntroduce } - return UITableViewCell() + return cell } + return UITableViewCell() + } - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.row == 1 { - let ctrl = NEAboutWebViewController(url: "https://netease.im/m/") - navigationController?.pushViewController(ctrl, animated: true) - } + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + if indexPath.row == 1 { + let ctrl = NEAboutWebViewController(url: "https://netease.im/m/") + navigationController?.pushViewController(ctrl, animated: true) } + } } - diff --git a/app/Mine/IntroduceViewModel.swift b/app/Mine/IntroduceViewModel.swift index 127a5faf..00fa2a3c 100644 --- a/app/Mine/IntroduceViewModel.swift +++ b/app/Mine/IntroduceViewModel.swift @@ -1,25 +1,23 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import Foundation import NEKitTeamUI public class IntroduceViewModel { - var sectionData = [SettingCellModel]() + var sectionData = [SettingCellModel]() - func getData(){ - let versionItem = SettingCellModel() - versionItem.cellName = "版本号" - let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String - if let version = appVersion { - versionItem.subTitle = "V\(version)" - } - - let introduceItem = SettingCellModel() - introduceItem.cellName = "产品介绍" - sectionData.append(contentsOf: [versionItem,introduceItem]) + func getData() { + let versionItem = SettingCellModel() + versionItem.cellName = NSLocalizedString("version", comment: "") + let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String + if let version = appVersion { + versionItem.subTitle = "V\(version)" } - - - + + let introduceItem = SettingCellModel() + introduceItem.cellName = NSLocalizedString("product_intro", comment: "") + sectionData.append(contentsOf: [versionItem, introduceItem]) + } } diff --git a/app/Mine/MeViewController.swift b/app/Mine/MeViewController.swift index bdc4bdf1..ba073b4f 100644 --- a/app/Mine/MeViewController.swift +++ b/app/Mine/MeViewController.swift @@ -1,6 +1,7 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import UIKit import YXLogin @@ -8,181 +9,184 @@ import NEKitCore import NIMSDK import NEKitCoreIM import NEKitQChatUI -import YXLogin class MeViewController: UIViewController { - // private let mineData = [["收藏":"mine_collection"],["关于云信":"about_yunxin"],["设置":"mine_setting"]] - private let mineData = [["关于云信":"about_yunxin"],["设置":"mine_setting"]] - private let userProvider = UserInfoProvider.shared - - lazy var header: NEUserHeaderView = { - let view = NEUserHeaderView(frame: .zero) - view.titleLabel.font = UIFont.systemFont(ofSize: 22.0) - view.translatesAutoresizingMaskIntoConstraints = false - return view - }() - - lazy var nameLabel: UILabel = { - let name = UILabel() - name.textColor = .ne_darkText - name.font = UIFont.systemFont(ofSize: 22.0) - name.translatesAutoresizingMaskIntoConstraints = false - return name - }() - - lazy var idLabel: UILabel = { - let label = UILabel() - label.textColor = .ne_darkText - label.font = UIFont.systemFont(ofSize: 16.0) - label.translatesAutoresizingMaskIntoConstraints = false - return label - }() - - - override func viewDidLoad() { - super.viewDidLoad() - setupSubviews() - } - - override func viewWillAppear(_ animated: Bool) { - navigationController?.setNavigationBarHidden(true, animated: false) - updateUserInfo() - super.viewWillAppear(animated) - } - - func setupSubviews(){ - - view.addSubview(header) - if #available(iOS 11.0, *) { - NSLayoutConstraint.activate([ - header.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20), - header.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: 20), - header.widthAnchor.constraint(equalToConstant: 60), - header.heightAnchor.constraint(equalToConstant: 60) - ]) - } else { - // Fallback on earlier versions - NSLayoutConstraint.activate([ - header.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20), - header.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 20), - header.widthAnchor.constraint(equalToConstant: 60), - header.heightAnchor.constraint(equalToConstant: 60) - ]) - } - header.clipsToBounds = true - header.layer.cornerRadius = 30 - - view.addSubview(nameLabel) - NSLayoutConstraint.activate([ - nameLabel.leftAnchor.constraint(equalTo: header.rightAnchor, constant: 15), - nameLabel.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20), - nameLabel.topAnchor.constraint(equalTo: header.topAnchor) - ]) - - view.addSubview(idLabel) - NSLayoutConstraint.activate([ - idLabel.leftAnchor.constraint(equalTo: nameLabel.leftAnchor), - idLabel.rightAnchor.constraint(equalTo: nameLabel.rightAnchor), - idLabel.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 8) - ]) - - //更新个人信息 - updateUserInfo() - - - let divider = UIView() - view.addSubview(divider) - divider.translatesAutoresizingMaskIntoConstraints = false - divider.backgroundColor = UIColor(hexString: "EFF1F4") - NSLayoutConstraint.activate([ - divider.leftAnchor.constraint(equalTo: view.leftAnchor), - divider.heightAnchor.constraint(equalToConstant: 6), - divider.rightAnchor.constraint(equalTo: view.rightAnchor), - divider.topAnchor.constraint(equalTo: header.bottomAnchor, constant: 32) - ]) - - view.addSubview(tableView) - view.addSubview(arrow) - view.addSubview(personInfoBtn) - - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: divider.bottomAnchor), - tableView.leftAnchor.constraint(equalTo: view.leftAnchor), - tableView.rightAnchor.constraint(equalTo: view.rightAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor) - ]) - - NSLayoutConstraint.activate([ - arrow.centerYAnchor.constraint(equalTo: header.centerYAnchor), - arrow.rightAnchor.constraint(equalTo: view.rightAnchor,constant: -20), - ]) - - NSLayoutConstraint.activate([ - personInfoBtn.topAnchor.constraint(equalTo: header.topAnchor), - personInfoBtn.leftAnchor.constraint(equalTo: view.leftAnchor), - personInfoBtn.rightAnchor.constraint(equalTo: view.rightAnchor), - personInfoBtn.bottomAnchor.constraint(equalTo: divider.topAnchor) - ]) - } - - func updateUserInfo(){ - let user = userProvider.getUserInfo(userId: IMKitLoginManager.instance.imAccid) - idLabel.text = "账号:\(user?.userId ?? "")" - nameLabel.text = user?.userInfo?.nickName - header.configHeadData(headUrl: user?.userInfo?.avatarUrl, name: user?.showName() ?? "") - } - - //MAKR: lazy method - private lazy var tableView:UITableView = { - let tableView = UITableView.init(frame: .zero, style: .plain) - tableView.translatesAutoresizingMaskIntoConstraints = false - tableView.separatorStyle = .none - tableView.delegate = self - tableView.dataSource = self - tableView.register(MineTableViewCell.self, forCellReuseIdentifier: "\(NSStringFromClass(MineTableViewCell.self))") - tableView.rowHeight = 52 - tableView.backgroundColor = .white - return tableView - }() - - private lazy var arrow: UIImageView = { - let imageView = UIImageView(image:UIImage.init(named: "arrow_right")) - imageView.translatesAutoresizingMaskIntoConstraints = false - return imageView - }() - - private lazy var personInfoBtn:UIButton = { - let btn = UIButton() - btn.translatesAutoresizingMaskIntoConstraints = false - btn.addTarget(self, action: #selector(personInfoBtnClick), for: .touchUpInside) - return btn - - }() - - - @objc func personInfoBtnClick(sender:UIButton){ - let personInfo = PersonInfoViewController() - navigationController?.pushViewController(personInfo, animated: true) + private let mineData = [ + [NSLocalizedString("about_yunxin", comment: ""): "about_yunxin"], + [NSLocalizedString("setting", comment: ""): "mine_setting"], + ] + private let userProvider = UserInfoProvider.shared + + lazy var header: NEUserHeaderView = { + let view = NEUserHeaderView(frame: .zero) + view.titleLabel.font = UIFont.systemFont(ofSize: 22.0) + view.translatesAutoresizingMaskIntoConstraints = false + return view + }() + + lazy var nameLabel: UILabel = { + let name = UILabel() + name.textColor = .ne_darkText + name.font = UIFont.systemFont(ofSize: 22.0) + name.translatesAutoresizingMaskIntoConstraints = false + return name + }() + + lazy var idLabel: UILabel = { + let label = UILabel() + label.textColor = .ne_darkText + label.font = UIFont.systemFont(ofSize: 16.0) + label.translatesAutoresizingMaskIntoConstraints = false + return label + }() + + override func viewDidLoad() { + super.viewDidLoad() + setupSubviews() + } + + override func viewWillAppear(_ animated: Bool) { + navigationController?.setNavigationBarHidden(true, animated: false) + updateUserInfo() + super.viewWillAppear(animated) + } + + func setupSubviews() { + view.addSubview(header) + if #available(iOS 11.0, *) { + NSLayoutConstraint.activate([ + header.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20), + header.topAnchor.constraint( + equalTo: self.view.safeAreaLayoutGuide.topAnchor, + constant: 20 + ), + header.widthAnchor.constraint(equalToConstant: 60), + header.heightAnchor.constraint(equalToConstant: 60), + ]) + } else { + // Fallback on earlier versions + NSLayoutConstraint.activate([ + header.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20), + header.topAnchor.constraint(equalTo: view.topAnchor, constant: 20), + header.widthAnchor.constraint(equalToConstant: 60), + header.heightAnchor.constraint(equalToConstant: 60), + ]) } + header.clipsToBounds = true + header.layer.cornerRadius = 30 + + view.addSubview(nameLabel) + NSLayoutConstraint.activate([ + nameLabel.leftAnchor.constraint(equalTo: header.rightAnchor, constant: 15), + nameLabel.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20), + nameLabel.topAnchor.constraint(equalTo: header.topAnchor), + ]) + + view.addSubview(idLabel) + NSLayoutConstraint.activate([ + idLabel.leftAnchor.constraint(equalTo: nameLabel.leftAnchor), + idLabel.rightAnchor.constraint(equalTo: nameLabel.rightAnchor), + idLabel.topAnchor.constraint(equalTo: nameLabel.bottomAnchor, constant: 8), + ]) + + // 更新个人信息 + updateUserInfo() + let divider = UIView() + view.addSubview(divider) + divider.translatesAutoresizingMaskIntoConstraints = false + divider.backgroundColor = UIColor(hexString: "EFF1F4") + NSLayoutConstraint.activate([ + divider.leftAnchor.constraint(equalTo: view.leftAnchor), + divider.heightAnchor.constraint(equalToConstant: 6), + divider.rightAnchor.constraint(equalTo: view.rightAnchor), + divider.topAnchor.constraint(equalTo: header.bottomAnchor, constant: 32), + ]) + + view.addSubview(tableView) + view.addSubview(arrow) + view.addSubview(personInfoBtn) + + NSLayoutConstraint.activate([ + tableView.topAnchor.constraint(equalTo: divider.bottomAnchor), + tableView.leftAnchor.constraint(equalTo: view.leftAnchor), + tableView.rightAnchor.constraint(equalTo: view.rightAnchor), + tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), + ]) + + NSLayoutConstraint.activate([ + arrow.centerYAnchor.constraint(equalTo: header.centerYAnchor), + arrow.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20), + ]) + + NSLayoutConstraint.activate([ + personInfoBtn.topAnchor.constraint(equalTo: header.topAnchor), + personInfoBtn.leftAnchor.constraint(equalTo: view.leftAnchor), + personInfoBtn.rightAnchor.constraint(equalTo: view.rightAnchor), + personInfoBtn.bottomAnchor.constraint(equalTo: divider.topAnchor), + ]) + } + + func updateUserInfo() { + let user = userProvider.getUserInfo(userId: IMKitEngine.instance.imAccid) + idLabel.text = "账号:\(user?.userId ?? "")" + nameLabel.text = user?.userInfo?.nickName + header.configHeadData(headUrl: user?.userInfo?.avatarUrl, name: user?.showName() ?? "") + } + + // MAKR: lazy method + private lazy var tableView: UITableView = { + let tableView = UITableView(frame: .zero, style: .plain) + tableView.translatesAutoresizingMaskIntoConstraints = false + tableView.separatorStyle = .none + tableView.delegate = self + tableView.dataSource = self + tableView.register( + MineTableViewCell.self, + forCellReuseIdentifier: "\(NSStringFromClass(MineTableViewCell.self))" + ) + tableView.rowHeight = 52 + tableView.backgroundColor = .white + return tableView + }() + + private lazy var arrow: UIImageView = { + let imageView = UIImageView(image: UIImage(named: "arrow_right")) + imageView.translatesAutoresizingMaskIntoConstraints = false + return imageView + }() + + private lazy var personInfoBtn: UIButton = { + let btn = UIButton() + btn.translatesAutoresizingMaskIntoConstraints = false + btn.addTarget(self, action: #selector(personInfoBtnClick), for: .touchUpInside) + return btn + + }() + + @objc func personInfoBtnClick(sender: UIButton) { + let personInfo = PersonInfoViewController() + navigationController?.pushViewController(personInfo, animated: true) + } } -extension MeViewController:UITableViewDelegate,UITableViewDataSource { - - public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return mineData.count - } - - public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "\(NSStringFromClass(MineTableViewCell.self))", for: indexPath) as! MineTableViewCell - cell.configCell(data: mineData[indexPath.row]) - return cell - - } - - public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - +extension MeViewController: UITableViewDelegate, UITableViewDataSource { + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + mineData.count + } + + public func tableView(_ tableView: UITableView, + cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell( + withIdentifier: "\(NSStringFromClass(MineTableViewCell.self))", + for: indexPath + ) as! MineTableViewCell + cell.configCell(data: mineData[indexPath.row]) + return cell + } + + public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { // if indexPath.row == 0 { // // }else if indexPath.row == 1{ @@ -192,18 +196,13 @@ extension MeViewController:UITableViewDelegate,UITableViewDataSource { // let ctrl = MineSettingViewController() // navigationController?.pushViewController(ctrl, animated: true) // } - - if indexPath.row == 0 { - let ctrl = IntroduceBrandViewController() - navigationController?.pushViewController(ctrl, animated: true) - }else if indexPath.row == 1{ - let ctrl = MineSettingViewController() - navigationController?.pushViewController(ctrl, animated: true) - }else if indexPath.row == 2{ - - } - - - } + if indexPath.row == 0 { + let ctrl = IntroduceBrandViewController() + navigationController?.pushViewController(ctrl, animated: true) + } else if indexPath.row == 1 { + let ctrl = MineSettingViewController() + navigationController?.pushViewController(ctrl, animated: true) + } else if indexPath.row == 2 {} + } } diff --git a/app/Mine/MessageRemindViewController.swift b/app/Mine/MessageRemindViewController.swift index 8add738c..37068fff 100644 --- a/app/Mine/MessageRemindViewController.swift +++ b/app/Mine/MessageRemindViewController.swift @@ -8,7 +8,8 @@ import NEKitCore import NEKitTeamUI import NEKitChatUI -class MessageRemindViewController: NEBaseViewController,UITableViewDelegate, UITableViewDataSource { +class MessageRemindViewController: NEBaseViewController, UITableViewDelegate, + UITableViewDataSource { public var cellClassDic = [SettingCellType.SettingSwitchCell.rawValue: TeamSettingSwitchCell.self] private var viewModel = MessageRemindViewModel() @@ -21,7 +22,7 @@ class MessageRemindViewController: NEBaseViewController,UITableViewDelegate, UIT } func initialConfig() { - title = "消息提醒" + title = NSLocalizedString("message_remind", comment: "") } func setupSubviews() { @@ -52,59 +53,58 @@ class MessageRemindViewController: NEBaseViewController,UITableViewDelegate, UIT } return table }() - - //MARK: UITableViewDelegate, UITableViewDataSource - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if viewModel.sectionData.count > section { - let model = viewModel.sectionData[section] - return model.cellModels.count - } - return 0 - } - func numberOfSections(in tableView: UITableView) -> Int { - viewModel.sectionData.count - } + // MARK: UITableViewDelegate, UITableViewDataSource - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] - if let cell = tableView.dequeueReusableCell( - withIdentifier: "\(model.type)", - for: indexPath - ) as? BaseTeamSettingCell { - cell.configure(model) - return cell - } - return UITableViewCell() + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if viewModel.sectionData.count > section { + let model = viewModel.sectionData[section] + return model.cellModels.count } + return 0 + } - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - // let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] - // if let block = model.cellClick { - // block() - // } - } + func numberOfSections(in tableView: UITableView) -> Int { + viewModel.sectionData.count + } - func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] - return model.rowHeight + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] + if let cell = tableView.dequeueReusableCell( + withIdentifier: "\(model.type)", + for: indexPath + ) as? BaseTeamSettingCell { + cell.configure(model) + return cell } + return UITableViewCell() + } - func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - if viewModel.sectionData.count > section { - let model = viewModel.sectionData[section] - if model.cellModels.count > 0 { - return 12.0 - } + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + // let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] + // if let block = model.cellClick { + // block() + // } + } + + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] + return model.rowHeight + } + + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + if viewModel.sectionData.count > section { + let model = viewModel.sectionData[section] + if model.cellModels.count > 0 { + return 12.0 } - return 0 } + return 0 + } - func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - let header = UIView() - header.backgroundColor = UIColor(hexString: "0xF1F1F6") - return header - } + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let header = UIView() + header.backgroundColor = UIColor(hexString: "0xF1F1F6") + return header + } } - - diff --git a/app/Mine/MessageRemindViewModel.swift b/app/Mine/MessageRemindViewModel.swift index 2c11f48a..4aaed11e 100644 --- a/app/Mine/MessageRemindViewModel.swift +++ b/app/Mine/MessageRemindViewModel.swift @@ -1,89 +1,83 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import Foundation import NEKitTeamUI public class MessageRemindViewModel { - var sectionData = [SettingSectionModel]() - - let repo = SettingRepo() + var sectionData = [SettingSectionModel]() - func getData(){ - sectionData.append(getFirstSection()) + let repo = SettingRepo() + + func getData() { + sectionData.append(getFirstSection()) // sectionData.append(getSecondSection()) - sectionData.append(getThirdSection()) + sectionData.append(getThirdSection()) + } + private func getFirstSection() -> SettingSectionModel { + let model = SettingSectionModel() + weak var weakSelf = self + let messageNotify = SettingCellModel() + messageNotify.cellName = NSLocalizedString("new_message_remind", comment: "") + messageNotify.type = SettingCellType.SettingSwitchCell.rawValue + messageNotify.cornerType = .topLeft.union(.topRight).union(.bottomLeft).union(.bottomRight) + messageNotify.switchOpen = repo.getPushEnable() + messageNotify.swichChange = { isOpen in + weakSelf?.repo.setPushEnable(isOpen) } + model.cellModels.append(contentsOf: [messageNotify]) + return model + } - - private func getFirstSection() -> SettingSectionModel { - - let model = SettingSectionModel() - weak var weakSelf = self - let messageNotify = SettingCellModel() - messageNotify.cellName = "新消息通知" - messageNotify.type = SettingCellType.SettingSwitchCell.rawValue - messageNotify.cornerType = .topLeft.union(.topRight).union(.bottomLeft).union(.bottomRight) - messageNotify.switchOpen = repo.getPushEnable() - messageNotify.swichChange = { isOpen in - weakSelf?.repo.setPushEnable(isOpen) - } - model.cellModels.append(contentsOf: [messageNotify]) - return model - - + private func getSecondSection() -> SettingSectionModel { + let model = SettingSectionModel() + weak var weakSelf = self + let ringBellItem = SettingCellModel() + ringBellItem.cellName = NSLocalizedString("ring_mode", comment: "") + ringBellItem.type = SettingCellType.SettingSwitchCell.rawValue + ringBellItem.cornerType = .topLeft.union(.topRight) + ringBellItem.switchOpen = repo.getPushAudioEnable() + ringBellItem.swichChange = { isOpen in + weakSelf?.repo.setPushAudioEnable(isOpen) } - - private func getSecondSection() -> SettingSectionModel { - let model = SettingSectionModel() - weak var weakSelf = self - let ringBellItem = SettingCellModel() - ringBellItem.cellName = "响铃模式" - ringBellItem.type = SettingCellType.SettingSwitchCell.rawValue - ringBellItem.cornerType = .topLeft.union(.topRight) - ringBellItem.switchOpen = repo.getPushAudioEnable() - ringBellItem.swichChange = { isOpen in - weakSelf?.repo.setPushAudioEnable(isOpen) - } - - let vibrationItem = SettingCellModel() - vibrationItem.cellName = "震动模式" - vibrationItem.type = SettingCellType.SettingSwitchCell.rawValue - vibrationItem.cornerType = .bottomLeft.union(.bottomRight) - vibrationItem.switchOpen = repo.getPushShakeEnable() - vibrationItem.swichChange = { isOpen in - weakSelf?.repo.setPushShakeEnable(isOpen) - } - model.cellModels.append(contentsOf: [ringBellItem, vibrationItem]) - return model + + let vibrationItem = SettingCellModel() + vibrationItem.cellName = NSLocalizedString("vibration_mode", comment: "") + vibrationItem.type = SettingCellType.SettingSwitchCell.rawValue + vibrationItem.cornerType = .bottomLeft.union(.bottomRight) + vibrationItem.switchOpen = repo.getPushShakeEnable() + vibrationItem.swichChange = { isOpen in + weakSelf?.repo.setPushShakeEnable(isOpen) } - - private func getThirdSection() -> SettingSectionModel { - let model = SettingSectionModel() - weak var weakSelf = self - let receiveItem = SettingCellModel() - receiveItem.cellName = "PC/Web同步接收推送" - receiveItem.type = SettingCellType.SettingSwitchCell.rawValue - receiveItem.cornerType = .topLeft.union(.topRight) - receiveItem.switchOpen = repo.getPcWebPushEnable() - receiveItem.swichChange = { isOpen in - weakSelf?.repo.updatePcWebPushEnable(isOpen) - } - - let messageDetailItem = SettingCellModel() - messageDetailItem.cellName = "通知栏显示消息详情" - messageDetailItem.type = SettingCellType.SettingSwitchCell.rawValue - messageDetailItem.cornerType = .bottomLeft.union(.bottomRight) - messageDetailItem.switchOpen = repo.getPushDetailEnable() - messageDetailItem.swichChange = { isOpen in - weakSelf?.repo.settingProvider.setPushDetailEnable(isOpen) - } - - model.cellModels.append(contentsOf: [receiveItem, messageDetailItem]) - return model + model.cellModels.append(contentsOf: [ringBellItem, vibrationItem]) + return model + } + + private func getThirdSection() -> SettingSectionModel { + let model = SettingSectionModel() + weak var weakSelf = self +// let receiveItem = SettingCellModel() +// receiveItem.cellName = NSLocalizedString("syn_receive_push", comment: "") +// receiveItem.type = SettingCellType.SettingSwitchCell.rawValue +// receiveItem.cornerType = .topLeft.union(.topRight) +// receiveItem.switchOpen = repo.getPcWebPushEnable() +// receiveItem.swichChange = { isOpen in +// weakSelf?.repo.updatePcWebPushEnable(isOpen) +// } + + let messageDetailItem = SettingCellModel() + messageDetailItem.cellName = NSLocalizedString("display_message_detail", comment: "") + messageDetailItem.type = SettingCellType.SettingSwitchCell.rawValue + messageDetailItem.cornerType = .bottomLeft.union(.bottomRight) + messageDetailItem.switchOpen = repo.getPushDetailEnable() + messageDetailItem.swichChange = { isOpen in + weakSelf?.repo.settingProvider.setPushDetailEnable(isOpen) } - - + + model.cellModels.append(contentsOf: [messageDetailItem]) + return model + } } diff --git a/app/Mine/MineSettingViewController.swift b/app/Mine/MineSettingViewController.swift index e1e12123..af5ed881 100644 --- a/app/Mine/MineSettingViewController.swift +++ b/app/Mine/MineSettingViewController.swift @@ -9,7 +9,7 @@ import NEKitTeamUI import YXLogin import NIMSDK -class MineSettingViewController: NEBaseViewController,UITableViewDataSource, UITableViewDelegate { +class MineSettingViewController: NEBaseViewController, UITableViewDataSource, UITableViewDelegate { private var viewModel = MineSettingViewModel() public var cellClassDic = [ SettingCellType.SettingArrowCell.rawValue: TeamArrowSettingCell.self, @@ -30,7 +30,7 @@ class MineSettingViewController: NEBaseViewController,UITableViewDataSource, UIT } func initialConfig() { - title = "设置" + title = NSLocalizedString("setting", comment: "") viewModel.delegate = self } @@ -79,7 +79,7 @@ class MineSettingViewController: NEBaseViewController,UITableViewDataSource, UIT button.setTitle(title, for: .normal) button.addTarget(self, action: #selector(loginOutAction), for: .touchUpInside) button.layer.cornerRadius = 8.0 - button.setTitle("退出登录", for: .normal) + button.setTitle(NSLocalizedString("logout", comment: ""), for: .normal) NSLayoutConstraint.activate([ button.leftAnchor.constraint(equalTo: footer.leftAnchor, constant: 20), button.rightAnchor.constraint(equalTo: footer.rightAnchor, constant: -20), @@ -89,9 +89,7 @@ class MineSettingViewController: NEBaseViewController,UITableViewDataSource, UIT return footer } - //logout action @objc func loginOutAction(){ - NIMSDK.shared().loginManager.logout { error in NIMSDK.shared().qchatManager.logout { chatError in if error != nil { @@ -102,69 +100,69 @@ class MineSettingViewController: NEBaseViewController,UITableViewDataSource, UIT } } } + + } + // MARK: UITableViewDataSource, UITableViewDelegate + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if viewModel.sectionData.count > section { + let model = viewModel.sectionData[section] + return model.cellModels.count } - - //MARK: UITableViewDataSource, UITableViewDelegate - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if viewModel.sectionData.count > section { - let model = viewModel.sectionData[section] - return model.cellModels.count - } - return 0 - } + return 0 + } - func numberOfSections(in tableView: UITableView) -> Int { - viewModel.sectionData.count - } + func numberOfSections(in tableView: UITableView) -> Int { + viewModel.sectionData.count + } - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] - if let cell = tableView.dequeueReusableCell( - withIdentifier: "\(model.type)", - for: indexPath - ) as? BaseTeamSettingCell { - cell.configure(model) - return cell - } - return UITableViewCell() + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] + if let cell = tableView.dequeueReusableCell( + withIdentifier: "\(model.type)", + for: indexPath + ) as? BaseTeamSettingCell { + cell.configure(model) + return cell } + return UITableViewCell() + } - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] - if let block = model.cellClick { - block() - } + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] + if let block = model.cellClick { + block() } + } - func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] - return model.rowHeight - } + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] + return model.rowHeight + } - func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - if viewModel.sectionData.count > section { - let model = viewModel.sectionData[section] - if model.cellModels.count > 0 { - return 12.0 - } + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + if viewModel.sectionData.count > section { + let model = viewModel.sectionData[section] + if model.cellModels.count > 0 { + return 12.0 } - return 0 } + return 0 + } - func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - let header = UIView() - header.backgroundColor = UIColor(hexString: "0xF1F1F6") - return header - } + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let header = UIView() + header.backgroundColor = UIColor(hexString: "0xF1F1F6") + return header + } - func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { - if section == viewModel.sectionData.count - 1 { - return 12.0 - } - return 0 + func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { + if section == viewModel.sectionData.count - 1 { + return 12.0 } + return 0 + } } extension MineSettingViewController: MineSettingViewModelDelegate { @@ -175,4 +173,3 @@ extension MineSettingViewController: MineSettingViewModelDelegate { func didClickCleanCache() {} } - diff --git a/app/Mine/MineSettingViewModel.swift b/app/Mine/MineSettingViewModel.swift index 197c7043..81fe4425 100644 --- a/app/Mine/MineSettingViewModel.swift +++ b/app/Mine/MineSettingViewModel.swift @@ -1,39 +1,37 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import Foundation import NEKitTeamUI protocol MineSettingViewModelDelegate: AnyObject { - func didMessageRemindClick() - func didClickCleanCache() + func didMessageRemindClick() + func didClickCleanCache() } public class MineSettingViewModel { - - var sectionData = [SettingSectionModel]() - weak var delegate: MineSettingViewModelDelegate? + var sectionData = [SettingSectionModel]() + weak var delegate: MineSettingViewModelDelegate? + public func getData() { + sectionData.append(getFirstSection()) + sectionData.append(getSecondSection()) + } - - public func getData(){ - sectionData.append(getFirstSection()) - sectionData.append(getSecondSection()) - } - - private func getFirstSection() -> SettingSectionModel { - let model = SettingSectionModel() - weak var weakSelf = self - let remind = SettingCellModel() - remind.cellName = "消息提醒" - remind.type = SettingCellType.SettingArrowCell.rawValue + private func getFirstSection() -> SettingSectionModel { + let model = SettingSectionModel() + weak var weakSelf = self + let remind = SettingCellModel() + remind.cellName = NSLocalizedString("message_remind", comment: "") + remind.type = SettingCellType.SettingArrowCell.rawValue // remind.cornerType = .topLeft.union(.topRight) - remind.cornerType = .topLeft.union(.topRight).union(.bottomLeft).union(.bottomRight) - remind.cellClick = { - weakSelf?.delegate?.didMessageRemindClick() - } - + remind.cornerType = .topLeft.union(.topRight).union(.bottomLeft).union(.bottomRight) + remind.cellClick = { + weakSelf?.delegate?.didMessageRemindClick() + } + // let cleanCache = SettingCellModel() // cleanCache.cellName = "清理缓存" // cleanCache.type = SettingCellType.SettingArrowCell.rawValue @@ -42,27 +40,25 @@ public class MineSettingViewModel { // weakSelf?.delegate?.didClickCleanCache() // } // model.cellModels.append(contentsOf: [remind, cleanCache]) - - model.cellModels.append(contentsOf: [remind]) - return model - } - - - private func getSecondSection() -> SettingSectionModel { - - let model = SettingSectionModel() - //听筒模式 - let receiverModel = SettingCellModel() - receiverModel.cellName = "听筒模式" - receiverModel.type = SettingCellType.SettingSwitchCell.rawValue - receiverModel.cornerType = .topLeft.union(.topRight) + model.cellModels.append(contentsOf: [remind]) + + return model + } + + private func getSecondSection() -> SettingSectionModel { + let model = SettingSectionModel() + // 听筒模式 + let receiverModel = SettingCellModel() + receiverModel.cellName = NSLocalizedString("receiver_mode", comment: "") + receiverModel.type = SettingCellType.SettingSwitchCell.rawValue + receiverModel.cornerType = .topLeft.union(.topRight) // receiverModel.switchOpen = CoreKitEngine.instance.repo.getHandSetMode() - receiverModel.switchOpen = IMKitEngine.instance.repo.getHandSetMode() + receiverModel.switchOpen = IMKitEngine.instance.repo.getHandSetMode() - receiverModel.swichChange = { isOpen in - IMKitEngine.instance.repo.setHandSetMode(isOpen) - } + receiverModel.swichChange = { isOpen in + IMKitEngine.instance.repo.setHandSetMode(isOpen) + } // //过滤通知 // let filterNotify = SettingCellModel() // filterNotify.cellName = "过滤通知" @@ -72,31 +68,28 @@ public class MineSettingViewModel { // filterNotify.swichChange = { isOpen in // // } - - //删除好友是否同步删除备注 - let deleteFriend = SettingCellModel() - deleteFriend.cellName = "删除好友是否同步删除备注" - deleteFriend.type = SettingCellType.SettingSwitchCell.rawValue - deleteFriend.switchOpen = IMKitEngine.instance.repo.getDeleteFriendAlias() - - deleteFriend.swichChange = { isOpen in - IMKitEngine.instance.repo.setDeleteFriendAlias(isOpen) - } - - //消息已读未读功能 - let hasRead = SettingCellModel() - hasRead.cellName = "消息已读未读功能" - hasRead.type = SettingCellType.SettingSwitchCell.rawValue - hasRead.cornerType = .bottomLeft.union(.bottomRight) + + // 删除好友是否同步删除备注 +// let deleteFriend = SettingCellModel() +// deleteFriend.cellName = NSLocalizedString("delete_friend", comment: "") +// deleteFriend.type = SettingCellType.SettingSwitchCell.rawValue +// deleteFriend.switchOpen = IMKitEngine.instance.repo.getDeleteFriendAlias() +// +// deleteFriend.swichChange = { isOpen in +// IMKitEngine.instance.repo.setDeleteFriendAlias(isOpen) +// } + + // 消息已读未读功能 + let hasRead = SettingCellModel() + hasRead.cellName = NSLocalizedString("message_read_function", comment: "") + hasRead.type = SettingCellType.SettingSwitchCell.rawValue + hasRead.cornerType = .bottomLeft.union(.bottomRight) // hasRead.switchOpen = true - hasRead.switchOpen = IMKitEngine.instance.repo.getMessageRead() - hasRead.swichChange = { isOpen in - IMKitEngine.instance.repo.setMessageRead(isOpen) - } - model.cellModels.append(contentsOf: [receiverModel ,deleteFriend,hasRead]) - return model - + hasRead.switchOpen = IMKitEngine.instance.repo.getMessageRead() + hasRead.swichChange = { isOpen in + IMKitEngine.instance.repo.setMessageRead(isOpen) } - - + model.cellModels.append(contentsOf: [receiverModel, hasRead]) + return model + } } diff --git a/app/Mine/MineTableViewCell.swift b/app/Mine/MineTableViewCell.swift index f06f395f..6ed50b6c 100644 --- a/app/Mine/MineTableViewCell.swift +++ b/app/Mine/MineTableViewCell.swift @@ -1,12 +1,12 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import UIKit - +import NEKitCommonUI public class MineTableViewCell: UITableViewCell { - // override func awakeFromNib() { // super.awakeFromNib() // // Initialization code @@ -17,84 +17,83 @@ public class MineTableViewCell: UITableViewCell { // // // Configure the view for the selected state // } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } - public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - setUpSubViews() - } - - func setUpSubViews(){ - - self.selectionStyle = .none - self.contentView.addSubview(avatarImage) - self.contentView.addSubview(titleLabel) - self.contentView.addSubview(bottomLine) - self.contentView.addSubview(arrow) - - NSLayoutConstraint.activate([ - avatarImage.leftAnchor.constraint(equalTo: self.contentView.leftAnchor, constant: 20), - avatarImage.centerYAnchor.constraint(equalTo: self.contentView.centerYAnchor), - avatarImage.widthAnchor.constraint(equalToConstant: 20), - avatarImage.heightAnchor.constraint(equalToConstant: 20) - ]) - - NSLayoutConstraint.activate([ - titleLabel.leftAnchor.constraint(equalTo: avatarImage.rightAnchor, constant: 14), - titleLabel.centerYAnchor.constraint(equalTo: avatarImage.centerYAnchor), - ]) - - NSLayoutConstraint.activate([ - bottomLine.leftAnchor.constraint(equalTo: self.contentView.leftAnchor,constant: 20), - bottomLine.rightAnchor.constraint(equalTo: self.rightAnchor), - bottomLine.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor), - bottomLine.heightAnchor.constraint(equalToConstant: 0.5) - ]) - - NSLayoutConstraint.activate([ - arrow.rightAnchor.constraint(equalTo: self.contentView.rightAnchor, constant: -25), + override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + setUpSubViews() + } + + func setUpSubViews() { + selectionStyle = .none + contentView.addSubview(avatarImage) + contentView.addSubview(titleLabel) + contentView.addSubview(bottomLine) + contentView.addSubview(arrow) + + NSLayoutConstraint.activate([ + avatarImage.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 20), + avatarImage.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), + avatarImage.widthAnchor.constraint(equalToConstant: 20), + avatarImage.heightAnchor.constraint(equalToConstant: 20), + ]) + + NSLayoutConstraint.activate([ + titleLabel.leftAnchor.constraint(equalTo: avatarImage.rightAnchor, constant: 14), + titleLabel.centerYAnchor.constraint(equalTo: avatarImage.centerYAnchor), + ]) + + NSLayoutConstraint.activate([ + bottomLine.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 20), + bottomLine.rightAnchor.constraint(equalTo: rightAnchor), + bottomLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), + bottomLine.heightAnchor.constraint(equalToConstant: 0.5), + ]) + + NSLayoutConstraint.activate([ + arrow.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: -25), // arrow.widthAnchor.constraint(equalToConstant: 15), - arrow.centerYAnchor.constraint(equalTo: self.contentView.centerYAnchor), - ]) - } + arrow.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), + ]) + } - func configCell(data:[String:String]) { - titleLabel.text = data.keys.first - if let imageName = data.values.first { - avatarImage.image = UIImage.init(named: imageName) - } + func configCell(data: [String: String]) { + titleLabel.text = data.keys.first + if let imageName = data.values.first { + avatarImage.image = UIImage(named: imageName) } - - //MARK: lazy Method - public lazy var avatarImage: UIImageView = { - let avatar = UIImageView() - avatar.translatesAutoresizingMaskIntoConstraints = false - return avatar - }() - - public lazy var titleLabel: UILabel = { - let name = UILabel() - name.translatesAutoresizingMaskIntoConstraints = false - name.textColor = UIColor.ne_darkText - name.font = UIFont.systemFont(ofSize: 16.0) - name.text = "设置" - return name - }() - - private lazy var bottomLine:UIView = { - let view = UIView() - view.translatesAutoresizingMaskIntoConstraints = false - view.backgroundColor = UIColor.init(hexString: "0xDBE0E8") - return view - }() - - public lazy var arrow: UIImageView = { - let imageView = UIImageView(image:UIImage.init(named: "arrow_right")) - imageView.translatesAutoresizingMaskIntoConstraints = false - return imageView - }() + } + + // MARK: lazy Method + + public lazy var avatarImage: UIImageView = { + let avatar = UIImageView() + avatar.translatesAutoresizingMaskIntoConstraints = false + return avatar + }() + + public lazy var titleLabel: UILabel = { + let name = UILabel() + name.translatesAutoresizingMaskIntoConstraints = false + name.textColor = UIColor.ne_darkText + name.font = UIFont.systemFont(ofSize: 16.0) + name.text = NSLocalizedString("setting", comment: "") + return name + }() + + private lazy var bottomLine: UIView = { + let view = UIView() + view.translatesAutoresizingMaskIntoConstraints = false + view.backgroundColor = UIColor(hexString: "0xDBE0E8") + return view + }() + + public lazy var arrow: UIImageView = { + let imageView = UIImageView(image: UIImage(named: "arrow_right")) + imageView.translatesAutoresizingMaskIntoConstraints = false + return imageView + }() } diff --git a/app/Mine/NEAboutWebViewController.swift b/app/Mine/NEAboutWebViewController.swift index 9935e182..e44307b1 100644 --- a/app/Mine/NEAboutWebViewController.swift +++ b/app/Mine/NEAboutWebViewController.swift @@ -1,50 +1,47 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import UIKit import NEKitCore import WebKit +import NEKitCommonUI class NEAboutWebViewController: NEBaseViewController { + private var loadUrl: String = "" - private var loadUrl:String = "" - - override func viewDidLoad() { - super.viewDidLoad() - setUpSubViews() - } - - init(url:String) { - super.init(nibName: nil, bundle: nil) - loadUrl = url - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - - func setUpSubViews(){ - - self.title = "产品介绍" - guard let requestUrl = URL.init(string: loadUrl) else { - return - } - - let webview = WKWebView.init() - webview.translatesAutoresizingMaskIntoConstraints = false - let request = URLRequest.init(url:requestUrl ) - webview.load(request) - view.addSubview(webview) - - NSLayoutConstraint.activate([ - webview.leftAnchor.constraint(equalTo: view.leftAnchor), - webview.rightAnchor.constraint(equalTo: view.rightAnchor), - webview.topAnchor.constraint(equalTo: view.topAnchor), - webview.bottomAnchor.constraint(equalTo: view.bottomAnchor) - ]) + override func viewDidLoad() { + super.viewDidLoad() + setUpSubViews() + } + + init(url: String) { + super.init(nibName: nil, bundle: nil) + loadUrl = url + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func setUpSubViews() { + title = NSLocalizedString("product_intro", comment: "") + guard let requestUrl = URL(string: loadUrl) else { + return } + let webview = WKWebView() + webview.translatesAutoresizingMaskIntoConstraints = false + let request = URLRequest(url: requestUrl) + webview.load(request) + view.addSubview(webview) + NSLayoutConstraint.activate([ + webview.leftAnchor.constraint(equalTo: view.leftAnchor), + webview.rightAnchor.constraint(equalTo: view.rightAnchor), + webview.topAnchor.constraint(equalTo: view.topAnchor), + webview.bottomAnchor.constraint(equalTo: view.bottomAnchor), + ]) + } } diff --git a/app/Mine/PersonInfoViewController.swift b/app/Mine/PersonInfoViewController.swift index 4884eb6e..284b7495 100644 --- a/app/Mine/PersonInfoViewController.swift +++ b/app/Mine/PersonInfoViewController.swift @@ -9,7 +9,9 @@ import NEKitTeamUI import NEKitChatUI import NIMSDK -class PersonInfoViewController: NEBaseViewController,NIMUserManagerDelegate,UINavigationControllerDelegate,PersonInfoViewModelDelegate,UITableViewDelegate, UITableViewDataSource { +class PersonInfoViewController: NEBaseViewController, NIMUserManagerDelegate, + UINavigationControllerDelegate, PersonInfoViewModelDelegate, UITableViewDelegate, + UITableViewDataSource { public var cellClassDic = [ SettingCellType.SettingSubtitleCell.rawValue: TeamSettingSubtitleCell.self, SettingCellType.SettingHeaderCell.rawValue: TeamSettingHeaderCell.self, @@ -31,7 +33,7 @@ class PersonInfoViewController: NEBaseViewController,NIMUserManagerDelegate,UINa } func initialConfig() { - title = "个人信息" + title = NSLocalizedString("person_info", comment: "") view.backgroundColor = UIColor(hexString: "0xF1F1F6") viewModel.delegate = self NIMSDK.shared().userManager.add(self) @@ -66,7 +68,8 @@ class PersonInfoViewController: NEBaseViewController,NIMUserManagerDelegate,UINa } second.setValue(UIColor(hexString: "0x333333"), forKey: "_titleTextColor") - let cancel = UIAlertAction(title: "取消", style: .cancel) { action in + let cancel = UIAlertAction(title: NSLocalizedString("cancel", comment: ""), + style: .cancel) { action in } cancel.setValue(UIColor(hexString: "0x333333"), forKey: "_titleTextColor") @@ -85,7 +88,7 @@ class PersonInfoViewController: NEBaseViewController,NIMUserManagerDelegate,UINa if let t = time { weakSelf?.viewModel.updateBirthday(birthDay: t) { error in if error != nil { - weakSelf?.showToast("设置生日失败") + weakSelf?.showToast(NSLocalizedString("setting_birthday_failure", comment: "")) } } } @@ -123,191 +126,198 @@ class PersonInfoViewController: NEBaseViewController,NIMUserManagerDelegate,UINa deinit { NIMSDK.shared().userManager.remove(self) } - //MARK: NIMUserManagerDelegate - func onUserInfoChanged(_ user: NIMUser) { - if user.userId == IMKitLoginManager.instance.imAccid { - viewModel.getData() - tableView.reloadData() - } - } - - - //MARK: UIImagePickerControllerDelegate - - func imagePickerController(_ picker: UIImagePickerController, - didFinishPickingMediaWithInfo info: [UIImagePickerController - .InfoKey: Any]) { - let image: UIImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage - uploadHeadImage(image: image) - dismiss(animated: true, completion: nil) + + // MARK: NIMUserManagerDelegate + + func onUserInfoChanged(_ user: NIMUser) { + if user.userId == IMKitEngine.instance.imAccid { + viewModel.getData() + tableView.reloadData() } + } - public func uploadHeadImage(image: UIImage) { - view.makeToastActivity(.center) - weak var weakSelf = self - if let imageData = image.jpegData(compressionQuality: 0.6) as NSData? { - let filePath = NSHomeDirectory().appending("/Documents/") - .appending(IMKitLoginManager.instance.imAccid) - let succcess = imageData.write(toFile: filePath, atomically: true) - if succcess { - NIMSDK.shared().resourceManager - .upload(filePath, scene: NIMNOSSceneTypeAvatar, - progress: nil) { urlString, error in - if error == nil { - weakSelf?.viewModel.updateAvatar(avatar: urlString ?? "") { error in - if error != nil { - weakSelf?.showToast("修改头像失败失败") - } - } + // MARK: UIImagePickerControllerDelegate + + func imagePickerController(_ picker: UIImagePickerController, + didFinishPickingMediaWithInfo info: [UIImagePickerController + .InfoKey: Any]) { + let image: UIImage = info[UIImagePickerController.InfoKey.editedImage] as! UIImage + uploadHeadImage(image: image) + dismiss(animated: true, completion: nil) + } - } else { - NELog.errorLog( - weakSelf?.className ?? "", - desc: "❌upload image failed,error = \(error!)" - ) + public func uploadHeadImage(image: UIImage) { + view.makeToastActivity(.center) + weak var weakSelf = self + if let imageData = image.jpegData(compressionQuality: 0.6) as NSData? { + let filePath = NSHomeDirectory().appending("/Documents/") + .appending(IMKitEngine.instance.imAccid) + let succcess = imageData.write(toFile: filePath, atomically: true) + if succcess { + NIMSDK.shared().resourceManager + .upload(filePath, scene: NIMNOSSceneTypeAvatar, + progress: nil) { urlString, error in + if error == nil { + weakSelf?.viewModel.updateAvatar(avatar: urlString ?? "") { error in + if error != nil { + weakSelf?.showToast(NSLocalizedString("setting_head_failure", comment: "")) + } } - self.view.hideToastActivity() + + } else { + NELog.errorLog( + weakSelf?.className ?? "", + desc: "❌upload image failed,error = \(error!)" + ) } - } + self.view.hideToastActivity() + } } } - //MARK: PersonInfoViewModelDelegate - func didClickHeadImage() { - showBottomAlert(self) - } + } - func didClickNickName(name: String) { - let ctrl = InputPersonInfoController() - ctrl.configTitle(editType: .nickName) - ctrl.contentText = name - weak var weakSelf = self - ctrl.callBack = { editText in - weakSelf?.viewModel.updateNickName(name: editText) { error in - if error != nil { - weakSelf?.showToast("修改昵称失败") - } + // MARK: PersonInfoViewModelDelegate + + func didClickHeadImage() { + showBottomAlert(self) + } + + func didClickNickName(name: String) { + let ctrl = InputPersonInfoController() + ctrl.configTitle(editType: .nickName) + ctrl.contentText = name + weak var weakSelf = self + ctrl.callBack = { editText in + weakSelf?.viewModel.updateNickName(name: editText) { error in + if error != nil { + weakSelf?.showToast(NSLocalizedString("setting_nickname_failure", comment: "")) } } - navigationController?.pushViewController(ctrl, animated: true) } + navigationController?.pushViewController(ctrl, animated: true) + } - func didClickGender() { - var sex = NIMUserGender.unknown - weak var weakSelf = self - showAlert(firstContent: "男", secondContent: "女") { value in - sex = value == 0 ? .male : .female - weakSelf?.viewModel.updateSex(sex: sex) { error in - if error != nil { - weakSelf?.showToast("修改性别失败") - } + func didClickGender() { + var sex = NIMUserGender.unknown + weak var weakSelf = self + showAlert( + firstContent: NSLocalizedString("male", comment: ""), + secondContent: NSLocalizedString("female", comment: "") + ) { value in + sex = value == 0 ? .male : .female + weakSelf?.viewModel.updateSex(sex: sex) { error in + if error != nil { + weakSelf?.showToast(NSLocalizedString("change_gender_failure", comment: "")) } } } + } - func didClickBirthday() { - showDatePicker() - } + func didClickBirthday() { + showDatePicker() + } - func didClickMobile(mobile: String) { - let ctrl = InputPersonInfoController() - ctrl.configTitle(editType: .cellphone) - ctrl.contentText = mobile - weak var weakSelf = self - ctrl.callBack = { editText in - weakSelf?.viewModel.updateMobile(mobile: editText) { error in - if error != nil { - weakSelf?.showToast("修改手机号失败") - } + func didClickMobile(mobile: String) { + let ctrl = InputPersonInfoController() + ctrl.configTitle(editType: .cellphone) + ctrl.contentText = mobile + weak var weakSelf = self + ctrl.callBack = { editText in + weakSelf?.viewModel.updateMobile(mobile: editText) { error in + if error != nil { + weakSelf?.showToast(NSLocalizedString("change_phone_failure", comment: "")) } } - navigationController?.pushViewController(ctrl, animated: true) } + navigationController?.pushViewController(ctrl, animated: true) + } - func didClickEmail(email: String) { - let ctrl = InputPersonInfoController() - ctrl.configTitle(editType: .email) - ctrl.contentText = email - weak var weakSelf = self - ctrl.callBack = { editText in - weakSelf?.viewModel.updateEmail(email: editText) { error in - if error != nil { - weakSelf?.showToast("修改邮箱失败") - } + func didClickEmail(email: String) { + let ctrl = InputPersonInfoController() + ctrl.configTitle(editType: .email) + ctrl.contentText = email + weak var weakSelf = self + ctrl.callBack = { editText in + weakSelf?.viewModel.updateEmail(email: editText) { error in + if error != nil { + weakSelf?.showToast(NSLocalizedString("change_email_failure", comment: "")) } } - navigationController?.pushViewController(ctrl, animated: true) } + navigationController?.pushViewController(ctrl, animated: true) + } - func didClickSign(sign: String) { - let ctrl = InputPersonInfoController() - ctrl.configTitle(editType: .specialSign) - ctrl.contentText = sign - weak var weakSelf = self - ctrl.callBack = { editText in - weakSelf?.viewModel.updateSign(sign: editText) { error in - if error != nil { - weakSelf?.showToast("修改签名失败") - } + func didClickSign(sign: String) { + let ctrl = InputPersonInfoController() + ctrl.configTitle(editType: .specialSign) + ctrl.contentText = sign + weak var weakSelf = self + ctrl.callBack = { editText in + weakSelf?.viewModel.updateSign(sign: editText) { error in + if error != nil { + weakSelf?.showToast(NSLocalizedString("change_sign_failure", comment: "")) } } - navigationController?.pushViewController(ctrl, animated: true) } + navigationController?.pushViewController(ctrl, animated: true) + } - func didCopyAccount(account: String) { - showToast("复制成功") - UIPasteboard.general.string = account - } - //MARK: UITableViewDelegate, UITableViewDataSource - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if viewModel.sectionData.count > section { - let model = viewModel.sectionData[section] - return model.cellModels.count - } - return 0 - } + func didCopyAccount(account: String) { + showToast(NSLocalizedString("copy_success", comment: "")) + UIPasteboard.general.string = account + } - func numberOfSections(in tableView: UITableView) -> Int { - viewModel.sectionData.count - } + // MARK: UITableViewDelegate, UITableViewDataSource - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] - if let cell = tableView.dequeueReusableCell( - withIdentifier: "\(model.type)", - for: indexPath - ) as? BaseTeamSettingCell { - cell.configure(model) - return cell - } - return UITableViewCell() + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + if viewModel.sectionData.count > section { + let model = viewModel.sectionData[section] + return model.cellModels.count } + return 0 + } - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] - if let block = model.cellClick { - block() - } + func numberOfSections(in tableView: UITableView) -> Int { + viewModel.sectionData.count + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] + if let cell = tableView.dequeueReusableCell( + withIdentifier: "\(model.type)", + for: indexPath + ) as? BaseTeamSettingCell { + cell.configure(model) + return cell } + return UITableViewCell() + } - func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] - return model.rowHeight + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] + if let block = model.cellClick { + block() } + } - func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { - if viewModel.sectionData.count > section { - let model = viewModel.sectionData[section] - if model.cellModels.count > 0 { - return 12.0 - } + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { + let model = viewModel.sectionData[indexPath.section].cellModels[indexPath.row] + return model.rowHeight + } + + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { + if viewModel.sectionData.count > section { + let model = viewModel.sectionData[section] + if model.cellModels.count > 0 { + return 12.0 } - return 0 } + return 0 + } - func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - let header = UIView() - header.backgroundColor = UIColor(hexString: "0xF1F1F6") - return header - } + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let header = UIView() + header.backgroundColor = UIColor(hexString: "0xF1F1F6") + return header + } } - diff --git a/app/Mine/PersonInfoViewModel.swift b/app/Mine/PersonInfoViewModel.swift index f21c6d10..1653f41e 100644 --- a/app/Mine/PersonInfoViewModel.swift +++ b/app/Mine/PersonInfoViewModel.swift @@ -1,234 +1,233 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import Foundation import NEKitTeamUI import NIMSDK protocol PersonInfoViewModelDelegate: AnyObject { - func didClickHeadImage() - func didClickNickName(name:String) - func didClickGender() - func didClickBirthday() - func didClickMobile(mobile:String) - func didClickEmail(email:String) - func didClickSign(sign:String) - func didCopyAccount(account:String) + func didClickHeadImage() + func didClickNickName(name: String) + func didClickGender() + func didClickBirthday() + func didClickMobile(mobile: String) + func didClickEmail(email: String) + func didClickSign(sign: String) + func didCopyAccount(account: String) } -public class PersonInfoViewModel{ - - var sectionData = [SettingSectionModel]() - public let friendProvider = FriendProvider.shared - public let userProvider = UserInfoProvider.shared - - private var userInfo:User? - weak var delegate:PersonInfoViewModelDelegate? - - func getData(){ - sectionData.removeAll() - userInfo = userProvider.getUserInfo(userId: IMKitLoginManager.instance.imAccid) - sectionData.append(getFirstSection()) - sectionData.append(getSecondSection()) - } - - - private func getFirstSection() -> SettingSectionModel { - let model = SettingSectionModel() - - guard let mineInfo = userInfo else { - return model - } - - weak var weakSelf = self - let headImageItem = SettingCellModel() - headImageItem.cornerType = .topLeft.union(.topRight) - headImageItem.type = SettingCellType.SettingHeaderCell.rawValue - headImageItem.cellName = "头像" - headImageItem.headerUrl = userInfo?.userInfo?.avatarUrl - headImageItem.defaultHeadData = userInfo?.showName() - headImageItem.rowHeight = 64.0 - headImageItem.cellClick = { - weakSelf?.delegate?.didClickHeadImage() - } - - - //昵称 - let nickNameItem = SettingCellModel() - nickNameItem.type = SettingCellType.SettingSubtitleCell.rawValue - nickNameItem.cellName = "昵称" - nickNameItem.subTitle = mineInfo.showName() - nickNameItem.rowHeight = 46.0 - nickNameItem.cellClick = { - weakSelf?.delegate?.didClickNickName(name: nickNameItem.subTitle ?? "") - } - - //账号 - let accountItem = SettingCellModel() - accountItem.type = SettingCellType.SettingSubtitleCustomCell.rawValue - accountItem.cellName = "账号" - accountItem.subTitle = mineInfo.userId - accountItem.rowHeight = 46.0 - accountItem.rightCustomViewIcon = "copy_icon" - accountItem.customViewClick = { - weakSelf?.delegate?.didCopyAccount(account: mineInfo.userId ?? "") - } - - //性别 - let sexItem = SettingCellModel() - sexItem.type = SettingCellType.SettingSubtitleCell.rawValue - sexItem.cellName = "性别" - var sex = "未知" - switch mineInfo.userInfo?.gender { - case .male: - sex = "男" - break - case .female: - sex = "女" - break - default: - sex = "未知" - } - sexItem.subTitle = sex - sexItem.rowHeight = 46.0 - sexItem.cellClick = { - weakSelf?.delegate?.didClickGender() - } - - //生日 - let birthdayItem = SettingCellModel() - birthdayItem.type = SettingCellType.SettingSubtitleCell.rawValue - birthdayItem.cellName = "生日" - birthdayItem.subTitle = mineInfo.userInfo?.birth - birthdayItem.rowHeight = 46.0 - birthdayItem.cellClick = { - weakSelf?.delegate?.didClickBirthday() - } - //手机 - let telephoneItem = SettingCellModel() - telephoneItem.type = SettingCellType.SettingSubtitleCell.rawValue - telephoneItem.cellName = "手机" - telephoneItem.subTitle = mineInfo.userInfo?.mobile - telephoneItem.rowHeight = 46.0 - telephoneItem.cellClick = { - weakSelf?.delegate?.didClickMobile(mobile: telephoneItem.subTitle ?? "") - } - - //邮箱 - let emailItem = SettingCellModel() - emailItem.type = SettingCellType.SettingSubtitleCell.rawValue - emailItem.cellName = "邮箱" - emailItem.subTitle = mineInfo.userInfo?.email - emailItem.cornerType = .bottomLeft.union(.bottomRight) - emailItem.rowHeight = 46.0 - emailItem.cellClick = { - weakSelf?.delegate?.didClickEmail(email: emailItem.subTitle ?? "") - } - model.cellModels.append(contentsOf: [headImageItem, nickNameItem,accountItem,sexItem,birthdayItem,telephoneItem,emailItem]) - return model - - } - - private func getSecondSection() -> SettingSectionModel { - - let model = SettingSectionModel() - guard let mineInfo = userInfo else { - return model - } - - - let signItem = SettingCellModel() - signItem.type = SettingCellType.SettingSubtitleCell.rawValue - signItem.cellName = "个性签名" - signItem.subTitle = mineInfo.userInfo?.sign - signItem.rowHeight = 46.0 - signItem.cornerType = .topLeft.union(.topRight).union(.bottomLeft).union(.bottomRight) - weak var weakSelf = self - signItem.cellClick = { - weakSelf?.delegate?.didClickSign(sign: signItem.subTitle ?? "") - } - model.cellModels.append(contentsOf: [signItem]) - return model - } - - - func updateAvatar(avatar:String,_ completion:@escaping (NSError?)->Void) { - let changeValue = [NSNumber.init(value: NIMUserInfoUpdateTag.avatar.rawValue):avatar] - userProvider.updateMyUserInfo(values: changeValue) { error in - if error == nil { - completion(nil) - }else { - completion(error) - } - } - } - - func updateSex(sex:NIMUserGender,_ completion:@escaping (NSError?)->Void) { - let changeValue = [NSNumber.init(value: NIMUserInfoUpdateTag.gender.rawValue):NSNumber.init(value: sex.rawValue)] - userProvider.updateMyUserInfo(values: changeValue) { error in - if error == nil { - completion(nil) - }else { - completion(error) - } - } - } - - - func updateBirthday(birthDay:String,_ completion:@escaping (NSError?)->Void) { - let changeValue = [NSNumber.init(value: NIMUserInfoUpdateTag.birth.rawValue):birthDay] - userProvider.updateMyUserInfo(values: changeValue) { error in - if error == nil { - completion(nil) - }else { - completion(error) - } - } - } - - - func updateNickName(name:String,_ completion:@escaping (NSError?)->Void) { - let changeValue = [NSNumber.init(value: NIMUserInfoUpdateTag.nick.rawValue):name] - userProvider.updateMyUserInfo(values: changeValue) { error in - if error == nil { - completion(nil) - }else { - completion(error) - } - } - } - - func updateMobile(mobile:String,_ completion:@escaping (NSError?)->Void) { - let changeValue = [NSNumber.init(value: NIMUserInfoUpdateTag.mobile.rawValue):mobile] - userProvider.updateMyUserInfo(values: changeValue) { error in - if error == nil { - completion(nil) - }else { - completion(error) - } - } - } - - func updateEmail(email:String,_ completion:@escaping (NSError?)->Void) { - let changeValue = [NSNumber.init(value: NIMUserInfoUpdateTag.email.rawValue):email] - userProvider.updateMyUserInfo(values: changeValue) { error in - if error == nil { - completion(nil) - }else { - completion(error) - } - } - } - - func updateSign(sign:String,_ completion:@escaping (NSError?)->Void) { - let changeValue = [NSNumber.init(value: NIMUserInfoUpdateTag.sign.rawValue):sign] - userProvider.updateMyUserInfo(values: changeValue) { error in - if error == nil { - completion(nil) - }else { - completion(error) - } - } +public class PersonInfoViewModel { + var sectionData = [SettingSectionModel]() + public let friendProvider = FriendProvider.shared + public let userProvider = UserInfoProvider.shared + + private var userInfo: User? + weak var delegate: PersonInfoViewModelDelegate? + + func getData() { + sectionData.removeAll() + userInfo = userProvider.getUserInfo(userId: IMKitEngine.instance.imAccid) + sectionData.append(getFirstSection()) + sectionData.append(getSecondSection()) + } + + private func getFirstSection() -> SettingSectionModel { + let model = SettingSectionModel() + + guard let mineInfo = userInfo else { + return model + } + + weak var weakSelf = self + let headImageItem = SettingCellModel() + headImageItem.cornerType = .topLeft.union(.topRight) + headImageItem.type = SettingCellType.SettingHeaderCell.rawValue + headImageItem.cellName = NSLocalizedString("headImage", comment: "") + headImageItem.headerUrl = userInfo?.userInfo?.avatarUrl + headImageItem.defaultHeadData = userInfo?.showName() + headImageItem.rowHeight = 64.0 + headImageItem.cellClick = { + weakSelf?.delegate?.didClickHeadImage() + } + + // 昵称 + let nickNameItem = SettingCellModel() + nickNameItem.type = SettingCellType.SettingSubtitleCell.rawValue + nickNameItem.cellName = NSLocalizedString("nickname", comment: "") + nickNameItem.subTitle = mineInfo.showName() + nickNameItem.rowHeight = 46.0 + nickNameItem.cellClick = { + weakSelf?.delegate?.didClickNickName(name: nickNameItem.subTitle ?? "") + } + + // 账号 + let accountItem = SettingCellModel() + accountItem.type = SettingCellType.SettingSubtitleCustomCell.rawValue + accountItem.cellName = NSLocalizedString("account", comment: "") + accountItem.subTitle = mineInfo.userId + accountItem.rowHeight = 46.0 + accountItem.rightCustomViewIcon = "copy_icon" + accountItem.customViewClick = { + weakSelf?.delegate?.didCopyAccount(account: mineInfo.userId ?? "") + } + + // 性别 + let sexItem = SettingCellModel() + sexItem.type = SettingCellType.SettingSubtitleCell.rawValue + sexItem.cellName = NSLocalizedString("gender", comment: "") + var sex = NSLocalizedString("unknown", comment: "") + switch mineInfo.userInfo?.gender { + case .male: + sex = NSLocalizedString("male", comment: "") + case .female: + sex = NSLocalizedString("female", comment: "") + default: + sex = NSLocalizedString("unknown", comment: "") + } + sexItem.subTitle = sex + sexItem.rowHeight = 46.0 + sexItem.cellClick = { + weakSelf?.delegate?.didClickGender() + } + + // 生日 + let birthdayItem = SettingCellModel() + birthdayItem.type = SettingCellType.SettingSubtitleCell.rawValue + birthdayItem.cellName = NSLocalizedString("birehday", comment: "") + birthdayItem.subTitle = mineInfo.userInfo?.birth + birthdayItem.rowHeight = 46.0 + birthdayItem.cellClick = { + weakSelf?.delegate?.didClickBirthday() + } + // 手机 + let telephoneItem = SettingCellModel() + telephoneItem.type = SettingCellType.SettingSubtitleCell.rawValue + telephoneItem.cellName = NSLocalizedString("phone", comment: "") + telephoneItem.subTitle = mineInfo.userInfo?.mobile + telephoneItem.rowHeight = 46.0 + telephoneItem.cellClick = { + weakSelf?.delegate?.didClickMobile(mobile: telephoneItem.subTitle ?? "") + } + + // 邮箱 + let emailItem = SettingCellModel() + emailItem.type = SettingCellType.SettingSubtitleCell.rawValue + emailItem.cellName = NSLocalizedString("email", comment: "") + emailItem.subTitle = mineInfo.userInfo?.email + emailItem.cornerType = .bottomLeft.union(.bottomRight) + emailItem.rowHeight = 46.0 + emailItem.cellClick = { + weakSelf?.delegate?.didClickEmail(email: emailItem.subTitle ?? "") + } + model.cellModels.append(contentsOf: [ + headImageItem, + nickNameItem, + accountItem, + sexItem, + birthdayItem, + telephoneItem, + emailItem, + ]) + return model + } + + private func getSecondSection() -> SettingSectionModel { + let model = SettingSectionModel() + guard let mineInfo = userInfo else { + return model + } + + let signItem = SettingCellModel() + signItem.type = SettingCellType.SettingSubtitleCell.rawValue + signItem.cellName = NSLocalizedString("individuality_sign", comment: "") + signItem.subTitle = mineInfo.userInfo?.sign + signItem.rowHeight = 46.0 + signItem.cornerType = .topLeft.union(.topRight).union(.bottomLeft).union(.bottomRight) + weak var weakSelf = self + signItem.cellClick = { + weakSelf?.delegate?.didClickSign(sign: signItem.subTitle ?? "") + } + model.cellModels.append(contentsOf: [signItem]) + return model + } + + func updateAvatar(avatar: String, _ completion: @escaping (NSError?) -> Void) { + let changeValue = [NSNumber(value: NIMUserInfoUpdateTag.avatar.rawValue): avatar] + userProvider.updateMyUserInfo(values: changeValue) { error in + if error == nil { + completion(nil) + } else { + completion(error) + } + } + } + + func updateSex(sex: NIMUserGender, _ completion: @escaping (NSError?) -> Void) { + let changeValue = + [NSNumber(value: NIMUserInfoUpdateTag.gender.rawValue): NSNumber(value: sex.rawValue)] + userProvider.updateMyUserInfo(values: changeValue) { error in + if error == nil { + completion(nil) + } else { + completion(error) + } + } + } + + func updateBirthday(birthDay: String, _ completion: @escaping (NSError?) -> Void) { + let changeValue = [NSNumber(value: NIMUserInfoUpdateTag.birth.rawValue): birthDay] + userProvider.updateMyUserInfo(values: changeValue) { error in + if error == nil { + completion(nil) + } else { + completion(error) + } + } + } + + func updateNickName(name: String, _ completion: @escaping (NSError?) -> Void) { + let changeValue = [NSNumber(value: NIMUserInfoUpdateTag.nick.rawValue): name] + userProvider.updateMyUserInfo(values: changeValue) { error in + if error == nil { + completion(nil) + } else { + completion(error) + } + } + } + + func updateMobile(mobile: String, _ completion: @escaping (NSError?) -> Void) { + let changeValue = [NSNumber(value: NIMUserInfoUpdateTag.mobile.rawValue): mobile] + userProvider.updateMyUserInfo(values: changeValue) { error in + if error == nil { + completion(nil) + } else { + completion(error) + } + } + } + + func updateEmail(email: String, _ completion: @escaping (NSError?) -> Void) { + let changeValue = [NSNumber(value: NIMUserInfoUpdateTag.email.rawValue): email] + userProvider.updateMyUserInfo(values: changeValue) { error in + if error == nil { + completion(nil) + } else { + completion(error) + } + } + } + + func updateSign(sign: String, _ completion: @escaping (NSError?) -> Void) { + let changeValue = [NSNumber(value: NIMUserInfoUpdateTag.sign.rawValue): sign] + userProvider.updateMyUserInfo(values: changeValue) { error in + if error == nil { + completion(nil) + } else { + completion(error) + } } + } } diff --git a/app/Mine/VersionCell.swift b/app/Mine/VersionCell.swift index 13ef29aa..788a7005 100644 --- a/app/Mine/VersionCell.swift +++ b/app/Mine/VersionCell.swift @@ -1,113 +1,112 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import UIKit import NEKitTeamUI -enum IntroduceCellType:Int { - case version = 0 - case productIntroduce +enum IntroduceCellType: Int { + case version = 0 + case productIntroduce } class VersionCell: UITableViewCell { - - public var cellType:IntroduceCellType? { - didSet { - if cellType == .version { - subTitle.isHidden = false - arrow.isHidden = true - }else { - subTitle.isHidden = true - arrow.isHidden = false - } - } - } - - override func awakeFromNib() { - super.awakeFromNib() - // Initialization code + public var cellType: IntroduceCellType? { + didSet { + if cellType == .version { + subTitle.isHidden = false + arrow.isHidden = true + } else { + subTitle.isHidden = true + arrow.isHidden = false + } } + } - override func setSelected(_ selected: Bool, animated: Bool) { - super.setSelected(selected, animated: animated) + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } - // Configure the view for the selected state - } + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) - override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { - super.init(style: style, reuseIdentifier: reuseIdentifier) - setupSubviews() - self.selectionStyle = .none - } - - func setupSubviews(){ - contentView.addSubview(titleLabel) - contentView.addSubview(subTitle) - contentView.addSubview(arrow) - contentView.addSubview(bottomLine) - - NSLayoutConstraint.activate([ - titleLabel.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 20), - titleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), - ]) - - NSLayoutConstraint.activate([ - subTitle.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: -20), - subTitle.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), - ]) - - NSLayoutConstraint.activate([ - arrow.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: -20), - arrow.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), - ]) - - NSLayoutConstraint.activate([ - bottomLine.leftAnchor.constraint(equalTo: contentView.leftAnchor,constant: 20), - bottomLine.rightAnchor.constraint(equalTo: rightAnchor), - bottomLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - bottomLine.heightAnchor.constraint(equalToConstant: 0.5) - ]) + // Configure the view for the selected state + } - } - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - func configData(model:SettingCellModel){ - titleLabel.text = model.cellName - subTitle.text = model.subTitle - } - - lazy var titleLabel: UILabel = { - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.textColor = UIColor.init(hexString: "0x333333") - label.font = UIFont.systemFont(ofSize: 14) - return label - }() - - lazy var subTitle: UILabel = { - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.textColor = UIColor.init(hexString: "0x333333") - label.font = UIFont.systemFont(ofSize: 14) - label.isHidden = true - return label - }() - - public lazy var arrow: UIImageView = { - let imageView = UIImageView(image:UIImage.init(named: "arrow_right")) - imageView.translatesAutoresizingMaskIntoConstraints = false - imageView.isHidden = true - return imageView - }() - - - private lazy var bottomLine:UIView = { - let view = UIView() - view.translatesAutoresizingMaskIntoConstraints = false - view.backgroundColor = UIColor.init(hexString: "0xDBE0E8") - return view - }() + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + setupSubviews() + selectionStyle = .none + } + + func setupSubviews() { + contentView.addSubview(titleLabel) + contentView.addSubview(subTitle) + contentView.addSubview(arrow) + contentView.addSubview(bottomLine) + + NSLayoutConstraint.activate([ + titleLabel.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 20), + titleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), + ]) + + NSLayoutConstraint.activate([ + subTitle.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: -20), + subTitle.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), + ]) + + NSLayoutConstraint.activate([ + arrow.rightAnchor.constraint(equalTo: contentView.rightAnchor, constant: -20), + arrow.centerYAnchor.constraint(equalTo: contentView.centerYAnchor), + ]) + + NSLayoutConstraint.activate([ + bottomLine.leftAnchor.constraint(equalTo: contentView.leftAnchor, constant: 20), + bottomLine.rightAnchor.constraint(equalTo: rightAnchor), + bottomLine.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), + bottomLine.heightAnchor.constraint(equalToConstant: 0.5), + ]) + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + func configData(model: SettingCellModel) { + titleLabel.text = model.cellName + subTitle.text = model.subTitle + } + + lazy var titleLabel: UILabel = { + let label = UILabel() + label.translatesAutoresizingMaskIntoConstraints = false + label.textColor = UIColor(hexString: "0x333333") + label.font = UIFont.systemFont(ofSize: 14) + return label + }() + + lazy var subTitle: UILabel = { + let label = UILabel() + label.translatesAutoresizingMaskIntoConstraints = false + label.textColor = UIColor(hexString: "0x333333") + label.font = UIFont.systemFont(ofSize: 14) + label.isHidden = true + return label + }() + + public lazy var arrow: UIImageView = { + let imageView = UIImageView(image: UIImage(named: "arrow_right")) + imageView.translatesAutoresizingMaskIntoConstraints = false + imageView.isHidden = true + return imageView + }() + + private lazy var bottomLine: UIView = { + let view = UIView() + view.translatesAutoresizingMaskIntoConstraints = false + view.backgroundColor = UIColor(hexString: "0xDBE0E8") + return view + }() } diff --git a/app/NENavigationController.swift b/app/NENavigationController.swift index 7d565566..2d85dd65 100644 --- a/app/NENavigationController.swift +++ b/app/NENavigationController.swift @@ -1,23 +1,34 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import UIKit class NENavigationController: UINavigationController { + override public func viewDidLoad() { + super.viewDidLoad() + setUpNavigation() + } - public override func viewDidLoad() { - super.viewDidLoad() - } - - public override func pushViewController(_ viewController: UIViewController, animated: Bool) { - if children.count > 0 { - viewController.hidesBottomBarWhenPushed = true - if children.count > 1 { - viewController.hidesBottomBarWhenPushed = false - } - } - super.pushViewController(viewController, animated: true) + func setUpNavigation() { + if #available(iOS 13.0, *) { + let appearance = UINavigationBarAppearance() + appearance.backgroundImage = UIImage() + appearance.backgroundColor = .white + appearance.shadowColor = .white + navigationBar.standardAppearance = appearance + navigationBar.scrollEdgeAppearance = appearance } + } + override public func pushViewController(_ viewController: UIViewController, animated: Bool) { + if children.count > 0 { + viewController.hidesBottomBarWhenPushed = true + if children.count > 1 { + viewController.hidesBottomBarWhenPushed = false + } + } + super.pushViewController(viewController, animated: true) + } } diff --git a/app/NETabBarController.swift b/app/NETabBarController.swift index dfb683bf..d2bfd419 100644 --- a/app/NETabBarController.swift +++ b/app/NETabBarController.swift @@ -1,6 +1,7 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import UIKit import NIMSDK @@ -13,97 +14,109 @@ import NEKitChatUI import NEKitContactUI class NETabBarController: UITabBarController { + private var sessionUnreadCount = 0 + private var contactUnreadCount = 0 - private var sessionUnreadCount = 0 - private var contactUnreadCount = 0 - - - override func viewDidLoad() { - super.viewDidLoad() - setUpControllers() - setUpSessionBadgeValue() - setUpContactBadgeValue() - NIMSDK.shared().conversationManager.add(self) - NIMSDK.shared().systemNotificationManager.add(self) - } + override func viewDidLoad() { + super.viewDidLoad() + setUpControllers() + setUpSessionBadgeValue() + setUpContactBadgeValue() + NIMSDK.shared().conversationManager.add(self) + NIMSDK.shared().systemNotificationManager.add(self) + } - func setUpControllers(){ - //chat - let chat = ConversationController() - chat.view.backgroundColor = UIColor.init(hexString: "#e9eff5") - chat.tabBarItem = UITabBarItem(title: "消息", image: UIImage(named: "chat"), selectedImage: UIImage(named: "chatSelect")?.withRenderingMode(.alwaysOriginal)) - let chatNav = NENavigationController(rootViewController: chat) - - //qchat - let qchat = QChatHomeViewController() - qchat.view.backgroundColor = UIColor.init(hexString: "#e9eff5") - qchat.tabBarItem = UITabBarItem(title: "圈组", image: UIImage(named: "qchat_tabbar_icon"), selectedImage: UIImage(named: "qchat_tabbar_icon")?.withRenderingMode(.alwaysOriginal)) - let qChatNav = NENavigationController(rootViewController: qchat) - - - // Contacts - let contactVC = ContactsViewController() - contactVC.tabBarItem = UITabBarItem(title: "通讯录", image: UIImage(named: "contact"), selectedImage: UIImage(named: "contactSelect")?.withRenderingMode(.alwaysOriginal)) - contactVC.title = "通讯录" - let contactsNav = NENavigationController(rootViewController: contactVC) - - // Me - let meVC = MeViewController() - meVC.view.backgroundColor = UIColor.white - meVC.tabBarItem = UITabBarItem(title: "我", image: UIImage(named: "person"), selectedImage: UIImage(named: "personSelect")?.withRenderingMode(.alwaysOriginal)) - let meNav = NENavigationController(rootViewController: meVC) - - tabBar.backgroundColor = .white - self.viewControllers = [chatNav,qChatNav,contactsNav,meNav] - self.selectedIndex = 0 - } - - func setUpSessionBadgeValue(){ - sessionUnreadCount = ConversationRepo().getMsgUnreadCount(notify: true) - if sessionUnreadCount > 0 { - self.tabBar.showBadgOn(index: 0) - }else { - self.tabBar.hideBadg(on: 0) - } - } - - func setUpContactBadgeValue() { - contactUnreadCount = NIMSDK.shared().systemNotificationManager.allUnreadCount() - if contactUnreadCount > 0 { - self.tabBar.showBadgOn(index: 2) - }else { - self.tabBar.hideBadg(on: 2) - } - } - - private func refreshSessionBadge(){ - setUpSessionBadgeValue() + func setUpControllers() { + // chat + let chat = ConversationController() + chat.view.backgroundColor = UIColor(hexString: "#e9eff5") + chat.tabBarItem = UITabBarItem( + title: NSLocalizedString("message", comment: ""), + image: UIImage(named: "chat"), + selectedImage: UIImage(named: "chatSelect")?.withRenderingMode(.alwaysOriginal) + ) + let chatNav = NENavigationController(rootViewController: chat) + + // qchat + let qchat = QChatHomeViewController() + qchat.view.backgroundColor = UIColor(hexString: "#e9eff5") + qchat.tabBarItem = UITabBarItem( + title: NSLocalizedString("qchat", comment: ""), + image: UIImage(named: "qchat_tabbar_icon"), + selectedImage: UIImage(named: "qchat_tabbar_icon")?.withRenderingMode(.alwaysOriginal) + ) + let qChatNav = NENavigationController(rootViewController: qchat) + + // Contacts + let contactVC = ContactsViewController() + contactVC.tabBarItem = UITabBarItem( + title: NSLocalizedString("contact", comment: ""), + image: UIImage(named: "contact"), + selectedImage: UIImage(named: "contactSelect")?.withRenderingMode(.alwaysOriginal) + ) + contactVC.title = NSLocalizedString("contact", comment: "") + let contactsNav = NENavigationController(rootViewController: contactVC) + + // Me + let meVC = MeViewController() + meVC.view.backgroundColor = UIColor.white + meVC.tabBarItem = UITabBarItem( + title: NSLocalizedString("mine", comment: ""), + image: UIImage(named: "person"), + selectedImage: UIImage(named: "personSelect")?.withRenderingMode(.alwaysOriginal) + ) + let meNav = NENavigationController(rootViewController: meVC) + + tabBar.backgroundColor = .white + viewControllers = [chatNav, qChatNav, contactsNav, meNav] + selectedIndex = 0 + } + + func setUpSessionBadgeValue() { + sessionUnreadCount = ConversationRepo().getMsgUnreadCount(notify: true) + if sessionUnreadCount > 0 { + tabBar.showBadgOn(index: 0) + } else { + tabBar.hideBadg(on: 0) } - - deinit { - NIMSDK.shared().systemNotificationManager.remove(self) - NIMSDK.shared().conversationManager.remove(self) + } + + func setUpContactBadgeValue() { + contactUnreadCount = NIMSDK.shared().systemNotificationManager.allUnreadCount() + if contactUnreadCount > 0 { + tabBar.showBadgOn(index: 2) + } else { + tabBar.hideBadg(on: 2) } + } + + private func refreshSessionBadge() { + setUpSessionBadgeValue() + } + + deinit { + NIMSDK.shared().systemNotificationManager.remove(self) + NIMSDK.shared().conversationManager.remove(self) + } } -extension NETabBarController:NIMConversationManagerDelegate { - - func didAdd(_ recentSession: NIMRecentSession, totalUnreadCount: Int) { - refreshSessionBadge() - } - - func didUpdate(_ recentSession: NIMRecentSession, totalUnreadCount: Int) { - refreshSessionBadge() - } - - func didRemove(_ recentSession: NIMRecentSession, totalUnreadCount: Int) { - refreshSessionBadge() - } +extension NETabBarController: NIMConversationManagerDelegate { + func didAdd(_ recentSession: NIMRecentSession, totalUnreadCount: Int) { + refreshSessionBadge() + } + + func didUpdate(_ recentSession: NIMRecentSession, totalUnreadCount: Int) { + refreshSessionBadge() + } + + func didRemove(_ recentSession: NIMRecentSession, totalUnreadCount: Int) { + refreshSessionBadge() + } } -extension NETabBarController:NIMSystemNotificationManagerDelegate { - func onSystemNotificationCountChanged(_ unreadCount: Int) { - contactUnreadCount = unreadCount - setUpContactBadgeValue() - } +extension NETabBarController: NIMSystemNotificationManagerDelegate { + func onSystemNotificationCountChanged(_ unreadCount: Int) { + contactUnreadCount = unreadCount + setUpContactBadgeValue() + } } diff --git a/app/ViewController.swift b/app/ViewController.swift index 3e6a873d..18bc3f23 100644 --- a/app/ViewController.swift +++ b/app/ViewController.swift @@ -1,76 +1,98 @@ -// Copyright (c) 2022 NetEase, Inc. All rights reserved. -// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. import UIKit +import NEKitCommonUI class ViewController: UIViewController { + lazy var launchIcon: UIImageView = { + let imageView = UIImageView() + imageView.translatesAutoresizingMaskIntoConstraints = false + imageView.image = UIImage(named: "launchIcon") + return imageView + }() - lazy var launchIcon : UIImageView = { - let imageView = UIImageView() - imageView.translatesAutoresizingMaskIntoConstraints = false - imageView.image = UIImage(named: "launch_icon") - return imageView - }() - - lazy var copyrightImage: UIImageView = { - let imageView = UIImageView() - imageView.translatesAutoresizingMaskIntoConstraints = false - imageView.image = UIImage(named: "copy_right") - return imageView - }() - - lazy var slogan: UILabel = { - let label = UILabel() - label.translatesAutoresizingMaskIntoConstraints = false - label.text = "真正稳定的IM云服务" - label.font = UIFont.systemFont(ofSize: 16.0) - label.textColor = UIColor(hexString: "666666") - return label - }() - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view. - setupUI() - } - - func setupUI(){ - - view.addSubview(launchIcon) - if #available(iOS 11.0, *) { - NSLayoutConstraint.activate([ - launchIcon.centerXAnchor.constraint(equalTo: view.centerXAnchor), - launchIcon.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 160.0) - ]) - }else { - NSLayoutConstraint.activate([ - launchIcon.centerXAnchor.constraint(equalTo: view.centerXAnchor), - launchIcon.topAnchor.constraint(equalTo: view.topAnchor, constant: 160.0) - ]) - } - - view.addSubview(slogan) - NSLayoutConstraint.activate([ - slogan.centerXAnchor.constraint(equalTo: view.centerXAnchor), - slogan.topAnchor.constraint(equalTo: launchIcon.bottomAnchor, constant: 12.0) - - ]) - - view.addSubview(copyrightImage) - if #available(iOS 11.0, *) { - NSLayoutConstraint.activate([ - copyrightImage.centerXAnchor.constraint(equalTo: view.centerXAnchor), - copyrightImage.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -48) - ]) - } else { - NSLayoutConstraint.activate([ - copyrightImage.centerXAnchor.constraint(equalTo: view.centerXAnchor), - copyrightImage.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -48) - ]) - } + lazy var launchIconLabel: UILabel = { + let label = UILabel() + label.translatesAutoresizingMaskIntoConstraints = false + label.text = NSLocalizedString("appName", comment: "") + label.font = UIFont.systemFont(ofSize: 24.0) + label.textColor = UIColor(hexString: "333333") + return label + }() + + lazy var copyright: UIButton = { + let btn = UIButton() + btn.translatesAutoresizingMaskIntoConstraints = false + btn.setImage(UIImage(named: "yunxin_brand"), for: .normal) + btn.setTitle(NSLocalizedString("brand_des", comment: ""), for: .normal) + btn.titleLabel?.font = UIFont.systemFont(ofSize: 16.0) + btn.setTitleColor(UIColor(hexString: "333333"), for: .normal) + btn.layoutButtonImage(style: .left, space: 5.0) + return btn + }() + + lazy var slogan: UILabel = { + let label = UILabel() + label.translatesAutoresizingMaskIntoConstraints = false + label.text = NSLocalizedString("real_service", comment: "") + label.font = UIFont.systemFont(ofSize: 16.0) + label.textColor = UIColor(hexString: "666666") + return label + }() + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + setupUI() + } + + func setupUI() { + view.addSubview(launchIcon) + if #available(iOS 11.0, *) { + NSLayoutConstraint.activate([ + launchIcon.centerXAnchor.constraint(equalTo: view.centerXAnchor), + launchIcon.topAnchor.constraint( + equalTo: view.safeAreaLayoutGuide.topAnchor, + constant: 145.0 + ), + ]) + } else { + NSLayoutConstraint.activate([ + launchIcon.centerXAnchor.constraint(equalTo: view.centerXAnchor), + launchIcon.topAnchor.constraint(equalTo: view.topAnchor, constant: 145.0), + ]) } + view.addSubview(launchIconLabel) + NSLayoutConstraint.activate([ + launchIconLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor), + launchIconLabel.topAnchor.constraint(equalTo: launchIcon.bottomAnchor, constant: -12.0), + ]) -} + view.addSubview(slogan) + NSLayoutConstraint.activate([ + slogan.centerXAnchor.constraint(equalTo: view.centerXAnchor), + slogan.topAnchor.constraint(equalTo: launchIconLabel.bottomAnchor, constant: 12.0), + + ]) + view.addSubview(copyright) + if #available(iOS 11.0, *) { + NSLayoutConstraint.activate([ + copyright.centerXAnchor.constraint(equalTo: view.centerXAnchor), + copyright.bottomAnchor.constraint( + equalTo: view.safeAreaLayoutGuide.bottomAnchor, + constant: -48 + ), + ]) + } else { + NSLayoutConstraint.activate([ + copyright.centerXAnchor.constraint(equalTo: view.centerXAnchor), + copyright.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -48), + ]) + } + } +} diff --git a/app/en.lproj/InfoPlist.strings b/app/en.lproj/InfoPlist.strings new file mode 100644 index 00000000..d7aa4665 --- /dev/null +++ b/app/en.lproj/InfoPlist.strings @@ -0,0 +1,10 @@ + +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +"NSCameraUsageDescription"="Can't take photo before agree"; +"NSPhotoLibraryAddUsageDescription"="Can't upload photo before agree"; +"NSPhotoLibraryUsageDescription"="Can't use album before agree"; +"NSMicrophoneUsageDescription"="Can't use microphone before agree"; +"CFBundleDisplayName"="CommsEase IM"; diff --git a/app/en.lproj/Localizable.strings b/app/en.lproj/Localizable.strings new file mode 100644 index 00000000..19bc34c6 --- /dev/null +++ b/app/en.lproj/Localizable.strings @@ -0,0 +1,58 @@ + +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +"open_push"="Please open the push in the setting"; +"message"="Message"; +"qchat"="Qchat"; +"contact"="Contact"; +"mine"="Me"; +"logout"="Log out"; +"about_yunxin"="About CommsEase"; +"want_to_logout"="Sure to log out?"; +"person_info"="My Proflie"; +"cancel"="Cancel"; +"setting_birthday_failure"="Set birthday Failed"; +"setting_head_failure"="Set Avatar Failed"; +"setting_nickname_failure"="Set Nick Name Failed"; +"male"="Male"; +"female"="Female"; +"change_gender_failure"="Set Sex Failed"; +"change_phone_failure"="Set mobile Failed"; +"change_email_failure"="Set e-mail Failed"; +"change_sign_failure"="Set What's up Failed"; +"copy_success"="Copy ssuccessfully"; +"save"="Save"; +"birehday"="Birthday"; +"phone"="Mobile"; +"email"="E-mail"; +"sign_remind"="sign remind"; + +"message_remind"="Message Notification"; +"product_intro"="Product introduction"; +"receiver_mode"="Handset mode"; +"delete_friend"="删除好友是否同步删除备注";//功能移除可删除 +"message_read_function"="Read/Unread"; +"version"="Version"; +"headImage"="Avator"; +"nickname"="Nick Name"; +"account"="Account"; +"gneder"="Sex"; +"unknown"="Unknown"; +"individuality_sign"="What's up"; +"new_message_remind"="message notification"; +"ring_mode"="Ring mode"; +"vibration_mode"="Vibration mode"; +"syn_receive_push"="PC/Web同步接收推送";//功能移除可删除 +"display_message_detail"="displays the details in notification bar"; +"setting"="Setting"; +"confirm"="yes"; +"cancel"="cancel"; +"real_service"="Truly Stable IM Product"; +"appName"="CommsEase IM"; +"brand_des"="CommsEase"; + +//image + + diff --git a/app/zh-Hans.lproj/InfoPlist.strings b/app/zh-Hans.lproj/InfoPlist.strings new file mode 100644 index 00000000..262ad21e --- /dev/null +++ b/app/zh-Hans.lproj/InfoPlist.strings @@ -0,0 +1,10 @@ + +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +"NSCameraUsageDescription"="若不允许,你将无法拍摄照片"; +"NSPhotoLibraryAddUsageDescription"="若不允许,你将无法导入照片"; +"NSPhotoLibraryUsageDescription"="若不允许,则无法使用相册功能"; +"NSMicrophoneUsageDescription"="若不允许,则无法使用麦克风功能"; +"CFBundleDisplayName"="云信IM"; diff --git a/app/zh-Hans.lproj/Localizable.strings b/app/zh-Hans.lproj/Localizable.strings new file mode 100644 index 00000000..f9ea31ba --- /dev/null +++ b/app/zh-Hans.lproj/Localizable.strings @@ -0,0 +1,56 @@ + +// Copyright (c) 2022 NetEase, Inc. All rights reserved. +// Use of this source code is governed by a MIT license that can be +// found in the LICENSE file. + +"open_push"="请到设置中开启推送功能"; +"message"="消息"; +"qchat"="圈组"; +"contact"="通讯录"; +"mine"="我"; +"logout"="退出登录"; +"about_yunxin"="关于云信"; +"want_to_logout"="确认要退出登录吗?"; +"person_info"="个人信息"; +"cancel"="取消"; +"setting_birthday_failure"="设置生日失败"; +"setting_head_failure"="修改头像失败"; +"setting_nickname_failure"="修改昵称失败"; +"male"="男"; +"female"="女"; +"change_gender_failure"="修改性别失败"; +"change_phone_failure"="修改手机号失败"; +"change_email_failure"="修改邮箱失败"; +"change_sign_failure"="修改签名失败"; +"copy_success"="复制成功"; +"save"="保存"; +"birehday"="生日"; +"phone"="手机"; +"email"="邮箱"; +"sign_remind"="个性签名消息提醒"; + +"message_remind"="消息提醒"; +"product_intro"="产品介绍"; +"receiver_mode"="听筒模式"; +"delete_friend"="删除好友是否同步删除备注"; +"message_read_function"="消息已读未读功能"; +"version"="版本号"; +"headImage"="头像"; +"nickname"="昵称"; +"account"="账号"; +"gender"="性别"; +"unknown"="未知"; +"individuality_sign"="个性签名"; +"new_message_remind"="新消息通知"; +"ring_mode"="响铃模式"; +"vibration_mode"="震动模式"; +"syn_receive_push"="PC/Web同步接收推送"; +"display_message_detail"="通知栏显示消息详情"; +"setting"="设置"; +"confirm"="确认"; +"cancel"="取消"; +"real_service"="真正稳定的IM云服务"; +"appName"="云信IM"; +"brand_des"="网易云信"; +//image +