-
Notifications
You must be signed in to change notification settings - Fork 0
/
food.js
40 lines (35 loc) · 1.01 KB
/
food.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
import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import { SettingsContext } from './settings/SettingsContext';
class Food extends Component {
static contextType = SettingsContext;
constructor(props) {
super(props);
}
render() {
const x = this.props.position[0];
const y = this.props.position[1];
return (
<View
style={[
styles.food,
{
width: this.props.size,
height: this.props.size,
left: x * this.props.size,
top: y * this.props.size,
backgroundColor: this.context.theme.secondary,
borderColor: this.context.theme.primary,
},
]}
/>
);
}
}
const styles = StyleSheet.create({
food: {
position: 'absolute',
borderWidth: 1,
},
});
export { Food };