@sunsama/event-calendar 0.7.0 → 0.8.0
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/lib/commonjs/components/all-day-events.js +38 -10
- package/lib/commonjs/components/all-day-events.js.map +1 -1
- package/lib/module/components/all-day-events.js +39 -11
- package/lib/module/components/all-day-events.js.map +1 -1
- package/lib/typescript/commonjs/components/all-day-events.d.ts.map +1 -1
- package/lib/typescript/module/components/all-day-events.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/all-day-events.tsx +38 -8
|
@@ -30,8 +30,10 @@ const AllDayEvents = /*#__PURE__*/(0, _react.memo)(() => {
|
|
|
30
30
|
if (!newState) {
|
|
31
31
|
measuredHeight.value = (0, _reactNativeReanimated.withTiming)(originalHeight.value, {
|
|
32
32
|
duration: 250
|
|
33
|
-
},
|
|
34
|
-
|
|
33
|
+
}, finished => {
|
|
34
|
+
if (finished) {
|
|
35
|
+
(0, _reactNativeReanimated.runOnJS)(setShowAllDayEvents)(newState);
|
|
36
|
+
}
|
|
35
37
|
});
|
|
36
38
|
} else {
|
|
37
39
|
setShowAllDayEvents(newState);
|
|
@@ -46,6 +48,8 @@ const AllDayEvents = /*#__PURE__*/(0, _react.memo)(() => {
|
|
|
46
48
|
}, [canCreateEvents, onCreateEvent]);
|
|
47
49
|
const allDayEvents = showAllDayEvents ? layout.allDayEventsLayout : layout.allDayEventsLayout.slice(0, maxAllDayEvents);
|
|
48
50
|
const restEventAmount = layout.allDayEventsLayout.length - allDayEvents.length;
|
|
51
|
+
const moreAvailable = layout.allDayEventsLayout.length > maxAllDayEvents;
|
|
52
|
+
const refView = (0, _reactNativeReanimated.useAnimatedRef)();
|
|
49
53
|
const onContentLayout = (0, _react.useCallback)(e => {
|
|
50
54
|
const {
|
|
51
55
|
height
|
|
@@ -57,27 +61,50 @@ const AllDayEvents = /*#__PURE__*/(0, _react.memo)(() => {
|
|
|
57
61
|
}
|
|
58
62
|
measuredHeight.value = (0, _reactNativeReanimated.withTiming)(height, {
|
|
59
63
|
duration: 250
|
|
64
|
+
}, () => {
|
|
65
|
+
if (moreAvailable) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Once we have done the animation we need to measure the height as
|
|
70
|
+
// the height might have changed due to the amount of events
|
|
71
|
+
const measured = (0, _reactNativeReanimated.measure)(refView);
|
|
72
|
+
if (measured?.height && measured.height !== originalHeight.value) {
|
|
73
|
+
originalHeight.value = measured.height;
|
|
74
|
+
}
|
|
60
75
|
});
|
|
61
|
-
}, [measuredHeight,
|
|
62
|
-
const
|
|
76
|
+
}, [originalHeight, measuredHeight, refView, moreAvailable]);
|
|
77
|
+
const animatedStyleRight = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
63
78
|
return {
|
|
64
79
|
minHeight: 1,
|
|
65
80
|
height: measuredHeight.value
|
|
66
81
|
};
|
|
67
82
|
});
|
|
68
|
-
|
|
83
|
+
const animatedStyleLeft = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
84
|
+
return {
|
|
85
|
+
width: 50,
|
|
86
|
+
height: measuredHeight.value + _globals.DEFAULT_MINUTE_HEIGHT * 24
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
69
90
|
style: [styles.container, theme?.allDayContainer],
|
|
70
|
-
children: /*#__PURE__*/(0, _jsxRuntime.
|
|
91
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.Pressable, {
|
|
92
|
+
onPress: onPressCreateEvent,
|
|
93
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
94
|
+
style: [animatedStyleLeft]
|
|
95
|
+
})
|
|
96
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
71
97
|
style: [styles.eventContainer, theme?.allDayEventContainer],
|
|
72
98
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
73
|
-
style:
|
|
99
|
+
style: animatedStyleRight,
|
|
100
|
+
ref: refView,
|
|
74
101
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
75
102
|
onLayout: onContentLayout,
|
|
76
103
|
children: allDayEvents.map(allDayLayout => /*#__PURE__*/(0, _jsxRuntime.jsx)(_eventContainer.default, {
|
|
77
104
|
layout: allDayLayout
|
|
78
105
|
}, allDayLayout.event.id))
|
|
79
106
|
})
|
|
80
|
-
}),
|
|
107
|
+
}), moreAvailable ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeGestureHandler.Pressable, {
|
|
81
108
|
onPress: onPressShowMore,
|
|
82
109
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
83
110
|
style: [styles.moreContainer, theme?.allDayShowMoreContainer],
|
|
@@ -92,17 +119,18 @@ const AllDayEvents = /*#__PURE__*/(0, _react.memo)(() => {
|
|
|
92
119
|
style: [styles.deadSpace, theme?.allDayDeadSpace]
|
|
93
120
|
})
|
|
94
121
|
})]
|
|
95
|
-
})
|
|
122
|
+
})]
|
|
96
123
|
});
|
|
97
124
|
}, () => true);
|
|
98
125
|
var _default = exports.default = AllDayEvents;
|
|
99
126
|
const styles = _reactNative.StyleSheet.create({
|
|
100
127
|
container: {
|
|
128
|
+
flexDirection: "row",
|
|
101
129
|
borderBottomWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
102
130
|
borderColor: "black"
|
|
103
131
|
},
|
|
104
132
|
eventContainer: {
|
|
105
|
-
|
|
133
|
+
flex: 1,
|
|
106
134
|
marginRight: 10,
|
|
107
135
|
borderLeftWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
108
136
|
borderColor: "black"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_globals","_reactNative","_eventContainer","_interopRequireDefault","_reactNativeGestureHandler","_reactNativeReanimated","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AllDayEvents","memo","layout","theme","maxAllDayEvents","onCreateEvent","canCreateEvents","useContext","ConfigProvider","showAllDayEvents","setShowAllDayEvents","useState","measuredHeight","useSharedValue","originalHeight","onPressShowMore","useCallback","newState","value","withTiming","duration","runOnJS","onPressCreateEvent","isAllDay","allDayEvents","allDayEventsLayout","slice","restEventAmount","length","onContentLayout","height","nativeEvent","
|
|
1
|
+
{"version":3,"names":["_react","require","_globals","_reactNative","_eventContainer","_interopRequireDefault","_reactNativeGestureHandler","_reactNativeReanimated","_interopRequireWildcard","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AllDayEvents","memo","layout","theme","maxAllDayEvents","onCreateEvent","canCreateEvents","useContext","ConfigProvider","showAllDayEvents","setShowAllDayEvents","useState","measuredHeight","useSharedValue","originalHeight","onPressShowMore","useCallback","newState","value","withTiming","duration","finished","runOnJS","onPressCreateEvent","isAllDay","allDayEvents","allDayEventsLayout","slice","restEventAmount","length","moreAvailable","refView","useAnimatedRef","onContentLayout","height","nativeEvent","measured","measure","animatedStyleRight","useAnimatedStyle","minHeight","animatedStyleLeft","width","DEFAULT_MINUTE_HEIGHT","jsxs","View","style","styles","container","allDayContainer","children","jsx","Pressable","onPress","eventContainer","allDayEventContainer","ref","onLayout","map","allDayLayout","event","id","moreContainer","allDayShowMoreContainer","Text","moreContainerText","allDayShowMoreText","deadSpace","allDayDeadSpace","_default","exports","StyleSheet","create","flexDirection","borderBottomWidth","hairlineWidth","borderColor","flex","marginRight","borderLeftWidth","padding","fontSize","fontWeight","color"],"sourceRoot":"../../../src","sources":["components/all-day-events.tsx"],"mappings":";;;;;;AAAA,IAA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,eAAe,EAAER,uBAAU,CAACI,aAAa;IACzCC,WAAW,EAAE;EACf,CAAC;EACDd,aAAa,EAAE;IACbkB,OAAO,EAAE;EACX,CAAC;EACDf,iBAAiB,EAAE;IACjBgB,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBC,KAAK,EAAE;EACT,CAAC;EACDhB,SAAS,EAAE;IACTjC,MAAM,EAAES,8BAAqB,GAAG;EAClC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -5,7 +5,7 @@ import { ConfigProvider, DEFAULT_MINUTE_HEIGHT } from "../utils/globals.js";
|
|
|
5
5
|
import { StyleSheet, Text, View } from "react-native";
|
|
6
6
|
import EventContainer from "../components/event-container.js";
|
|
7
7
|
import { Pressable } from "react-native-gesture-handler";
|
|
8
|
-
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
8
|
+
import Animated, { measure, runOnJS, useAnimatedRef, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
const AllDayEvents = /*#__PURE__*/memo(() => {
|
|
11
11
|
const {
|
|
@@ -23,8 +23,10 @@ const AllDayEvents = /*#__PURE__*/memo(() => {
|
|
|
23
23
|
if (!newState) {
|
|
24
24
|
measuredHeight.value = withTiming(originalHeight.value, {
|
|
25
25
|
duration: 250
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, finished => {
|
|
27
|
+
if (finished) {
|
|
28
|
+
runOnJS(setShowAllDayEvents)(newState);
|
|
29
|
+
}
|
|
28
30
|
});
|
|
29
31
|
} else {
|
|
30
32
|
setShowAllDayEvents(newState);
|
|
@@ -39,6 +41,8 @@ const AllDayEvents = /*#__PURE__*/memo(() => {
|
|
|
39
41
|
}, [canCreateEvents, onCreateEvent]);
|
|
40
42
|
const allDayEvents = showAllDayEvents ? layout.allDayEventsLayout : layout.allDayEventsLayout.slice(0, maxAllDayEvents);
|
|
41
43
|
const restEventAmount = layout.allDayEventsLayout.length - allDayEvents.length;
|
|
44
|
+
const moreAvailable = layout.allDayEventsLayout.length > maxAllDayEvents;
|
|
45
|
+
const refView = useAnimatedRef();
|
|
42
46
|
const onContentLayout = useCallback(e => {
|
|
43
47
|
const {
|
|
44
48
|
height
|
|
@@ -50,27 +54,50 @@ const AllDayEvents = /*#__PURE__*/memo(() => {
|
|
|
50
54
|
}
|
|
51
55
|
measuredHeight.value = withTiming(height, {
|
|
52
56
|
duration: 250
|
|
57
|
+
}, () => {
|
|
58
|
+
if (moreAvailable) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Once we have done the animation we need to measure the height as
|
|
63
|
+
// the height might have changed due to the amount of events
|
|
64
|
+
const measured = measure(refView);
|
|
65
|
+
if (measured?.height && measured.height !== originalHeight.value) {
|
|
66
|
+
originalHeight.value = measured.height;
|
|
67
|
+
}
|
|
53
68
|
});
|
|
54
|
-
}, [measuredHeight,
|
|
55
|
-
const
|
|
69
|
+
}, [originalHeight, measuredHeight, refView, moreAvailable]);
|
|
70
|
+
const animatedStyleRight = useAnimatedStyle(() => {
|
|
56
71
|
return {
|
|
57
72
|
minHeight: 1,
|
|
58
73
|
height: measuredHeight.value
|
|
59
74
|
};
|
|
60
75
|
});
|
|
61
|
-
|
|
76
|
+
const animatedStyleLeft = useAnimatedStyle(() => {
|
|
77
|
+
return {
|
|
78
|
+
width: 50,
|
|
79
|
+
height: measuredHeight.value + DEFAULT_MINUTE_HEIGHT * 24
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
62
83
|
style: [styles.container, theme?.allDayContainer],
|
|
63
|
-
children: /*#__PURE__*/
|
|
84
|
+
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
85
|
+
onPress: onPressCreateEvent,
|
|
86
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
87
|
+
style: [animatedStyleLeft]
|
|
88
|
+
})
|
|
89
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
64
90
|
style: [styles.eventContainer, theme?.allDayEventContainer],
|
|
65
91
|
children: [/*#__PURE__*/_jsx(Animated.View, {
|
|
66
|
-
style:
|
|
92
|
+
style: animatedStyleRight,
|
|
93
|
+
ref: refView,
|
|
67
94
|
children: /*#__PURE__*/_jsx(View, {
|
|
68
95
|
onLayout: onContentLayout,
|
|
69
96
|
children: allDayEvents.map(allDayLayout => /*#__PURE__*/_jsx(EventContainer, {
|
|
70
97
|
layout: allDayLayout
|
|
71
98
|
}, allDayLayout.event.id))
|
|
72
99
|
})
|
|
73
|
-
}),
|
|
100
|
+
}), moreAvailable ? /*#__PURE__*/_jsx(Pressable, {
|
|
74
101
|
onPress: onPressShowMore,
|
|
75
102
|
children: /*#__PURE__*/_jsx(View, {
|
|
76
103
|
style: [styles.moreContainer, theme?.allDayShowMoreContainer],
|
|
@@ -85,17 +112,18 @@ const AllDayEvents = /*#__PURE__*/memo(() => {
|
|
|
85
112
|
style: [styles.deadSpace, theme?.allDayDeadSpace]
|
|
86
113
|
})
|
|
87
114
|
})]
|
|
88
|
-
})
|
|
115
|
+
})]
|
|
89
116
|
});
|
|
90
117
|
}, () => true);
|
|
91
118
|
export default AllDayEvents;
|
|
92
119
|
const styles = StyleSheet.create({
|
|
93
120
|
container: {
|
|
121
|
+
flexDirection: "row",
|
|
94
122
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
95
123
|
borderColor: "black"
|
|
96
124
|
},
|
|
97
125
|
eventContainer: {
|
|
98
|
-
|
|
126
|
+
flex: 1,
|
|
99
127
|
marginRight: 10,
|
|
100
128
|
borderLeftWidth: StyleSheet.hairlineWidth,
|
|
101
129
|
borderColor: "black"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["memo","useCallback","useContext","useState","ConfigProvider","DEFAULT_MINUTE_HEIGHT","StyleSheet","Text","View","EventContainer","Pressable","Animated","runOnJS","useAnimatedStyle","useSharedValue","withTiming","jsx","_jsx","jsxs","_jsxs","AllDayEvents","layout","theme","maxAllDayEvents","onCreateEvent","canCreateEvents","showAllDayEvents","setShowAllDayEvents","measuredHeight","originalHeight","onPressShowMore","newState","value","duration","onPressCreateEvent","isAllDay","allDayEvents","allDayEventsLayout","slice","restEventAmount","length","onContentLayout","e","height","nativeEvent","
|
|
1
|
+
{"version":3,"names":["memo","useCallback","useContext","useState","ConfigProvider","DEFAULT_MINUTE_HEIGHT","StyleSheet","Text","View","EventContainer","Pressable","Animated","measure","runOnJS","useAnimatedRef","useAnimatedStyle","useSharedValue","withTiming","jsx","_jsx","jsxs","_jsxs","AllDayEvents","layout","theme","maxAllDayEvents","onCreateEvent","canCreateEvents","showAllDayEvents","setShowAllDayEvents","measuredHeight","originalHeight","onPressShowMore","newState","value","duration","finished","onPressCreateEvent","isAllDay","allDayEvents","allDayEventsLayout","slice","restEventAmount","length","moreAvailable","refView","onContentLayout","e","height","nativeEvent","measured","animatedStyleRight","minHeight","animatedStyleLeft","width","style","styles","container","allDayContainer","children","onPress","eventContainer","allDayEventContainer","ref","onLayout","map","allDayLayout","event","id","moreContainer","allDayShowMoreContainer","moreContainerText","allDayShowMoreText","deadSpace","allDayDeadSpace","create","flexDirection","borderBottomWidth","hairlineWidth","borderColor","flex","marginRight","borderLeftWidth","padding","fontSize","fontWeight","color"],"sourceRoot":"../../../src","sources":["components/all-day-events.tsx"],"mappings":";;AAAA,SAASA,IAAI,EAAEC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,OAAO;AAC/D,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,qBAAkB;AACxE,SAA4BC,UAAU,EAAEC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AACxE,OAAOC,cAAc,MAAM,kCAA+B;AAC1D,SAASC,SAAS,QAAQ,8BAA8B;AACxD,OAAOC,QAAQ,IACbC,OAAO,EACPC,OAAO,EACPC,cAAc,EACdC,gBAAgB,EA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;MAAC,CACE,CAAC,gBAEZvB,IAAA,CAACT,SAAS;QAACkD,OAAO,EAAEvB,kBAAmB;QAAAsB,QAAA,eACrCxC,IAAA,CAACX,IAAI;UAAC+C,KAAK,EAAE,CAACC,MAAM,CAACiB,SAAS,EAAEjD,KAAK,EAAEkD,eAAe;QAAE,CAAE;MAAC,CAClD,CACZ;IAAA,CACG,CAAC;EAAA,CACH,CAAC;AAEX,CAAC,EACD,MAAM,IACR,CAAC;AAED,eAAepD,YAAY;AAE3B,MAAMkC,MAAM,GAAGlD,UAAU,CAACqE,MAAM,CAAC;EAC/BlB,SAAS,EAAE;IACTmB,aAAa,EAAE,KAAK;IACpBC,iBAAiB,EAAEvE,UAAU,CAACwE,aAAa;IAC3CC,WAAW,EAAE;EACf,CAAC;EACDlB,cAAc,EAAE;IACdmB,IAAI,EAAE,CAAC;IACPC,WAAW,EAAE,EAAE;IACfC,eAAe,EAAE5E,UAAU,CAACwE,aAAa;IACzCC,WAAW,EAAE;EACf,CAAC;EACDV,aAAa,EAAE;IACbc,OAAO,EAAE;EACX,CAAC;EACDZ,iBAAiB,EAAE;IACjBa,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,MAAM;IAClBC,KAAK,EAAE;EACT,CAAC;EACDb,SAAS,EAAE;IACTzB,MAAM,EAAE3C,qBAAqB,GAAG;EAClC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-day-events.d.ts","sourceRoot":"","sources":["../../../../src/components/all-day-events.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"all-day-events.d.ts","sourceRoot":"","sources":["../../../../src/components/all-day-events.tsx"],"names":[],"mappings":"AAeA,QAAA,MAAM,YAAY,wEA2HjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-day-events.d.ts","sourceRoot":"","sources":["../../../../src/components/all-day-events.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"all-day-events.d.ts","sourceRoot":"","sources":["../../../../src/components/all-day-events.tsx"],"names":[],"mappings":"AAeA,QAAA,MAAM,YAAY,wEA2HjB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,9 @@ import { LayoutChangeEvent, StyleSheet, Text, View } from "react-native";
|
|
|
4
4
|
import EventContainer from "../components/event-container";
|
|
5
5
|
import { Pressable } from "react-native-gesture-handler";
|
|
6
6
|
import Animated, {
|
|
7
|
+
measure,
|
|
7
8
|
runOnJS,
|
|
9
|
+
useAnimatedRef,
|
|
8
10
|
useAnimatedStyle,
|
|
9
11
|
useSharedValue,
|
|
10
12
|
withTiming,
|
|
@@ -29,8 +31,10 @@ const AllDayEvents = memo(
|
|
|
29
31
|
{
|
|
30
32
|
duration: 250,
|
|
31
33
|
},
|
|
32
|
-
() => {
|
|
33
|
-
|
|
34
|
+
(finished) => {
|
|
35
|
+
if (finished) {
|
|
36
|
+
runOnJS(setShowAllDayEvents)(newState);
|
|
37
|
+
}
|
|
34
38
|
}
|
|
35
39
|
);
|
|
36
40
|
} else {
|
|
@@ -50,6 +54,9 @@ const AllDayEvents = memo(
|
|
|
50
54
|
const restEventAmount =
|
|
51
55
|
layout.allDayEventsLayout.length - allDayEvents.length;
|
|
52
56
|
|
|
57
|
+
const moreAvailable = layout.allDayEventsLayout.length > maxAllDayEvents;
|
|
58
|
+
|
|
59
|
+
const refView = useAnimatedRef();
|
|
53
60
|
const onContentLayout = useCallback(
|
|
54
61
|
(e: LayoutChangeEvent) => {
|
|
55
62
|
const { height } = e.nativeEvent.layout;
|
|
@@ -60,22 +67,44 @@ const AllDayEvents = memo(
|
|
|
60
67
|
return;
|
|
61
68
|
}
|
|
62
69
|
|
|
63
|
-
measuredHeight.value = withTiming(height, { duration: 250 })
|
|
70
|
+
measuredHeight.value = withTiming(height, { duration: 250 }, () => {
|
|
71
|
+
if (moreAvailable) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Once we have done the animation we need to measure the height as
|
|
76
|
+
// the height might have changed due to the amount of events
|
|
77
|
+
const measured = measure(refView);
|
|
78
|
+
|
|
79
|
+
if (measured?.height && measured.height !== originalHeight.value) {
|
|
80
|
+
originalHeight.value = measured.height;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
64
83
|
},
|
|
65
|
-
[measuredHeight,
|
|
84
|
+
[originalHeight, measuredHeight, refView, moreAvailable]
|
|
66
85
|
);
|
|
67
86
|
|
|
68
|
-
const
|
|
87
|
+
const animatedStyleRight = useAnimatedStyle(() => {
|
|
69
88
|
return {
|
|
70
89
|
minHeight: 1,
|
|
71
90
|
height: measuredHeight.value,
|
|
72
91
|
};
|
|
73
92
|
});
|
|
74
93
|
|
|
94
|
+
const animatedStyleLeft = useAnimatedStyle(() => {
|
|
95
|
+
return {
|
|
96
|
+
width: 50,
|
|
97
|
+
height: measuredHeight.value + DEFAULT_MINUTE_HEIGHT * 24,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
|
|
75
101
|
return (
|
|
76
102
|
<View style={[styles.container, theme?.allDayContainer]}>
|
|
103
|
+
<Pressable onPress={onPressCreateEvent}>
|
|
104
|
+
<Animated.View style={[animatedStyleLeft]} />
|
|
105
|
+
</Pressable>
|
|
77
106
|
<View style={[styles.eventContainer, theme?.allDayEventContainer]}>
|
|
78
|
-
<Animated.View style={
|
|
107
|
+
<Animated.View style={animatedStyleRight} ref={refView}>
|
|
79
108
|
<View onLayout={onContentLayout}>
|
|
80
109
|
{allDayEvents.map((allDayLayout: AllDayEventLayoutType<any>) => (
|
|
81
110
|
<EventContainer
|
|
@@ -85,7 +114,7 @@ const AllDayEvents = memo(
|
|
|
85
114
|
))}
|
|
86
115
|
</View>
|
|
87
116
|
</Animated.View>
|
|
88
|
-
{
|
|
117
|
+
{moreAvailable ? (
|
|
89
118
|
<Pressable onPress={onPressShowMore}>
|
|
90
119
|
<View
|
|
91
120
|
style={[styles.moreContainer, theme?.allDayShowMoreContainer]}
|
|
@@ -113,11 +142,12 @@ export default AllDayEvents;
|
|
|
113
142
|
|
|
114
143
|
const styles = StyleSheet.create({
|
|
115
144
|
container: {
|
|
145
|
+
flexDirection: "row",
|
|
116
146
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
117
147
|
borderColor: "black",
|
|
118
148
|
},
|
|
119
149
|
eventContainer: {
|
|
120
|
-
|
|
150
|
+
flex: 1,
|
|
121
151
|
marginRight: 10,
|
|
122
152
|
borderLeftWidth: StyleSheet.hairlineWidth,
|
|
123
153
|
borderColor: "black",
|