2022-01-04 18:05:37 +01:00
|
|
|
import React, { Component } from 'react';
|
2022-01-08 00:02:07 +01:00
|
|
|
import { Text, Button, Modal, StyleSheet, TextInput, View } from 'react-native';
|
2022-01-04 18:05:37 +01:00
|
|
|
|
|
|
|
export default class NewQuote extends Component {
|
2022-01-08 00:02:07 +01:00
|
|
|
state = { content: null, author: null } //Inizialer Zustand
|
2022-01-04 18:05:37 +01:00
|
|
|
render() {
|
2022-01-21 23:54:30 +01:00
|
|
|
const { visible, onSave } = this.props; // Einfachere strukturierung, ansonsten z.b this.probs.onSave
|
2022-01-08 00:02:07 +01:00
|
|
|
const { content, author } = this.state;
|
2022-01-04 18:05:37 +01:00
|
|
|
return (
|
|
|
|
//Neuer Screen
|
|
|
|
<Modal
|
2022-01-08 00:02:07 +01:00
|
|
|
visible={visible}
|
2022-01-21 23:54:30 +01:00
|
|
|
onRequestClose={() => {
|
|
|
|
this.setState({ content: null, author: null });
|
|
|
|
onSave(null, null);
|
|
|
|
}} //Wird nur für Android benötigt
|
2022-01-04 18:05:37 +01:00
|
|
|
animationType='slide'>
|
|
|
|
<View style={styles.container}>
|
2022-01-08 00:02:07 +01:00
|
|
|
<TextInput
|
|
|
|
style={[styles.textInput, { height: 150 }]} //Einzelne Styleelemente im Array festgelegt
|
|
|
|
multiline={true}
|
|
|
|
placeholder='Zitat'
|
|
|
|
onChangeText={text => this.setState({ content: text })} />
|
|
|
|
<Text title='TESTFELD'>
|
|
|
|
{this.state.content}
|
|
|
|
</Text>
|
|
|
|
<TextInput
|
|
|
|
style={styles.textInput}
|
|
|
|
placeholder='Autor/in'
|
|
|
|
onChangeText={text => this.setState({ author: text })} />
|
|
|
|
<View
|
|
|
|
style={styles.saveButton}>
|
2022-01-04 18:05:37 +01:00
|
|
|
<Button
|
|
|
|
title="Save"
|
2022-01-21 23:54:30 +01:00
|
|
|
onPress={() => {
|
|
|
|
this.setState({ content: null, author: null });
|
|
|
|
onSave(content, author);
|
|
|
|
}
|
|
|
|
} />
|
2022-01-04 18:05:37 +01:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
backgroundColor: '#eee',
|
|
|
|
alignItems: 'center', //FlexBox Layout
|
2022-01-08 00:02:07 +01:00
|
|
|
justifyContent: 'center'
|
2022-01-04 18:05:37 +01:00
|
|
|
},
|
|
|
|
saveButton: {
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 5,
|
|
|
|
|
|
|
|
},
|
|
|
|
textInput: {
|
|
|
|
borderWidth: 1,
|
|
|
|
borderColor: 'deepskyblue',
|
|
|
|
borderRadius: 4,
|
|
|
|
width: '80%', //Breite
|
|
|
|
marginBottom: 20, // Abstand
|
|
|
|
fontSize: 20, // Schriftgröße
|
|
|
|
padding: 10,
|
|
|
|
height: 50,
|
|
|
|
}
|
|
|
|
});
|