Skip to content

Commit fbb9f9f

Browse files
author
adamsfliu
committed
【RoomKit】【iOS】Fixed the issue where bundle image resources and localized strings failed to load in RoomKit.
1 parent ef4dac8 commit fbb9f9f

13 files changed

Lines changed: 84 additions & 81 deletions

application/Podfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ target 'App-UIKit' do
1111
pod 'RTCCommon'
1212

1313
pod 'TUICallKit_Swift', :path=>'../call/TUICallKit_Swift.podspec'
14-
pod 'TUIRoomKit/Professional', :path=>'../room/TUIRoomKit.podspec'
15-
14+
pod 'TUIRoomKit', :path=>'../room/TUIRoomKit.podspec'
1615
pod 'TUILiveKit', :path=>'../live/TUILiveKit.podspec'
1716
pod 'AtomicX', :path=>'../atomic_x/AtomicX.podspec'
1817

room/Source/Base/Localized/TUIRoomKitLocalized.swift

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,30 @@ import Foundation
1919
/// - defaultValue: 默认值
2020
/// - Returns: 本地化后的字符串
2121
@objc public static func localizedString(_ key: String) -> String {
22-
return NSLocalizedString(key, tableName: "TUIRoomKitLocalized", bundle: ResourceLoader.bundle, comment: "")
22+
if let bundlePath = ResourceLoader.bundle.path(forResource: getPreferredLanguage(), ofType: "lproj"),
23+
let bundle = Bundle(path: bundlePath) {
24+
return bundle.localizedString(forKey: key, value: "", table: "TUIRoomKitLocalized")
25+
}
26+
return ResourceLoader.bundle.localizedString(forKey: key, value: "", table: "TUIRoomKitLocalized")
27+
}
28+
29+
private static func getPreferredLanguage() -> String {
30+
return normalizeLanguageCode(Locale.preferredLanguages.first ?? "en")
31+
}
32+
33+
private static func normalizeLanguageCode(_ code: String) -> String {
34+
let components = code.components(separatedBy: "-")
35+
guard components.count >= 2 else { return code }
36+
37+
let base = components[0]
38+
let second = components[1]
39+
40+
// BCP 47 standard: UPPERCASE=region(CN/US), Titlecase=script(Hans/Hant), lowercase=language(zh/en)
41+
let isScript = second.first?.isUppercase == true && second.dropFirst().allSatisfy { $0.isLowercase }
42+
if isScript {
43+
return "\(base)-\(second)"
44+
}
45+
return base
2346
}
2447
}
2548

room/Source/Base/UI/BaseView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
/// Base view protocol for custom views
1212
/// All custom views must conform to this protocol
13-
protocol BaseView: AnyObject {
13+
public protocol BaseView: AnyObject {
1414
/// Router context for triggering navigation (weak reference to avoid retain cycles)
1515
var routerContext: RouterContext? { get set }
1616

room/Source/Base/UI/RouterContext.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
/// Router context protocol for navigation and presentation
1212
/// All custom UIViewControllers must conform to this protocol
13-
protocol RouterContext: AnyObject {
13+
public protocol RouterContext: AnyObject {
1414
/// Current navigation controller
1515
var navigationController: UINavigationController? { get }
1616

@@ -49,25 +49,25 @@ protocol RouterContext: AnyObject {
4949
// MARK: - Default Implementation for UIViewController
5050

5151
extension RouterContext where Self: UIViewController {
52-
func push(_ viewController: UIViewController, animated: Bool = true) {
52+
public func push(_ viewController: UIViewController, animated: Bool = true) {
5353
navigationController?.pushViewController(viewController, animated: animated)
5454
}
5555

5656
@discardableResult
57-
func pop(animated: Bool = true) -> UIViewController? {
57+
public func pop(animated: Bool = true) -> UIViewController? {
5858
return navigationController?.popViewController(animated: animated)
5959
}
6060

6161
@discardableResult
62-
func popToRoot(animated: Bool = true) -> [UIViewController]? {
62+
public func popToRoot(animated: Bool = true) -> [UIViewController]? {
6363
return navigationController?.popToRootViewController(animated: animated)
6464
}
6565

66-
func present(_ viewController: UIViewController, animated: Bool = true, completion: (() -> Void)? = nil) {
66+
public func present(_ viewController: UIViewController, animated: Bool = true, completion: (() -> Void)? = nil) {
6767
present(viewController, animated: animated, completion: completion)
6868
}
6969

70-
func dismiss(animated: Bool = true, completion: (() -> Void)? = nil) {
70+
public func dismiss(animated: Bool = true, completion: (() -> Void)? = nil) {
7171
dismiss(animated: animated, completion: completion)
7272
}
7373
}

room/Source/Base/Utils/ResourceLoader.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import UIKit
1313

1414
// MARK: - Properties
1515
@objc public static let bundle: Bundle = {
16-
if let bundlePath = Bundle.main.path(forResource: "TUIRoomKit", ofType: "bundle"),
16+
if let bundlePath = Bundle.main.path(forResource: "TUIRoomKitBundle", ofType: "bundle"),
1717
let bundle = Bundle(path: bundlePath) {
1818
return bundle
1919
}
2020

2121
let currentBundle = Bundle(for: ResourceLoader.self)
22-
if let bundlePath = currentBundle.path(forResource: "TUIRoomKit", ofType: "bundle"),
22+
if let bundlePath = currentBundle.path(forResource: "TUIRoomKitBundle", ofType: "bundle"),
2323
let bundle = Bundle(path: bundlePath) {
2424
return bundle
2525
}

room/Source/View/Main/RoomBottomBarView.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public protocol RoomBottomBarViewDelegate: AnyObject {
1818
// MARK: - RoomBottomBarView Component
1919
public class RoomBottomBarView: UIView, BaseView {
2020
// MARK: - BaseView Properties
21-
weak var routerContext: RouterContext?
21+
public weak var routerContext: RouterContext?
2222

2323
// MARK: - Properties
2424
public weak var delegate: RoomBottomBarViewDelegate?
@@ -96,15 +96,15 @@ public class RoomBottomBarView: UIView, BaseView {
9696
}
9797

9898
// MARK: - Setup
99-
func setupViews() {
99+
public func setupViews() {
100100
addSubview(buttonStackView)
101101
buttonStackView.subviews.enumerated().forEach { index, view in
102102
let button = buttons[index]
103103
view.addSubview(button)
104104
}
105105
}
106106

107-
func setupConstraints() {
107+
public func setupConstraints() {
108108
buttonStackView.snp.makeConstraints { make in
109109
make.width.equalTo(200)
110110
make.centerX.equalToSuperview()
@@ -124,11 +124,9 @@ public class RoomBottomBarView: UIView, BaseView {
124124
}
125125
}
126126

127-
func setupStyles() {
128-
129-
}
127+
public func setupStyles() {}
130128

131-
func setupBindings() {
129+
public func setupBindings() {
132130
membersButton.addTarget(self, action: #selector(membersButtonTapped), for: .touchUpInside)
133131
microphoneButton.addTarget(self, action: #selector(microphoneButtonTapped), for: .touchUpInside)
134132
cameraButton.addTarget(self, action: #selector(cameraButtonTapped), for: .touchUpInside)

room/Source/View/Main/RoomTopBarView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public protocol RoomTopBarViewDelegate: AnyObject {
1717

1818
public class RoomTopBarView: UIView, BaseView {
1919
// MARK: - BaseView Properties
20-
weak var routerContext: RouterContext?
20+
public weak var routerContext: RouterContext?
2121

2222
// MARK: - Properties
2323
weak var delegate: RoomTopBarViewDelegate?
@@ -100,7 +100,7 @@ public class RoomTopBarView: UIView, BaseView {
100100
}
101101

102102
// MARK: - BaseView Implementation
103-
func setupViews() {
103+
public func setupViews() {
104104
addSubview(audioSourceButton)
105105
addSubview(flipCameraButton)
106106
addSubview(roomInfoContainerView)
@@ -110,7 +110,7 @@ public class RoomTopBarView: UIView, BaseView {
110110
addSubview(endButton)
111111
}
112112

113-
func setupConstraints() {
113+
public func setupConstraints() {
114114
audioSourceButton.snp.makeConstraints { make in
115115
make.left.equalToSuperview().offset(RoomSpacing.standard)
116116
make.centerY.equalToSuperview()
@@ -152,7 +152,7 @@ public class RoomTopBarView: UIView, BaseView {
152152
}
153153
}
154154

155-
func setupBindings() {
155+
public func setupBindings() {
156156
audioSourceButton.addTarget(self, action: #selector(audioSourceButtonTapped), for: .touchUpInside)
157157
flipCameraButton.addTarget(self, action: #selector(flipCameraButtonTapped), for: .touchUpInside)
158158
endButton.addTarget(self, action: #selector(endButtonTapped(sender:)), for: .touchUpInside)
@@ -186,7 +186,7 @@ public class RoomTopBarView: UIView, BaseView {
186186
.store(in: &cancellableSet)
187187
}
188188

189-
func setupStyles() {
189+
public func setupStyles() {
190190
// Set content compression resistance to ensure downArrowImageView is always visible
191191
roomInfoLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
192192
downArrowImageView.setContentCompressionResistancePriority(.required, for: .horizontal)

room/Source/View/Main/RoomView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct DataChanges {
2424
// MARK: - RoomView Component
2525
public class RoomView: UIView, BaseView {
2626
// MARK: - BaseView Properties
27-
weak var routerContext: RouterContext?
27+
public weak var routerContext: RouterContext?
2828
private let roomID: String
2929

3030
private lazy var roomParticipantStore: RoomParticipantStore = {
@@ -95,13 +95,13 @@ public class RoomView: UIView, BaseView {
9595
}
9696

9797
// MARK: - BaseView Implementation
98-
func setupViews() {
98+
public func setupViews() {
9999
addSubview(collectionView)
100100
addSubview(previousPageButton)
101101
addSubview(nextPageButton)
102102
}
103103

104-
func setupConstraints() {
104+
public func setupConstraints() {
105105
collectionView.snp.makeConstraints { make in
106106
make.edges.equalToSuperview()
107107
}
@@ -117,11 +117,11 @@ public class RoomView: UIView, BaseView {
117117
}
118118
}
119119

120-
func setupStyles() {
120+
public func setupStyles() {
121121
backgroundColor = .clear
122122
}
123123

124-
func setupBindings() {
124+
public func setupBindings() {
125125
// MARK: - Real Data Binding
126126
roomParticipantStore.state
127127
.subscribe(StatePublisherSelector(keyPath: \.participantList))

room/Source/View/RoomCreateView.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Combine
1414
public class RoomCreateView: UIView, BaseView {
1515

1616
// MARK: - Properties
17-
weak var routerContext: RouterContext?
17+
public weak var routerContext: RouterContext?
1818
private var cancellableSet = Set<AnyCancellable>()
1919
private var connectConfig: ConnectConfig = ConnectConfig()
2020

@@ -155,7 +155,7 @@ public class RoomCreateView: UIView, BaseView {
155155

156156
// MARK: - BaseView Implementation
157157

158-
func setupViews() {
158+
public func setupViews() {
159159
// Add subviews
160160
addSubview(backButtonContainerView)
161161
backButtonContainerView.addSubview(backButton)
@@ -181,7 +181,7 @@ public class RoomCreateView: UIView, BaseView {
181181
addSubview(createRoomButton)
182182
}
183183

184-
func setupConstraints() {
184+
public func setupConstraints() {
185185
// Back button container - expand click area
186186
backButtonContainerView.snp.makeConstraints { make in
187187
make.left.equalToSuperview()
@@ -282,14 +282,14 @@ public class RoomCreateView: UIView, BaseView {
282282
}
283283
}
284284

285-
func setupStyles() {
285+
public func setupStyles() {
286286
backgroundColor = RoomColors.g8
287287
microphoneSwitch.isOn = connectConfig.autoEnableMicrophone
288288
speakerSwitch.isOn = connectConfig.autoEnableSpeaker
289289
cameraSwitch.isOn = connectConfig.autoEnableCamera
290290
}
291291

292-
func setupBindings() {
292+
public func setupBindings() {
293293
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleBackButtonTapped))
294294
backButtonContainerView.addGestureRecognizer(tapGesture)
295295

room/Source/View/RoomHomeView.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ import Kingfisher
1515
public class RoomHomeView: UIView, BaseView {
1616

1717
// MARK: - Properties
18-
weak var routerContext: RouterContext?
18+
public weak var routerContext: RouterContext?
1919
private let roomStore: RoomStore = RoomStore.shared
2020
private var cancellableSet = Set<AnyCancellable>()
2121

2222
// MARK: - UI Components
2323
private lazy var backButtonContainerView: UIView = {
2424
let view = UIView()
2525
view.backgroundColor = .clear
26-
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleBackButtonTapped))
27-
view.addGestureRecognizer(tapGesture)
2826
view.isUserInteractionEnabled = true
2927
return view
3028
}()
@@ -38,8 +36,6 @@ public class RoomHomeView: UIView, BaseView {
3836

3937
private lazy var userAvatarContainerView: UIView = {
4038
let view = UIView()
41-
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleUserAvatarTapped))
42-
view.addGestureRecognizer(tapGesture)
4339
view.isUserInteractionEnabled = true
4440
return view
4541
}()
@@ -65,7 +61,6 @@ public class RoomHomeView: UIView, BaseView {
6561
title: .joinRoom,
6662
iconName: "join_room"
6763
)
68-
button.addTarget(self, action: #selector(handleJoinRoomButtonTapped), for: .touchUpInside)
6964
return button
7065
}()
7166

@@ -74,7 +69,6 @@ public class RoomHomeView: UIView, BaseView {
7469
title: .createRoom,
7570
iconName: "create_room"
7671
)
77-
button.addTarget(self, action: #selector(handleCreateRoomButtonTapped), for: .touchUpInside)
7872
return button
7973
}()
8074

@@ -95,7 +89,7 @@ public class RoomHomeView: UIView, BaseView {
9589

9690
// MARK: - BaseView Implementation
9791

98-
func setupViews() {
92+
public func setupViews() {
9993
addSubview(backButtonContainerView)
10094
backButtonContainerView.addSubview(backButton)
10195
backButtonContainerView.addSubview(userAvatarContainerView)
@@ -105,7 +99,7 @@ public class RoomHomeView: UIView, BaseView {
10599
addSubview(createRoomButton)
106100
}
107101

108-
func setupConstraints() {
102+
public func setupConstraints() {
109103
backButtonContainerView.snp.makeConstraints { make in
110104
make.left.equalToSuperview()
111105
make.top.equalTo(safeAreaLayoutGuide.snp.top)
@@ -153,10 +147,21 @@ public class RoomHomeView: UIView, BaseView {
153147
}
154148
}
155149

156-
func setupStyles() {
150+
public func setupStyles() {
157151
backgroundColor = RoomColors.themeBackground
158152
}
159153

154+
public func setupBindings() {
155+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleBackButtonTapped))
156+
backButtonContainerView.addGestureRecognizer(tapGesture)
157+
158+
let userAvatarTapGesture = UITapGestureRecognizer(target: self, action: #selector(handleUserAvatarTapped))
159+
userAvatarContainerView.addGestureRecognizer(userAvatarTapGesture)
160+
161+
createRoomButton.addTarget(self, action: #selector(handleCreateRoomButtonTapped), for: .touchUpInside)
162+
joinRoomButton.addTarget(self, action: #selector(handleJoinRoomButtonTapped), for: .touchUpInside)
163+
}
164+
160165
// MARK: - Helper Methods
161166

162167
private func createActionButton(title: String, iconName: String) -> UIButton {

0 commit comments

Comments
 (0)