产品动态
公告
git clone https://github.com/Tencent-RTC/TUIKit_iOS_SwiftUI.git
atomic-x/├── Sources/ # UI 组件源码(必需集成)│ ├── MessageList/ # 消息列表组件│ ├── MessageInput/ # 消息输入组件│ ├── ConversationList/ # 会话列表组件│ ├── ContactList/ # 联系人列表组件│ ├── BaseComponent/ # 基础组件│ └── ... # 其他UI组件├── Resources/ # 资源文件(必需集成)│ ├── assets/ # 图片资源│ └── strings/ # 本地化字符串文件chat/├── uikit/ # Page 组件(参考实现)│ ├── ChatPage.swift│ ├── ContactsPage.swift│ └── ConversationsPage.swift└── demo/ # 示例应用(可选参考)

pod 'AtomicX/Chat', :path => '../TUIKit_iOS_SwiftUI/atomic-x/AtomicX.podspec'pod 'AtomicX/Chat', :path => './TUIKit_iOS_SwiftUI/atomic-x/AtomicX.podspec'pod 'AtomicX/Chat', :path => '/TUIKit_iOS_SwiftUI/atomic-x/AtomicX.podspec'platform :ios, '14.0'target 'Demo' douse_frameworks! :linkage => :staticpod 'AtomicX/Chat', :path => './TUIKit_iOS_SwiftUI/atomic-x/AtomicX.podspec'pod 'ChatUIKit', :path => './TUIKit_iOS_SwiftUI/chat/uikit/ChatUIKit.podspec'pod 'AtomicXCore', '3.4.0'end#Pods configpost_install do |installer|installer.pods_project.targets.each do |target|target.build_configurations.each do |config|config.build_settings['SWIFT_VERSION'] = '5.0'#Do not strip Swift symbolsconfig.build_settings['STRIP_SWIFT_SYMBOLS'] = 'NO'config.build_settings['DEBUG_INFORMATION_FORMAT'] = 'dwarf-with-dsym'#Fix Xcode14 Bundle target errorconfig.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"config.build_settings['ENABLE_BITCODE'] = "NO"config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "14.0"endendend
pod install

<key>NSCameraUsageDescription</key><string>App需要访问相机来拍摄照片和视频</string><key>NSMicrophoneUsageDescription</key><string>App需要访问麦克风来录制音频</string><key>NSPhotoLibraryUsageDescription</key><string>App需要访问相册来选择图片和视频</string>

import AtomicXCore// 用户登录LoginStore.shared.login(sdkAppID: sdkAppID, userID: userID, userSig: userSig, completion: { [weak self] result inguard let self = self else { return }switch result {case .success:// 登录成功,可跳转聊天或会话页case .failure(let error):// 登录失败,可弹框报错}})

chat/uikit/ConversationsPage.swift 文件里的实现,ConversationsPage 主要做了以下工作:import AtomicXimport AtomicXCoreimport SwiftUIpublic struct ConversationsPage: View {...public var body: some View {VStack(spacing: 0) {headerViewConversationList(onConversationClick: { conversation in// Customize onConversationClick eventonShowMessage?(NavigationInfo(conversation: conversation))}).environmentObject(themeState)}.onReceive(contactListStore.state.subscribe(StatePublisherSelector(keyPath: \\ContactListState.friendList))) { friendList inif self.friendList != friendList {self.friendList = friendList}}.onAppear {contactListStore.fetchFriendList(completion: { _ in })}.overlay(// Click + to show this menu.ChatsMenuOverlay(showChatsMenu: $showChatsMenu,showStartConversation: $showStartConversation,showUserPicker: $showUserPicker))...}...}private var headerView: some View {HStack {Text(LocalizedChatString("TabChats")).font(.system(size: 34, weight: .semibold)).tracking(0.3).foregroundColor(themeState.colors.textColorPrimary).background(themeState.colors.listColorDefault).padding(.leading, 16)Spacer()if AppBuilderConfig.shared.enableCreateConversation {Button(action: {showChatsMenu.toggle()}) {Image(systemName: "plus").font(.system(size: 20)).foregroundColor(themeState.colors.buttonColorPrimaryDefault).frame(width: 28, height: 28).cornerRadius(14)}.padding(.trailing, 16)}}.padding(.top, 12).padding(.bottom, 16)}

chat/uikit/ChatPage.swift 文件里的实现,ChatPage 主要做了以下工作:import AtomicXimport AtomicXCoreimport SwiftUIpublic struct ChatPage: View {...public var body: some View {return VStack(spacing: 0) {self.navigationBarViewDivider().background(self.themeState.colors.strokeColorPrimary)VStack(spacing: 0) {MessageList(conversationID: self.conversation.id,listStyle: self.listStyle,locateMessage: self.locateMessage,onUserClick: { userID inonUserAvatarClick?(userID)})self.messageInputAreaView}.ignoresSafeArea(.keyboard)}.toast(toast)}// Headerprivate var navigationBarView: some View {HStack {Button(action: {onBack?()}) {Image(systemName: "chevron.left").font(.system(size: 18, weight: .semibold)).foregroundColor(themeState.colors.textColorLink)}.padding(.leading, 16)Button(action: {onNavigationAvatarClick?()}) {HStack(spacing: 12) {Avatar(url: conversation.avatarURL,name: conversation.title ?? conversation.conversationID,size: .s)VStack(alignment: .leading, spacing: 2) {Text(conversation.title ?? conversation.conversationID).font(.system(size: 17, weight: .semibold)).foregroundColor(themeState.colors.textColorPrimary).lineLimit(1)if conversation.type == .group {Text("Group Chat").font(.system(size: 12)).foregroundColor(themeState.colors.textColorSecondary)}}}}.buttonStyle(PlainButtonStyle())Spacer()}.frame(height: 44)}// MessageInputprivate var messageInputAreaView: some View {VStack(spacing: 0) {MessageInput(text: $messageText,conversationID: conversation.id,style: inputStyle,onHeightChange: { height inself.inputAreaHeight = height}).padding(.bottom, 8)}}...}

chat/uikit/ContactsPage.swift 文件里的实现,ContactsPage 主要做了以下工作:import AtomicXimport AtomicXCoreimport SwiftUIpublic struct ContactsPage: View {...public var body: some View {VStack(spacing: 0) {headerViewContactList(contactStore: contactStore,onShowMessage: onShowMessage,onContactClick: onContactClick,onGroupClick: onGroupClick,onNewFriendsClick: onNewFriendsClick,onGroupApplicationsClick: onGroupApplicationsClick,onGroupListClick: onGroupListClick,onBlackListClick: onBlackListClick)}.overlay(Group {if showAddContactMenu {VStack {HStack {Spacer()AddContactPopView(onDismiss: {showAddContactMenu = false},onShowAddFriend: {showAddFriend = true},onShowJoinGroup: {showJoinGroup = true}).padding(.trailing, 16).padding(.top, 50)}Spacer()}.background(Color.clear.contentShape(Rectangle()).onTapGesture {showAddContactMenu = false}).animation(.easeInOut(duration: 0.2), value: showAddContactMenu)}}).sheet(isPresented: $showAddFriend) {AddFriendView(contactStore: contactStore)}.sheet(isPresented: $showJoinGroup) {JoinGroupView(contactStore: contactStore)}}private var headerView: some View {HStack {Text(LocalizedChatString("TabContacts")).font(.system(size: 34, weight: .semibold)).tracking(0.3).foregroundColor(themeState.colors.textColorPrimary).padding(.leading, 16)Spacer()Button(action: {showAddContactMenu = true}) {Image(systemName: "plus").font(.system(size: 20)).foregroundColor(themeState.colors.buttonColorPrimaryDefault).frame(width: 28, height: 28).cornerRadius(14)}.padding(.trailing, 16)}.padding(.top, 12).padding(.bottom, 16)}...}
Page | 回调 | 建议跳转逻辑 |
ConversationsPage | onConversationClick: ((NavigationInfo) -> Void)? | 点击会话列表中的会话时触发,建议跳转到聊天页面(ChatPage)。 |
ContactPage | onContactClick: ((AZOrderedListItem) -> Void)? | 点击联系人 cell 时触发,建议跳转联系人详情页面(C2CChatSetting)。 |
| onGroupClick: ((AZOrderedListItem) -> Void)? | 点击群组 cell 时触发,建议跳转群聊页面(ChatPage)。 |
ChatPage | onBack: (() -> Void)? | 点击返回按钮时触发,建议返回上一级页面。 |
| onUserAvatarClick: ((String) -> Void)? | 点击消息中的用户头像时触发,建议跳转用户信息页(C2CChatSetting)。 |
| onNavigationAvatarClick: (() -> Void)? | 点击导航栏中的头像时触发,建议跳转用户信息页(C2CChatSetting)或群聊信息页(GroupChatSetting) |
// 点击会话列表 cell 跳转ConversationsPage(onConversationClick: { navigationInfo inshowChatPage(conversation: navigationInfo.conversation, locateMessage: navigationInfo.locateMessage)})// 点击联系人页面跳转ContactsPage(onContactClick: { user inshowContactDetail(user)},onGroupClick: { group inlet conversation = createConversationFromGroup(group)showChatPage(conversation: conversation)})// ChatNavPage 是对 ChatPage 外层封装了导航栏的页面ChatNavPage(conversation: conversation,locateMessage: currentLocateMessage,onBack: {dismissChatPage()},onContactDelete: {dismissChatPage()},onGroupDelete: {dismissChatPage()},onNavigateToChat: { newConversation in// First dismiss current chat page, then navigate to the new chatdismissChatPage()DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {showChatPage(conversation: newConversation)}})
文档反馈