Skip to content

Commit

Permalink
【iOS】update version to 1.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Tangjianing123 authored and AbySwifter committed Dec 16, 2023
1 parent 8bd50ee commit b3cc72a
Show file tree
Hide file tree
Showing 52 changed files with 859 additions and 797 deletions.
4 changes: 4 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 发布日志

### Version 1.7.0 @ 2023.12.15
- iOS & Android: 优化界面,修改UI问题;
- iOS & Android: 修改roomId生成逻辑;

### Version 1.6.1 @ 2023.11.10
- Android & iOS:优化产品体验,进一步美化横屏UI;
- Android & iOS:优化产品体验,解决演讲者模式小画面切换抖动,设置小画面切换间隔为5秒;
Expand Down
4 changes: 2 additions & 2 deletions iOS/Example/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return
}
let prePareViewController = RoomPrePareViewController()
let nav = UINavigationController(rootViewController: prePareViewController)
let nav = RoomNavigationController(rootViewController: prePareViewController)
nav.modalPresentationStyle = .fullScreen
getCurrentWindowViewController()?.present(nav, animated: true)
}

func showLoginViewController() {
let loginVC = TRTCLoginViewController()
let nav = UINavigationController(rootViewController: loginVC)
let nav = RoomNavigationController(rootViewController: loginVC)
if let keyWindow = SceneDelegate.getCurrentWindow() {
keyWindow.rootViewController = nav
keyWindow.makeKeyAndVisible()
Expand Down

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion iOS/Example/App/Main/View/Component/ListCellItemView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ class ListCellItemView: UIView {
let color = UIColor(0xBBBBBB)
textField.attributedPlaceholder = NSAttributedString(string: item.fieldPlaceholderText,attributes:
[NSAttributedString.Key.foregroundColor:color])
textField.becomeFirstResponder()
} else {
textField.text = item.fieldText
}
Expand Down
30 changes: 30 additions & 0 deletions iOS/Example/App/Main/View/Component/RoomNavigationController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// RoomNavigationController.swift
// DemoApp
//
// Created by 唐佳宁 on 2023/12/11.
//

import Foundation
import UIKit

class RoomNavigationController: UINavigationController {
override init(rootViewController: UIViewController) {
super.init(rootViewController: rootViewController)
interactivePopGestureRecognizer?.isEnabled = false
}

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

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
guard let supportedInterfaceOrientations = topViewController?.supportedInterfaceOrientations as? UIInterfaceOrientationMask
else { return .portrait }
return supportedInterfaceOrientations
}
override var shouldAutorotate: Bool {
guard let shouldAutorotate = topViewController?.shouldAutorotate else { return false }
return shouldAutorotate
}
}
66 changes: 44 additions & 22 deletions iOS/Example/App/Main/View/Controller/CreateRoomViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ class CreateRoomViewController: UIViewController {
private var enableLocalVideo: Bool = true
private var isSoundOnSpeaker: Bool = true
let roomHashNumber: Int = 0x3B9AC9FF
lazy var roomId: String = {
let userId = currentUserId
let result = "\(String(describing: userId))_room_kit".hash & roomHashNumber
return String(result)
}()
var roomId: String?

let backButton: UIButton = {
let button = UIButton(type: .custom)
Expand Down Expand Up @@ -68,16 +64,8 @@ class CreateRoomViewController: UIViewController {
navigationController?.setNavigationBarHidden(false, animated: false)
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backButton)
UIApplication.shared.isIdleTimerDisabled = false
UIDevice.current.setValue(UIDeviceOrientation.portrait.rawValue, forKey: "orientation")
renewRootViewState()
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
appDelegate.orientation = .portrait
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
appDelegate.orientation = .allButUpsideDown
setupRoomId()
}

@objc
Expand All @@ -96,17 +84,13 @@ extension CreateRoomViewController {
roomTypeItem.titleText = .roomTypeText
roomTypeItem.messageText = .freedomSpeakText
roomTypeItem.hasOverAllAction = true
roomTypeItem.hasButton = true
roomTypeItem.action = { [weak self] sender in
guard let self = self else { return }
self.switchRoomTypeClick()
}
inputViewItems.append(roomTypeItem)

let createRoomIdItem = ListCellItemData()
createRoomIdItem.titleText = .roomNumText
createRoomIdItem.messageText = roomId
inputViewItems.append(createRoomIdItem)

let userNameItem = ListCellItemData()
userNameItem.titleText = .userNameText
userNameItem.messageText = currentUserName
Expand Down Expand Up @@ -148,6 +132,11 @@ extension CreateRoomViewController {
func enterButtonClick(sender: UIButton) {
rootView?.updateEnterButtonState(isEnabled: false)
rootView?.updateLoadingState(isStarted: true)
guard let roomId = self.roomId else {
self.view.makeToast(.generatingRoomIdText)
self.renewRootViewState()
return
}
roomInfo.roomId = roomId
roomInfo.name = currentUserName.truncateUtf8String(maxByteLength: 30)
roomInfo.speechMode = roomSpeechMode
Expand Down Expand Up @@ -213,6 +202,39 @@ extension CreateRoomViewController {
view.freedomButton.isSelected = false
chooseSpeechMode = .applySpeakAfterTakingSeat
}

private func setupRoomId() {
let roomId = getRandomRoomId(numberOfDigits: 6)
checkIfRoomIdExists(roomId: roomId) { [weak self] in
guard let self = self else { return }
self.setupRoomId()
} onNotExist: { [weak self] in
guard let self = self else { return }
self.roomId = roomId
}
}

//获取随机数roomId,numberOfDigits为位数
private func getRandomRoomId(numberOfDigits: Int) -> String {
var numberOfDigit = numberOfDigits > 0 ? numberOfDigits : 1
numberOfDigit = numberOfDigit < 10 ? numberOfDigit : 9
let minNumber = Int(truncating: NSDecimalNumber(decimal: pow(10, numberOfDigit - 1)))
let maxNumber = Int(truncating: NSDecimalNumber(decimal: pow(10, numberOfDigit))) - 1
let randomNumber = arc4random_uniform(UInt32(maxNumber - minNumber)) + UInt32(minNumber)
return String(randomNumber)
}

private func checkIfRoomIdExists(roomId: String, onExist: @escaping () -> (), onNotExist: @escaping () -> ()) {
V2TIMManager.sharedInstance().getGroupsInfo([roomId]) { infoResult in
if infoResult?.first?.resultCode == 0 {
onExist()
} else {
onNotExist()
}
} fail: { code, message in
onNotExist()
}
}
}

private extension String {
Expand All @@ -222,9 +244,6 @@ private extension String {
static var roomTypeText: String {
RoomDemoLocalize("Demo.TUIRoomKit.room.type")
}
static var roomNumText: String {
RoomDemoLocalize("Demo.TUIRoomKit.room.num")
}
static var openCameraText: String {
RoomDemoLocalize("Demo.TUIRoomKit.open.video")
}
Expand All @@ -243,6 +262,9 @@ private extension String {
static var videoConferenceText: String {
RoomDemoLocalize("Demo.TUIRoomKit.video.conference")
}
static var generatingRoomIdText: String {
RoomDemoLocalize("Demo.TUIRoomKit.generating.roomId")
}
func truncateUtf8String(maxByteLength: Int) -> String {
let length = self.utf8.count
if length <= maxByteLength {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,7 @@ class EnterRoomViewController: UIViewController {
navigationController?.setNavigationBarHidden(false, animated: false)
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: backButton)
UIApplication.shared.isIdleTimerDisabled = false
UIDevice.current.setValue(UIDeviceOrientation.portrait.rawValue, forKey: "orientation")
renewRootViewState()
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
appDelegate.orientation = .portrait
}

override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
appDelegate.orientation = .allButUpsideDown
}

@objc func backButtonClick(sender: UIButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ class RoomPrePareViewController: UIViewController {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(true, animated: false)
UIApplication.shared.isIdleTimerDisabled = false
UIDevice.current.setValue(UIDeviceOrientation.portrait.rawValue, forKey: "orientation")
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return }
appDelegate.orientation = .portrait
}

override func loadView() {
Expand Down
73 changes: 47 additions & 26 deletions iOS/Example/App/Main/View/View/PrePareView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit
import TUICore
import TUIRoomEngine

class PrePareView: UIView {

Expand Down Expand Up @@ -49,25 +50,18 @@ class PrePareView: UIView {
return button
}()

let tencentBigView: UIView = {
let view = UIView(frame: .zero)
let iconImageView = UIImageView(frame: .zero)
iconImageView.image = UIImage(named: "room_tencent")
view.addSubview(iconImageView)
iconImageView.snp.makeConstraints { make in
make.top.equalToSuperview()
make.centerX.equalToSuperview()
make.width.equalTo(136)
make.height.equalTo(36)
}
let textImageView = UIImageView(frame: .zero)
textImageView.image = UIImage(named: "room_tencent_text")
view.addSubview(textImageView)
textImageView.snp.makeConstraints { make in
make.top.equalTo(iconImageView.snp.bottom).offset(5)
make.centerX.equalToSuperview()
}
return view
let signImageView: UIView = {
let imageView = UIImageView(frame: .zero)
imageView.image = UIImage(named: "room_tencent")
return imageView
}()

let signLabel: UILabel = {
let label = UILabel()
label.textAlignment = .center
label.font = UIFont.systemFont(ofSize: 24, weight: .bold)
label.text = .videoConferencingText
return label
}()

let joinRoomButton: UIButton = {
Expand Down Expand Up @@ -101,7 +95,9 @@ class PrePareView: UIView {
return tip
}()

init() {
private let signViewHeight: CGFloat = 36

init() {
super.init(frame: .zero)
}

Expand Down Expand Up @@ -142,7 +138,8 @@ class PrePareView: UIView {
topViewContainer.addSubview(userNameLabel)
topViewContainer.addSubview(debugButton)
topViewContainer.addSubview(switchLanguageButton)
addSubview(tencentBigView)
addSubview(signImageView)
addSubview(signLabel)
addSubview(joinRoomButton)
addSubview(createRoomButton)
addSubview(appVersionTipLabel)
Expand Down Expand Up @@ -176,13 +173,17 @@ class PrePareView: UIView {
make.trailing.equalToSuperview().offset(-20)
make.width.height.equalTo(30)
}
tencentBigView.snp.makeConstraints { make in
make.width.equalTo(136.scale375())
make.height.equalTo(36.scale375())
make.leading.equalToSuperview().offset(119.scale375())
signImageView.snp.makeConstraints { make in
make.width.equalTo(136)
make.height.equalTo(signViewHeight)
make.centerX.equalToSuperview()
make.top.equalToSuperview().offset(157.scale375())
}

signLabel.snp.makeConstraints { make in
make.top.equalTo(signImageView.snp.bottom).offset(5)
make.centerX.equalToSuperview()
make.height.equalTo(signViewHeight)
}
joinRoomButton.snp.makeConstraints { make in
make.height.equalTo(60.scale375())
make.width.equalTo(204.scale375())
Expand Down Expand Up @@ -217,6 +218,8 @@ class PrePareView: UIView {
let placeholderImage = UIImage(named: "room_default_avatar")
avatarButton.sd_setImage(with: URL(string: TUILogin.getFaceUrl() ?? ""), for: .normal, placeholderImage: placeholderImage)
userNameLabel.text = TUILogin.getNickName() ?? ""
guard let image = getGradientImage(size: CGSize(width: UIScreen.main.bounds.width, height: signViewHeight)) else { return }
signLabel.textColor = UIColor(patternImage: image)
}

@objc
Expand Down Expand Up @@ -244,6 +247,21 @@ class PrePareView: UIView {
rootViewController?.switchLanguageAction()
joinRoomButton.setTitle(.joinRoomText, for: .normal)
createRoomButton.setTitle(.createRoomText, for: .normal)
signLabel.text = .videoConferencingText
}

private func getGradientImage(size:CGSize) -> UIImage? {
UIGraphicsBeginImageContextWithOptions(size, false, UIScreen.main.scale)
guard let context = UIGraphicsGetCurrentContext() else{ return nil }
let colorSpace = CGColorSpaceCreateDeviceRGB()
guard let gradientRef = CGGradient(colorsSpace: colorSpace, colors: [UIColor(0x00CED9).cgColor, UIColor(0x0C59F2).cgColor]
as CFArray, locations: nil) else { return nil }
let startPoint = CGPoint(x: 0, y: 0)
let endPoint = CGPoint(x: size.width, y: 0)
context.drawLinearGradient(gradientRef, start: startPoint, end: endPoint, options: CGGradientDrawingOptions(arrayLiteral: .drawsBeforeStartLocation,.drawsAfterEndLocation))
let gradientImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return gradientImage
}

deinit {
Expand All @@ -258,5 +276,8 @@ private extension String {
static var createRoomText: String {
RoomDemoLocalize("Demo.TUIRoomKit.create.room")
}
static var videoConferencingText: String {
RoomDemoLocalize("Demo.TUIRoomKit.video.conferencing")
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
"Demo.TUIRoomKit.raise.speaker" = "Raise hand Speaker Room";
"Demo.TUIRoomKit.video.conference" = "`s quick meeting";
"Demo.TUIRoomKit.prepareSetting" = "Prepare Settings";
"Demo.TUIRoomKit.tip" = "Tencent Cloud TUIRoomKit";
"Demo.TUIRoomKit.video.conferencing" = "Multi-party video conferencing";
"Demo.TUIRoomKit.generating.roomId" = "Generating room number, please try again later";
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
"Demo.TUIRoomKit.raise.speaker" = "举手发言房间";
"Demo.TUIRoomKit.video.conference" = "的快速会议";
"Demo.TUIRoomKit.prepareSetting" = "进房前设置";
"Demo.TUIRoomKit.tip" = "腾讯云 TUIRoomKit";
"Demo.TUIRoomKit.video.conferencing" = "多人视频会议";
"Demo.TUIRoomKit.generating.roomId" = "正在生成房间号,请稍后重试";
2 changes: 1 addition & 1 deletion iOS/Example/App/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
window?.backgroundColor = UIColor.white

let loginVC = TRTCLoginViewController()
let nav = UINavigationController(rootViewController: loginVC)
let nav = RoomNavigationController(rootViewController: loginVC)
window?.rootViewController = nav
window?.makeKeyAndVisible()
}
Expand Down
Loading

0 comments on commit b3cc72a

Please sign in to comment.