React Native
export function CometChatUI() { return <View></View>; }
CometChatTabs
import { CometChatTabs } from "@cometchat/chat-uikit-react-native"; export function CometChatUI() { return ( <View style={{ marginTop: 10, height: "100%", width: "100%" }}> <CometChatTabs /> </View> ); }
CometChatConversationsWithMessages
import { CometChatUsersWithMessages, CometChatGroupsWithMessages, CometChatConversationsWithMessages, CometChatTabs, } from "@cometchat/chat-uikit-react-native"; export function CometChatUI() { const tabItemStyle: TabItemStyleInterface = { activeBackgroundColor: "#6851D6", }; const chatsTab: TabItem = { id: "chats", //iconURL: <custom icon>, title: "Chats", style: tabItemStyle, isActive: true, childView: () => <CometChatConversationsWithMessages />, }; const usersTab: TabItem = { id: "users", //iconURL: <custom icon>, title: "Users", style: tabItemStyle, childView: () => <CometChatUsersWithMessages />, }; const groupsTab: TabItem = { id: "groups", title: "Groups", //iconURL: <custom icon>, style: tabItemStyle, childView: () => <CometChatGroupsWithMessages />, }; const tabs = [chatsTab, usersTab, groupsTab]; const tabsStyle = { titleTextFont: theme.typography.heading, titleTextColor: theme.palette.getAccent(), tabHeight: 36, tabBorderRadius: 18, activeTabBackgroundColor: theme.palette.getPrimary(), activeTabTitleTextColor: theme.palette.getSecondary(), backgroundColor: theme.palette.getBackgroundColor(), borderRadius: 18, backIconTint: theme.palette.getPrimary(), selectionIconTint: theme.palette.getPrimary(), tabBackgroundColor: theme.palette.getAccent200(), tabTitleTextColor: theme.palette.getAccent(), tabTitleTextFont: theme.typography.text1, }; return ( <SafeAreaView style={{ flex: 1 }}> <CometChatContextProvider theme={theme}> <View style={{ marginTop: 10, height: "100%", width: "100%" }}> <CometChatTabs tabs={tabs} tabAlignment="top" keepAlive={true} style={tabsStyle} ></CometChatTabs> </View> </CometChatContextProvider> </SafeAreaView> ); }
import { CometChatUI } from "./CometChatUI"; function App() { const theme = new CometChatTheme({}); theme.palette.setPrimary({ light: "#6851D6", dark: "#6851D6" }); const [currentTheme, setCurrentTheme] = useState(theme); return ( <SafeAreaView style={{ flex: 1 }}> <CometChatContextProvider theme={currentTheme}> <CometChatUI /> </CometChatContextProvider> </SafeAreaView> ); } export default App;