From e1a1af00c83ff21f482d63e2593142c233ab65d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=AF=97=E6=96=87?= <zhangshiwen@corp.netease.com> Date: Thu, 6 Jun 2024 19:57:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Podfile=20=E7=AE=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Podfile | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/Podfile b/Podfile index 826d290d..6be3f861 100644 --- a/Podfile +++ b/Podfile @@ -6,31 +6,17 @@ target 'app' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! - #登录组件 + # 登录组件 pod 'YXLogin', '1.0.0' - # 不指定 NIM SDK 版本, 可不指定基础库版本 + # UI 库 pod 'NEChatUIKit', '10.1.0' pod 'NEContactUIKit', '10.1.0' pod 'NEConversationUIKit', '10.1.0' pod 'NETeamUIKit', '10.1.0' pod 'NEMapKit', '10.1.0' - # 指定 NIM SDK 版本, 建议指定基础库版本 - pod 'lottie-ios', '2.5.3' - pod 'NECoreKit', '9.6.9' - pod 'NECoreIM2Kit', '1.0.0' - pod 'NECommonKit', '9.6.8' - pod 'NECommonUIKit', '9.6.8' - pod 'NEChatKit/NOS_Special', '10.1.0' - - pod 'NEChatUIKit/NOS_Special', '10.1.0' - pod 'NEContactUIKit/NOS_Special', '10.1.0' - pod 'NEConversationUIKit/NOS_Special', '10.1.0' - pod 'NETeamUIKit/NOS_Special', '10.1.0' - pod 'NEMapKit/NOS_Special', '10.1.0' - - #呼叫组件,音视频通话能力,需要开通 音视频2.0,可选,聊天一面会根据依赖初始化自动显示音视频通话入口 + # 呼叫组件,音视频通话能力,需要开通 音视频2.0,可选,聊天一面会根据依赖初始化自动显示音视频通话入口 pod 'NIMSDK_LITE','10.2.6-beta' pod 'NERtcCallKit/NOS_Special', '2.4.0' pod 'NERtcCallUIKit/NOS_Special', '2.4.0' @@ -49,7 +35,7 @@ target 'app' do end -#⚠️如果pod依赖报错,可打开以下注释 +# ⚠️如果pod依赖报错,可打开以下注释 post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| From fa9635e68e40006a529376049d6d790972f71764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=AF=97=E6=96=87?= <zhangshiwen@corp.netease.com> Date: Thu, 6 Jun 2024 20:34:09 +0800 Subject: [PATCH 2/2] remove YXLogin --- Podfile | 3 - app.xcodeproj/project.pbxproj | 4 - app/Main/AppDelegate.swift | 1 - app/Mine/Controller/MeViewController.swift | 1 - .../MineSettingViewController.swift | 382 +++++++++--------- .../Controller/NELoginViewController.swift | 227 ----------- 6 files changed, 183 insertions(+), 435 deletions(-) delete mode 100644 app/Mine/Controller/NELoginViewController.swift diff --git a/Podfile b/Podfile index 6be3f861..08200ad0 100644 --- a/Podfile +++ b/Podfile @@ -6,9 +6,6 @@ target 'app' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks! - # 登录组件 - pod 'YXLogin', '1.0.0' - # UI 库 pod 'NEChatUIKit', '10.1.0' pod 'NEContactUIKit', '10.1.0' diff --git a/app.xcodeproj/project.pbxproj b/app.xcodeproj/project.pbxproj index 03ee1bf2..71f6b995 100644 --- a/app.xcodeproj/project.pbxproj +++ b/app.xcodeproj/project.pbxproj @@ -21,7 +21,6 @@ 181EE5EF2B234E540043817F /* MeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5D32B234E540043817F /* MeViewController.swift */; }; 181EE5F02B234E540043817F /* StyleSelectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5D42B234E540043817F /* StyleSelectionViewController.swift */; }; 181EE5F12B234E540043817F /* NEAboutWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5D52B234E540043817F /* NEAboutWebViewController.swift */; }; - 181EE5F22B234E540043817F /* NELoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5D62B234E540043817F /* NELoginViewController.swift */; }; 181EE5F32B234E540043817F /* InputPersonInfoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5D72B234E540043817F /* InputPersonInfoController.swift */; }; 181EE5F42B234E540043817F /* MineSettingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5D82B234E540043817F /* MineSettingViewController.swift */; }; 181EE5F52B234E540043817F /* MessageRemindViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 181EE5D92B234E540043817F /* MessageRemindViewController.swift */; }; @@ -89,7 +88,6 @@ 181EE5D32B234E540043817F /* MeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MeViewController.swift; sourceTree = "<group>"; }; 181EE5D42B234E540043817F /* StyleSelectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StyleSelectionViewController.swift; sourceTree = "<group>"; }; 181EE5D52B234E540043817F /* NEAboutWebViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NEAboutWebViewController.swift; sourceTree = "<group>"; }; - 181EE5D62B234E540043817F /* NELoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NELoginViewController.swift; sourceTree = "<group>"; }; 181EE5D72B234E540043817F /* InputPersonInfoController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InputPersonInfoController.swift; sourceTree = "<group>"; }; 181EE5D82B234E540043817F /* MineSettingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MineSettingViewController.swift; sourceTree = "<group>"; }; 181EE5D92B234E540043817F /* MessageRemindViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageRemindViewController.swift; sourceTree = "<group>"; }; @@ -181,7 +179,6 @@ 181EE5D32B234E540043817F /* MeViewController.swift */, 181EE5D42B234E540043817F /* StyleSelectionViewController.swift */, 181EE5D52B234E540043817F /* NEAboutWebViewController.swift */, - 181EE5D62B234E540043817F /* NELoginViewController.swift */, 181EE5D72B234E540043817F /* InputPersonInfoController.swift */, 181EE5D82B234E540043817F /* MineSettingViewController.swift */, 181EE5D92B234E540043817F /* MessageRemindViewController.swift */, @@ -434,7 +431,6 @@ 181EE58E2B234C510043817F /* CustomChatCell.swift in Sources */, 181EE5F02B234E540043817F /* StyleSelectionViewController.swift in Sources */, 181EE5F42B234E540043817F /* MineSettingViewController.swift in Sources */, - 181EE5F22B234E540043817F /* NELoginViewController.swift in Sources */, DD141DFD2A56ABFE0091318F /* ViewController.swift in Sources */, DD141DFF2A56ABFE0091318F /* NENavigationController.swift in Sources */, 181EE5FF2B234E540043817F /* CustomTeamArrowSettingCell.swift in Sources */, diff --git a/app/Main/AppDelegate.swift b/app/Main/AppDelegate.swift index d80ff9df..f6dcfbf1 100644 --- a/app/Main/AppDelegate.swift +++ b/app/Main/AppDelegate.swift @@ -5,7 +5,6 @@ import UIKit import NEContactUIKit -import YXLogin import NECoreKit import NIMSDK import NECoreIM2Kit diff --git a/app/Mine/Controller/MeViewController.swift b/app/Mine/Controller/MeViewController.swift index 93c87ec6..3e878577 100644 --- a/app/Mine/Controller/MeViewController.swift +++ b/app/Mine/Controller/MeViewController.swift @@ -10,7 +10,6 @@ import NECoreIM2Kit import NECoreKit import NIMSDK import UIKit -import YXLogin class MeViewController: UIViewController, UIGestureRecognizerDelegate { private var mineData = [ diff --git a/app/Mine/Controller/MineSettingViewController.swift b/app/Mine/Controller/MineSettingViewController.swift index f897d50a..cb31f39e 100644 --- a/app/Mine/Controller/MineSettingViewController.swift +++ b/app/Mine/Controller/MineSettingViewController.swift @@ -8,222 +8,206 @@ import NECoreKit import NETeamUIKit import NIMSDK import UIKit -import YXLogin class MineSettingViewController: NEBaseViewController, UITableViewDataSource, UITableViewDelegate { - private var viewModel = MineSettingViewModel() - public var cellClassDic = [ - SettingCellType.SettingArrowCell.rawValue: CustomTeamArrowSettingCell.self, - SettingCellType.SettingSwitchCell.rawValue: CustomTeamSettingSwitchCell.self, - ] - private var tag = "MineSettingViewController" - private let userDefault = UserDefaults.standard - - /// 设置列表 - lazy var tableView: UITableView = { - let tableView = UITableView() - tableView.translatesAutoresizingMaskIntoConstraints = false - tableView.backgroundColor = .clear - tableView.dataSource = self - tableView.delegate = self - tableView.separatorColor = .clear - tableView.separatorStyle = .none - tableView.tableFooterView = getFooterView() - if #available(iOS 15.0, *) { - tableView.sectionHeaderTopPadding = 0.0 - } - return tableView - }() - - /// 退出登录按钮 - let logoutButton = UIButton() - - override func viewDidLoad() { - super.viewDidLoad() - viewModel.delegate = self - viewModel.getData() - setupSubviews() - initialConfig() - } - - func initialConfig() { - title = NSLocalizedString("setting", comment: "") - - if NEStyleManager.instance.isNormalStyle() { - view.backgroundColor = .ne_backgroundColor - navigationView.backgroundColor = .ne_backgroundColor - navigationController?.navigationBar.backgroundColor = .ne_backgroundColor - } else { - view.backgroundColor = .funChatBackgroundColor - } - } - - func setupSubviews() { - view.addSubview(tableView) - if NEStyleManager.instance.isNormalStyle() { - topConstant += 12 - } - NSLayoutConstraint.activate([ - tableView.leftAnchor.constraint(equalTo: view.leftAnchor), - tableView.rightAnchor.constraint(equalTo: view.rightAnchor), - tableView.topAnchor.constraint(equalTo: view.topAnchor, constant: topConstant), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) - - for (key, value) in cellClassDic { - tableView.register(value, forCellReuseIdentifier: "\(key)") + private var viewModel = MineSettingViewModel() + public var cellClassDic = [ + SettingCellType.SettingArrowCell.rawValue: CustomTeamArrowSettingCell.self, + SettingCellType.SettingSwitchCell.rawValue: CustomTeamSettingSwitchCell.self, + ] + private var tag = "MineSettingViewController" + private let userDefault = UserDefaults.standard + + /// 设置列表 + lazy var tableView: UITableView = { + let tableView = UITableView() + tableView.translatesAutoresizingMaskIntoConstraints = false + tableView.backgroundColor = .clear + tableView.dataSource = self + tableView.delegate = self + tableView.separatorColor = .clear + tableView.separatorStyle = .none + tableView.tableFooterView = getFooterView() + if #available(iOS 15.0, *) { + tableView.sectionHeaderTopPadding = 0.0 + } + return tableView + }() + + /// 退出登录按钮 + let logoutButton = UIButton() + + override func viewDidLoad() { + super.viewDidLoad() + viewModel.delegate = self + viewModel.getData() + setupSubviews() + initialConfig() } - } - - func getFooterView() -> UIView? { - let footerView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 64.0)) - footerView.addSubview(logoutButton) - logoutButton.backgroundColor = .white - logoutButton.clipsToBounds = true - logoutButton.setTitleColor(UIColor(hexString: "0xE6605C"), for: .normal) - logoutButton.titleLabel?.font = UIFont.systemFont(ofSize: 16) - logoutButton.setTitle(title, for: .normal) - logoutButton.addTarget(self, action: #selector(loginOutAction), for: .touchUpInside) - logoutButton.setTitle(NSLocalizedString("logout", comment: ""), for: .normal) - logoutButton.accessibilityIdentifier = "id.logout" - if NEStyleManager.instance.isNormalStyle() { - logoutButton.layer.cornerRadius = 8.0 - logoutButton.frame = CGRect(x: 20, y: 12, width: view.frame.size.width - 40, height: 40) - } else { - logoutButton.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([ - logoutButton.leftAnchor.constraint(equalTo: footerView.leftAnchor, constant: 0), - logoutButton.rightAnchor.constraint(equalTo: footerView.rightAnchor, constant: 0), - logoutButton.topAnchor.constraint(equalTo: footerView.topAnchor, constant: 12), - logoutButton.heightAnchor.constraint(equalToConstant: 40), - ]) + + func initialConfig() { + title = NSLocalizedString("setting", comment: "") + + if NEStyleManager.instance.isNormalStyle() { + view.backgroundColor = .ne_backgroundColor + navigationView.backgroundColor = .ne_backgroundColor + navigationController?.navigationBar.backgroundColor = .ne_backgroundColor + } else { + view.backgroundColor = .funChatBackgroundColor + } } - - return footerView - } - - @objc func loginOutAction() { - weak var weakSelf = self - AuthorManager.shareInstance()? - .logout( - withConfirm: NSLocalizedString("want_to_logout", comment: ""), - withCompletion: { [weak self] user, error in - if error != nil { - NEALog.infoLog(self?.className() ?? "", desc: "logout author manager error : \(error?.localizedDescription ?? "")") - self?.view.makeToast(error?.localizedDescription) - NEALog.errorLog( - self?.tag ?? "", - desc: "CALLBACK logout failed,error = \(error!)" - ) - } else { - weakSelf?.logoutButton.isEnabled = false - IMKitClient.instance.logoutIM { error in - weakSelf?.logoutButton.isEnabled = true - if error != nil { - NEALog.infoLog(self?.className() ?? "", desc: "logout im error : \(error?.localizedDescription ?? "")") - self?.view.makeToast(error?.localizedDescription) + + func setupSubviews() { + view.addSubview(tableView) + if NEStyleManager.instance.isNormalStyle() { + topConstant += 12 + } + NSLayoutConstraint.activate([ + tableView.leftAnchor.constraint(equalTo: view.leftAnchor), + tableView.rightAnchor.constraint(equalTo: view.rightAnchor), + tableView.topAnchor.constraint(equalTo: view.topAnchor, constant: topConstant), + tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), + ]) + + for (key, value) in cellClassDic { + tableView.register(value, forCellReuseIdentifier: "\(key)") + } + } + + func getFooterView() -> UIView? { + let footerView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: 64.0)) + footerView.addSubview(logoutButton) + logoutButton.backgroundColor = .white + logoutButton.clipsToBounds = true + logoutButton.setTitleColor(UIColor(hexString: "0xE6605C"), for: .normal) + logoutButton.titleLabel?.font = UIFont.systemFont(ofSize: 16) + logoutButton.setTitle(title, for: .normal) + logoutButton.addTarget(self, action: #selector(loginOutAction), for: .touchUpInside) + logoutButton.setTitle(NSLocalizedString("logout", comment: ""), for: .normal) + logoutButton.accessibilityIdentifier = "id.logout" + if NEStyleManager.instance.isNormalStyle() { + logoutButton.layer.cornerRadius = 8.0 + logoutButton.frame = CGRect(x: 20, y: 12, width: view.frame.size.width - 40, height: 40) + } else { + logoutButton.translatesAutoresizingMaskIntoConstraints = false + NSLayoutConstraint.activate([ + logoutButton.leftAnchor.constraint(equalTo: footerView.leftAnchor, constant: 0), + logoutButton.rightAnchor.constraint(equalTo: footerView.rightAnchor, constant: 0), + logoutButton.topAnchor.constraint(equalTo: footerView.topAnchor, constant: 12), + logoutButton.heightAnchor.constraint(equalToConstant: 40), + ]) + } + + return footerView + } + + @objc func loginOutAction() { + weak var weakSelf = self + logoutButton.isEnabled = false + IMKitClient.instance.logoutIM { error in + weakSelf?.logoutButton.isEnabled = true + if error != nil { + NEALog.infoLog(weakSelf?.className() ?? "", desc: "logout im error : \(error?.localizedDescription ?? "")") + weakSelf?.view.makeToast(error?.localizedDescription) NEALog.errorLog( - self?.tag ?? "", - desc: "CALLBACK logout SUCCESS = \(error!)" + weakSelf?.tag ?? "", + desc: "CALLBACK logout SUCCESS = \(error!)" ) - } else { - NEALog.infoLog(self?.className() ?? "", desc: "logout im success ") + } else { + NEALog.infoLog(weakSelf?.className() ?? "", desc: "logout im success ") NotificationCenter.default.post( - name: Notification.Name("logout"), - object: nil + name: Notification.Name("logout"), + object: nil ) NEALog.infoLog( - self?.tag ?? "", - desc: "CALLBACK logout SUCCESS" + weakSelf?.tag ?? "", + desc: "CALLBACK logout SUCCESS" ) NEFriendUserCache.shared.removeAllFriendInfo() - } } - } } - ) - } - - // 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 - } - - 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? NEBaseTeamSettingCell { - 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() + + // 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 } - } - - 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 section == 0 { - return 0 - } - if viewModel.sectionData.count > section { - let model = viewModel.sectionData[section] - if model.cellModels.count > 0 { - return 12.0 - } - } - return 0 - } - - func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { - let headerView = UIView() - headerView.backgroundColor = .clear - return headerView - } - - func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { - if section == viewModel.sectionData.count - 1 { - return 12.0 + + 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? NEBaseTeamSettingCell { + 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, 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 section == 0 { + return 0 + } + if viewModel.sectionData.count > section { + let model = viewModel.sectionData[section] + if model.cellModels.count > 0 { + return 12.0 + } + } + return 0 + } + + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { + let headerView = UIView() + headerView.backgroundColor = .clear + return headerView + } + + func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { + if section == viewModel.sectionData.count - 1 { + return 12.0 + } + return 0 } - return 0 - } } extension MineSettingViewController: MineSettingViewModelDelegate { - func didMessageRemindClick() { - let messageRemindCtrl = MessageRemindViewController() - navigationController?.pushViewController(messageRemindCtrl, animated: true) - } - - func didStyleClick() { - let styleSelectionCtrl = StyleSelectionViewController() - navigationController?.pushViewController(styleSelectionCtrl, animated: true) - } - - func didClickCleanCache() {} - - func didClickConfigTest() { - let configTestVC = ConfigTestViewController() - navigationController?.pushViewController(configTestVC, animated: true) - } + func didMessageRemindClick() { + let messageRemindCtrl = MessageRemindViewController() + navigationController?.pushViewController(messageRemindCtrl, animated: true) + } + + func didStyleClick() { + let styleSelectionCtrl = StyleSelectionViewController() + navigationController?.pushViewController(styleSelectionCtrl, animated: true) + } + + func didClickCleanCache() {} + + func didClickConfigTest() { + let configTestVC = ConfigTestViewController() + navigationController?.pushViewController(configTestVC, animated: true) + } } diff --git a/app/Mine/Controller/NELoginViewController.swift b/app/Mine/Controller/NELoginViewController.swift deleted file mode 100644 index 81e0a43c..00000000 --- a/app/Mine/Controller/NELoginViewController.swift +++ /dev/null @@ -1,227 +0,0 @@ - -// 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 NEChatUIKit -import NECommonKit -import NECoreIM2Kit -import NIMSDK -import UIKit -import YXLogin - -public class NELoginViewController: UIViewController { - // 登录成功 - public typealias LoginBlock = () -> Void - - public var successLogin: LoginBlock? - - lazy var launchIconView: UIImageView = { - let imageView = UIImageView() - imageView.translatesAutoresizingMaskIntoConstraints = false - imageView.image = UIImage(named: "launchIcon") - return imageView - }() - - 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") - label.accessibilityIdentifier = "id.appYunxin" - return label - }() - - lazy var loginButton: UIButton = { - let button = UIButton() - button.translatesAutoresizingMaskIntoConstraints = false - button.layer.cornerRadius = 8 - button.backgroundColor = UIColor.ne_normalTheme - button.setTitleColor(UIColor.white, for: .normal) - button.titleLabel?.font = UIFont.systemFont(ofSize: 15.0) - button.setTitle(NSLocalizedString("register_login", comment: ""), for: .normal) - button.addTarget(self, action: #selector(loginBtnClick), for: .touchUpInside) - button.accessibilityIdentifier = "id.loginButton" - return button - }() - - lazy var emailLoginButton: UIButton = { - let button = UIButton() - button.translatesAutoresizingMaskIntoConstraints = false - button.setTitleColor(UIColor.ne_lightText, for: .normal) - button.titleLabel?.font = UIFont.systemFont(ofSize: 12.0) - button.setTitle(NSLocalizedString("email_login", comment: ""), for: .normal) - button.addTarget(self, action: #selector(emailLoginBtnClick), for: .touchUpInside) - button.accessibilityIdentifier = "id.emailLogin" - return button - }() - - lazy var dividerLineView: UIView = { - let view = UIView() - view.translatesAutoresizingMaskIntoConstraints = false - view.backgroundColor = UIColor.ne_lightText - return view - }() - - /// 节点按钮 - lazy var nodeButton: UIButton = { - let button = UIButton() - button.translatesAutoresizingMaskIntoConstraints = false - button.setTitleColor(UIColor.ne_lightText, for: .normal) - button.titleLabel?.font = UIFont.systemFont(ofSize: 12.0) - button.setTitle(NSLocalizedString("node_select", comment: ""), for: .normal) - button.addTarget(self, action: #selector(nodeBtnClick), for: .touchUpInside) - button.accessibilityIdentifier = "id.serverConfig" - return button - }() - - override public func viewDidLoad() { - super.viewDidLoad() - setupUI() - } - - override public func viewWillAppear(_ animated: Bool) { - navigationController?.navigationBar.isHidden = true - } - - override public func viewWillDisappear(_ animated: Bool) { - navigationController?.navigationBar.isHidden = false - } - - func setupUI() { - view.addSubview(launchIconView) - view.addSubview(launchIconLabel) - view.addSubview(loginButton) - view.addSubview(emailLoginButton) - view.addSubview(dividerLineView) - view.addSubview(nodeButton) - - if #available(iOS 11.0, *) { - NSLayoutConstraint.activate([ - launchIconView.centerXAnchor.constraint(equalTo: view.centerXAnchor), - launchIconView.topAnchor.constraint( - equalTo: view.safeAreaLayoutGuide.topAnchor, - constant: 145.0 - ), - ]) - } else { - NSLayoutConstraint.activate([ - launchIconView.centerXAnchor.constraint(equalTo: view.centerXAnchor), - launchIconView.topAnchor.constraint(equalTo: view.topAnchor, constant: 145.0), - ]) - } - NSLayoutConstraint.activate([ - launchIconLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor), - launchIconLabel.topAnchor.constraint(equalTo: launchIconView.bottomAnchor, constant: -12.0), - ]) - - NSLayoutConstraint.activate([ - loginButton.centerXAnchor.constraint(equalTo: view.centerXAnchor), - loginButton.topAnchor.constraint(equalTo: launchIconLabel.bottomAnchor, constant: 20), - loginButton.widthAnchor.constraint(equalToConstant: NEConstant.screenWidth - 80), - loginButton.heightAnchor.constraint(equalToConstant: 44), - ]) - - NSLayoutConstraint.activate([ - dividerLineView.bottomAnchor.constraint( - equalTo: view.bottomAnchor, - constant: -10 - NEConstant.statusBarHeight - ), - dividerLineView.centerXAnchor.constraint(equalTo: view.centerXAnchor), - dividerLineView.widthAnchor.constraint(equalToConstant: 1), - dividerLineView.heightAnchor.constraint(equalToConstant: 10), - ]) - - NSLayoutConstraint.activate([ - emailLoginButton.centerYAnchor.constraint(equalTo: dividerLineView.centerYAnchor), - emailLoginButton.rightAnchor.constraint(equalTo: dividerLineView.leftAnchor, constant: -8), - ]) - - NSLayoutConstraint.activate([ - nodeButton.centerYAnchor.constraint(equalTo: dividerLineView.centerYAnchor), - nodeButton.leftAnchor.constraint(equalTo: dividerLineView.rightAnchor, constant: 8), - ]) - } - - @objc func loginBtnClick(sender: UIButton) { - // login to business server - let config = YXConfig() - config.appKey = AppKey.appKey - config.parentScope = NSNumber(integerLiteral: 2) - config.scope = NSNumber(integerLiteral: 7) - config.supportInternationalize = true - config.type = .phone - #if DEBUG - config.isOnline = false - print("debug") - #else - config.isOnline = true - print("release") - #endif - AuthorManager.shareInstance()?.initAuthor(with: config) - - weak var weakSelf = self - AuthorManager.shareInstance()?.startLogin(completion: { user, error in - if let err = error { - print("login error : ", err) - } else { - weakSelf?.setupSuccessLogic(user) - } - }) - } - - @objc func emailLoginBtnClick(sender: UIButton) { - // login to business server - let config = YXConfig() - config.appKey = AppKey.appKey - config.parentScope = NSNumber(integerLiteral: 2) - config.scope = NSNumber(integerLiteral: 7) - config.supportInternationalize = false - config.type = .email - #if DEBUG - config.isOnline = false - print("debug") - #else - config.isOnline = true - print("release") - #endif - AuthorManager.shareInstance()?.initAuthor(with: config) - - weak var weakSelf = self - AuthorManager.shareInstance()?.startLogin(completion: { user, error in - if let err = error { - print("login error : ", err) - } else { - weakSelf?.setupSuccessLogic(user) - } - }) - } - - @objc func nodeBtnClick(sender: UIButton) { - let ctrl = NENodeViewController() - navigationController?.pushViewController(ctrl, animated: true) - } - - private func setupSuccessLogic(_ user: YXUserInfo?) { - if let token = user?.imToken, let account = user?.imAccid { - weak var weakSelf = self - print("login accid : ", account) - print("login token : ", token) - - let option = V2NIMLoginOption() - IMKitClient.instance.login(account, token, option) { error in - if let err = error { - NEALog.infoLog(weakSelf?.className() ?? "", desc: "login IM error : \(err.localizedDescription)") - UIApplication.shared.keyWindow?.makeToast(err.localizedDescription) - } else { - NEALog.infoLog(weakSelf?.className() ?? "", desc: "login IM Success") - ChatRouter.setupInit() - if let block = weakSelf?.successLogin { - block() - } - } - } - } - } -}