@momo-kits/calendar 0.0.74-beta → 0.72.1

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.
@@ -1,154 +1,146 @@
1
- import React, { Component, } from 'react';
2
- import { TouchableOpacity, View } from 'react-native';
1
+ import React, {Component} from 'react';
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 {
8
- processMinDate() {
9
- const { minDate } = this.props;
10
- if (minDate) {
11
- minDate.setHours(0, 0, 0, 0);
12
- if (this.date < minDate) {
13
- this.disableTouch = true;
14
- }
15
- }
7
+ processMinDate() {
8
+ const {minDate} = this.props;
9
+ if (minDate) {
10
+ minDate.setHours(0, 0, 0, 0);
11
+ if (this.date < minDate) {
12
+ this.disableTouch = true;
13
+ }
16
14
  }
15
+ }
17
16
 
18
- processMaxDate() {
19
- const { maxDate } = this.props;
20
- if (maxDate) {
21
- maxDate.setHours(0, 0, 0, 0);
22
- if (this.date > maxDate) {
23
- this.disableTouch = true;
24
- }
25
- }
17
+ processMaxDate() {
18
+ const {maxDate} = this.props;
19
+ if (maxDate) {
20
+ maxDate.setHours(0, 0, 0, 0);
21
+ if (this.date > maxDate) {
22
+ this.disableTouch = true;
23
+ }
26
24
  }
25
+ }
27
26
 
28
- processDoubleDate() {
29
- const {
30
- mode, otherMonth, firstDate, secondDate, tabSelected
31
- } = this.props;
32
- const { date } = this;
33
- if (mode === 'doubleDate' && !otherMonth) {
34
- if (firstDate && tabSelected === 1) {
35
- firstDate.setHours(0, 0, 0, 0);
36
- if (date < firstDate) {
37
- this.disableTouch = true;
38
- this.styleDouble = {};
39
- } else if (date.getTime() === firstDate.getTime()) {
40
- this.colorCanTouch = '#2eb3e8';
41
- this.colorText = 'white';
42
- this.styleDouble = {};
43
- }
44
- }
45
- if (secondDate && firstDate) {
46
- secondDate.setHours(0, 0, 0, 0);
47
- if (date > firstDate && date < secondDate) {
48
- this.colorCanTouch = '#90d6f3';
27
+ processDoubleDate() {
28
+ const {mode, otherMonth, firstDate, secondDate, tabSelected} = this.props;
29
+ const {date} = this;
30
+ if (mode === 'doubleDate' && !otherMonth) {
31
+ if (firstDate && tabSelected === 1) {
32
+ firstDate.setHours(0, 0, 0, 0);
33
+ if (date < firstDate) {
34
+ this.disableTouch = true;
35
+ this.styleDouble = {};
36
+ } else if (date.getTime() === firstDate.getTime()) {
37
+ this.colorCanTouch = '#2eb3e8';
38
+ this.colorText = 'white';
39
+ this.styleDouble = {};
40
+ }
41
+ }
42
+ if (secondDate && firstDate) {
43
+ secondDate.setHours(0, 0, 0, 0);
44
+ if (date > firstDate && date < secondDate) {
45
+ this.colorCanTouch = '#90d6f3';
49
46
 
50
- this.styleDouble = styles.styleBetween;
47
+ this.styleDouble = styles.styleBetween;
51
48
 
52
- this.colorText = 'white';
53
- }
54
- if (secondDate.getTime() !== firstDate.getTime()) {
55
- if (date.getTime() === firstDate.getTime()) {
56
- this.colorCanTouch = '#2eb3e8';
57
- this.colorText = 'white';
58
- this.styleDouble = styles.styleFirstDate;
59
- }
60
- if (date.getTime() === secondDate.getTime()) {
61
- this.styleDouble = styles.styleSecondDate;
62
- this.colorCanTouch = '#2eb3e8';
63
- this.colorText = 'white';
64
- }
65
- }
66
- }
49
+ this.colorText = 'white';
67
50
  }
68
- }
69
-
70
- processSelected() {
71
- const { selected } = this.props;
72
- if (selected && !this.disableTouch) {
51
+ if (secondDate.getTime() !== firstDate.getTime()) {
52
+ if (date.getTime() === firstDate.getTime()) {
73
53
  this.colorCanTouch = '#2eb3e8';
74
54
  this.colorText = 'white';
75
- }
76
- }
77
-
78
- processDateNow() {
79
- const { selected } = this.props;
80
- if (!selected && this.date.getTime() === this.dateNow.getTime()) {
81
- this.colorCanTouch = '#8F8E94';
55
+ this.styleDouble = styles.styleFirstDate;
56
+ }
57
+ if (date.getTime() === secondDate.getTime()) {
58
+ this.styleDouble = styles.styleSecondDate;
59
+ this.colorCanTouch = '#2eb3e8';
82
60
  this.colorText = 'white';
61
+ }
83
62
  }
63
+ }
84
64
  }
65
+ }
85
66
 
86
- processOtherMonth() {
87
- const { otherMonth } = this.props;
88
- if (otherMonth) {
89
- this.colorTextDisable = 'white';
90
- }
67
+ processSelected() {
68
+ const {selected} = this.props;
69
+ if (selected && !this.disableTouch) {
70
+ this.colorCanTouch = '#2eb3e8';
71
+ this.colorText = 'white';
91
72
  }
73
+ }
92
74
 
93
- processRender() {
94
- this.processMinDate();
95
- this.processMaxDate();
96
- // this.processDateNow()
97
- this.processDoubleDate();
98
- this.processSelected();
99
- this.processOtherMonth();
75
+ processDateNow() {
76
+ const {selected} = this.props;
77
+ if (!selected && this.date.getTime() === this.dateNow.getTime()) {
78
+ this.colorCanTouch = '#8F8E94';
79
+ this.colorText = 'white';
100
80
  }
81
+ }
101
82
 
102
- render() {
103
- const {
104
- day, month, year, otherMonth, onDayChange
105
- } = this.props;
106
- this.colorCanTouch = 'white';
107
- this.colorText = '#393939';
108
- this.colorTextDisable = '#DADADA';
109
- this.styleDouble = {};
110
- this.disableTouch = false;
111
- this.dateNow = new Date();
112
- this.dateNow.setHours(0, 0, 0, 0);
113
- this.date = new Date(year, month, day);
114
- this.date.setHours(0, 0, 0, 0);
115
- this.processRender();
116
- return (
117
-
118
- <View style={styles.dayWrapper}>
119
- <View style={this.styleDouble} />
120
- {
121
- this.disableTouch || otherMonth
122
- ? (
123
- <View style={styles.dayButton}>
124
- <Text.Title style={[styles.dayLabel, { color: this.colorTextDisable }]}>
125
- {day}
126
- </Text.Title>
127
- </View>
128
- )
129
- : (
130
- <View style={[styles.dayButtonSelected, { backgroundColor: this.colorCanTouch }]}>
131
- <TouchableOpacity
132
- style={styles.dayButton}
133
- onPress={() => onDayChange(day, month, year)}
134
- >
135
- <Text.Title style={[styles.dayLabel, { color: this.colorText }]}>
136
- {day}
137
- </Text.Title>
138
- </TouchableOpacity>
83
+ processOtherMonth() {
84
+ const {otherMonth} = this.props;
85
+ if (otherMonth) {
86
+ this.colorTextDisable = 'white';
87
+ }
88
+ }
139
89
 
140
- </View>
141
- )
90
+ processRender() {
91
+ this.processMinDate();
92
+ this.processMaxDate();
93
+ // this.processDateNow()
94
+ this.processDoubleDate();
95
+ this.processSelected();
96
+ this.processOtherMonth();
97
+ }
142
98
 
143
- }
144
- </View>
145
- );
146
- }
99
+ render() {
100
+ const {day, month, year, otherMonth, onDayChange} = this.props;
101
+ this.colorCanTouch = 'white';
102
+ this.colorText = '#393939';
103
+ this.colorTextDisable = '#DADADA';
104
+ this.styleDouble = {};
105
+ this.disableTouch = false;
106
+ this.dateNow = new Date();
107
+ this.dateNow.setHours(0, 0, 0, 0);
108
+ this.date = new Date(year, month, day);
109
+ this.date.setHours(0, 0, 0, 0);
110
+ this.processRender();
111
+ return (
112
+ <View style={styles.dayWrapper}>
113
+ <View style={this.styleDouble} />
114
+ {this.disableTouch || otherMonth ? (
115
+ <View style={styles.dayButton}>
116
+ <Text.Title
117
+ style={[styles.dayLabel, {color: this.colorTextDisable}]}>
118
+ {day}
119
+ </Text.Title>
120
+ </View>
121
+ ) : (
122
+ <View
123
+ style={[
124
+ styles.dayButtonSelected,
125
+ {backgroundColor: this.colorCanTouch},
126
+ ]}>
127
+ <TouchableOpacity
128
+ style={styles.dayButton}
129
+ onPress={() => onDayChange(day, month, year)}>
130
+ <Text.Title style={[styles.dayLabel, {color: this.colorText}]}>
131
+ {day}
132
+ </Text.Title>
133
+ </TouchableOpacity>
134
+ </View>
135
+ )}
136
+ </View>
137
+ );
138
+ }
147
139
  }
148
140
  Day.propTypes = {
149
- day: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
150
- month: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
151
- year: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
152
- otherMonth: PropTypes.bool,
153
- onDayChange: PropTypes.func,
141
+ day: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
142
+ month: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
143
+ year: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
144
+ otherMonth: PropTypes.bool,
145
+ onDayChange: PropTypes.func,
154
146
  };