Skip to content

Commit 07c9673

Browse files
adamsfliuAbySwifter
authored andcommitted
【TUIRoomKit】update version 4.0.2
1 parent 9c9261b commit 07c9673

179 files changed

Lines changed: 5705 additions & 1191 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

application/App-UIKit/Chat/ChatViewController.swift

Lines changed: 0 additions & 12 deletions
This file was deleted.

atomic_x/AtomicX.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Pod::Spec.new do |s|
1919
s.dependency 'RTCRoomEngine/Professional'
2020
s.dependency 'SnapKit'
2121
s.dependency 'RTCCommon'
22-
s.dependency 'TXLiteAVSDK_Professional', '~> 13.1.20454'
22+
s.dependency 'TXLiteAVSDK_Professional'
2323
s.dependency 'TUICore'
2424
s.dependency 'Kingfisher'
2525
s.dependency 'AtomicXCore'

atomic_x/Sources/CallView/Core/Common/Utils/Logger.swift

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// BaseLogger.swift
3+
// AtomicX
4+
//
5+
// Created by CY zhao on 2026/1/13.
6+
//
7+
8+
import Foundation
9+
10+
#if canImport(TXLiteAVSDK_TRTC)
11+
import TXLiteAVSDK_TRTC
12+
#elseif canImport(TXLiteAVSDK_Professional)
13+
import TXLiteAVSDK_Professional
14+
#endif
15+
16+
17+
public protocol Loggable {
18+
static var moduleName: String { get }
19+
}
20+
21+
public enum LogLevel: Int {
22+
case error = 2
23+
case warn = 1
24+
case info = 0
25+
}
26+
27+
public extension Loggable {
28+
static func error(file: String = #file, line: Int = #line, _ messages: String...) {
29+
log(level: .error, file: file, line: line, messages: messages)
30+
}
31+
32+
static func warn(file: String = #file, line: Int = #line, _ messages: String...) {
33+
log(level: .warn, file: file, line: line, messages: messages)
34+
}
35+
36+
static func info(file: String = #file, line: Int = #line, _ messages: String...) {
37+
log(level: .info, file: file, line: line, messages: messages)
38+
}
39+
40+
private static func log(level: LogLevel, file: String, line: Int, messages: [String]) {
41+
let apiParams: [String: Any] = [
42+
"api": "TuikitLog",
43+
"params": [
44+
"level": level.rawValue,
45+
"message": messages.joined(),
46+
"module": self.moduleName,
47+
"file": file,
48+
"line": line,
49+
],
50+
]
51+
52+
guard let jsonData = try? JSONSerialization.data(withJSONObject: apiParams, options: .prettyPrinted),
53+
let jsonString = String(data: jsonData, encoding: .utf8) else { return }
54+
55+
TRTCCloud.sharedInstance().callExperimentalAPI(jsonString)
56+
}
57+
}
58+
59+
internal class Logger: Loggable {
60+
static var moduleName: String { "AtomicX" }
61+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//
2+
// BundleLoader.swift
3+
// AtomicX
4+
//
5+
// Created by CY zhao on 2026/1/12.
6+
//
7+
8+
import Foundation
9+
10+
// MARK: - Bundle Loader
11+
12+
public class BundleLoader {
13+
14+
/// 通用的模块 Bundle 查找方法
15+
/// - Parameters:
16+
/// - bundleName: 资源包名称,如 "TUILiveKitBundle"
17+
/// - moduleName: 框架名称,如 "TUILiveKit"
18+
/// - aClass: 用于定位的类
19+
/// - Returns: 找到的 Bundle,失败返回 nil
20+
public static func moduleBundle(named bundleName: String,
21+
moduleName: String,
22+
for aClass: AnyClass) -> Bundle? {
23+
if let url = Bundle(for: aClass).url(forResource: bundleName, withExtension: "bundle") {
24+
return Bundle(url: url)
25+
}
26+
27+
if let url = Bundle.main.url(forResource: bundleName, withExtension: "bundle") {
28+
return Bundle(url: url)
29+
}
30+
31+
var url = Bundle.main.url(forResource: "Frameworks", withExtension: nil)
32+
url = url?.appendingPathComponent(moduleName)
33+
url = url?.appendingPathComponent("framework")
34+
if let frameworkURL = url,
35+
let bundle = Bundle(url: frameworkURL),
36+
let resourceURL = bundle.url(forResource: bundleName, withExtension: "bundle") {
37+
return Bundle(url: resourceURL)
38+
}
39+
40+
return nil
41+
}
42+
43+
44+
private static let placeholders = ["xxx", "yyy", "zzz", "mmm", "nnn"]
45+
/// 统一的国际化核心方法
46+
/// - Parameters:
47+
/// - key: Localizable.strings 中的 Key
48+
/// - bundle: 所在模块的 Bundle
49+
/// - tableName: .strings 文件名
50+
/// - arguments: 动态参数 (可选)
51+
/// - Returns: 翻译后的字符串
52+
///
53+
public static func moduleLocalized(key: String,
54+
in bundle: Bundle,
55+
tableName: String,
56+
arguments: [CVarArg] = []) -> String {
57+
var localizedString = ""
58+
59+
if let path = bundle.path(forResource: getPreferredLanguage(), ofType: "lproj"),
60+
let langBundle = Bundle(path: path) {
61+
localizedString = langBundle.localizedString(forKey: key, value: nil, table: tableName)
62+
} else {
63+
localizedString = bundle.localizedString(forKey: key, value: nil, table: tableName)
64+
}
65+
66+
if arguments.isEmpty {
67+
return localizedString
68+
}
69+
70+
if localizedString.contains("xxx") {
71+
return applyReplacement(origin: localizedString, args: arguments)
72+
} else {
73+
return String(format: localizedString, arguments: arguments)
74+
}
75+
}
76+
77+
private static func applyReplacement(origin: String, args: [CVarArg]) -> String {
78+
var result = origin
79+
80+
for (index, arg) in args.enumerated() {
81+
guard index < placeholders.count else { break }
82+
83+
let placeholder = placeholders[index]
84+
85+
let stringValue = String(describing: arg)
86+
87+
result = result.replacingOccurrences(of: placeholder, with: stringValue)
88+
}
89+
90+
return result
91+
}
92+
}

atomic_x/Sources/Widgets/Utils/LanguageConfiguration.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,22 @@ public let LRM = "\u{200E}"
2525
public let RLM = "\u{200F}"
2626

2727
public func getPreferredLanguage() -> String {
28-
return Locale.preferredLanguages.first ?? "en"
28+
return normalizeLanguageCode(Locale.preferredLanguages.first ?? "en")
29+
}
30+
31+
private func normalizeLanguageCode(_ code: String) -> String {
32+
let components = code.components(separatedBy: "-")
33+
guard components.count >= 2 else { return code }
34+
35+
let base = components[0]
36+
let second = components[1]
37+
38+
// BCP 47 standard: UPPERCASE=region(CN/US), Titlecase=script(Hans/Hant), lowercase=language(zh/en)
39+
let isScript = second.first?.isUppercase == true && second.dropFirst().allSatisfy { $0.isLowercase }
40+
if isScript {
41+
return "\(base)-\(second)"
42+
}
43+
return base
2944
}
3045

3146
public func isRTLLanguage() -> Bool {

call/TUICallKit_Swift/TUICallKitImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class TUICallKitImpl: TUICallKit {
9595
return
9696
}
9797

98-
CallStore.shared.calls(participantIds: userIdList, callMediaType: callMediaType, params: params ?? getCallParams(), completion: completion)
98+
CallStore.shared.calls(participantIds: userIdList, mediaType: callMediaType, params: params ?? getCallParams(), completion: completion)
9999
}
100100

101101
override func join(callId: String, completion: CompletionClosure?) {

call/TUICallKit_Swift/View/Component/Recents/RecentCallsViewModel.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class RecentCallsViewModel: ObservableObject {
123123
if (callInfo.chatGroupId.isEmpty && userIds.count <= 1) {
124124
repeatSingleCall(callInfo, userIds)
125125
} else {
126-
CallStore.shared.calls(participantIds: userIds, callMediaType: mediaType, params: nil, completion: nil)
126+
CallStore.shared.calls(participantIds: userIds, mediaType: mediaType, params: nil, completion: nil)
127127
}
128128
}
129129

@@ -138,7 +138,7 @@ class RecentCallsViewModel: ObservableObject {
138138
guard let userid = otherUserIds.first else { return }
139139
targetUserId = userid
140140
}
141-
CallStore.shared.calls(participantIds: [targetUserId], callMediaType: mediaType, params: nil, completion: nil)
141+
CallStore.shared.calls(participantIds: [targetUserId], mediaType: mediaType, params: nil, completion: nil)
142142
}
143143

144144
func deleteAllRecordCalls() {

0 commit comments

Comments
 (0)