Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DemoUI调整 #420

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update NEConversationUIKit (#419)
* add sample code
zsw666 authored Dec 27, 2024
commit 956ee53405287f0c21994ed6605f0366e305b493
Original file line number Diff line number Diff line change
@@ -37,8 +37,6 @@

"you_were_mentioned"="[You were mentioned]";

"security_warning"="For test only. Beware of money transfer, lottery winnings & strange call scams.";

// error toast
"leave_team_desc"="You have been removed from the group chat or the group chat has been dissolved.";

Original file line number Diff line number Diff line change
@@ -36,9 +36,6 @@

"you_were_mentioned"="[有人@我]";

"security_warning"="仅用于体验云信IM 产品功能,请勿轻信汇款、中奖等涉及钱款的信息,勿轻易拨打陌生电话,谨防上当受骗。";


// error toast

"leave_team_desc"="您已被移出群聊或该群聊已被解散";
Original file line number Diff line number Diff line change
@@ -12,8 +12,3 @@ func localizable(_ key: String) -> String {
}

public let ModuleName = "NEConversationUIKit"

extension UIColor {
static let securityWarningBg = UIColor(hexString: "#FFF5E1")
static let securityWarningTextColor = UIColor(hexString: "#EB9718")
}
Original file line number Diff line number Diff line change
@@ -96,19 +96,11 @@ open class NEBaseConversationController: UIViewController, UIGestureRecognizerDe
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .clear

view.addSubview(securityWarningView)
view.addSubview(brokenNetworkView)
view.addSubview(contentView)

NSLayoutConstraint.activate([
securityWarningView.topAnchor.constraint(equalTo: view.topAnchor),
securityWarningView.leftAnchor.constraint(equalTo: view.leftAnchor),
securityWarningView.rightAnchor.constraint(equalTo: view.rightAnchor),
securityWarningView.heightAnchor.constraint(equalToConstant: 56),
])

NSLayoutConstraint.activate([
brokenNetworkView.topAnchor.constraint(equalTo: securityWarningView.bottomAnchor),
brokenNetworkView.topAnchor.constraint(equalTo: view.topAnchor),
brokenNetworkView.leftAnchor.constraint(equalTo: view.leftAnchor),
brokenNetworkView.rightAnchor.constraint(equalTo: view.rightAnchor),
brokenNetworkView.heightAnchor.constraint(equalToConstant: brokenNetworkViewHeight),
@@ -132,12 +124,6 @@ open class NEBaseConversationController: UIViewController, UIGestureRecognizerDe
return view
}()

public lazy var securityWarningView: NESecurityWarningView = {
let view = NESecurityWarningView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()

public lazy var contentView: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
@@ -246,10 +232,10 @@ open class NEBaseConversationController: UIViewController, UIGestureRecognizerDe
NEChatDetectNetworkTool.shareInstance.netWorkReachability { [weak self] status in
if status == .notReachable {
self?.brokenNetworkView.isHidden = false
self?.contentViewTopAnchor?.constant = (self?.brokenNetworkViewHeight ?? 36) + 56
self?.contentViewTopAnchor?.constant = (self?.brokenNetworkViewHeight ?? 36)
} else {
self?.brokenNetworkView.isHidden = true
self?.contentViewTopAnchor?.constant = 56
self?.contentViewTopAnchor?.constant = 0
}
}

Original file line number Diff line number Diff line change
@@ -63,7 +63,6 @@ open class FunConversationController: NEBaseConversationController {
popListView = FunPopListView()
searchView.searchButton.setTitle(commonLocalizable("search"), for: .normal)
brokenNetworkView.contentLabel.text = commonLocalizable("network_error")
securityWarningView.warningLabel.text = localizable("security_warning")
}

override func initSystemNav() {
Original file line number Diff line number Diff line change
@@ -67,7 +67,6 @@ open class ConversationController: NEBaseConversationController {
initSystemNav()
popListView = PopListView()
brokenNetworkView.contentLabel.text = commonLocalizable("network_error")
securityWarningView.warningLabel.text = localizable("security_warning")
}

override func initSystemNav() {
4 changes: 4 additions & 0 deletions app.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@
181EE58D2B234C510043817F /* CustomContactTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5842B234C510043817F /* CustomContactTableViewCell.swift */; };
181EE58E2B234C510043817F /* CustomChatCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5852B234C510043817F /* CustomChatCell.swift */; };
181EE58F2B234C510043817F /* CustomConversationListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5862B234C510043817F /* CustomConversationListCell.swift */; };
18A6A9842D1E822900209FC5 /* NESecurityWarningView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18A6A9832D1E822900209FC5 /* NESecurityWarningView.swift */; };
18B05B342BD5FD0300666AD1 /* CustomFunChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18B05B322BD5FD0300666AD1 /* CustomFunChatViewController.swift */; };
18B05B352BD5FD0300666AD1 /* CustomNormalChatViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18B05B332BD5FD0300666AD1 /* CustomNormalChatViewController.swift */; };
18CF8A3B2D01B312000CF406 /* CustomContactViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18CF8A392D01B312000CF406 /* CustomContactViewController.swift */; };
@@ -125,6 +126,7 @@
181EE5842B234C510043817F /* CustomContactTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomContactTableViewCell.swift; sourceTree = "<group>"; };
181EE5852B234C510043817F /* CustomChatCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomChatCell.swift; sourceTree = "<group>"; };
181EE5862B234C510043817F /* CustomConversationListCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomConversationListCell.swift; sourceTree = "<group>"; };
18A6A9832D1E822900209FC5 /* NESecurityWarningView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NESecurityWarningView.swift; sourceTree = "<group>"; };
18B05B322BD5FD0300666AD1 /* CustomFunChatViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomFunChatViewController.swift; sourceTree = "<group>"; };
18B05B332BD5FD0300666AD1 /* CustomNormalChatViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomNormalChatViewController.swift; sourceTree = "<group>"; };
18CF8A382D01B312000CF406 /* CustomConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomConfig.swift; sourceTree = "<group>"; };
@@ -244,6 +246,7 @@
181EE57D2B234C510043817F /* Custom */ = {
isa = PBXGroup;
children = (
18A6A9832D1E822900209FC5 /* NESecurityWarningView.swift */,
18CF8A382D01B312000CF406 /* CustomConfig.swift */,
18CF8A392D01B312000CF406 /* CustomContactViewController.swift */,
18B05B322BD5FD0300666AD1 /* CustomFunChatViewController.swift */,
@@ -470,6 +473,7 @@
buildActionMask = 2147483647;
files = (
181EE58D2B234C510043817F /* CustomContactTableViewCell.swift in Sources */,
18A6A9842D1E822900209FC5 /* NESecurityWarningView.swift in Sources */,
181EE5872B234C510043817F /* CustomView.swift in Sources */,
181EE58F2B234C510043817F /* CustomConversationListCell.swift in Sources */,
181EE5882B234C510043817F /* CustomP2PChatViewController.swift in Sources */,
26 changes: 26 additions & 0 deletions app/Custom/CustomConfig.swift
Original file line number Diff line number Diff line change
@@ -352,6 +352,26 @@ public class CustomConfig {
}
}

/// 通过布局自定义实现顶部警告
open func loadSecurityWarningView() {
ConversationUIConfig.shared.customController = { [weak self] viewController in
guard let self = self else {
return
}

// 顶部bodyTopView中添加自定义view(需要设置bodyTopView的高度)
self.securityWarningView.warningLabel.text = localizable("security_warning")
viewController.bodyTopView.addSubview(self.securityWarningView)
NSLayoutConstraint.activate([
self.securityWarningView.topAnchor.constraint(equalTo: viewController.bodyTopView.topAnchor),
self.securityWarningView.leftAnchor.constraint(equalTo: viewController.bodyTopView.leftAnchor),
self.securityWarningView.rightAnchor.constraint(equalTo: viewController.bodyTopView.rightAnchor),
self.securityWarningView.heightAnchor.constraint(equalToConstant: 56),
])
viewController.bodyTopViewHeight = 56
}
}

@objc func customClick(_ button: UIButton) {
button.neViewContainingController()?.showToast("文本输入框下方 tab 按钮自定义点击事件")
}
@@ -369,4 +389,10 @@ public class CustomConfig {
view.backgroundColor = .green
return view
}()

public lazy var securityWarningView: NESecurityWarningView = {
let view = NESecurityWarningView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
}
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
// found in the LICENSE file.

import Foundation
import UIKit

open class NESecurityWarningView: UIView {
override public init(frame: CGRect) {
@@ -27,7 +28,7 @@ open class NESecurityWarningView: UIView {
public lazy var backView: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = .securityWarningBg
view.backgroundColor = UIColor(hexString: "#FFF5E1")

view.addSubview(warningLabel)
NSLayoutConstraint.activate([
@@ -42,7 +43,7 @@ open class NESecurityWarningView: UIView {
public lazy var warningLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.textColor = .securityWarningTextColor
label.textColor = UIColor(hexString: "#EB9718")
label.font = .systemFont(ofSize: 14)
label.text = localizable("security_warning")
label.textAlignment = .justified
7 changes: 6 additions & 1 deletion app/Main/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -103,15 +103,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
self.window?.rootViewController = tab
}

// regist router
// regist router
func loadService() {
// 注册路由
ChatKitClient.shared.setupInit(isFun: !NEStyleManager.instance.isNormalStyle())
if NEStyleManager.instance.isNormalStyle() == false {
registerFunCustom()
}else {
registerNormalCustom()
}

// 会话列表顶部插入警告内容
CustomConfig.shared.loadSecurityWarningView()

// 注册【个人信息】页面
Router.shared.register(MeSettingRouter) { param in
if let nav = param["nav"] as? UINavigationController {
let me = PersonInfoViewController()
1 change: 1 addition & 0 deletions app/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -72,3 +72,4 @@

"privatized_configuration"="Privatized configuration";
"login_by_account"="login";
"security_warning"="For test only. Beware of money transfer, lottery winnings & strange call scams.";
1 change: 1 addition & 0 deletions app/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -71,3 +71,4 @@
"anti_error"="存在不安全内容,请重新输入。";
"privatized_configuration"="私有化配置";
"login_by_account"="账号登录";
"security_warning"="仅用于体验云信IM 产品功能,请勿轻信汇款、中奖等涉及钱款的信息,勿轻易拨打陌生电话,谨防上当受骗。";