8
8
import * as React from 'react' ;
9
9
import { Pressable , SafeAreaView , Text , View } from 'react-native' ;
10
10
import {
11
- Container ,
12
- ConversationDetail ,
11
+ ChatFragment ,
13
12
TextInput ,
14
- useChatContext ,
15
- } from 'react-native-chat-uikit' ;
13
+ useChatSdkContext ,
14
+ } from 'react-native-agora-chat-uikit' ;
15
+
16
+ import { GlobalContainer } from 'react-native-agora-chat-uikit' ;
16
17
17
18
const appKey = 'xxx' ;
18
19
const userId = 'xxx' ;
@@ -25,7 +26,7 @@ function SendMessage() {
25
26
const [ id , setId ] = React . useState ( userId ) ;
26
27
const [ ps , setPs ] = React . useState ( userPs ) ;
27
28
const [ peer , setPeer ] = React . useState ( peerId ) ;
28
- const im = useChatContext ( ) ;
29
+ const im = useChatSdkContext ( ) ;
29
30
30
31
if ( page === 0 ) {
31
32
return (
@@ -55,14 +56,16 @@ function SendMessage() {
55
56
onPress = { ( ) => {
56
57
console . log ( 'test:zuoyu:login' , id , ps ) ;
57
58
im . login ( {
58
- userId : id ,
59
- userToken : ps ,
60
- usePassword : true ,
61
- result : res => {
59
+ id : id ,
60
+ pass : ps ,
61
+ type : 'agora' ,
62
+ onResult : res => {
62
63
console . log ( 'login result' , res ) ;
63
64
console . log ( 'test:zuoyu:error' , res ) ;
64
- if ( res . isOk === true ) {
65
+ if ( res . result === true ) {
65
66
setPage ( 1 ) ;
67
+ } else {
68
+ console . warn ( 'login failed' ) ;
66
69
}
67
70
} ,
68
71
} ) ;
@@ -72,7 +75,9 @@ function SendMessage() {
72
75
< Pressable
73
76
onPress = { ( ) => {
74
77
im . logout ( {
75
- result : ( ) => { } ,
78
+ onResult : result => {
79
+ console . log ( 'logout result' , result ) ;
80
+ } ,
76
81
} ) ;
77
82
} } >
78
83
< Text > { 'Logout' } </ Text >
@@ -83,17 +88,7 @@ function SendMessage() {
83
88
// 聊天页面
84
89
return (
85
90
< SafeAreaView style = { { flex : 1 } } >
86
- < ConversationDetail
87
- convId = { peer }
88
- convType = { 0 }
89
- onBack = { ( ) => {
90
- setPage ( 0 ) ;
91
- im . logout ( {
92
- result : ( ) => { } ,
93
- } ) ;
94
- } }
95
- type = { 'chat' }
96
- />
91
+ < ChatFragment screenParams = { { params : { chatId : peer , chatType : 0 } } } />
97
92
</ SafeAreaView >
98
93
) ;
99
94
} else {
@@ -102,11 +97,12 @@ function SendMessage() {
102
97
}
103
98
104
99
function App ( ) : React . JSX . Element {
105
- // 初始化 UIKit
100
+ // return <View><Text>{'test'}</Text></View>;
106
101
return (
107
- < Container options = { { appKey : appKey , autoLogin : false } } >
102
+ < GlobalContainer
103
+ option = { { appKey : appKey , autoLogin : false , debugModel : true } } >
108
104
< SendMessage />
109
- </ Container >
105
+ </ GlobalContainer >
110
106
) ;
111
107
}
112
108
0 commit comments