dhre-ui-kit 0.0.15 → 0.0.17

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dhre-ui-kit",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "main": "src/index.ts",
5
5
  "files": [
6
6
  "src",
@@ -28,6 +28,7 @@
28
28
  "react": "18.2.0",
29
29
  "react-native": "0.74.3",
30
30
  "react-native-blob-util": "^0.19.11",
31
+ "react-native-calendars": "^1.1306.0",
31
32
  "react-native-gesture-handler": "2.17.0",
32
33
  "react-native-otp-verify": "^1.1.8",
33
34
  "react-native-pdf": "^6.7.5",
@@ -3,7 +3,7 @@ import {TouchableOpacity, View, StyleSheet, ViewStyle} from 'react-native';
3
3
  import {SvgProps} from 'react-native-svg';
4
4
  import CustomText from '../customText';
5
5
  import {withThemeProvider} from '../../theme/withThemeProvider';
6
- import {useTheme} from 'src/theme/ThemeContext';
6
+ import {useTheme} from '../../theme/ThemeContext';
7
7
 
8
8
  interface OurOfficesButtonProps {
9
9
  leftIcon?: ReactElement<SvgProps>;
@@ -0,0 +1,3 @@
1
+ export interface DateRangePickerProps {
2
+ onPress: (startDate: string, endDate: string) => void;
3
+ }
@@ -0,0 +1,19 @@
1
+ import {StyleSheet} from 'react-native';
2
+ import {FONT_STYLES} from '../../theme/fonts';
3
+ import {verticalScale, moderateScale} from '../../utils/stylehelper';
4
+
5
+ const styles = StyleSheet.create({
6
+ container: {marginTop: verticalScale(8)},
7
+ applyButton: {
8
+ height: verticalScale(48),
9
+ alignItems: 'center',
10
+ borderRadius: moderateScale(25),
11
+ backgroundColor: '#fff',
12
+ },
13
+ applyButtonText: {
14
+ color: '#000',
15
+ ...FONT_STYLES.L1_REGULAR,
16
+ },
17
+ });
18
+
19
+ export default styles;
@@ -0,0 +1,97 @@
1
+ import React, {useState} from 'react';
2
+ import {View} from 'react-native';
3
+ import {Calendar} from 'react-native-calendars';
4
+ import Button from '../button';
5
+ import {DateRangePickerProps} from './DateRangePicker.interface';
6
+ import styles from './DateRangePicker.styles';
7
+
8
+ const DateRangePicker = ({onPress}: DateRangePickerProps) => {
9
+ const [selectedRange, setSelectedRange] = useState<{
10
+ startDate: string;
11
+ endDate: string;
12
+ }>({
13
+ startDate: '',
14
+ endDate: '',
15
+ });
16
+
17
+ const onDayPress = day => {
18
+ const {dateString} = day;
19
+ const {startDate, endDate} = selectedRange;
20
+
21
+ if (!startDate || (startDate && endDate)) {
22
+ setSelectedRange({startDate: dateString, endDate: ''});
23
+ } else if (startDate && !endDate) {
24
+ if (new Date(dateString) >= new Date(startDate)) {
25
+ setSelectedRange({startDate, endDate: dateString});
26
+ } else {
27
+ setSelectedRange({startDate: dateString, endDate: ''});
28
+ }
29
+ }
30
+ };
31
+
32
+ const getMarkedDates = () => {
33
+ const {startDate, endDate} = selectedRange;
34
+ const markedDates = {};
35
+
36
+ if (startDate) {
37
+ markedDates[startDate] = {
38
+ startingDay: true,
39
+ color: '#2DE3A6',
40
+ textColor: '#000000',
41
+ };
42
+ }
43
+ if (endDate) {
44
+ markedDates[endDate] = {
45
+ endingDay: true,
46
+ color: '#2DE3A6',
47
+ textColor: '#000000',
48
+ };
49
+ }
50
+
51
+ if (startDate && endDate) {
52
+ const start = new Date(startDate);
53
+ const end = new Date(endDate);
54
+
55
+ while (start < end) {
56
+ start.setDate(start.getDate() + 1);
57
+ markedDates[start.toISOString().split('T')[0]] = {
58
+ color: '#2DE3A6',
59
+ textColor: '#000000',
60
+ };
61
+ }
62
+ }
63
+
64
+ return markedDates;
65
+ };
66
+
67
+ return (
68
+ <View style={styles.container}>
69
+ <Calendar
70
+ markedDates={getMarkedDates()}
71
+ mode="date"
72
+ theme={{
73
+ calendarBackground: 'transparent',
74
+ arrowColor: '#fff',
75
+ monthTextColor: '#FFFFFF',
76
+ dayTextColor: '#A7A7A7',
77
+ todayTextColor: '#2DE3A6',
78
+ }}
79
+ style={{
80
+ backgroundColor: 'transparent',
81
+ color: '#A7A7A7',
82
+ }}
83
+ onDayPress={onDayPress}
84
+ />
85
+ <Button
86
+ title="Apply"
87
+ onPress={() => {
88
+ onPress(selectedRange?.startDate, selectedRange?.endDate);
89
+ }}
90
+ containerStyle={styles.applyButton}
91
+ textStyle={styles.applyButtonText}
92
+ />
93
+ </View>
94
+ );
95
+ };
96
+
97
+ export default DateRangePicker;
@@ -0,0 +1 @@
1
+ export {default} from './DateRangePicker';
package/src/index.ts CHANGED
@@ -28,6 +28,7 @@ export {default as CustomLoader} from './components/customLoader';
28
28
  export {default as Line} from './components/horizontalLine';
29
29
  export {default as Topic} from './components/topic';
30
30
  export {default as ContactModel} from './components/ContactModel';
31
+ export {default as DateRangePicker} from './components/dateRangePicker';
31
32
  export {default as OurOfficesButton} from './components/OutOfOffice';
32
33
 
33
34
  export * from './utils/stylehelper';