-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
113 lines (99 loc) · 2.77 KB
/
index.ios.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
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
103
104
105
106
107
108
109
110
111
112
113
'use strict';
import React from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
NativeModules,
Slider,
TouchableOpacity
} from 'react-native';
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#5A585A',
},
contentcontainer: {
flex: 1,
margin: 20,
},
welcome: {
fontSize: 16,
textAlign: 'center',
marginTop: 20,
marginBottom: 60
},
setKeyboardColorButton: {
marginTop: 20,
alignSelf: 'center',
},
setKeyboardColorText: {
fontSize: 20,
}
});
class DongerBoardApp extends React.Component {
constructor(props) {
super(props);
// These are the initial colors of the key in KeyboardViewController.swift
this.state = {
redValue: .37,
greenValue: .76,
blueValue: .89
};
}
onPressButton() {
// Pass the keyboard color variables to this swift function
NativeModules.KeyboardManager.recordColor(this.state.color,
this.state.redValue,
this.state.greenValue,
this.state.blueValue);
}
// Called by each style component to dynamically update the colors
getColor = function() {
var r = (this.state.redValue * 256).toFixed(0)
var g = (this.state.greenValue * 256).toFixed(0)
var b = (this.state.blueValue * 256).toFixed(0)
return {
color: 'rgba(' + r + ',' + g + ',' + b + ', 1.0)'
}
}
render() {
return (
<View style={styles.container}>
<View style={styles.contentcontainer}>
<Text style={[styles.welcome, this.getColor()]}>
(つ▀¯▀)つ Dongerboard Settings
</Text>
<Text style={this.getColor()}>
Red - {(this.state.redValue * 256).toFixed(0)}
</Text>
<Slider
value={this.state.redValue}
onValueChange={(value) => this.setState({redValue: value})} />
<Text style={this.getColor()}>
Green - {(this.state.greenValue * 256).toFixed(0)}
</Text>
<Slider
value={this.state.greenValue}
onValueChange={(value) => this.setState({greenValue: value})} />
<Text style={this.getColor()}>
Blue - {(this.state.blueValue * 256).toFixed(0)}
</Text>
<Slider
value={this.state.blueValue}
onValueChange={(value) => this.setState({blueValue: value})} />
<TouchableOpacity
style={styles.setKeyboardColorButton}
onPress={this.onPressButton.bind(this)}>
<Text style={[styles.setKeyboardColorText, this.getColor()]}>
Set Keyboard Color
</Text>
</TouchableOpacity>
</View>
</View>
)
}
}
AppRegistry.registerComponent('DongerBoardApp', () => DongerBoardApp);