forked from unomed-dev/react-native-matrix-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
43 lines (36 loc) · 1.25 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import * as React from 'react';
import { StyleSheet, View, Text, TextInput, Button } from 'react-native';
import { ClientBuilder } from '@unomed/react-native-matrix-sdk';
export default function App() {
const [homeserver, setHomeserver] = React.useState("https://matrix.org");
const [status, setStatus] = React.useState("");
const updateHomeserverLoginDetails = React.useCallback(async () => {
if (!homeserver.length) {
setStatus("");
return;
}
try {
const client = await (new ClientBuilder()).homeserverUrl(homeserver).build();
const loginDetails = await client.homeserverLoginDetails();
setStatus(`url: ${loginDetails.url()}\n`
+ `supportsOidcLogin: ${loginDetails.supportsOidcLogin()}\n`
+ `supportsPasswordLogin: ${loginDetails.supportsPasswordLogin()}`);
} catch (error) {
setStatus(`${error}`);
}
}, [homeserver]);
return (
<View style={styles.container}>
<TextInput value={homeserver} onChangeText={setHomeserver}></TextInput>
<Button title='Go' onPress={updateHomeserverLoginDetails}></Button>
<Text>{status}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}
});