Week.js
1.95 KB
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
'use strict';
import React from 'react';
import ReactNative from 'react-native';
const {
Component,
} = React;
const {
StyleSheet,
TouchableOpacity,
Text,
} = ReactNative;
export default class Day extends Component {
render() {
let {week, status, disabled, onWeekPress, width, first} = this.props;
let onPress, textColor, backColor;
if (disabled) {
status = 'disabled';
onPress = null;
} else {
onPress = () => {
onWeekPress({
belongWeek: week,
});
}
}
let borderTopLeftRadius = first ? 5 : 0;
let borderBottomLeftRadius = first ? 5 : 0;
switch (status) {
case 'disabled':
backColor = this.props.dayDisabledBackColor;
textColor = this.props.dayDisabledTextColor;
break;
case 'common':
backColor = this.props.dayCommonBackColor;
textColor = this.props.dayCommonTextColor;
break;
case 'selected':
backColor = this.props.daySelectedBackColor;
textColor = this.props.daySelectedTextColor;
break;
case 'inRange':
backColor = this.props.dayInRangeBackColor;
textColor = this.props.dayInRangeTextColor;
break;
}
return (
<TouchableOpacity
activeOpacity={disabled ? 1 : 1}
style={[styles.common, {backgroundColor: backColor, width: width / 8, height: width / 8, borderTopLeftRadius, borderBottomLeftRadius}]}
onPress={onPress}>
<Text style={{color: textColor}}>{week}</Text>
</TouchableOpacity>
);
}
}
const styles = StyleSheet.create({
common: {
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'white'
}
});