-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ios.js
More file actions
197 lines (174 loc) · 5.3 KB
/
index.ios.js
File metadata and controls
197 lines (174 loc) · 5.3 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import React, {Component} from 'react'
import {Dimensions, processColor, requireNativeComponent} from 'react-native'
import _ from 'lodash'
import {settingsLoadSuccess} from '../../App/Modules/User/Redux/ContactRedux'
import PropTypes from 'prop-types'
function convertProps(props) {
if (props.fillDefaultColorDates) {
const items = props.fillDefaultColorDates;
props.fillDefaultColorDates = {};
props.subtitleDefaultColorDates = {};
props.subtitleForDates = {};
_.each(items, (item, key) => {
props.fillDefaultColorDates[key] = processColor(item.color);
if (item.textColor)
props.subtitleDefaultColorDates[key] = item.textColor;
if (item.text)
props.subtitleForDates[key] = item.text;
}
);
props.lastUpdate=(new Date()).getTime()
}
let allKeys = [
'fillSelectionColorDates',
'borderDefaultColorDates',
'borderSelectionColorDates',
'titleDefaultColorDates',
'titleSelectionColorDates',
'subtitleDefaultColorDates',
'subtitleSelectionColorDates'
];
_.each(allKeys, (key) => {
if (!props[key]) {
return
}
_.each(props[key], (color, date) => {
props[key][date] = processColor(color)
})
})
if (props.today) {
props.today = props
.today
.getTime()
}
if (props.dateBounds) {
_.each(props.dateBounds, (value, index) => {
if (value) {
props.dateBounds[index] = value.getTime()
}
})
}
console.log("=====RNFSCalendar",props);
}
export default class FSCalendar extends Component {
constructor(props) {
super(props)
this._props = _.assign({}, this.props)
convertProps(this._props)
const dt= new Date();
this.props.onMonthChange && this
.props
.onMonthChange(new Date(dt.getFullYear(),dt.getMonth(),1))
}
static propTypes = {
width: PropTypes.number,
height: PropTypes.number,
hideHeader: PropTypes.bool, // 是否隐藏头部
hideWeekDay: PropTypes.bool, // 是否隐藏顶部的星期
scrollEnabled: PropTypes.bool,
today:PropTypes
.instanceOf(Date),
lastUpdate:PropTypes.number,
dateBounds: PropTypes
.arrayOf(Date),
scopeMode: PropTypes
.oneOf(['month', 'week']),
borderRadius: PropTypes.number,
subtitleTextSize: PropTypes.number,
// 回调函数
onSelectDate: PropTypes.func,
onDeselectDate: PropTypes.func,
onMonthChange: PropTypes.func,
// 颜色样式
headerTitleColor: PropTypes.string,
weekdayTextColor: PropTypes.string,
titleDefaultColor: PropTypes.string,
titleSelectionColor: PropTypes.string,
subtitleDefaultColor: PropTypes.string,
subtitleSelectionColor: PropTypes.string,
titleWeekendColor: PropTypes.string,
subtitleWeekendColor: PropTypes.string,
titleTodayColor: PropTypes.string,
subtitleTodayColor: PropTypes.string,
titlePlaceholderColor: PropTypes.string,
subtitlePlaceholderColor: PropTypes.string,
todayColor: PropTypes.string,
todaySelectionColor: PropTypes.string,
eventColor: PropTypes.string,
eventDefaultColor: PropTypes.string,
eventSelectionColor: PropTypes.string,
borderDefaultColor: PropTypes.string,
borderSelectionColor: PropTypes.string,
selectionColor: PropTypes.string,
// 针对每个单独的日期设置样式
fillDefaultColorDates: PropTypes.object,
fillSelectionColorDates: PropTypes.object,
borderDefaultColorDates: PropTypes.object,
borderSelectionColorDates: PropTypes.object,
cellShapeDates: PropTypes.objectOf(PropTypes.number),
titleDefaultColorDates: PropTypes.object,
titleSelectionColorDates: PropTypes.object,
subtitleDefaultColorDates: PropTypes.object,
subtitleSelectionColorDates: PropTypes.object,
subtitleForDates: PropTypes.object,
// 头部样式
headerMinimumDissolvedAlpha: PropTypes.number,
headerDateFormat: PropTypes.string
}
static defaultProps = {
width: Dimensions
.get('window')
.width,
height: 280, // scopeMode 为 month 建议高度 280, 为 week 建议高度 70
hideHeader: false,
hideWeekDay: false,
scrollEnabled: true,
today: null,
scopeMode: 'month',
borderRadius: 0.15,
lastUpdate:(new Date()).getTime()
}
componentWillReceiveProps(nextProps) {
this._props = _.assign({}, nextProps)
convertProps(this._props)
}
_onSelectDate(ev) {
this.props.onSelectDate && this
.props
.onSelectDate(new Date(ev.nativeEvent.date))
}
_onDeselectDate(ev) {
this.props.onDeselectDate && this
.props
.onDeselectDate(new Date(ev.nativeEvent.date))
}
_onCurrentPageChange(ev) {
this.props.onMonthChange && this
.props
.onMonthChange(new Date(ev.nativeEvent.date))
}
render() {
const {
onSelectDate,
onDeselectDate,
onMonthChange,
...nativeProps
} = this._props;
return (<RNFSCalendar
onSelectDate={(ev) => this._onSelectDate(ev)}
onDeselectDate={(ev) => this._onDeselectDate(ev)}
onCurrentPageChange={(ev) => this._onCurrentPageChange(ev)}
{ ...nativeProps }/>)
}
}
const RNFSCalendar = requireNativeComponent('RNFSCalendar', {
propTypes: {
...FSCalendar.propTypes,
onCurrentPageChange: PropTypes.func,
today: PropTypes.number
}
})
export const CellShape = {
Circle: 0,
Rectangle: 1
}