Commit f439fdb8 authored by Linden Darling's avatar Linden Darling

Added copy-to-clipboard feature for token, productivity++

parent 689d7872
...@@ -9,7 +9,8 @@ import { ...@@ -9,7 +9,8 @@ import {
StyleSheet, StyleSheet,
Text, Text,
TouchableOpacity, TouchableOpacity,
View View,
Clipboard
} from 'react-native'; } from 'react-native';
import PushController from "./PushController"; import PushController from "./PushController";
...@@ -20,12 +21,13 @@ export default class App extends Component { ...@@ -20,12 +21,13 @@ export default class App extends Component {
super(props); super(props);
this.state = { this.state = {
token: "" token: "",
tokenCopyFeedback: ""
} }
} }
render() { render() {
let { token } = this.state; let { token, tokenCopyFeedback } = this.state;
return ( return (
<View style={styles.container}> <View style={styles.container}>
...@@ -36,10 +38,14 @@ export default class App extends Component { ...@@ -36,10 +38,14 @@ export default class App extends Component {
Welcome to Simple Fcm Client! Welcome to Simple Fcm Client!
</Text> </Text>
<Text style={styles.instructions}> <Text selectable={true} onPress={() => this.setClipboardContent(this.state.token)} style={styles.instructions}>
Token: {this.state.token} Token: {this.state.token}
</Text> </Text>
<Text style={styles.feedback}>
{this.state.tokenCopyFeedback}
</Text>
<TouchableOpacity onPress={() => firebaseClient.sendNotification(token)} style={styles.button}> <TouchableOpacity onPress={() => firebaseClient.sendNotification(token)} style={styles.button}>
<Text style={styles.buttonText}>Send Notification</Text> <Text style={styles.buttonText}>Send Notification</Text>
</TouchableOpacity> </TouchableOpacity>
...@@ -54,6 +60,16 @@ export default class App extends Component { ...@@ -54,6 +60,16 @@ export default class App extends Component {
</View> </View>
); );
} }
setClipboardContent(text) {
Clipboard.setString(text);
this.setState({tokenCopyFeedback: "Token copied to clipboard."});
setTimeout(() => {this.clearTokenCopyFeedback()}, 2000);
}
clearTokenCopyFeedback() {
this.setState({tokenCopyFeedback: ""});
}
} }
const styles = StyleSheet.create({ const styles = StyleSheet.create({
...@@ -71,7 +87,12 @@ const styles = StyleSheet.create({ ...@@ -71,7 +87,12 @@ const styles = StyleSheet.create({
instructions: { instructions: {
textAlign: 'center', textAlign: 'center',
color: '#333333', color: '#333333',
marginBottom: 5, marginBottom: 2,
},
feedback: {
textAlign: 'center',
color: '#996633',
marginBottom: 3,
}, },
button: { button: {
backgroundColor: "teal", backgroundColor: "teal",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment