@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tactics/toddle-styleguide",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -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 flingRightGesture = Gesture.Fling()
62
- .direction(Directions.RIGHT)
63
- .onStart((e) => {
64
- onSwipeLeft();
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 flingLeftGesture = Gesture.Fling()
68
- .direction(Directions.LEFT)
69
- .onStart((e) => {
69
+ const onSwipeOpen = (direction:string) => {
70
+ if (direction == "left") {
71
+ onSwipeLeft();
72
+ } else if (direction == "right") {
70
73
  onSwipeRight();
71
- });
74
+ }
72
75
 
73
- const composedGesture = Gesture.Simultaneous(
74
- flingLeftGesture.runOnJS(true),
75
- flingRightGesture.runOnJS(true)
76
- );
76
+ if (swipeableRef.current) {
77
+ swipeableRef.current.close();
78
+ }
79
+ }
77
80
 
78
81
  return (
79
82
  <GestureHandlerRootView>
80
- <GestureDetector gesture={composedGesture}>
81
- <View style={styles.container}>
82
- {weekData.map((weekday, index) => {
83
- return (
84
- <Day
85
- key={index}
86
- date={weekday}
87
- onSelect={onClick}
88
- isSelected={isThisDaySelected(weekday)}
89
- />
90
- );
91
- })}
92
- </View>
93
- </GestureDetector>
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
  };
@@ -12,7 +12,7 @@ export const DaySelectPreview = ({}: {}) => {
12
12
  );
13
13
 
14
14
  return (
15
- <View style={{paddingHorizontal: 48}}>
15
+ <View>
16
16
  <DaySelect
17
17
  startDate={startOfWeek}
18
18
  onSelectDate={setSelectedDate}
@@ -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
  });
@@ -1,10 +0,0 @@
1
- export function Stylesheet(context: any): {
2
- container: {
3
- backgroundColor: any;
4
- padding: number;
5
- flexDirection: 'row';
6
- justifyContent: 'space-evenly';
7
- borderRadius: number;
8
- overflow: 'hidden';
9
- };
10
- };