Skip to content

Commit

Permalink
【TUILiveKit】【iOS】2.0.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsfliu authored and AbySwifter committed Jun 14, 2024
1 parent 567ff77 commit c7fbbd9
Show file tree
Hide file tree
Showing 290 changed files with 7,771 additions and 6,588 deletions.
1 change: 0 additions & 1 deletion iOS/Example/App/Login/LoginRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class LoginRootView: UIView {
textField.textColor = UIColor(hex: "333333")
textField.attributedPlaceholder = NSAttributedString(string: "userId")
textField.delegate = self
textField.keyboardType = .phonePad
return textField
}()
weak var currentTextField: UITextField?
Expand Down
53 changes: 32 additions & 21 deletions iOS/Example/App/Main/MainRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ class MainRootView: UIView {
return textField
}()

let roomSegment: UISegmentedControl = {
let segment = UISegmentedControl(items: [String.videoLiveText, String.audioLiveText])
segment.selectedSegmentTintColor = .systemBlue
segment.selectedSegmentIndex = 0
segment.backgroundColor = UIColor(0xd8d8d8)
segment.setTitleTextAttributes([.foregroundColor: UIColor.white], for: .normal)
segment.setTitleTextAttributes([.foregroundColor: UIColor.white], for: .selected)
return segment
}()

lazy var joinBtn: UIButton = {
let btn = UIButton(frame: .zero)
btn.setTitle(.joinLiveStreamText, for: .normal)
Expand All @@ -64,7 +54,18 @@ class MainRootView: UIView {
btn.setTitle(.startLiveStreamText, for: .normal)
btn.setTitleColor(.white, for: .normal)
btn.backgroundColor = .systemBlue
btn.layer.cornerRadius = 24
btn.layer.cornerRadius = 10
btn.titleLabel?.font = UIFont.systemFont(ofSize: 18)
btn.titleLabel?.adjustsFontSizeToFitWidth = true
return btn
}()

lazy var liveRoomListBtn: UIButton = {
let btn = UIButton()
btn.setTitle(.liveRoomListText, for: .normal)
btn.setTitleColor(.white, for: .normal)
btn.backgroundColor = .systemBlue
btn.layer.cornerRadius = 10
btn.titleLabel?.font = UIFont.systemFont(ofSize: 18)
btn.titleLabel?.adjustsFontSizeToFitWidth = true
return btn
Expand Down Expand Up @@ -92,8 +93,8 @@ extension MainRootView {
private func constructViewHierarchy() {
addSubview(textContainerView)
textContainerView.addSubview(streamIdTextField)
addSubview(roomSegment)
addSubview(joinBtn)
addSubview(liveRoomListBtn)
addSubview(loading)
addSubview(startBtn)
}
Expand All @@ -109,17 +110,19 @@ extension MainRootView {
streamIdTextField.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
roomSegment.snp.makeConstraints { make in
make.top.equalTo(streamIdTextField.snp.bottom).offset(15)
make.trailing.equalTo(streamIdTextField.snp.trailing)
make.leading.equalTo(streamIdTextField.snp.leading)
make.height.equalTo(30)
}

joinBtn.snp.makeConstraints { make in
make.leading.equalTo(textContainerView.snp.leading)
make.trailing.equalTo(textContainerView.snp.trailing)
make.height.equalTo(textContainerView.snp.height)
make.top.equalTo(roomSegment.snp.bottom).offset(40)
make.top.equalTo(streamIdTextField.snp.bottom).offset(60)
}

liveRoomListBtn.snp.makeConstraints { make in
make.leading.equalTo(textContainerView.snp.leading)
make.trailing.equalTo(textContainerView.snp.trailing)
make.height.equalTo(textContainerView.snp.height)
make.top.equalTo(joinBtn.snp.bottom).offset(60)
}

loading.snp.makeConstraints { make in
Expand All @@ -128,15 +131,17 @@ extension MainRootView {
}

startBtn.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.bottom.equalTo(safeAreaLayoutGuide.snp.bottom).offset(-60)
make.size.equalTo(CGSize(width: 163, height: 60))
make.leading.equalTo(textContainerView.snp.leading)
make.trailing.equalTo(textContainerView.snp.trailing)
make.height.equalTo(textContainerView.snp.height)
}
}

private func bindInteraction() {
startBtn.addTarget(self, action: #selector(startBtnClick), for:.touchUpInside)
joinBtn.addTarget(self, action: #selector(joinBtnTouchEvent), for: .touchUpInside)
liveRoomListBtn.addTarget(self, action: #selector(liveRoomListBtnClick(sender:)), for: .touchUpInside)
}
@objc
private func startBtnClick(sender: UIButton) {
Expand All @@ -147,6 +152,11 @@ extension MainRootView {
guard let roomId = streamIdTextField.text else { return }
rootVC?.joinBtnClick(sender: sender, view: self, roomId: roomId)
}

@objc
private func liveRoomListBtnClick(sender: UIButton) {
rootVC?.liveRoomListBtnClick(sender: sender, view: self)
}

@objc
private func streamIdTextFieldValueChange(sender: UITextField) {
Expand Down Expand Up @@ -176,4 +186,5 @@ private extension String {
static let enterLiveStreamListText = TUILiveKitAppLocalize("TUILiveKitApp.Main.enterLiveStreamList")
static let videoLiveText = TUILiveKitAppLocalize("TUILiveKitApp.Main.video")
static let audioLiveText = TUILiveKitAppLocalize("TUILiveKitApp.Main.audio")
static let liveRoomListText = TUILiveKitAppLocalize("TUILiveKitApp.Main.liveRoomList")
}
21 changes: 14 additions & 7 deletions iOS/Example/App/Main/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,27 +122,34 @@ extension MainViewController {
}

@objc func helpBtnClick() {
if let url = URL(string: "https://cloud.tencent.com/document/product/647/35429") {
if let url = URL(string: "https://cloud.tencent.com/document/product/647/105441") {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}

func joinBtnClick(sender: UIButton, view: MainRootView, roomId: String) {
let viewController:UIViewController
if view.roomSegment.selectedSegmentIndex == 0 {
viewController = TUILiveRoomAudienceViewController(roomId: roomId)
} else {
viewController = TUIVoiceRoomViewController(roomId: roomId, behavior: .join)
guard let roomType = LiveIdentityGenerator.shared.getIDType(roomId) else { return }
switch roomType {
case .live:
viewController = TUILiveRoomAudienceViewController(roomId: roomId)
case .voice:
viewController = TUIVoiceRoomViewController(roomId: roomId, behavior: .join)
}
self.navigationController?.pushViewController(viewController, animated: true)
}

func startBtnClick(sender: UIButton, view: MainRootView) {
let liveRoomId = (TUILogin.getUserID() ?? "")
let voiceRoomId = (TUILogin.getUserID() ?? "")
let liveRoomId = LiveIdentityGenerator.shared.generateId(TUILogin.getUserID() ?? "", .live)
let voiceRoomId = LiveIdentityGenerator.shared.generateId(TUILogin.getUserID() ?? "", .voice)
let viewController = TUILivePreviewViewController(liveRoomId: liveRoomId, voiceRoomId: voiceRoomId)
self.navigationController?.pushViewController(viewController, animated: true)
}

func liveRoomListBtnClick(sender: UIButton, view: MainRootView) {
let roomListViewController = TUIRoomListViewController()
self.navigationController?.pushViewController(roomListViewController, animated: true)
}
}

extension String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"TUILiveKitApp.Login.limit20count" = "Chinese characters, letters, numbers and underscores, 2 - 20 words";
"TUILiveKitApp.Login.registersuccess" = "Registration successful";
"TUILiveKitApp.Main.videointeraction" = "Interactive Live Video Streaming";
"TUILiveKitApp.Main.startLiveStream" = "Start Living";
"TUILiveKitApp.Main.startLiveStream" = "Go Live";
"TUILiveKitApp.Main.enterLiveStreamList" = "Live Room List";
"TUILiveKitApp.Main.streamId" = "Stream ID";
"TUILiveKitApp.Main.joinLiveStream" = "Join Living";
Expand All @@ -29,3 +29,5 @@
"TUILiveKitApp.Main.confirm" = "OK";
"TUILiveKitApp.Main.video" = "Living";
"TUILiveKitApp.Main.audio" = "Voice";
"TUILiveKitApp.Main.liveRoomList" = "Live Room List";

Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
"TUILiveKitApp.Main.confirm" = "确定";
"TUILiveKitApp.Main.video" = "视频直播";
"TUILiveKitApp.Main.audio" = "语音直播";
"TUILiveKitApp.Main.liveRoomList" = "直播间列表";
1 change: 1 addition & 0 deletions iOS/Example/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target 'TUILiveKitApp' do
pod 'Alamofire'
# Local Library
pod 'TUILiveKit', :path => '../TUILiveKit'
pod 'RTCCommon'
end

post_install do |installer|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
"live.category.music" = "Music";
"live.category.xxx" = "Live Category:xxx";
"live.mode.xxx" = "Live Mode:xxx";
"live.start.living.title" = "Start Live";
"live.start.living.title" = "Go Live";
"live.portrait.title" = "Switch to Portrait";
"live.landscape.title" = "Switch to Landscape";
"live.landscape.title" = "Switch to Landscape";
"live.audience.mask.title" = "Broadcast has been ended";
"live.audience.count.unit.xxx" = "xxx people";
"live.audience.barrage.placeholder" = "Chat~";
"live.audience.barrage.placeholder" = "Let`s talk";
"live.audience.linkType.title" = "Choose Link Mode";
"live.audience.linkType.tips" = "Choose the link mode, and the anchor will connect after agreeing";
"live.audience.linkType.tips" = "connect upon host`s approval";
"live.audience.linkType.videoLinkRequest" = "Apply for video link";
"live.audience.linkType.audioLinkRequest" = "Apply for audio link";
"live.audience.videoLinkConfig.title" = "Adjust video link screen";
Expand All @@ -48,8 +47,8 @@
"live.audience.videoLinkConfig.flip" = "Flip";
"live.audience.wait.link.tips" = "You have submitted a request to join the live stream, please wait for the host to approve.";
"live.audience.wait.link.mic.desc.xxx" = "Waiting for link xxx";
"live.audience.link.float.toBePassed" = "To be passed xxx";
"live.audience.link.float.applyLinkMicCount.xxx" = "Apply for link (xxx)";
"live.audience.link.float.toBePassed.xxx" = "Waitingxxx";
"live.audience.link.float.applyLinkMicCount.xxx" = "Requesting(xxx)";
"live.audience.link.confirm.cancelLinkMicRequest" = "Cancel link request";
"live.audience.link.confirm.closeLinkMic" = "End link";
"live.audience.link.confirm.cancel" = "Cancel";
Expand All @@ -75,13 +74,13 @@
"live.anchor.setting.audio.effects" = "Audio Effects";
"live.anchor.setting.flip" = "Flip";
"live.anchor.setting.mirror" = "Mirror";
"live.anchor.setting.video.parameters" = "Video Parameters";
"live.anchor.setting.video.parameters" = "Video";
"live.anchor.setting.more.setting" = "More Settings";
"live.link.success" = "Link Successfully";
"live.alert.confirm" = "Confirm";
"live.alert.known" = "I know";
"live.alert.enterRoom.failed.title" = "Failed to enter room";
"live.alert.enterRoom.failed.message" = "Failed to enter the room, please try again later. Status information: {xxx}";
"live.alert.enterRoom.failed.message.xxx" = "Entry failed, please try later. Status Information: {xxx}";
"live.alert.linkMic.rejected.title" = "Anchor Rejected";
"live.alert.linkMic.rejected.message" = "The anchor did not approve your request, please try again later";
"live.alert.linkMic.timeout.title" = "Timeout";
Expand Down Expand Up @@ -133,6 +132,7 @@
"live.barrage.enterButtonTitle" = "Say something";
"live.barrage.me" = "me";
"live.barrage.coming" = "enters the room";
"live.barrage.anchor" = "ANCHOR";
"live.operation.fail.xxx" = "Operation failed, please try again later. Status information: {xxx}";
"live.stream.list.title" = "Live Room List";
"live.giftView.sendGift" = "Send Gift";
Expand Down Expand Up @@ -160,10 +160,12 @@
"live.anchor.live.data" = "Live data";
"live.anchor.live.data.duration" = "Duration";
"live.anchor.live.data.gift.income" = "Gift Income";
"live.anchor.live.data.audience.count" = "Number of viewers";
"live.anchor.live.data.message.count" = "Number of messages";
"live.anchor.live.data.gift.people.count" = "Number of gift givers";
"live.anchor.live.data.like.count" = "Number of likes";
"live.anchor.live.data.audience.count" = "Total Viewers";
"live.anchor.live.data.message.count" = "Messages";
"live.anchor.live.data.gift.people.count" = "Gift givers";
"live.anchor.live.data.like.count" = "Likes";
"live.user.follow" = "Follow";
"live.user.unfollow" = "Unfollow";

// MARK: - Error Toast

Expand Down Expand Up @@ -193,6 +195,7 @@
"live.error.operation.notSupported.inCurrentSpeechMode" = "This operation is not supported in the current speaking mode";
"live.error.roomId.invalid" = "Invalid room ID created, custom ID must be printable ASCII characters (0x20-0x7e), up to 48 bytes";
"live.error.roomId.occupied" = "Room ID already in use, please choose another room ID";
"live.error.userNotExist" = "User does not exist";
"live.error.roomName.invalid" = "Invalid room name, the name can be up to 30 bytes, and the character encoding must be UTF-8 if it contains Chinese";
"live.error.already.in.OtherRoom" = "The current user is already in another room, you need to leave the room before joining a new one";
"live.error.userNotEntered" = "User is not in the current room";
Expand All @@ -218,3 +221,15 @@
"live.error.open.screen.share.need.permission.from.admin" = "You need to apply to the room owner or administrator before opening the screen sharing";
"live.error.send.message.disabled.for.all" = "All users are muted in the current room";
"live.error.send.message.disabled.for.current" = "You have been muted in the current room";
"live.error.invalid.userId" = "Invalid userId";
"live.roomId.xxx" = "Stream Id: xxx";
"live.fans.count.xxx" = "xxx fans";

"live.room.list.live" = "Live";
"live.room.list.pullToRefresh" = "Pull to refresh";
"live.room.list.releaseToRefresh" = "Release to refresh";
"live.room.list.loading" = "Loading...";
"live.room.list.loadingMore" = "Loading more";
"live.room.list.noMoreData" = "There is no more data";
"live.room.list.startLiveRoom" = "Please start a live room";
"live.room.list.watching.xxx" = "xxx people are watching";
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"live.landscape.title" = "切换至横屏";
"live.landscape.title" = "切换至横屏";
"live.audience.mask.title" = "直播已结束";
"live.audience.count.unit.xxx" = "xxx人";
"live.audience.barrage.placeholder" = "聊聊吧~";
"live.audience.linkType.title" = "选择连麦方式";
"live.audience.linkType.tips" = "选择连麦方式,主播同意后接通";
Expand Down Expand Up @@ -133,6 +132,7 @@
"live.barrage.enterButtonTitle" = "说点啥...";
"live.barrage.me" = "我";
"live.barrage.coming" = "进入房间";
"live.barrage.anchor" = "主播";
"live.operation.fail.xxx" = "操作失败,请稍后尝试。状态信息:{xxx}";
"live.stream.list.title" = "直播间列表";
"live.giftView.sendGift" = "发送礼物";
Expand Down Expand Up @@ -164,6 +164,8 @@
"live.anchor.live.data.message.count" = "消息数量";
"live.anchor.live.data.gift.people.count" = "送礼人数";
"live.anchor.live.data.like.count" = "点赞数量";
"live.user.follow" = "关注";
"live.user.unfollow" = "取消关注";

// MARK: - Error Toast
"live.error.success" = "操作成功";
Expand Down Expand Up @@ -218,3 +220,16 @@
"live.error.open.screen.share.need.permission.from.admin" = "需要向房主或管理员申请后打开屏幕分享";
"live.error.send.message.disabled.for.all" = "当前房间已开启全员禁言";
"live.error.send.message.disabled.for.current" = "当前房间内,您已被禁言";
"live.error.invalid.userId" = "非法的userId";
"live.roomId.xxx" = "直播房间ID: xxx";
"live.fans.count.xxx" = "xxx粉丝";


"live.room.list.live" = "直播";
"live.room.list.pullToRefresh" = "下拉刷新";
"live.room.list.releaseToRefresh" = "松开刷新";
"live.room.list.loading" = "正在加载...";
"live.room.list.loadingMore" = "加载更多";
"live.room.list.noMoreData" = "没有更多数据了";
"live.room.list.startLiveRoom" = "请先开启一个直播间";
"live.room.list.watching.xxx" = "xxx人正在观看";
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"images" : [
{
"filename" : "livekit_emoji_icon.pdf",
"filename" : "barrage_level1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{
"images" : [
{
"filename" : "livekit_beautify_icon.pdf",
"filename" : "barrage_level2.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"preserves-vector-representation" : true
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "barrage_level3.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "barrage_level4.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Loading

0 comments on commit c7fbbd9

Please sign in to comment.