@artsy/palette-mobile 17.24.0 → 17.25.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.
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { Dimensions } from "react-native";
|
|
4
|
-
import Animated, { Easing, FadeIn, FadeOut, useDerivedValue } from "react-native-reanimated";
|
|
2
|
+
import Animated, { Easing, FadeIn, FadeOut, useAnimatedStyle, useDerivedValue, } from "react-native-reanimated";
|
|
5
3
|
import { useScreenScrollContext } from "./ScreenScrollContext";
|
|
6
|
-
import { BOTTOM_TABS_HEIGHT, STICKY_BAR_HEIGHT } from "./StickySubHeader";
|
|
7
4
|
import { NAVBAR_HEIGHT, ZINDEX } from "./constants";
|
|
8
5
|
import { DEFAULT_HIT_SLOP } from "../../constants";
|
|
9
6
|
import { ArrowLeftIcon } from "../../svgs/ArrowLeftIcon";
|
|
@@ -20,17 +17,20 @@ const Right = ({ hideRightElements, rightElements }) => {
|
|
|
20
17
|
return _jsx(_Fragment, { children: !hideRightElements && rightElements });
|
|
21
18
|
};
|
|
22
19
|
const Center = ({ animated, hideTitle, title }) => {
|
|
23
|
-
const { scrollYOffset = 0, currentScrollYAnimated
|
|
24
|
-
const { height: screenHeight } = Dimensions.get("window");
|
|
25
|
-
const scrollViewContentHeight = screenHeight - NAVBAR_HEIGHT - STICKY_BAR_HEIGHT - BOTTOM_TABS_HEIGHT;
|
|
20
|
+
const { scrollYOffset = 0, currentScrollYAnimated } = useScreenScrollContext();
|
|
26
21
|
// Show / hide the title to avoid rerenders, which retrigger the animation
|
|
27
22
|
const display = useDerivedValue(() => {
|
|
28
|
-
// The user is scrolling on a screen that is too small to show the small header
|
|
29
|
-
if (scrollViewDimensionsAnimated?.value < scrollViewContentHeight) {
|
|
30
|
-
return "none";
|
|
31
|
-
}
|
|
32
23
|
return currentScrollYAnimated.value < NAVBAR_HEIGHT + scrollYOffset ? "none" : "flex";
|
|
33
24
|
}, [currentScrollYAnimated, scrollYOffset]);
|
|
25
|
+
const opacity = useDerivedValue(() => {
|
|
26
|
+
return display.value === "flex" ? 1 : 0;
|
|
27
|
+
});
|
|
28
|
+
const style = useAnimatedStyle(() => {
|
|
29
|
+
return {
|
|
30
|
+
display: display.value,
|
|
31
|
+
opacity: opacity.value,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
34
|
if (hideTitle) {
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
@@ -38,11 +38,7 @@ const Center = ({ animated, hideTitle, title }) => {
|
|
|
38
38
|
if (!animated) {
|
|
39
39
|
return titleTextElement;
|
|
40
40
|
}
|
|
41
|
-
return (_jsx(Animated.View, { entering: FadeIn.duration(400).easing(Easing.out(Easing.exp)), exiting: FadeOut.duration(400).easing(Easing.out(Easing.exp)), style:
|
|
42
|
-
display: display.value,
|
|
43
|
-
}, children: _jsx(MotiView, { animate: {
|
|
44
|
-
opacity: display.value === "flex" ? 1 : 0,
|
|
45
|
-
}, children: titleTextElement }) }));
|
|
41
|
+
return (_jsx(Animated.View, { entering: FadeIn.duration(400).easing(Easing.out(Easing.exp)), exiting: FadeOut.duration(400).easing(Easing.out(Easing.exp)), style: style, children: titleTextElement }));
|
|
46
42
|
};
|
|
47
43
|
const Left = ({ hideLeftElements, leftElements, onBack }) => {
|
|
48
44
|
if (hideLeftElements)
|
|
@@ -8,4 +8,4 @@ storiesOf("Tabs", module)
|
|
|
8
8
|
.add("Simple Tabs", () => (_jsxs(Tabs, { children: [_jsx(Tabs.Tab, { name: "Tab 1", label: "Tab 1", children: _jsx(Tabs.ScrollView, { children: _jsx(Text, { children: "Tab 1 content" }) }) }), _jsx(Tabs.Tab, { name: "Tab 2", label: "Tab 2", children: _jsx(Tabs.ScrollView, { children: _jsx(Text, { children: "Tab 2 content" }) }) })] })))
|
|
9
9
|
.add("Tabs with Indicator", () => (_jsxs(Tabs, { indicators: [{ tabName: "tab1", Component: () => _jsx(Text, { textAlign: "right", children: "hi" }) }], children: [_jsx(Tabs.Tab, { name: "tab1", label: "Tab 1", children: _jsx(Tabs.ScrollView, { children: _jsx(Text, { children: "Tab 1 content" }) }) }), _jsx(Tabs.Tab, { name: "tab2", label: "Tab 2", children: _jsx(Tabs.ScrollView, { children: _jsx(Text, { children: "Tab 2 content" }) }) })] })))
|
|
10
10
|
.add("Tabs with AnimatedHeader", () => (_jsxs(Screen, { children: [_jsx(Screen.AnimatedHeader, { title: "Title" }), _jsx(Screen.Body, { fullwidth: true, children: _jsxs(Tabs, { children: [_jsx(Tabs.Tab, { name: "tab1", label: "Tab 1", children: _jsx(Tabs.ScrollView, { children: Array.from({ length: 5 }).map((_, i) => (_jsx(Text, { my: 1, children: "\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\"" }, i))) }) }), _jsx(Tabs.Tab, { name: "tab2", label: "Tab 2", children: _jsx(Tabs.ScrollView, { children: Array.from({ length: 5 }).map((_, i) => (_jsx(Text, { my: 1, children: "\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\"" }, i))) }) })] }) })] })))
|
|
11
|
-
.add("Tabs with header", () => (_jsxs(Tabs.TabsWithHeader, { title: "Artist Header", showLargeHeaderText: false, BelowTitleHeaderComponent: () => (_jsxs(Flex, { pointerEvents: "none", p: 2, children: [_jsx(Text, { children: "
|
|
11
|
+
.add("Tabs with header", () => (_jsxs(Tabs.TabsWithHeader, { title: "Artist Header", showLargeHeaderText: false, BelowTitleHeaderComponent: () => (_jsxs(Flex, { pointerEvents: "none", p: 2, children: [_jsx(Text, { children: "Info" }), _jsx(Text, { children: "More Info" })] })), children: [_jsx(Tabs.Tab, { name: "tab1", label: "Tab 1", children: _jsx(Tabs.ScrollView, { children: _jsx(Text, { children: "Some long text ".repeat(150) }) }) }), _jsx(Tabs.Tab, { name: "tab2", label: "Tab 2", children: _jsx(Text, { children: "Some long text ".repeat(150) }) })] })));
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
2
|
import { useCurrentTabScrollY } from "react-native-collapsible-tab-view";
|
|
3
|
+
import { useAnimatedReaction } from "react-native-reanimated";
|
|
3
4
|
import { useScreenScrollContext } from "../../Screen/ScreenScrollContext";
|
|
4
5
|
import { useAnimatedHeaderScrolling } from "../../Screen/hooks/useAnimatedHeaderScrolling";
|
|
5
6
|
export const useListenForTabContentScroll = () => {
|
|
6
|
-
|
|
7
|
-
const
|
|
7
|
+
// TODO: move away from JS variables, use the animated values instead
|
|
8
|
+
const { updateCurrentScrollY, scrollYOffset, currentScrollYAnimated } = useScreenScrollContext();
|
|
9
|
+
const currentTabScrollY = useCurrentTabScrollY();
|
|
10
|
+
const scrollY = useAnimatedHeaderScrolling(currentTabScrollY, scrollYOffset);
|
|
8
11
|
useEffect(() => {
|
|
9
12
|
updateCurrentScrollY(scrollY);
|
|
10
13
|
}, [scrollY, updateCurrentScrollY]);
|
|
14
|
+
useAnimatedReaction(() => currentTabScrollY.value, (current) => {
|
|
15
|
+
currentScrollYAnimated?.set(current);
|
|
16
|
+
});
|
|
11
17
|
};
|
package/package.json
CHANGED