Skip to content

Instantly share code, notes, and snippets.

@ysfzrn
Created October 2, 2017 07:18
Show Gist options
  • Save ysfzrn/6c4a84bcde918f37180ae06303cb42c9 to your computer and use it in GitHub Desktop.
Save ysfzrn/6c4a84bcde918f37180ae06303cb42c9 to your computer and use it in GitHub Desktop.
//src/components/segment.js
import React, { Component } from "react";
import { View, Text, StyleSheet } from "react-native";
import SharedStyle from "../utils/sharedStyle";
// create a component
class Segment extends Component {
render() {
const customStyle = {
left: this.props.x,
top: this.props.y
};
return <View style={[styles.container, customStyle]} />;
}
}
// define your styles
const styles = StyleSheet.create({
container: {
position: "absolute",
width: SharedStyle.segment.width,
height: SharedStyle.segment.height,
backgroundColor: SharedStyle.color.snake,
borderWidth: SharedStyle.segment.borderWidth,
borderColor: SharedStyle.segment.borderColor
}
});
//make this component available to the app
export default Segment;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment