'use strict';
var React = require('react-native');
var Slider = require('../Slider');
var {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
ScrollView,
View,
SliderIOS,
} = React;
var DEFAULT_VALUE = 0.2;
var SliderContainer = React.createClass({
getInitialState() {
return {
value: DEFAULT_VALUE,
};
},
render() {
var value = this.state.value;
return (
{this.props.caption}
{value}
{this._renderChildren()}
)
},
_renderChildren() {
return React.Children.map(this.props.children, (child) => {
if (child.type === Slider
|| child.type === SliderIOS) {
var value = this.state.value;
return React.addons.cloneWithProps(child, {
value: value,
onValueChange: (value) => this.setState({value: value}),
})
} else {
return child;
}
}.bind(this))
},
});
var SliderExample = React.createClass({
getInitialState() {
return {
//value: 0.2,
};
},
render() {
return (
);
},
_addSlider(i, comp) {
var valueKey = 'value' + i;
var value = this.state[valueKey] !== undefined ? this.state[valueKey] : DEFAULT_VALUE;
comp.props.value = value;
comp.props.onValueChange = (value) => this.setState({[valueKey]: value});
return (
{comp}
Value: {value}
);
}
});
var styles = StyleSheet.create({
container: {
margin: 20,
paddingBottom: 20,
justifyContent: 'flex-start',
alignItems: 'stretch',
},
titleContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
},
caption: {
//flex: 1,
},
value: {
flex: 1,
textAlign: 'right',
marginLeft: 10,
}
});
var iosStyles = StyleSheet.create({
container: {
height: 40,
justifyContent: 'center',
},
track: {
height: 2,
borderRadius: 1,
},
thumb: {
marginTop: -16,
position: 'absolute',
width: 30,
height: 30,
borderRadius: 30 / 2,
backgroundColor: 'white',
shadowColor: 'black',
shadowOffset: {width: 0, height: 2},
shadowRadius: 2,
shadowOpacity: 0.35,
}
});
var customStyles2 = StyleSheet.create({
container: {
height: 40,
justifyContent: 'center',
},
track: {
height: 4,
borderRadius: 2,
},
thumb: {
marginTop: -17,
position: 'absolute',
width: 30,
height: 30,
borderRadius: 30 / 2,
backgroundColor: 'white',
borderColor: '#30a935',
borderWidth: 2,
}
});
var customStyles3 = StyleSheet.create({
container: {
height: 40,
justifyContent: 'center',
},
track: {
height: 10,
borderRadius: 5,
backgroundColor: '#d0d0d0',
},
thumb: {
marginTop: -20,
position: 'absolute',
width: 10,
height: 30,
borderRadius: 5,
backgroundColor: '#eb6e1b',
}
});
var customStyles4 = StyleSheet.create({
container: {
height: 40,
justifyContent: 'center',
},
track: {
height: 10,
borderRadius: 4,
backgroundColor: 'white',
shadowColor: 'black',
shadowOffset: {width: 0, height: 1},
shadowRadius: 1,
shadowOpacity: 0.15,
},
thumb: {
marginTop: -15,
position: 'absolute',
width: 20,
height: 20,
backgroundColor: '#f8a1d6',
borderColor: '#a4126e',
borderWidth: 5,
borderRadius: 10,
shadowColor: 'black',
shadowOffset: {width: 0, height: 2},
shadowRadius: 2,
shadowOpacity: 0.35,
}
});
var customStyles5 = StyleSheet.create({
container: {
height: 40,
justifyContent: 'center',
},
track: {
height: 18,
borderRadius: 1,
backgroundColor: '#d5d8e8',
},
thumb: {
marginTop: -24,
position: 'absolute',
width: 20,
height: 30,
borderRadius: 1,
backgroundColor: '#838486',
}
});
var customStyles6 = StyleSheet.create({
container: {
height: 40,
justifyContent: 'center',
},
track: {
height: 14,
borderRadius: 2,
backgroundColor: 'white',
borderColor: '#9a9a9a',
borderWidth: 1,
},
thumb: {
marginTop: -17,
position: 'absolute',
width: 20,
height: 20,
borderRadius: 2,
backgroundColor: '#eaeaea',
borderColor: '#9a9a9a',
borderWidth: 1,
}
});
var customStyles7 = StyleSheet.create({
container: {
height: 40,
justifyContent: 'center',
},
track: {
height: 1,
backgroundColor: '#303030',
},
thumb: {
marginTop: - 31 / 2,
position: 'absolute',
width: 30,
height: 30,
backgroundColor: 'rgba(150, 150, 150, 0.3)',
borderColor: 'rgba(150, 150, 150, 0.6)',
borderWidth: 14,
borderRadius: 15,
}
});
var customStyles8 = StyleSheet.create({
container: {
height: 20,
justifyContent: 'center',
},
track: {
height: 2,
backgroundColor: '#303030',
},
thumb: {
marginTop: - 6,
position: 'absolute',
width: 10,
height: 10,
backgroundColor: '#31a4db',
borderRadius: 10 / 2,
shadowColor: '#31a4db',
shadowOffset: {width: 0, height: 0},
shadowRadius: 2,
shadowOpacity: 1,
}
});
AppRegistry.registerComponent('SliderExample', () => SliderExample);