-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
76 lines (66 loc) · 1.86 KB
/
App.js
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
import React from 'react'
import { StyleSheet, Text, TextInput, Button, View, Clipboard } from 'react-native'
export default class App extends React.Component {
constructor(props) {
super(props)
this.state = { input: '', mode: true }
}
isEven = n => {
return n % 2 === 0
}
isOdd = n => {
return n % 2
}
treatInput = i => i.split('')
.map((letter, index) => {
let number = index + 1
// Ignore Whitespaces
if (letter.indexOf(' ') >= 0) return ' '
// Einfach Magieeee
if ((this.state.mode && this.isEven(number)) || (!this.state.mode && this.isOdd(number))) return letter.toUpperCase()
return letter.toLowerCase()
})
.join('')
render() {
return (
<View style={{ paddingTop: 25, padding: 15 }}>
<Text style={{ fontSize: 50, fontWeight: '800' }}>
{this.state.input
? this.treatInput(this.state.input)
: 'SpongeBob Meme'}
</Text>
<TextInput style={{ height: 40, fontSize: 20 }} placeholder="Type your Meme Text..." onChangeText={text => this.setState({ input: text })} />
<Button
onPress={() =>
this.setState(prevState => ({
mode: !prevState.mode
}))
}
title="Invert"
/>
<View
style={{
borderBottomColor: 'white',
borderBottomWidth: 1,
}}
/>
<Button
onPress={() => {
const i = this.treatInput(this.state.input)
Clipboard.setString(i)
alert(`Copied "${i}"`)
}}
title="Copy"
/>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center'
}
})