@tactics/toddle-styleguide 1.4.0 → 1.4.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.
- package/package.json +1 -1
- package/src/components/organisms/day-select/day-select.component.tsx +40 -31
- package/src/components/organisms/day-select/day-select.preview.tsx +1 -1
- package/src/components/organisms/day-select/day-select.styles.js +8 -0
- package/src/components/organisms/day-select/day-select.styles.d.ts +0 -10
package/package.json
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import React, {useContext, useEffect, useState} from 'react';
|
|
1
|
+
import React, {useContext, useEffect, useRef, useState} from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Directions,
|
|
4
|
-
Gesture,
|
|
5
|
-
GestureDetector,
|
|
6
3
|
GestureHandlerRootView,
|
|
7
4
|
} from 'react-native-gesture-handler';
|
|
8
5
|
import {View} from 'react-native';
|
|
@@ -10,6 +7,8 @@ import {ToddleDateTime} from '../../../utilities/toddle-datetime/toddle-datetime
|
|
|
10
7
|
import {ThemeCtx} from '../../../context/theme.context';
|
|
11
8
|
import {Stylesheet} from './day-select.styles';
|
|
12
9
|
import {Day} from '../../molecules/day/day.component';
|
|
10
|
+
import Swipeable from 'react-native-gesture-handler/Swipeable';
|
|
11
|
+
import { Icon } from '../../../icons';
|
|
13
12
|
|
|
14
13
|
type DaySelectProps = {
|
|
15
14
|
onSelectDate: (date: ToddleDateTime) => void;
|
|
@@ -20,6 +19,7 @@ type DaySelectProps = {
|
|
|
20
19
|
const DaySelect = ({onSelectDate, selectedDate, startDate}: DaySelectProps) => {
|
|
21
20
|
const context = useContext(ThemeCtx);
|
|
22
21
|
const styles = Stylesheet(context);
|
|
22
|
+
const swipeableRef = useRef<Swipeable>(null);
|
|
23
23
|
|
|
24
24
|
const createWeekDays = (day: ToddleDateTime) => {
|
|
25
25
|
let week = [];
|
|
@@ -58,39 +58,48 @@ const DaySelect = ({onSelectDate, selectedDate, startDate}: DaySelectProps) => {
|
|
|
58
58
|
onSelectDate(date);
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
const
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
const renderLeftActions = () => {
|
|
62
|
+
return <View style={styles.actionContainer}><Icon name={'chevron-left' } style='regular' color={context.colors.ui.grey} /></View>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const renderRightActions = () => {
|
|
66
|
+
return <View style={styles.actionContainer}><Icon name={'chevron-right' } style='regular' color={context.colors.ui.grey} /></View>;
|
|
67
|
+
}
|
|
66
68
|
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const onSwipeOpen = (direction:string) => {
|
|
70
|
+
if (direction == "left") {
|
|
71
|
+
onSwipeLeft();
|
|
72
|
+
} else if (direction == "right") {
|
|
70
73
|
onSwipeRight();
|
|
71
|
-
}
|
|
74
|
+
}
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
if (swipeableRef.current) {
|
|
77
|
+
swipeableRef.current.close();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
77
80
|
|
|
78
81
|
return (
|
|
79
82
|
<GestureHandlerRootView>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
83
|
+
<Swipeable
|
|
84
|
+
ref={swipeableRef}
|
|
85
|
+
renderLeftActions={renderLeftActions}
|
|
86
|
+
renderRightActions={renderRightActions}
|
|
87
|
+
onSwipeableOpen={onSwipeOpen}
|
|
88
|
+
containerStyle={styles.container}
|
|
89
|
+
childrenContainerStyle={styles.childrenContainer}
|
|
90
|
+
overshootFriction={8}
|
|
91
|
+
>
|
|
92
|
+
{weekData.map((weekday, index) => {
|
|
93
|
+
return (
|
|
94
|
+
<Day
|
|
95
|
+
key={index}
|
|
96
|
+
date={weekday}
|
|
97
|
+
onSelect={onClick}
|
|
98
|
+
isSelected={isThisDaySelected(weekday)}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
})}
|
|
102
|
+
</Swipeable>
|
|
94
103
|
</GestureHandlerRootView>
|
|
95
104
|
);
|
|
96
105
|
};
|
|
@@ -11,4 +11,12 @@ export const Stylesheet = (context) =>
|
|
|
11
11
|
borderRadius: Scale.m,
|
|
12
12
|
overflow: 'hidden',
|
|
13
13
|
},
|
|
14
|
+
childrenContainer: {
|
|
15
|
+
flexDirection: 'row',
|
|
16
|
+
justifyContent: 'space-evenly',
|
|
17
|
+
},
|
|
18
|
+
actionContainer: {
|
|
19
|
+
flexDirection: 'row',
|
|
20
|
+
alignItems: 'center'
|
|
21
|
+
}
|
|
14
22
|
});
|