This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4156ca0
commit 00ef405
Showing
9 changed files
with
282 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React from 'react'; | ||
import { Modal, StyleSheet, Text, View } from 'react-native'; | ||
import { Button, TextInput } from 'react-native-paper'; | ||
import PropTypes from 'prop-types'; | ||
|
||
class NoteModal extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
text: props.initialValue, | ||
}; | ||
} | ||
|
||
render() { | ||
return ( | ||
<Modal animationType="none" visible={true}> | ||
<View style={styles.modalHeader}> | ||
<Button | ||
onPress={() => { | ||
this.props.onClose(this.props.initialValue); | ||
}}> | ||
<Text>Cancel</Text> | ||
</Button> | ||
<Button | ||
onPress={() => { | ||
this.props.onClose(this.state.text); | ||
}}> | ||
<Text>Done</Text> | ||
</Button> | ||
</View> | ||
<View style={styles.modalBody}> | ||
<View> | ||
<TextInput | ||
label="Add a note" | ||
returnKeyLabel="Done" | ||
autoFocus | ||
value={this.state.text} | ||
onChangeText={text => this.setState({ text })} | ||
onSubmitEditing={() => { | ||
this.props.onClose(this.state.text); | ||
}} | ||
/> | ||
<View style={styles.buttonWrapper}> | ||
<Button | ||
raised | ||
primary | ||
dark | ||
onPress={() => { | ||
this.props.onClose(this.state.text); | ||
}}> | ||
<Text>Done</Text> | ||
</Button> | ||
</View> | ||
</View> | ||
</View> | ||
</Modal> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
padding: 20, | ||
backgroundColor: 'white', | ||
}, | ||
modalHeader: { | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
}, | ||
modalBody: { | ||
padding: 20, | ||
}, | ||
buttonWrapper: { | ||
marginTop: 20, | ||
}, | ||
}); | ||
|
||
NoteModal.propTypes = { | ||
initialValue: PropTypes.string, | ||
onClose: PropTypes.func, | ||
}; | ||
|
||
NoteModal.defaultProps = { | ||
initialValue: '', | ||
onClose: () => null, | ||
}; | ||
|
||
export default NoteModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.