@tactics/toddle-styleguide 1.4.0 → 1.4.2

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/App.tsx CHANGED
@@ -74,6 +74,10 @@ import {TabViewPreview} from './src/components/organisms/tab-view/tab-view.previ
74
74
  import {LinePreview} from './src/components/atoms/line/line.preview';
75
75
  import {JournalEntryPreview} from './src/components/organisms/journal-entry/journal-entry.preview';
76
76
 
77
+ import {
78
+ SafeAreaProvider,
79
+ } from 'react-native-safe-area-context';
80
+
77
81
  const Stack = createNativeStackNavigator();
78
82
 
79
83
  const HomeScreen = ({navigation}: {navigation: any}) => {
@@ -299,6 +303,7 @@ function App() {
299
303
  }
300
304
 
301
305
  return (
306
+ <SafeAreaProvider>
302
307
  <ThemeCtx.Provider value={StaffMemberTheme}>
303
308
  <NavigationContainer>
304
309
  <Stack.Navigator>
@@ -474,6 +479,7 @@ function App() {
474
479
  </Stack.Navigator>
475
480
  </NavigationContainer>
476
481
  </ThemeCtx.Provider>
482
+ </SafeAreaProvider>
477
483
  );
478
484
  }
479
485
 
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.2",
4
4
  "main": "index.tsx",
5
5
  "types": "index.d.ts",
6
6
  "prepublish": "tsc",
@@ -5,6 +5,9 @@ import {ViewStyle} from 'react-native';
5
5
  import {ThemeCtx} from '../../../context/theme.context';
6
6
  import {Stylesheet} from './footer.styles';
7
7
  import Animated, {AnimateStyle} from 'react-native-reanimated';
8
+ import {
9
+ useSafeAreaInsets,
10
+ } from 'react-native-safe-area-context';
8
11
 
9
12
  type FooterProps = {
10
13
  children: React.ReactNode;
@@ -13,15 +16,16 @@ type FooterProps = {
13
16
 
14
17
  const Footer = ({children, animatedStyle}: FooterProps) => {
15
18
  const context = useContext(ThemeCtx);
16
- const styles = Stylesheet(context);
19
+ const insets = useSafeAreaInsets();
20
+ const styles = Stylesheet(context, insets);
17
21
 
18
22
  return (
19
- <Animated.View
20
- style={[styles.container, animatedStyle]}
21
- testID="footer-container"
22
- >
23
- {children}
24
- </Animated.View>
23
+ <Animated.View
24
+ style={[styles.container, animatedStyle]}
25
+ testID="footer-container"
26
+ >
27
+ {children}
28
+ </Animated.View>
25
29
  );
26
30
  };
27
31
 
@@ -1,19 +1,18 @@
1
- import * as React from 'react';
2
- import {Platform, StyleSheet} from 'react-native';
1
+ import {StyleSheet} from 'react-native';
3
2
  import {Scale} from '../../../theme/scale/index';
4
3
 
5
- export const Stylesheet = (context) =>
4
+ export const Stylesheet = (context, insets) =>
6
5
  StyleSheet.create({
7
6
  container: {
8
7
  flexDirection: 'row',
9
- alignItems: Platform.OS === 'android' ? 'center' : 'flex-start',
8
+ alignItems: 'center',
10
9
  justifyContent: 'center',
11
- paddingTop: Platform.OS === 'android' ? 0 : Scale.m,
12
10
  backgroundColor: context.colors.ui.xlightgrey,
13
11
  borderTopColor: context.colors.ui.lightgrey,
14
12
  borderStyle: 'solid',
15
13
  borderTopWidth: 1,
16
- height: Platform.OS === 'android' ? Scale.xxxl : Scale.xxxxl,
14
+ minHeight: (Scale.xxxl + insets.bottom),
15
+ paddingBottom: insets.bottom,
17
16
  width: '100%',
18
17
  },
19
18
  });
@@ -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 = [];
@@ -41,12 +41,14 @@ const DaySelect = ({onSelectDate, selectedDate, startDate}: DaySelectProps) => {
41
41
  const onSwipeLeft = () => {
42
42
  let firstDayOfWeek = weekData.shift();
43
43
  if (!firstDayOfWeek) return;
44
+ onSelectDate(selectedDate.minus({weeks: 1}));
44
45
  setWeekData(createWeekDays(firstDayOfWeek.minus({weeks: 1})));
45
46
  };
46
47
 
47
48
  const onSwipeRight = () => {
48
49
  let firstDayOfWeek = weekData.shift();
49
50
  if (!firstDayOfWeek) return;
51
+ onSelectDate(selectedDate.plus({weeks: 1}));
50
52
  setWeekData(createWeekDays(firstDayOfWeek.plus({weeks: 1})));
51
53
  };
52
54
 
@@ -58,39 +60,48 @@ const DaySelect = ({onSelectDate, selectedDate, startDate}: DaySelectProps) => {
58
60
  onSelectDate(date);
59
61
  };
60
62
 
61
- const flingRightGesture = Gesture.Fling()
62
- .direction(Directions.RIGHT)
63
- .onStart((e) => {
64
- onSwipeLeft();
65
- });
63
+ const renderLeftActions = () => {
64
+ return <View style={styles.actionContainer}><Icon name={'chevron-left' } style='regular' color={context.colors.ui.grey} /></View>;
65
+ }
66
+
67
+ const renderRightActions = () => {
68
+ return <View style={styles.actionContainer}><Icon name={'chevron-right' } style='regular' color={context.colors.ui.grey} /></View>;
69
+ }
66
70
 
67
- const flingLeftGesture = Gesture.Fling()
68
- .direction(Directions.LEFT)
69
- .onStart((e) => {
71
+ const onSwipeOpen = (direction:string) => {
72
+ if (direction == "left") {
73
+ onSwipeLeft();
74
+ } else if (direction == "right") {
70
75
  onSwipeRight();
71
- });
76
+ }
72
77
 
73
- const composedGesture = Gesture.Simultaneous(
74
- flingLeftGesture.runOnJS(true),
75
- flingRightGesture.runOnJS(true)
76
- );
78
+ if (swipeableRef.current) {
79
+ swipeableRef.current.close();
80
+ }
81
+ }
77
82
 
78
83
  return (
79
84
  <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>
85
+ <Swipeable
86
+ ref={swipeableRef}
87
+ renderLeftActions={renderLeftActions}
88
+ renderRightActions={renderRightActions}
89
+ onSwipeableOpen={onSwipeOpen}
90
+ containerStyle={styles.container}
91
+ childrenContainerStyle={styles.childrenContainer}
92
+ overshootFriction={8}
93
+ >
94
+ {weekData.map((weekday, index) => {
95
+ return (
96
+ <Day
97
+ key={index}
98
+ date={weekday}
99
+ onSelect={onClick}
100
+ isSelected={isThisDaySelected(weekday)}
101
+ />
102
+ );
103
+ })}
104
+ </Swipeable>
94
105
  </GestureHandlerRootView>
95
106
  );
96
107
  };
@@ -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,14 +0,0 @@
1
- export function Stylesheet(context: any): {
2
- container: {
3
- flexDirection: "row";
4
- alignItems: "center" | "flex-start";
5
- justifyContent: "center";
6
- paddingTop: number;
7
- backgroundColor: any;
8
- borderTopColor: any;
9
- borderStyle: "solid";
10
- borderTopWidth: number;
11
- height: number;
12
- width: "100%";
13
- };
14
- };
@@ -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
- };