dhre-ui-kit 0.0.16 → 0.0.18

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.16",
3
+ "version": "0.0.18",
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",
package/src/App.tsx CHANGED
@@ -1,42 +1,14 @@
1
1
  import React from 'react';
2
2
  import {ThemeProvider} from './theme/ThemeContext';
3
- import {Badge, Line} from './index';
3
+ import {Badge, DateRangePicker, Line} from './index';
4
4
  import {ArrowLeft, CalenderDots} from './assets';
5
5
  import {View} from 'react-native';
6
6
  import CustomButton from './components/button/Button';
7
7
 
8
8
  const App = () => {
9
9
  return (
10
- <ThemeProvider>
11
- <View style={{marginTop: 50}}>
12
- <Badge
13
- handleIconPress={function (): void {}}
14
- text="gggsdfghjhgf"
15
- style={{margin: 20}}
16
- iconName={<CalenderDots width={20} height={20} />}
17
- textStyle={{color: 'black'}}
18
- iconStyle={{}}
19
- />
20
- <Line />
21
- <CustomButton
22
- title="Yes"
23
- onPress={() => console.log('Yes Button Pressed')}
24
- leftIcon={<ArrowLeft />}
25
- // titleColor={color.CONTENT_SECONDRY[currentTheme]}
26
- titleVariant="L2_REGULAR"
27
- containerStyle={[
28
- {
29
- borderWidth: 1,
30
- borderRadius: 20,
10
+ <DateRangePicker onPress={() => {}} />
31
11
 
32
- height: 40,
33
- },
34
- ]}
35
- // iconStyle={styles.iconStyle}
36
- imagePosition="left"
37
- />
38
- </View>
39
- </ThemeProvider>
40
12
  );
41
13
  };
42
14
 
@@ -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
+ applyButton: {
7
+ marginTop: verticalScale(40),
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,98 @@
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>
69
+ <Calendar
70
+ markedDates={getMarkedDates()}
71
+ mode="date"
72
+ markingType={'period'}
73
+ theme={{
74
+ calendarBackground: 'transparent',
75
+ arrowColor: '#fff',
76
+ monthTextColor: '#FFFFFF',
77
+ dayTextColor: '#A7A7A7',
78
+ todayTextColor: '#2DE3A6',
79
+ }}
80
+ style={{
81
+ backgroundColor: 'transparent',
82
+ color: '#A7A7A7',
83
+ }}
84
+ onDayPress={onDayPress}
85
+ />
86
+ <Button
87
+ title="Apply"
88
+ onPress={() => {
89
+ onPress(selectedRange?.startDate, selectedRange?.endDate);
90
+ }}
91
+ containerStyle={styles.applyButton}
92
+ textStyle={styles.applyButtonText}
93
+ />
94
+ </View>
95
+ );
96
+ };
97
+
98
+ export default DateRangePicker;
@@ -0,0 +1 @@
1
+ export {default} from './DateRangePicker';
@@ -9,8 +9,9 @@ import {
9
9
  const styles = StyleSheet.create({
10
10
  container: {
11
11
  position: 'absolute',
12
+ alignSelf: 'center',
12
13
  height: verticalScale(72),
13
- width: width - horizontalScale(48),
14
+ width: width - horizontalScale(32),
14
15
  top: 56,
15
16
  borderRadius: moderateScale(8),
16
17
  overflow: 'hidden',
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';
@@ -14,8 +14,8 @@ interface ThemeProviderProps {
14
14
 
15
15
  export const ThemeProvider: React.FC<ThemeProviderProps> = ({children}) => {
16
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- const mode = useSelector((state: any) => state.theme.currentTheme);
18
- // const mode = 'light'
17
+ // const mode = useSelector((state: any) => state.theme.currentTheme);
18
+ const mode = 'light'
19
19
  // Filter the theme based on the mode (light or dark)
20
20
  const filteredTheme = Object.keys(theme).reduce((acc, key) => {
21
21
  acc[key] = theme[key][mode];