-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWelcome.js
More file actions
102 lines (97 loc) · 3.28 KB
/
Copy pathWelcome.js
File metadata and controls
102 lines (97 loc) · 3.28 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import React, { Component } from 'react';
import {View, Text, WebView, Button, TextInput, Switch, StyleSheet} from 'react-native';
import {Picker} from '@react-native-picker/picker';
import AsyncStorage from '@react-native-community/async-storage';
import config from './config';
const {defaultServer} = config;
type Props = {};
export default class Welcome extends Component<Props> {
constructor(props) {
super(props);
this.state = {unsavedServer: props.baseURL}
}
save({baseURL}) {
const stored = AsyncStorage.setItem('FWEI.baseURL', baseURL);
this.props.onSave(baseURL);
return stored;
}
render() {
const {onClose, baseURL} = this.props;
const {unsavedServer, customServer} = this.state;
return (<View>
<Text style={styles.header}>Willkommen!</Text>
<Text style={styles.subheader}>Bitte wählen Sie ihren Server aus:</Text>
{customServer || <Picker style={styles.picker}
selectedValue={unsavedServer}
onValueChange={(itemValue, itemIndex) => this.setState({unsavedServer: itemValue})}>
{defaultServer.map((server) => <Picker.Item label={server.caption} key={server.caption} value={server.url}/>)}
</Picker>
}
<View style={styles.customServer}>
<View style={styles.toggleView}>
<Text style={styles.toggleText}>Eigener Server</Text>
<View>
<Switch
style={styles.toggleSwitch}
disabled={false}
value={customServer}
onValueChange={(value) => this.setState({customServer: value})}
/>
</View>
</View>
{customServer && (<TextInput
style={styles.customServerInput}
autoCapitalize = 'none'
placeholder="Server"
clearButtonMode="always"
value={unsavedServer}
onChangeText={(update) => this.setState({unsavedServer: update.toLowerCase()})}
/>)}
</View>
<Button flex title="Server übernehmen" onPress={() => this.save({baseURL: unsavedServer})} />
<Text style={styles.infoText}>Die Servereinstellung kann später jederzeit über das Optionsmenü geändert werden.</Text>
</View>);
}
}
const styles = StyleSheet.create({
header: {
color: 'white',
backgroundColor: 'black',
fontWeight: 'bold',
fontSize: 30,
padding: 5
},
subheader: {
fontSize: 24,
padding: 5
},
picker: {
height: 200
},
toggleText: {
height: 24,
fontSize: 22
},
toggleSwitch: {
height: 24
},
customServer: {
padding: 5,
paddingTop: 30,
paddingBottom: 30
},
toggleView: {
flexDirection: 'row',
justifyContent: 'space-between'
},
infoText: {
fontSize: 16,
padding: 5,
paddingTop: 20
},
customServerInput: {
paddingTop: 20,
height: 40,
fontSize: 24
}
});