@momo-kits/calendar 0.0.56-rc.1 → 0.0.57-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/Calendar.js +54 -12
- package/src/CalendarPro.js +25 -30
- package/src/Day/index.js +79 -28
- package/src/Day/style.js +27 -29
- package/src/HeaderControl.js +6 -5
- package/src/Month/index.js +24 -19
- package/src/MonthList.js +4 -2
- package/src/TabHeader.js +7 -13
- package/src/calendarPicker/Day.js +1 -2
- package/src/calendarPicker/WeekDaysLabels.js +2 -2
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/calendar",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@momo-kits/date-picker": "latest",
|
|
8
|
-
"moment": "^2.24.0"
|
|
8
|
+
"moment": "^2.24.0",
|
|
9
|
+
"@momo-platform/versions": "4.0.2"
|
|
9
10
|
},
|
|
10
11
|
"peerDependencies": {
|
|
11
12
|
"react": "16.9.0",
|
package/src/Calendar.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
View,
|
|
5
|
+
ScrollView,
|
|
6
|
+
Platform,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
Dimensions,
|
|
9
|
+
} from 'react-native';
|
|
4
10
|
import moment from 'moment';
|
|
5
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
Text,
|
|
13
|
+
SwitchLanguage,
|
|
14
|
+
Colors,
|
|
15
|
+
Spacing,
|
|
16
|
+
Radius,
|
|
17
|
+
ScaleSize,
|
|
18
|
+
} from '@momo-kits/core';
|
|
6
19
|
import Switch from '@momo-kits/switch';
|
|
7
20
|
import CalendarPro from './CalendarPro';
|
|
8
21
|
import TabHeader from './TabHeader';
|
|
@@ -23,6 +36,7 @@ class Calendar extends Component {
|
|
|
23
36
|
}
|
|
24
37
|
: {};
|
|
25
38
|
this.tabSelected = 0;
|
|
39
|
+
|
|
26
40
|
this.selectedDate = props.selectedDate
|
|
27
41
|
? moment(props.selectedDate)
|
|
28
42
|
: moment();
|
|
@@ -108,14 +122,19 @@ class Calendar extends Component {
|
|
|
108
122
|
if (
|
|
109
123
|
this.doubleDate.first &&
|
|
110
124
|
this.doubleDate.second &&
|
|
111
|
-
this.selectedDate <= this.doubleDate.
|
|
125
|
+
this.selectedDate <= this.doubleDate.first
|
|
112
126
|
) {
|
|
113
127
|
this.doubleDate.first = this.selectedDate;
|
|
128
|
+
this.doubleDate.second = null;
|
|
114
129
|
this.tabSelected = 1;
|
|
115
130
|
this.cellHeader1.current.updateView(
|
|
116
131
|
this.selectedDate,
|
|
117
132
|
this.tabSelected === 0,
|
|
118
133
|
);
|
|
134
|
+
this.cellHeader2.current.updateView(
|
|
135
|
+
this.doubleDate.second,
|
|
136
|
+
this.tabSelected === 1,
|
|
137
|
+
);
|
|
119
138
|
this.cellHeader2.current.setActiveTab(this.tabSelected === 1);
|
|
120
139
|
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
121
140
|
this.doubleDate.first,
|
|
@@ -173,10 +192,13 @@ class Calendar extends Component {
|
|
|
173
192
|
|
|
174
193
|
processDateSecond() {
|
|
175
194
|
const { onDateChange, onCTAStateChange } = this.props;
|
|
176
|
-
if (
|
|
195
|
+
if (
|
|
196
|
+
this.cellHeader2.current &&
|
|
197
|
+
this.selectedDate >= this.doubleDate.first
|
|
198
|
+
) {
|
|
199
|
+
this.doubleDate.second = this.selectedDate;
|
|
177
200
|
this.cellHeader2.current.updateView(this.selectedDate, false);
|
|
178
201
|
this.cellHeader1.current.setActiveTab(true);
|
|
179
|
-
this.doubleDate.second = this.selectedDate;
|
|
180
202
|
this.tabSelected = 0;
|
|
181
203
|
this.calendarPicker.current.setDoubleDateAndTabIndex(
|
|
182
204
|
this.doubleDate.first,
|
|
@@ -201,6 +223,12 @@ class Calendar extends Component {
|
|
|
201
223
|
// };
|
|
202
224
|
// onDateChange(cloned);
|
|
203
225
|
}
|
|
226
|
+
} else {
|
|
227
|
+
this.doubleDate.first = this.selectedDate;
|
|
228
|
+
this.doubleDate.second = null;
|
|
229
|
+
|
|
230
|
+
this.cellHeader1.current.updateView(this.selectedDate, false);
|
|
231
|
+
this.cellHeader2.current.updateView(null, false);
|
|
204
232
|
}
|
|
205
233
|
}
|
|
206
234
|
|
|
@@ -416,10 +444,19 @@ class Calendar extends Component {
|
|
|
416
444
|
maxDate,
|
|
417
445
|
doubleDate,
|
|
418
446
|
isHideHeaderPanel,
|
|
447
|
+
style,
|
|
419
448
|
} = this.props;
|
|
420
449
|
const { isDoubleDateMode } = this.state;
|
|
450
|
+
const { width } = Dimensions.get('window');
|
|
421
451
|
return (
|
|
422
|
-
<ScrollView
|
|
452
|
+
<ScrollView
|
|
453
|
+
style={[
|
|
454
|
+
styles.scrollView,
|
|
455
|
+
{
|
|
456
|
+
width: width - ScaleSize(24),
|
|
457
|
+
},
|
|
458
|
+
style,
|
|
459
|
+
]}>
|
|
423
460
|
<View
|
|
424
461
|
style={{
|
|
425
462
|
backgroundColor: Colors.black_01,
|
|
@@ -429,6 +466,7 @@ class Calendar extends Component {
|
|
|
429
466
|
{!isHideHeaderPanel && this.renderHeaderPanel()}
|
|
430
467
|
</View>
|
|
431
468
|
<CalendarPro
|
|
469
|
+
priceList={priceList}
|
|
432
470
|
ref={this.calendarPicker}
|
|
433
471
|
startDate={doubleDate?.first}
|
|
434
472
|
endDate={doubleDate?.second}
|
|
@@ -437,7 +475,6 @@ class Calendar extends Component {
|
|
|
437
475
|
selectedDate={this.selectedDate}
|
|
438
476
|
isShowLunar={isShowLunar}
|
|
439
477
|
onCallbackCalendar={onCallbackCalendar}
|
|
440
|
-
priceList={priceList}
|
|
441
478
|
labelFrom={labelFrom}
|
|
442
479
|
labelTo={labelTo}
|
|
443
480
|
isHideLabel={isHideLabel}
|
|
@@ -481,6 +518,7 @@ Calendar.propTypes = {
|
|
|
481
518
|
PropTypes.string,
|
|
482
519
|
PropTypes.instanceOf(Date),
|
|
483
520
|
]),
|
|
521
|
+
style: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
484
522
|
};
|
|
485
523
|
|
|
486
524
|
Calendar.defaultProps = {
|
|
@@ -490,11 +528,10 @@ Calendar.defaultProps = {
|
|
|
490
528
|
|
|
491
529
|
const styles = StyleSheet.create({
|
|
492
530
|
viewPanel_2: {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
paddingHorizontal: Spacing.M,
|
|
531
|
+
height: 50,
|
|
532
|
+
marginHorizontal: 12,
|
|
533
|
+
marginTop: 6,
|
|
534
|
+
flexDirection: 'row',
|
|
498
535
|
},
|
|
499
536
|
viewPanel: {
|
|
500
537
|
height: 50,
|
|
@@ -521,4 +558,9 @@ const styles = StyleSheet.create({
|
|
|
521
558
|
paddingHorizontal: 12,
|
|
522
559
|
paddingVertical: 8,
|
|
523
560
|
},
|
|
561
|
+
scrollView: {
|
|
562
|
+
flex: 1,
|
|
563
|
+
backgroundColor: 'transparent',
|
|
564
|
+
alignSelf: 'center',
|
|
565
|
+
},
|
|
524
566
|
});
|
package/src/CalendarPro.js
CHANGED
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
} from 'react-native';
|
|
12
12
|
import Moment from 'moment';
|
|
13
13
|
import {
|
|
14
|
-
Text,
|
|
15
14
|
SwitchLanguage,
|
|
16
15
|
LocalizedStrings,
|
|
17
|
-
Colors,
|
|
18
16
|
Image,
|
|
19
17
|
IconSource,
|
|
18
|
+
Text,
|
|
19
|
+
Colors,
|
|
20
20
|
Spacing,
|
|
21
21
|
Radius,
|
|
22
22
|
} from '@momo-kits/core';
|
|
@@ -251,7 +251,7 @@ export default class CalendarPro extends Component {
|
|
|
251
251
|
onPressNextArrow={this.onPressNextArrow}
|
|
252
252
|
/>
|
|
253
253
|
<View style={styles.blueSeperator} />
|
|
254
|
-
<View
|
|
254
|
+
<View>
|
|
255
255
|
<View style={styles.viewDay}>
|
|
256
256
|
{[1, 2, 3, 4, 5, 6, 7].map((item) => (
|
|
257
257
|
<Text
|
|
@@ -293,10 +293,15 @@ export default class CalendarPro extends Component {
|
|
|
293
293
|
</View>
|
|
294
294
|
</View>
|
|
295
295
|
{!isOffLunar && (
|
|
296
|
-
<View style={styles.viewLunar}>
|
|
296
|
+
<View style={[styles.viewLunar]}>
|
|
297
297
|
<TouchableWithoutFeedback
|
|
298
298
|
onPress={this.toggleLunarDate}>
|
|
299
299
|
<Image
|
|
300
|
+
tintColor={
|
|
301
|
+
showLunar
|
|
302
|
+
? Colors.pink_05_b
|
|
303
|
+
: Colors.black_17
|
|
304
|
+
}
|
|
300
305
|
source={
|
|
301
306
|
showLunar
|
|
302
307
|
? IconSource.ic_checkbox_checked_24
|
|
@@ -305,11 +310,11 @@ export default class CalendarPro extends Component {
|
|
|
305
310
|
style={styles.iconSelected}
|
|
306
311
|
/>
|
|
307
312
|
</TouchableWithoutFeedback>
|
|
308
|
-
<Text
|
|
313
|
+
<Text
|
|
309
314
|
style={styles.txtLunar}
|
|
310
315
|
onPress={this.toggleLunarDate}>
|
|
311
316
|
{SwitchLanguage.showLunar}
|
|
312
|
-
</Text
|
|
317
|
+
</Text>
|
|
313
318
|
</View>
|
|
314
319
|
)}
|
|
315
320
|
|
|
@@ -327,12 +332,13 @@ export default class CalendarPro extends Component {
|
|
|
327
332
|
const labelHighlight = showLunar
|
|
328
333
|
? item.highlight || ''
|
|
329
334
|
: '';
|
|
330
|
-
const labelDate =
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
:
|
|
335
|
+
const labelDate = `${
|
|
336
|
+
item.day > 9 ? item.day : `0${item.day}`
|
|
337
|
+
}/${
|
|
338
|
+
item.month > 9
|
|
339
|
+
? item.month
|
|
340
|
+
: `0${item.month}`
|
|
341
|
+
}`;
|
|
336
342
|
return (
|
|
337
343
|
<View
|
|
338
344
|
style={styles.row}
|
|
@@ -344,16 +350,6 @@ export default class CalendarPro extends Component {
|
|
|
344
350
|
<Text.SubTitle
|
|
345
351
|
style={styles.subTextLunar}>
|
|
346
352
|
{`${labelHoliday} `}
|
|
347
|
-
{labelHighlight ? (
|
|
348
|
-
<Text
|
|
349
|
-
style={{
|
|
350
|
-
color: Colors.red_05,
|
|
351
|
-
}}>
|
|
352
|
-
{labelHighlight}
|
|
353
|
-
</Text>
|
|
354
|
-
) : (
|
|
355
|
-
''
|
|
356
|
-
)}
|
|
357
353
|
</Text.SubTitle>
|
|
358
354
|
</View>
|
|
359
355
|
);
|
|
@@ -390,7 +386,7 @@ CalendarPro.defaultProps = {
|
|
|
390
386
|
|
|
391
387
|
const styles = StyleSheet.create({
|
|
392
388
|
row: { flexDirection: 'row' },
|
|
393
|
-
txtMonthLunar: { color: Colors.red_05,
|
|
389
|
+
txtMonthLunar: { color: Colors.red_05, marginRight: Spacing.S },
|
|
394
390
|
subTextLunar: {
|
|
395
391
|
// fontSize: 12,
|
|
396
392
|
color: '#222222',
|
|
@@ -402,21 +398,20 @@ const styles = StyleSheet.create({
|
|
|
402
398
|
txtLunar: {
|
|
403
399
|
paddingLeft: 6,
|
|
404
400
|
color: '#222222',
|
|
405
|
-
|
|
406
|
-
lineHeight: 14,
|
|
401
|
+
fontSize: 14,
|
|
407
402
|
},
|
|
408
403
|
viewLunar: {
|
|
409
404
|
flexDirection: 'row',
|
|
410
405
|
alignItems: 'center',
|
|
411
|
-
marginHorizontal:
|
|
412
|
-
|
|
413
|
-
|
|
406
|
+
marginHorizontal: Spacing.M,
|
|
407
|
+
borderTopWidth: 1,
|
|
408
|
+
paddingTop: Spacing.M,
|
|
414
409
|
borderStyle: 'solid',
|
|
415
|
-
borderColor:
|
|
410
|
+
borderColor: Colors.black_04,
|
|
416
411
|
},
|
|
417
412
|
viewDate: {},
|
|
418
413
|
textDay: {
|
|
419
|
-
|
|
414
|
+
fontSize: 12,
|
|
420
415
|
lineHeight: 16,
|
|
421
416
|
width: (widthScreen - 38) / 7,
|
|
422
417
|
textAlign: 'center',
|
package/src/Day/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
|
-
import { View, TouchableHighlight
|
|
5
|
-
import {
|
|
4
|
+
import { View, TouchableHighlight } from 'react-native';
|
|
5
|
+
import { Spacing, SwitchLanguage, Colors, Text } from '@momo-kits/core';
|
|
6
6
|
import style from './style';
|
|
7
7
|
|
|
8
8
|
class Day extends Component {
|
|
@@ -70,13 +70,14 @@ class Day extends Component {
|
|
|
70
70
|
this.isLunarHoliday = isLunarHoliday;
|
|
71
71
|
this.isLunarDayStart = this.lunarDate && this.lunarDate.lunarDay === 1;
|
|
72
72
|
this.isSolarHoliday = isSolarHoliday;
|
|
73
|
-
this.isInScope =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
this.isInScope = true;
|
|
74
|
+
// isDoubleDateMode
|
|
75
|
+
// ? tabSelected === 0 ||
|
|
76
|
+
// (tabSelected === 1 &&
|
|
77
|
+
// startDate &&
|
|
78
|
+
// date &&
|
|
79
|
+
// date.isSameOrAfter(startDate, 'day'))
|
|
80
|
+
// : true;
|
|
80
81
|
return this.isFocus || this.diffPrice;
|
|
81
82
|
};
|
|
82
83
|
|
|
@@ -144,13 +145,18 @@ class Day extends Component {
|
|
|
144
145
|
<TouchableHighlight
|
|
145
146
|
style={[
|
|
146
147
|
style.day,
|
|
148
|
+
{
|
|
149
|
+
paddingVertical: !!price
|
|
150
|
+
? Spacing.XS
|
|
151
|
+
: Spacing.S,
|
|
152
|
+
},
|
|
147
153
|
(this.isStart || this.isEnd) && style.focused,
|
|
148
154
|
]}
|
|
149
155
|
underlayColor="rgba(255, 255, 255, 0.35)"
|
|
150
156
|
onPress={this.chooseDay}>
|
|
151
157
|
<>
|
|
152
158
|
{this.lunarDate && this.showLunar && (
|
|
153
|
-
<Text
|
|
159
|
+
<Text.Caption
|
|
154
160
|
style={[
|
|
155
161
|
style.lunarDayText,
|
|
156
162
|
(this.isLunarHoliday ||
|
|
@@ -162,24 +168,58 @@ class Day extends Component {
|
|
|
162
168
|
{this.lunarDate.lunarDay === 1
|
|
163
169
|
? `${this.lunarDate.lunarDay}/${this.lunarDate.lunarMonth}`
|
|
164
170
|
: this.lunarDate.lunarDay}
|
|
165
|
-
</Text>
|
|
171
|
+
</Text.Caption>
|
|
166
172
|
)}
|
|
167
|
-
<Text
|
|
173
|
+
<Text.Title
|
|
168
174
|
style={[
|
|
169
175
|
style.dayText,
|
|
176
|
+
{ paddingTop: !!price ? 4 : 0 },
|
|
170
177
|
this.isWeekEnd && style.weekendDay,
|
|
171
178
|
this.isSolarHoliday && style.weekendDay,
|
|
172
179
|
(this.isStart || this.isEnd) &&
|
|
173
180
|
style.focusedText,
|
|
174
181
|
]}>
|
|
175
182
|
{text}
|
|
176
|
-
</Text>
|
|
183
|
+
</Text.Title>
|
|
184
|
+
{!!price ? (
|
|
185
|
+
<Text.Caption
|
|
186
|
+
style={[
|
|
187
|
+
this.isValid && this.isInScope
|
|
188
|
+
? style.price
|
|
189
|
+
: style.dayTextDisabled,
|
|
190
|
+
isBestPrice && {
|
|
191
|
+
color: Colors.pink_03,
|
|
192
|
+
},
|
|
193
|
+
(this.isStart || this.isEnd) && {
|
|
194
|
+
color: Colors.black_01,
|
|
195
|
+
},
|
|
196
|
+
]}>
|
|
197
|
+
{price}
|
|
198
|
+
</Text.Caption>
|
|
199
|
+
) : (
|
|
200
|
+
<View
|
|
201
|
+
style={{
|
|
202
|
+
paddingBottom: this.props
|
|
203
|
+
.havePriceList
|
|
204
|
+
? Spacing.S
|
|
205
|
+
: 0,
|
|
206
|
+
}}
|
|
207
|
+
/>
|
|
208
|
+
)}
|
|
177
209
|
</>
|
|
178
210
|
</TouchableHighlight>
|
|
179
211
|
) : (
|
|
180
|
-
<View
|
|
212
|
+
<View
|
|
213
|
+
style={[
|
|
214
|
+
style.day,
|
|
215
|
+
{
|
|
216
|
+
paddingVertical: !!price
|
|
217
|
+
? Spacing.XS + Spacing.XXS
|
|
218
|
+
: Spacing.S,
|
|
219
|
+
},
|
|
220
|
+
]}>
|
|
181
221
|
{this.lunarDate && this.showLunar && text ? (
|
|
182
|
-
<Text
|
|
222
|
+
<Text.Caption
|
|
183
223
|
style={[
|
|
184
224
|
style.lunarDayText,
|
|
185
225
|
style.dayTextDisabled,
|
|
@@ -187,27 +227,38 @@ class Day extends Component {
|
|
|
187
227
|
{this.lunarDate.lunarDay === 1
|
|
188
228
|
? `${this.lunarDate.lunarDay}/${this.lunarDate.lunarMonth}`
|
|
189
229
|
: this.lunarDate.lunarDay}
|
|
190
|
-
</Text>
|
|
230
|
+
</Text.Caption>
|
|
191
231
|
) : (
|
|
192
232
|
<View />
|
|
193
233
|
)}
|
|
194
|
-
<Text
|
|
234
|
+
<Text.Title
|
|
195
235
|
style={[style.dayText, style.dayTextDisabled]}>
|
|
196
236
|
{text}
|
|
197
|
-
</Text>
|
|
237
|
+
</Text.Title>
|
|
238
|
+
{text && !!price ? (
|
|
239
|
+
<Text.Caption
|
|
240
|
+
style={[
|
|
241
|
+
this.isValid && this.isInScope
|
|
242
|
+
? style.price
|
|
243
|
+
: style.dayTextDisabled,
|
|
244
|
+
isBestPrice && {
|
|
245
|
+
color: Colors.pink_05_b,
|
|
246
|
+
},
|
|
247
|
+
]}>
|
|
248
|
+
{price}
|
|
249
|
+
</Text.Caption>
|
|
250
|
+
) : (
|
|
251
|
+
<View
|
|
252
|
+
style={{
|
|
253
|
+
paddingBottom: this.props.havePriceList
|
|
254
|
+
? Spacing.S
|
|
255
|
+
: 0,
|
|
256
|
+
}}
|
|
257
|
+
/>
|
|
258
|
+
)}
|
|
198
259
|
</View>
|
|
199
260
|
)}
|
|
200
261
|
</View>
|
|
201
|
-
|
|
202
|
-
{this.isValid && this.isInScope && !!price && (
|
|
203
|
-
<Text
|
|
204
|
-
style={[
|
|
205
|
-
style.price,
|
|
206
|
-
isBestPrice && { color: Colors.pink_05_b },
|
|
207
|
-
]}>
|
|
208
|
-
{price}
|
|
209
|
-
</Text>
|
|
210
|
-
)}
|
|
211
262
|
</View>
|
|
212
263
|
);
|
|
213
264
|
}
|
package/src/Day/style.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Dimensions } from 'react-native';
|
|
2
|
-
import { Colors } from '@momo-kits/core';
|
|
2
|
+
import { Spacing, Colors } from '@momo-kits/core';
|
|
3
3
|
|
|
4
4
|
const dayWidth = (Dimensions.get('window').width - 38) / 7;
|
|
5
5
|
const SCREEN_WIDTH = Dimensions.get('window').width;
|
|
6
|
-
const SCREEN_DPI_WIDTH =
|
|
6
|
+
const SCREEN_DPI_WIDTH = SCREEN_WIDTH * Dimensions.get('window').scale;
|
|
7
7
|
const IPHONE_4_5_WIDTH = 640;
|
|
8
8
|
const dayTextSize = SCREEN_DPI_WIDTH === IPHONE_4_5_WIDTH ? 13 : 15;
|
|
9
9
|
const lunarTextSize = SCREEN_DPI_WIDTH === IPHONE_4_5_WIDTH ? 8 : 10;
|
|
@@ -11,7 +11,8 @@ const priceTextSize = SCREEN_DPI_WIDTH === IPHONE_4_5_WIDTH ? 8 : 10;
|
|
|
11
11
|
const lineHeightDayText = 1.3 * dayTextSize;
|
|
12
12
|
const lineHeightLunarText = 1.3 * lunarTextSize;
|
|
13
13
|
const lineHeightPriceText = 1.3 * priceTextSize;
|
|
14
|
-
const containerDayHeight =
|
|
14
|
+
const containerDayHeight =
|
|
15
|
+
lineHeightDayText + lineHeightLunarText + lineHeightPriceText + 10;
|
|
15
16
|
const heightDefault = lineHeightDayText + lineHeightLunarText;
|
|
16
17
|
export default {
|
|
17
18
|
dayContainer: {
|
|
@@ -22,55 +23,52 @@ export default {
|
|
|
22
23
|
},
|
|
23
24
|
day: {
|
|
24
25
|
width: dayWidth,
|
|
25
|
-
paddingVertical: 5,
|
|
26
26
|
overflow: 'hidden',
|
|
27
27
|
justifyContent: 'center',
|
|
28
28
|
alignItems: 'center',
|
|
29
29
|
borderRadius: 4,
|
|
30
|
-
height: heightDefault + 5
|
|
31
30
|
},
|
|
32
31
|
dayText: {
|
|
33
|
-
|
|
32
|
+
lineHeight: 24,
|
|
34
33
|
textAlign: 'center',
|
|
35
|
-
fontWeight: 'bold',
|
|
36
|
-
color: '#222222'
|
|
37
34
|
},
|
|
38
35
|
lunarDayText: {
|
|
39
36
|
width: dayWidth,
|
|
40
37
|
textAlign: 'right',
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
paddingRight: Spacing.XS,
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
top: Spacing.XXS,
|
|
41
|
+
lineHeight: 14,
|
|
44
42
|
},
|
|
45
43
|
todayText: {
|
|
46
|
-
color: 'blue'
|
|
44
|
+
color: 'blue',
|
|
47
45
|
},
|
|
48
46
|
weekendDay: {
|
|
49
|
-
color:
|
|
47
|
+
color: Colors.red_05,
|
|
50
48
|
},
|
|
51
49
|
dayTextDisabled: {
|
|
52
|
-
opacity: 0.
|
|
50
|
+
opacity: 0.4,
|
|
53
51
|
},
|
|
52
|
+
|
|
54
53
|
focused: {
|
|
55
|
-
backgroundColor: Colors.pink_05_b
|
|
54
|
+
backgroundColor: Colors.pink_05_b,
|
|
56
55
|
},
|
|
57
56
|
focusedText: {
|
|
58
|
-
|
|
57
|
+
fontWeight: 'bold',
|
|
58
|
+
color: 'white',
|
|
59
59
|
},
|
|
60
60
|
dayStartContainer: {
|
|
61
61
|
borderTopLeftRadius: 4,
|
|
62
62
|
borderBottomLeftRadius: 4,
|
|
63
|
-
backgroundColor: Colors.
|
|
64
|
-
// height: heightDefault
|
|
63
|
+
backgroundColor: Colors.pink_05_b,
|
|
65
64
|
},
|
|
66
65
|
dayEndContainer: {
|
|
67
66
|
borderTopRightRadius: 4,
|
|
68
67
|
borderBottomRightRadius: 4,
|
|
69
|
-
backgroundColor: Colors.
|
|
70
|
-
// height: heightDefault
|
|
68
|
+
backgroundColor: Colors.pink_05_b,
|
|
71
69
|
},
|
|
72
70
|
mid: {
|
|
73
|
-
backgroundColor: Colors.
|
|
71
|
+
backgroundColor: Colors.pink_10,
|
|
74
72
|
// height: heightDefault
|
|
75
73
|
},
|
|
76
74
|
departLabel: {
|
|
@@ -80,7 +78,7 @@ export default {
|
|
|
80
78
|
height: 20,
|
|
81
79
|
borderRadius: 10,
|
|
82
80
|
justifyContent: 'center',
|
|
83
|
-
alignItems: 'center'
|
|
81
|
+
alignItems: 'center',
|
|
84
82
|
},
|
|
85
83
|
returnLabel: {
|
|
86
84
|
position: 'absolute',
|
|
@@ -91,7 +89,7 @@ export default {
|
|
|
91
89
|
justifyContent: 'center',
|
|
92
90
|
alignItems: 'center',
|
|
93
91
|
top: 0,
|
|
94
|
-
right: 0
|
|
92
|
+
right: 0,
|
|
95
93
|
},
|
|
96
94
|
containerDayHeight,
|
|
97
95
|
txtBack: {
|
|
@@ -105,7 +103,7 @@ export default {
|
|
|
105
103
|
width: 15,
|
|
106
104
|
height: 15,
|
|
107
105
|
justifyContent: 'center',
|
|
108
|
-
alignItems: 'center'
|
|
106
|
+
alignItems: 'center',
|
|
109
107
|
},
|
|
110
108
|
txtGo: {
|
|
111
109
|
position: 'absolute',
|
|
@@ -118,12 +116,12 @@ export default {
|
|
|
118
116
|
width: 15,
|
|
119
117
|
height: 15,
|
|
120
118
|
justifyContent: 'center',
|
|
121
|
-
alignItems: 'center'
|
|
119
|
+
alignItems: 'center',
|
|
122
120
|
},
|
|
123
121
|
price: {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
color: Colors.black_15,
|
|
123
|
+
marginTop: -4,
|
|
124
|
+
lineHeight: 14,
|
|
127
125
|
},
|
|
128
|
-
lineHeightPriceText
|
|
126
|
+
lineHeightPriceText,
|
|
129
127
|
};
|
package/src/HeaderControl.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { useState, forwardRef, useImperativeHandle } from 'react';
|
|
2
2
|
import { View, TouchableOpacity, StyleSheet } from 'react-native';
|
|
3
3
|
import moment from 'moment';
|
|
4
|
-
import {
|
|
4
|
+
import { Icon, ScaleSize, Text, Colors, Spacing } from '@momo-kits/core';
|
|
5
|
+
|
|
5
6
|
import Util from './Util';
|
|
6
7
|
|
|
7
8
|
const HeaderControl = forwardRef(
|
|
@@ -33,7 +34,9 @@ const HeaderControl = forwardRef(
|
|
|
33
34
|
style={styles.icon}
|
|
34
35
|
/>
|
|
35
36
|
</TouchableOpacity>
|
|
36
|
-
<Text.
|
|
37
|
+
<Text.Title style={styles.txtHeader}>
|
|
38
|
+
{headerFormat}
|
|
39
|
+
</Text.Title>
|
|
37
40
|
<TouchableOpacity
|
|
38
41
|
style={styles.btnRight}
|
|
39
42
|
onPress={onPressNextArrow}>
|
|
@@ -55,10 +58,8 @@ const styles = StyleSheet.create({
|
|
|
55
58
|
icon: { width: 24, height: 24, resizeMode: 'contain' },
|
|
56
59
|
txtHeader: {
|
|
57
60
|
// fontSize: 15,
|
|
58
|
-
lineHeight: 19,
|
|
59
61
|
fontWeight: 'bold',
|
|
60
62
|
textAlign: 'center',
|
|
61
|
-
color: Colors.black_17,
|
|
62
63
|
},
|
|
63
64
|
btnRight: {
|
|
64
65
|
width: 36,
|
|
@@ -76,7 +77,7 @@ const styles = StyleSheet.create({
|
|
|
76
77
|
height: ScaleSize(44),
|
|
77
78
|
flexDirection: 'row',
|
|
78
79
|
justifyContent: 'space-between',
|
|
79
|
-
backgroundColor: Colors.
|
|
80
|
+
backgroundColor: Colors.blue_11,
|
|
80
81
|
alignItems: 'center',
|
|
81
82
|
borderRadius: 4,
|
|
82
83
|
},
|
package/src/Month/index.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
View
|
|
5
|
-
} from 'react-native';
|
|
3
|
+
import { View, Dimensions } from 'react-native';
|
|
6
4
|
import moment from 'moment';
|
|
7
5
|
import Day from '../Day';
|
|
6
|
+
import { Spacing, ScaleSize } from '@momo-kits/core';
|
|
7
|
+
|
|
8
|
+
const { width } = Dimensions.get('window');
|
|
8
9
|
|
|
9
10
|
export default class Month extends PureComponent {
|
|
10
11
|
constructor(props) {
|
|
11
12
|
super(props);
|
|
12
13
|
const { dateList } = props;
|
|
13
14
|
this.rowArray = new Array(dateList.length / 7).fill('');
|
|
14
|
-
this.temp = this.rowArray.map((item, i) =>
|
|
15
|
+
this.temp = this.rowArray.map((item, i) =>
|
|
16
|
+
dateList.slice(i * 7, i * 7 + 7),
|
|
17
|
+
);
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
findHoliday = (date) => {
|
|
@@ -19,7 +22,9 @@ export default class Month extends PureComponent {
|
|
|
19
22
|
if (date && holidays && holidays.length > 0) {
|
|
20
23
|
const day = date.date();
|
|
21
24
|
const month = date.month() + 1;
|
|
22
|
-
return holidays.find(
|
|
25
|
+
return holidays.find(
|
|
26
|
+
(item) => item.day === day && item.month === month,
|
|
27
|
+
);
|
|
23
28
|
}
|
|
24
29
|
return null;
|
|
25
30
|
};
|
|
@@ -28,7 +33,7 @@ export default class Month extends PureComponent {
|
|
|
28
33
|
const holiday = this.findHoliday(date);
|
|
29
34
|
return {
|
|
30
35
|
isSolarHoliday: !!(holiday && !holiday.lunar),
|
|
31
|
-
isLunarHoliday: !!(holiday && holiday.lunar)
|
|
36
|
+
isLunarHoliday: !!(holiday && holiday.lunar),
|
|
32
37
|
};
|
|
33
38
|
};
|
|
34
39
|
|
|
@@ -36,10 +41,9 @@ export default class Month extends PureComponent {
|
|
|
36
41
|
<View
|
|
37
42
|
style={{
|
|
38
43
|
flexDirection: 'row',
|
|
39
|
-
justifyContent: 'space-between'
|
|
44
|
+
justifyContent: 'space-between',
|
|
40
45
|
}}
|
|
41
|
-
key={`row${index}`}
|
|
42
|
-
>
|
|
46
|
+
key={`row${index}`}>
|
|
43
47
|
{dayList.map((item, i) => {
|
|
44
48
|
const keyDay = moment(item.date).format('YYYY-MM-DD');
|
|
45
49
|
const priceInfo = this.props?.priceListDate?.[keyDay];
|
|
@@ -48,6 +52,7 @@ export default class Month extends PureComponent {
|
|
|
48
52
|
{...this.props}
|
|
49
53
|
{...this.checkHoliday(item.date)}
|
|
50
54
|
date={item.date}
|
|
55
|
+
havePriceList={!!this.props.priceListDate}
|
|
51
56
|
lunarDate={item.lunarDate}
|
|
52
57
|
empty={item.empty}
|
|
53
58
|
key={`day${i.toString()}`}
|
|
@@ -56,25 +61,25 @@ export default class Month extends PureComponent {
|
|
|
56
61
|
isBestPrice={priceInfo?.isBestPrice}
|
|
57
62
|
/>
|
|
58
63
|
);
|
|
59
|
-
}
|
|
60
|
-
)}
|
|
64
|
+
})}
|
|
61
65
|
</View>
|
|
62
66
|
);
|
|
63
|
-
|
|
64
67
|
render() {
|
|
65
|
-
const {
|
|
66
|
-
month
|
|
67
|
-
} = this.props;
|
|
68
|
+
const { month } = this.props;
|
|
68
69
|
if (month) {
|
|
69
70
|
return (
|
|
70
71
|
<View>
|
|
71
|
-
<View
|
|
72
|
-
{
|
|
73
|
-
|
|
72
|
+
<View
|
|
73
|
+
style={{
|
|
74
|
+
paddingHorizontal: Spacing.S,
|
|
75
|
+
paddingVertical: 5,
|
|
76
|
+
width: width - ScaleSize(24),
|
|
77
|
+
}}>
|
|
78
|
+
{this.temp.map((item, i) => this.renderDayRow(item, i))}
|
|
74
79
|
</View>
|
|
75
80
|
</View>
|
|
76
81
|
);
|
|
77
82
|
}
|
|
78
|
-
return
|
|
83
|
+
return <View />;
|
|
79
84
|
}
|
|
80
85
|
}
|
package/src/MonthList.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/* eslint-disable react/no-did-update-set-state */
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
|
-
import { FlatList, Dimensions, Platform } from 'react-native';
|
|
3
|
+
import { FlatList, Dimensions, Platform, View } from 'react-native';
|
|
4
4
|
import moment from 'moment';
|
|
5
5
|
import Month from './Month';
|
|
6
6
|
import style from './Day/style';
|
|
7
7
|
import LunarDateConverter from './LunarDateConverter';
|
|
8
|
+
import { ScaleSize } from '@momo-kits/core';
|
|
8
9
|
|
|
9
|
-
const ITEM_WIDTH = Dimensions.get('window').width - 24;
|
|
10
|
+
const ITEM_WIDTH = Dimensions.get('window').width - ScaleSize(24);
|
|
10
11
|
const MAX_RENDER_PER_BATCH = Platform.OS === 'android' ? 1 : 12;
|
|
11
12
|
|
|
12
13
|
const converter = new LunarDateConverter();
|
|
@@ -266,6 +267,7 @@ export default class MonthList extends Component {
|
|
|
266
267
|
onViewableItemsChanged={this.getCurrentVisibleMonth}
|
|
267
268
|
onScrollToIndexFailed={() => {}}
|
|
268
269
|
// removeClippedSubviews
|
|
270
|
+
scrollEnabled
|
|
269
271
|
initialNumToRender={1}
|
|
270
272
|
maxToRenderPerBatch={MAX_RENDER_PER_BATCH}
|
|
271
273
|
windowSize={3}
|
package/src/TabHeader.js
CHANGED
|
@@ -55,36 +55,30 @@ export default class TabHeader extends React.Component {
|
|
|
55
55
|
flex: 1,
|
|
56
56
|
backgroundColor: Colors.white,
|
|
57
57
|
}}>
|
|
58
|
-
<Text
|
|
58
|
+
<Text.SubTitle
|
|
59
59
|
style={{
|
|
60
60
|
fontSize: 12,
|
|
61
61
|
lineHeight: 16,
|
|
62
62
|
color: Colors.black_09,
|
|
63
63
|
}}>
|
|
64
64
|
{label}
|
|
65
|
-
</Text>
|
|
66
|
-
<Text
|
|
67
|
-
weight={active ? '
|
|
65
|
+
</Text.SubTitle>
|
|
66
|
+
<Text.Title
|
|
67
|
+
weight={active ? 'bold' : 'regular'}
|
|
68
68
|
style={{
|
|
69
69
|
marginTop: 3,
|
|
70
|
-
fontSize: 14,
|
|
71
|
-
color: Colors.black_17,
|
|
72
70
|
}}>
|
|
73
|
-
<Text
|
|
74
|
-
weight={active ? 'semibold' : 'regular'}
|
|
75
|
-
style={{
|
|
76
|
-
color: Colors.black_17,
|
|
77
|
-
}}>
|
|
71
|
+
<Text.Title weight={active ? 'bold' : 'regular'}>
|
|
78
72
|
{`${
|
|
79
73
|
dayOfWeekFromState ||
|
|
80
74
|
dayOfWeekFromDefault ||
|
|
81
75
|
'--'
|
|
82
76
|
} `}
|
|
83
|
-
</Text>
|
|
77
|
+
</Text.Title>
|
|
84
78
|
{formattedDateFromState ||
|
|
85
79
|
formattedDateFromDefault ||
|
|
86
80
|
'--/--/----'}
|
|
87
|
-
</Text>
|
|
81
|
+
</Text.Title>
|
|
88
82
|
</View>
|
|
89
83
|
</TouchableWithoutFeedback>
|
|
90
84
|
);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { TouchableOpacity, View } from 'react-native';
|
|
2
|
+
import { TouchableOpacity, View, Text } from 'react-native';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { Text } from '@momo-kits/core';
|
|
5
4
|
import styles from './styles';
|
|
6
5
|
|
|
7
6
|
export default class Day extends Component {
|
|
@@ -9,11 +9,11 @@ const colorDay = '#9199a2';
|
|
|
9
9
|
const WeekDaysLabels = () => (
|
|
10
10
|
<View style={styles.dayLabelsWrapper}>
|
|
11
11
|
{WEEKDAYS.map((day, key) => (
|
|
12
|
-
<Text.
|
|
12
|
+
<Text.Title1
|
|
13
13
|
key={key.toString()}
|
|
14
14
|
style={[styles.dayLabels, { color: colorDay, fontSize: 16 }]}>
|
|
15
15
|
{day}
|
|
16
|
-
</Text.
|
|
16
|
+
</Text.Title1>
|
|
17
17
|
))}
|
|
18
18
|
</View>
|
|
19
19
|
);
|