Skip to content

Commit

Permalink
Merge pull request #338 from Dongshanxu/master
Browse files Browse the repository at this point in the history
9.2.2版本发布
  • Loading branch information
shine2008 authored Jun 24, 2022
2 parents fa61daf + 6390a71 commit 289250a
Show file tree
Hide file tree
Showing 886 changed files with 647 additions and 349 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import NEKitCommon
import NEKitCore
import NEKitCommonUI
import WebKit
public class ChatViewController: NEBaseViewController, UINavigationControllerDelegate, ChatInputViewDelegate, ChatViewModelDelegate, NIMMediaManagerDelegate,MessageOperationViewDelegate, UIGestureRecognizerDelegate {

@objcMembers

open class ChatViewController: NEBaseViewController, UINavigationControllerDelegate, ChatInputViewDelegate, ChatViewModelDelegate, NIMMediaManagerDelegate,MessageOperationViewDelegate, UIGestureRecognizerDelegate {

private let tag = "ChatViewController"
public var viewmodel:ChatViewModel
Expand All @@ -37,7 +40,7 @@ public class ChatViewController: NEBaseViewController, UINavigationControllerDel
NIMSDK.shared().mediaManager.setNeedProximityMonitor(viewmodel.getHandSetEnable())
}

required init?(coder: NSCoder) {
required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

Expand Down Expand Up @@ -72,7 +75,6 @@ public class ChatViewController: NEBaseViewController, UINavigationControllerDel
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.separatorStyle = .none
tableView.showsVerticalScrollIndicator = false
tableView.backgroundColor = .red
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = .white
Expand Down Expand Up @@ -150,7 +152,7 @@ extension ChatViewController: ChatBaseCellDelegate {
if let uid = model?.message?.from {
FriendProvider.shared.fetchUserInfo(accountList: [uid]) {[weak self] users, error in
if let u = users.first {
Router.shared.use("xkit://contact/userinfo/page", parameters: ["nav": self?.navigationController as Any, "user" : u], closure: nil)
Router.shared.use(ContactUserInfoPageRouter, parameters: ["nav": self?.navigationController as Any, "user" : u], closure: nil)
}
}
}
Expand Down Expand Up @@ -1229,7 +1231,7 @@ extension ChatViewController {
weak var weakSelf = self
let userAction = UIAlertAction(title: localizable("contact_user"), style: .default) { action in

Router.shared.register("didSelectedAccids") { param in
Router.shared.register(ContactSelectedUsersRouter) { param in
print("user setting accids : ", param)
var items = [ForwardItem]()

Expand Down Expand Up @@ -1337,7 +1339,7 @@ extension ChatViewController {
extension ChatViewController {
@objc func toSetting() {
if viewmodel.session.sessionType == .team {
Router.shared.use("xkit://team.setting.view", parameters: ["nav": navigationController as Any, "teamid": viewmodel.session.sessionId], closure: nil)
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import UIKit
import NIMSDK
import NEKitCoreIM

public class GroupChatViewController: ChatViewController, TeamChatViewModelDelegate {

@objcMembers
open class GroupChatViewController: ChatViewController, TeamChatViewModelDelegate {

// override init(session: NIMSession) {
// super.init(session: session)
Expand All @@ -23,7 +25,7 @@ public class GroupChatViewController: ChatViewController, TeamChatViewModelDeleg

}

required init?(coder: NSCoder) {
required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import UIKit
import NIMSDK
public class P2PChatViewController: ChatViewController {

@objcMembers
open class P2PChatViewController: ChatViewController {

public override func viewDidLoad() {
super.viewDidLoad()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public class UserSettingViewController: NEBaseViewController, UserSettingViewMod

@objc func createDiscuss(){
weak var weakSelf = self
Router.shared.register("didSelectedAccids") { param in
Router.shared.register(ContactSelectedUsersRouter) { param in
print("user setting create disscuss : ", param)
var convertParam = [String: Any]()
param.forEach { (key: String, value: Any) in
Expand All @@ -144,7 +144,7 @@ public class UserSettingViewController: NEBaseViewController, UserSettingViewMod
}
}
weakSelf?.view.makeToastActivity(.center)
Router.shared.use("xkit://team.create.discuss", parameters: convertParam, closure: nil)
Router.shared.use(TeamCreateDisuss, parameters: convertParam, closure: nil)
}
var filters = Set<String>()
if let uid = userId {
Expand All @@ -153,14 +153,12 @@ public class UserSettingViewController: NEBaseViewController, UserSettingViewMod

Router.shared.use(ContactUserSelectRouter, parameters: ["nav": navigationController as Any, "filters":filters, "limit": 199], closure: nil)

Router.shared.register("xkit://team.create.discuss.result") { param in
Router.shared.register(TeamCreateDiscussResult) { param in
print("create discuss ", param)
weakSelf?.view.hideToastActivity()
if let code = param["code"] as? Int, let teamid = param["teamId"] as? String, code == 0 {
let session = NIMSession(teamid, type: .team)

Router.shared.use("pushGroupChatVC", parameters: ["nav": weakSelf?.navigationController as Any, "session" : session as Any], closure: nil)

DispatchQueue.main.async {
if let allControllers = weakSelf?.navigationController?.viewControllers.filter({
if $0.isKind(of: P2PChatViewController.self) || $0.isKind(of: UserSettingViewController.self) {
Expand All @@ -169,6 +167,7 @@ public class UserSettingViewController: NEBaseViewController, UserSettingViewMod
return true
}){
weakSelf?.navigationController?.viewControllers = allControllers
Router.shared.use(ChatPushGroupVC, parameters: ["nav": weakSelf?.navigationController as Any, "session" : session as Any], closure: nil)
}
}
}else if let error = param["msg"] as? String {
Expand All @@ -179,7 +178,7 @@ public class UserSettingViewController: NEBaseViewController, UserSettingViewMod

@objc func showUserInfo(){
if let user = viewmodel.userInfo {
Router.shared.use("xkit://contact/userinfo/page", parameters: ["nav": navigationController as Any, "user" : user], closure: nil)
Router.shared.use(ContactUserInfoPageRouter, parameters: ["nav": navigationController as Any, "user" : user], closure: nil)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import UIKit

public class NEEmotionTool: NSObject {
class func getAttWithStr(str:String,font:UIFont, _ offset: CGPoint = CGPoint(x: 0, y: -3) )->NSAttributedString {
class func getAttWithStr(str:String,font:UIFont, _ offset: CGPoint = CGPoint(x: 0, y: -3) )->NSMutableAttributedString {
let regular = "\\[[^\\[|^\\]]+\\]"

var reExpression: NSRegularExpression? = nil
Expand All @@ -19,7 +19,7 @@ public class NEEmotionTool: NSObject {
let emoticons = NIMInputEmoticonManager.shared.emoticonCatalog(catalogID: NIMKit_EmojiCatalog)?.emoticons
let attStr = NSMutableAttributedString(string: str, attributes: [
NSAttributedString.Key.font: font,
.foregroundColor:UIColor.ne_darkText
.foregroundColor:NEKitChatConfig.shared.ui.messageColor
])

if let regArr = regularArr,regArr.count > 0,let targetEmotions = emoticons {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import Foundation
import NIMSDK
import NEKitCore
import NEKitCoreIM

public class MessageUtils {

public class func textMessage(text: String) -> NIMMessage {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// CustomerSampleAttachment.swift
// NEKitChatUI
//
// Created by vvj on 2022/6/17.
//

import UIKit
import NIMSDK

public class CustomerAttachment: NSObject,NIMCustomAttachment {

var title = "custAttachment"

var subTitle = "subCustAttachment"

public func encode() -> String {
return ""
}


}


public class CustomerAttachmentDecoder:NSObject, NIMCustomAttachmentCoding {

public func decodeAttachment(_ content: String?) -> NIMCustomAttachment? {

var attachment: NIMCustomAttachment? = nil
let data = content?.data(using: .utf8)
guard let dataInfo = data else {
return attachment
}

let infoDict = try? JSONSerialization.jsonObject(with: dataInfo, options: .mutableContainers)
let infoResult = infoDict as? [String:Any]
let type = infoResult?["type"] as? Int

switch type {
case 0:
attachment = decodeCustomMessage(info: infoDict as? [String : Any] ?? [String():String()])
default:
print("test")
}

return attachment
}


func decodeCustomMessage(info:[String:Any]) -> CustomerAttachment{
let customAttachment = CustomerAttachment()
customAttachment.title = info["title"] as? String ?? ""
customAttachment.subTitle = info["subTitle"] as? String ?? ""
return customAttachment
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class MessageContentModel: MessageModel {
required public init(message: NIMMessage?) {
self.message = message
contentSize = CGSize(width: 32.0, height: qChat_min_h)
if message?.session?.sessionType == .team && !CoreKitIMEngine.instance.isMySelf(message?.from) {
if message?.session?.sessionType == .team && !IMKitLoginManager.instance.isMySelf(message?.from) {
self.fullNameHeight = 20
}
print("self.fullNameHeight\(self.fullNameHeight)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MessageTextModel: MessageContentModel {
super.init(message: message)
type = .text
// text = message?.text
attributeStr = NEEmotionTool.getAttWithStr(str: message?.text ?? "", font: UIFont.systemFont(ofSize: 16))
attributeStr = NEEmotionTool.getAttWithStr(str: message?.text ?? "", font: NEKitChatConfig.shared.ui.messageFont)

let textSize = NEChatUITool.getSizeWithAtt(att: attributeStr ?? NSAttributedString.init(string: ""), font: DefaultTextFont(16), maxSize: CGSize.init(width: qChat_content_maxW, height: CGFloat.greatestFiniteMagnitude))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ChatBaseLeftCell: ChatBaseCell {
super.init(style: style, reuseIdentifier: reuseIdentifier)
baseCommonUI()
addGesture()
initSubviewsLayout()
}

required init?(coder: NSCoder) {
Expand Down Expand Up @@ -75,7 +76,7 @@ class ChatBaseLeftCell: ChatBaseCell {
])

// bubbleImage
if let image = UIImage.ne_imageNamed(name: "chat_message_receive") {
if let image = NEKitChatConfig.shared.ui.leftBubbleBg {
self.bubbleImage.image = image.resizableImage(withCapInsets: UIEdgeInsets.init(top: 35, left: 25, bottom: 10, right: 25))
}
self.bubbleImage.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -150,6 +151,15 @@ class ChatBaseLeftCell: ChatBaseCell {
self.bubbleImage.addGestureRecognizer(messageLongPress)
}

func initSubviewsLayout(){
if NEKitChatConfig.shared.ui.avatarType == .rectangle {
avatarImage.layer.cornerRadius = NEKitChatConfig.shared.ui.avatarCornerRadius
}else if NEKitChatConfig.shared.ui.avatarType == .cycle {
avatarImage.layer.cornerRadius = 16.0
}
}


// MARK: event
@objc func tapAvatar(tap: UITapGestureRecognizer) {
print(#function)
Expand Down Expand Up @@ -224,7 +234,7 @@ class ChatBaseLeftCell: ChatBaseCell {
private func updatePinStatus(_ model: MessageContentModel) {
self.pinLabel.isHidden = !model.isPined
self.pinImage.isHidden = !model.isPined
self.contentView.backgroundColor = model.isPined ? UIColor.ne_yellowBackgroundColor : .white
self.contentView.backgroundColor = model.isPined ? NEKitChatConfig.shared.ui.chatPinColor : .white
if model.isPined {
if let text = model.pinShowName {
self.pinLabel.text = text + localizable("pin_text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ChatBaseRightCell: ChatBaseCell {
super.init(style: style, reuseIdentifier: reuseIdentifier)
baseCommonUI()
addGesture()
initSubviewsLayout()
}

required init?(coder: NSCoder) {
Expand Down Expand Up @@ -77,7 +78,7 @@ class ChatBaseRightCell: ChatBaseCell {

// bubbleImage
self.bubbleImage.translatesAutoresizingMaskIntoConstraints = false
if let image = UIImage.ne_imageNamed(name: "chat_message_send") {
if let image = NEKitChatConfig.shared.ui.rightBubbleBg {
self.bubbleImage.image = image.resizableImage(withCapInsets: UIEdgeInsets.init(top: 35, left: 25, bottom: 10, right: 25))
}
self.bubbleImage.isUserInteractionEnabled = true
Expand Down Expand Up @@ -162,6 +163,14 @@ class ChatBaseRightCell: ChatBaseCell {

}

func initSubviewsLayout(){
if NEKitChatConfig.shared.ui.avatarType == .rectangle {
avatarImage.layer.cornerRadius = NEKitChatConfig.shared.ui.avatarCornerRadius
}else if NEKitChatConfig.shared.ui.avatarType == .cycle {
avatarImage.layer.cornerRadius = 16.0
}
}

// MARK: event
@objc func tapAvatar(tap: UITapGestureRecognizer) {
print(#function)
Expand Down Expand Up @@ -295,7 +304,7 @@ class ChatBaseRightCell: ChatBaseCell {
private func updatePinStatus(_ model: MessageContentModel) {
self.pinLabel.isHidden = !model.isPined
self.pinImage.isHidden = !model.isPined
self.contentView.backgroundColor = model.isPined ? UIColor.ne_yellowBackgroundColor : .white
self.contentView.backgroundColor = model.isPined ? NEKitChatConfig.shared.ui.chatPinColor : .white
if model.isPined {
if let text = model.pinShowName {
self.pinLabel.text = text + localizable("pin_text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ChatTimeTableViewCell: UITableViewCell {
private lazy var timeLable:UILabel = {
let label = UILabel()
label.font = DefaultTextFont(12)
label.textColor = UIColor.ne_emptyTitleColor
label.textColor = NEKitChatConfig.shared.ui.timeColor
label.textAlignment = .center
label.translatesAutoresizingMaskIntoConstraints = false
return label
Expand Down
Loading

0 comments on commit 289250a

Please sign in to comment.