@fountain-ui/core 2.0.0-beta.11 → 2.0.0-beta.12
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/build/commonjs/Accordion/Accordion.js +3 -3
- package/build/commonjs/Accordion/Accordion.js.map +1 -1
- package/build/commonjs/ButtonBase/ButtonBase.js +5 -5
- package/build/commonjs/ButtonBase/ButtonBase.js.map +1 -1
- package/build/commonjs/ButtonBase/useDisabledReaction/index.js +1 -1
- package/build/commonjs/ButtonBase/useDisabledReaction/index.js.map +1 -1
- package/build/commonjs/CircularProgress/CircularProgress.js +15 -18
- package/build/commonjs/CircularProgress/CircularProgress.js.map +1 -1
- package/build/commonjs/ImageCore/ImageCoreNative.js +3 -3
- package/build/commonjs/ImageCore/ImageCoreNative.js.map +1 -1
- package/build/commonjs/Slide/Slide.js +12 -13
- package/build/commonjs/Slide/Slide.js.map +1 -1
- package/build/commonjs/Tabs/TabIndicator.js +1 -1
- package/build/commonjs/Tabs/TabIndicator.js.map +1 -1
- package/build/commonjs/Tabs/Tabs.js +1 -1
- package/build/commonjs/Tabs/Tabs.js.map +1 -1
- package/build/commonjs/Tooltip/Tooltip.js +4 -4
- package/build/commonjs/Tooltip/Tooltip.js.map +1 -1
- package/build/commonjs/hooks/useCollapsibleAppBar.js +24 -30
- package/build/commonjs/hooks/useCollapsibleAppBar.js.map +1 -1
- package/build/commonjs/hooks/useFadeInAppBar.js +13 -14
- package/build/commonjs/hooks/useFadeInAppBar.js.map +1 -1
- package/build/module/Accordion/Accordion.js +3 -3
- package/build/module/Accordion/Accordion.js.map +1 -1
- package/build/module/ButtonBase/ButtonBase.js +5 -5
- package/build/module/ButtonBase/ButtonBase.js.map +1 -1
- package/build/module/ButtonBase/useDisabledReaction/index.js +1 -1
- package/build/module/ButtonBase/useDisabledReaction/index.js.map +1 -1
- package/build/module/CircularProgress/CircularProgress.js +16 -16
- package/build/module/CircularProgress/CircularProgress.js.map +1 -1
- package/build/module/ImageCore/ImageCoreNative.js +3 -3
- package/build/module/ImageCore/ImageCoreNative.js.map +1 -1
- package/build/module/Slide/Slide.js +14 -10
- package/build/module/Slide/Slide.js.map +1 -1
- package/build/module/Tabs/TabIndicator.js +1 -1
- package/build/module/Tabs/TabIndicator.js.map +1 -1
- package/build/module/Tabs/Tabs.js +1 -1
- package/build/module/Tabs/Tabs.js.map +1 -1
- package/build/module/Tooltip/Tooltip.js +4 -4
- package/build/module/Tooltip/Tooltip.js.map +1 -1
- package/build/module/hooks/useCollapsibleAppBar.js +24 -28
- package/build/module/hooks/useCollapsibleAppBar.js.map +1 -1
- package/build/module/hooks/useFadeInAppBar.js +13 -10
- package/build/module/hooks/useFadeInAppBar.js.map +1 -1
- package/package.json +2 -2
- package/src/Accordion/Accordion.tsx +5 -3
- package/src/ButtonBase/ButtonBase.tsx +5 -5
- package/src/ButtonBase/useDisabledReaction/index.ts +1 -0
- package/src/CircularProgress/CircularProgress.tsx +15 -20
- package/src/ImageCore/ImageCoreNative.tsx +3 -3
- package/src/Slide/Slide.tsx +17 -15
- package/src/Tabs/TabIndicator.tsx +1 -1
- package/src/Tabs/Tabs.tsx +1 -1
- package/src/Tooltip/Tooltip.tsx +4 -4
- package/src/hooks/useCollapsibleAppBar.ts +21 -22
- package/src/hooks/useFadeInAppBar.ts +13 -12
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
+
import type { WithTimingConfig } from 'react-native-reanimated';
|
|
2
3
|
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
3
4
|
import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
|
|
4
5
|
import { ChevronDown as ChevronDownIcon } from '../internal/icons';
|
|
@@ -13,7 +14,7 @@ import AccordionProps from './AccordionProps';
|
|
|
13
14
|
|
|
14
15
|
type AccordionStyles = NamedStylesStringUnion<'root'>;
|
|
15
16
|
|
|
16
|
-
const
|
|
17
|
+
const ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 250 };
|
|
17
18
|
|
|
18
19
|
const useStyles: UseStyles<AccordionStyles> = function (): AccordionStyles {
|
|
19
20
|
const theme = useTheme();
|
|
@@ -38,15 +39,16 @@ export default function Accordion(props: AccordionProps) {
|
|
|
38
39
|
const styles = useStyles();
|
|
39
40
|
|
|
40
41
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
42
|
+
|
|
41
43
|
const rotate = useSharedValue(0);
|
|
42
44
|
|
|
43
45
|
const animatedChevronDownStyles = useAnimatedStyle(() => ({
|
|
44
46
|
transform: [{ rotate: `${rotate.value}deg` }],
|
|
45
|
-
}));
|
|
47
|
+
}), []);
|
|
46
48
|
|
|
47
49
|
const onPress = () => {
|
|
48
50
|
setIsExpanded(prev => !prev);
|
|
49
|
-
rotate.value = withTiming(!isExpanded ? 180 : 0,
|
|
51
|
+
rotate.value = withTiming(!isExpanded ? 180 : 0, ANIMATION_CONFIG);
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
return (
|
|
@@ -14,7 +14,7 @@ const ACTIVE_OPACITY = .65;
|
|
|
14
14
|
const ORIGINAL_SCALE = 1;
|
|
15
15
|
const MINIFIED_SCALE = .96;
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 150 };
|
|
18
18
|
|
|
19
19
|
const styles = StyleSheet.create({
|
|
20
20
|
disabled: {
|
|
@@ -46,7 +46,7 @@ export default function ButtonBase(props: ButtonBaseProps) {
|
|
|
46
46
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
47
47
|
opacity: opacity.value,
|
|
48
48
|
transform: [{ scale: scale.value }],
|
|
49
|
-
}));
|
|
49
|
+
}), []);
|
|
50
50
|
|
|
51
51
|
useDisabledReaction(disabled, opacity);
|
|
52
52
|
|
|
@@ -59,16 +59,16 @@ export default function ButtonBase(props: ButtonBaseProps) {
|
|
|
59
59
|
if (pressIn) {
|
|
60
60
|
opacity.value = ACTIVE_OPACITY;
|
|
61
61
|
} else {
|
|
62
|
-
opacity.value = withTiming(ORIGINAL_OPACITY,
|
|
62
|
+
opacity.value = withTiming(ORIGINAL_OPACITY, ANIMATION_CONFIG);
|
|
63
63
|
}
|
|
64
64
|
} else if (!isHovered) {
|
|
65
65
|
if (pressIn) {
|
|
66
66
|
scale.value = withDelay(
|
|
67
67
|
100,
|
|
68
|
-
withTiming(MINIFIED_SCALE,
|
|
68
|
+
withTiming(MINIFIED_SCALE, ANIMATION_CONFIG),
|
|
69
69
|
);
|
|
70
70
|
} else {
|
|
71
|
-
scale.value = withTiming(ORIGINAL_SCALE,
|
|
71
|
+
scale.value = withTiming(ORIGINAL_SCALE, ANIMATION_CONFIG);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
};
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
import { ViewProps } from 'react-native';
|
|
3
3
|
import { NamedStylesStringUnion, UseStyles } from '@fountain-ui/styles';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
interpolate,
|
|
7
|
-
useAnimatedStyle,
|
|
8
|
-
useSharedValue,
|
|
9
|
-
withRepeat,
|
|
10
|
-
withTiming,
|
|
11
|
-
} from 'react-native-reanimated';
|
|
4
|
+
import type { WithTimingConfig } from 'react-native-reanimated';
|
|
5
|
+
import Animated, { Easing, useAnimatedStyle, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
|
|
12
6
|
import { CircularProgress as CircularProgressIcon } from '../internal/icons';
|
|
13
7
|
import { css } from '../styles';
|
|
14
8
|
import { OverridableComponentProps } from '../types';
|
|
15
9
|
|
|
16
10
|
type CircularProgressStyles = NamedStylesStringUnion<'root'>;
|
|
17
11
|
|
|
12
|
+
const ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 900, easing: Easing.linear };
|
|
13
|
+
|
|
14
|
+
const MIN_ROTATE = 0;
|
|
15
|
+
const MAX_ROTATE = 360;
|
|
16
|
+
|
|
18
17
|
const useStyles: UseStyles<CircularProgressStyles> = function (): CircularProgressStyles {
|
|
19
18
|
return {
|
|
20
19
|
root: {
|
|
@@ -34,19 +33,15 @@ export default function CircularProgress(props: OverridableComponentProps<ViewPr
|
|
|
34
33
|
style,
|
|
35
34
|
]);
|
|
36
35
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const spinStyle = useAnimatedStyle(() => {
|
|
40
|
-
const interpolatedSpin = interpolate(sharedSpin.value, [0, 1], [0, 360]);
|
|
36
|
+
const rotate = useSharedValue(MIN_ROTATE);
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
38
|
+
const spinStyle = useAnimatedStyle(() => ({
|
|
39
|
+
transform: [{ rotate: `${rotate}deg` }],
|
|
40
|
+
}), []);
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
withTiming(
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
rotate.value = withRepeat(
|
|
44
|
+
withTiming(MAX_ROTATE, ANIMATION_CONFIG),
|
|
50
45
|
-1,
|
|
51
46
|
false,
|
|
52
47
|
);
|
|
@@ -7,7 +7,7 @@ import type ImageCoreProps from './ImageCoreProps';
|
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
const AnimatedFastImage = Animated.createAnimatedComponent(FastImage);
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 150 };
|
|
11
11
|
|
|
12
12
|
export default function ImageCore(props: ImageCoreProps) {
|
|
13
13
|
const {
|
|
@@ -25,10 +25,10 @@ export default function ImageCore(props: ImageCoreProps) {
|
|
|
25
25
|
|
|
26
26
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
27
27
|
opacity: opacity.value,
|
|
28
|
-
}));
|
|
28
|
+
}), []);
|
|
29
29
|
|
|
30
30
|
const handleLoad = () => {
|
|
31
|
-
opacity.value = withTiming(1,
|
|
31
|
+
opacity.value = withTiming(1, ANIMATION_CONFIG);
|
|
32
32
|
|
|
33
33
|
if (onLoad) {
|
|
34
34
|
onLoad();
|
package/src/Slide/Slide.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { Dimensions } from 'react-native';
|
|
3
3
|
import type { WithTimingConfig } from 'react-native-reanimated';
|
|
4
4
|
import Animated, { Easing, runOnJS, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
5
5
|
import type SlideProps from './SlideProps';
|
|
@@ -7,6 +7,8 @@ import type SlideProps from './SlideProps';
|
|
|
7
7
|
const defaultEnterDuration = 300;
|
|
8
8
|
const defaultExitDuration = 300;
|
|
9
9
|
|
|
10
|
+
const getDisappearingOffsetY = (): number => Dimensions.get('window').height;
|
|
11
|
+
|
|
10
12
|
export default function Slide(props: SlideProps) {
|
|
11
13
|
const {
|
|
12
14
|
animatedY: animatedYProp,
|
|
@@ -21,38 +23,38 @@ export default function Slide(props: SlideProps) {
|
|
|
21
23
|
...otherProps
|
|
22
24
|
} = props;
|
|
23
25
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const y = useSharedValue(window.height);
|
|
26
|
+
const y = useSharedValue(getDisappearingOffsetY());
|
|
27
27
|
const animatedY = animatedYProp || y;
|
|
28
28
|
|
|
29
29
|
const animatedStyle = useAnimatedStyle(() => ({
|
|
30
30
|
transform: [{ translateY: animatedY.value }],
|
|
31
|
-
}));
|
|
31
|
+
}), []);
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
useEffect(() => {
|
|
34
34
|
if (appear) {
|
|
35
|
-
|
|
35
|
+
onEnter?.();
|
|
36
|
+
|
|
37
|
+
const toValue = 0;
|
|
38
|
+
const enterConfig: Readonly<WithTimingConfig> = {
|
|
36
39
|
duration: enterDuration,
|
|
37
40
|
easing: Easing.out(Easing.exp),
|
|
38
41
|
};
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
animatedY.value = withTiming(0, enterConfig, isFinished => {
|
|
43
|
+
animatedY.value = withTiming(toValue, enterConfig, isFinished => {
|
|
43
44
|
if (isFinished && onEntered) {
|
|
44
45
|
runOnJS(onEntered)();
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
} else {
|
|
48
|
-
|
|
49
|
+
onExit?.();
|
|
50
|
+
|
|
51
|
+
const toValue = getDisappearingOffsetY();
|
|
52
|
+
const exitConfig: Readonly<WithTimingConfig> = {
|
|
49
53
|
duration: exitDuration,
|
|
50
54
|
easing: Easing.in(Easing.ease),
|
|
51
55
|
};
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
animatedY.value = withTiming(window.height, exitConfig, isFinished => {
|
|
57
|
+
animatedY.value = withTiming(toValue, exitConfig, isFinished => {
|
|
56
58
|
if (isFinished && onExited) {
|
|
57
59
|
runOnJS(onExited)();
|
|
58
60
|
}
|
package/src/Tabs/Tabs.tsx
CHANGED
|
@@ -89,7 +89,7 @@ export default function Tabs(props: TabsProps) {
|
|
|
89
89
|
useEffect(() => {
|
|
90
90
|
const scrollView = scrollViewRef.current;
|
|
91
91
|
|
|
92
|
-
if (scrollView
|
|
92
|
+
if (scrollView) {
|
|
93
93
|
scrollView.scrollTo({ x: scrollPosition, y: 0, animated: true });
|
|
94
94
|
}
|
|
95
95
|
}, [scrollPosition, containerWidth]);
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import UpArrow from './UpArrow';
|
|
|
12
12
|
const defaultOpacity = 0.8;
|
|
13
13
|
const initialLayout = { width: 0, height: 0, x: 0, y: 0 };
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 150 };
|
|
16
16
|
|
|
17
17
|
export default function Tooltip(props: TooltipProps) {
|
|
18
18
|
const {
|
|
@@ -36,7 +36,7 @@ export default function Tooltip(props: TooltipProps) {
|
|
|
36
36
|
|
|
37
37
|
const tooltipAnimatedStyle = useAnimatedStyle(() => ({
|
|
38
38
|
transform: [{ scale: scale.value }],
|
|
39
|
-
}));
|
|
39
|
+
}), []);
|
|
40
40
|
|
|
41
41
|
const [r, g, b] = rgb(theme.palette.primary.main);
|
|
42
42
|
|
|
@@ -54,9 +54,9 @@ export default function Tooltip(props: TooltipProps) {
|
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
React.useEffect(() => {
|
|
57
|
-
const
|
|
57
|
+
const nextScaleValue = visible ? 1 : 0;
|
|
58
58
|
|
|
59
|
-
scale.value = withTiming(
|
|
59
|
+
scale.value = withTiming(nextScaleValue, ANIMATION_CONFIG);
|
|
60
60
|
}, [visible]);
|
|
61
61
|
|
|
62
62
|
const touchableStyle: ViewProps['style'] = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useRef } from 'react';
|
|
2
2
|
import { Falsy, Keyboard, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
import type { WithTimingConfig } from 'react-native-reanimated';
|
|
3
4
|
import {
|
|
4
5
|
runOnJS,
|
|
5
6
|
useAnimatedScrollHandler,
|
|
@@ -45,7 +46,7 @@ const defaultOptions: Required<Options> = {
|
|
|
45
46
|
keyboardDismissMode: 'none',
|
|
46
47
|
};
|
|
47
48
|
|
|
48
|
-
const
|
|
49
|
+
const ANIMATION_CONFIG: Readonly<WithTimingConfig> = { duration: 100 };
|
|
49
50
|
|
|
50
51
|
const SUPPORTS_DRAG_DETECTION = Platform.OS !== 'web';
|
|
51
52
|
|
|
@@ -62,7 +63,7 @@ export default function useCollapsibleAppBar(userOptions: Options = defaultOptio
|
|
|
62
63
|
const [appBarHeight, onAppBarLayout] = useHeight();
|
|
63
64
|
const [collapsibleToolbarHeight, onCollapsibleToolbarLayout] = useHeight();
|
|
64
65
|
|
|
65
|
-
const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight);
|
|
66
|
+
const maxTranslateY = useDerivedValue(() => -collapsibleToolbarHeight, [collapsibleToolbarHeight]);
|
|
66
67
|
|
|
67
68
|
const translateY = useSharedValue<number>(0);
|
|
68
69
|
const lastTranslateY = useSharedValue<number>(0);
|
|
@@ -71,21 +72,23 @@ export default function useCollapsibleAppBar(userOptions: Options = defaultOptio
|
|
|
71
72
|
|
|
72
73
|
const elevationStyle = useElevationStyle(4);
|
|
73
74
|
const animatedStyle = useAnimatedStyle(() => {
|
|
75
|
+
const transform = [{ translateY: translateY.value }];
|
|
76
|
+
|
|
74
77
|
if (Platform.OS === 'web') {
|
|
75
78
|
return {
|
|
76
|
-
transform
|
|
79
|
+
transform,
|
|
77
80
|
boxShadow: overlapped.value ? elevationStyle?.boxShadow : 0,
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
83
|
if (Platform.OS === 'android') {
|
|
81
84
|
return {
|
|
82
|
-
transform
|
|
85
|
+
transform,
|
|
83
86
|
elevation: overlapped.value ? elevationStyle?.elevation : 0,
|
|
84
87
|
};
|
|
85
88
|
}
|
|
86
89
|
if (Platform.OS === 'ios') {
|
|
87
90
|
return {
|
|
88
|
-
transform
|
|
91
|
+
transform,
|
|
89
92
|
shadowColor: elevationStyle?.shadowColor,
|
|
90
93
|
shadowOffset: elevationStyle?.shadowOffset,
|
|
91
94
|
shadowRadius: elevationStyle?.shadowRadius,
|
|
@@ -93,10 +96,14 @@ export default function useCollapsibleAppBar(userOptions: Options = defaultOptio
|
|
|
93
96
|
};
|
|
94
97
|
}
|
|
95
98
|
return {};
|
|
96
|
-
}
|
|
99
|
+
}, [
|
|
100
|
+
/**
|
|
101
|
+
* FIXME: Consider add `elevationStyle` to dependencies.
|
|
102
|
+
*/
|
|
103
|
+
]);
|
|
97
104
|
|
|
98
|
-
const indexRef =
|
|
99
|
-
const offsetsRef =
|
|
105
|
+
const indexRef = useRef<number>(0);
|
|
106
|
+
const offsetsRef = useRef<Array<number>>([]);
|
|
100
107
|
|
|
101
108
|
const onScrollViewChanged = (nextIndex: number) => {
|
|
102
109
|
const prevIndex = indexRef.current;
|
|
@@ -116,9 +123,7 @@ export default function useCollapsibleAppBar(userOptions: Options = defaultOptio
|
|
|
116
123
|
|
|
117
124
|
// If next ScrollView's offset is too short, expand app bar.
|
|
118
125
|
if (translateY.value < 0 && savedOffsetY < appBarHeight) {
|
|
119
|
-
translateY.value = withTiming(0,
|
|
120
|
-
duration: ANIMATION_DURATION_MILLIS,
|
|
121
|
-
});
|
|
126
|
+
translateY.value = withTiming(0, ANIMATION_CONFIG);
|
|
122
127
|
}
|
|
123
128
|
};
|
|
124
129
|
|
|
@@ -147,15 +152,11 @@ export default function useCollapsibleAppBar(userOptions: Options = defaultOptio
|
|
|
147
152
|
} else {
|
|
148
153
|
if (offsetY > -maxTy) {
|
|
149
154
|
if (ty === 0) {
|
|
150
|
-
translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0),
|
|
151
|
-
duration: ANIMATION_DURATION_MILLIS,
|
|
152
|
-
});
|
|
155
|
+
translateY.value = withTiming(Math.min(Math.max(-offsetY, maxTy), 0), ANIMATION_CONFIG);
|
|
153
156
|
}
|
|
154
157
|
} else {
|
|
155
158
|
if (ty === maxTy) {
|
|
156
|
-
translateY.value = withTiming(0,
|
|
157
|
-
duration: ANIMATION_DURATION_MILLIS,
|
|
158
|
-
});
|
|
159
|
+
translateY.value = withTiming(0, ANIMATION_CONFIG);
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
|
|
@@ -186,11 +187,9 @@ export default function useCollapsibleAppBar(userOptions: Options = defaultOptio
|
|
|
186
187
|
|
|
187
188
|
overlapped.value = offsetY + nextTranslateY > 0;
|
|
188
189
|
|
|
189
|
-
translateY.value = withTiming(nextTranslateY,
|
|
190
|
-
duration: ANIMATION_DURATION_MILLIS,
|
|
191
|
-
});
|
|
190
|
+
translateY.value = withTiming(nextTranslateY, ANIMATION_CONFIG);
|
|
192
191
|
},
|
|
193
|
-
});
|
|
192
|
+
}, [keyboardDismissMode]);
|
|
194
193
|
|
|
195
194
|
const hasCollapsible = collapsibleToolbarHeight > 0;
|
|
196
195
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
import { Falsy, Keyboard, Platform, RegisteredStyle, ScrollViewProps, ViewProps, ViewStyle } from 'react-native';
|
|
3
3
|
import type { SharedValue } from 'react-native-reanimated';
|
|
4
4
|
import { runOnJS, useAnimatedScrollHandler, useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
|
|
@@ -58,7 +58,7 @@ export default function useFadeInAppBar(userOptions: Options = defaultOptions):
|
|
|
58
58
|
|
|
59
59
|
const [appBarHeight, onAppBarLayout] = useHeight();
|
|
60
60
|
|
|
61
|
-
const [fromOffsetY, toOffsetY] =
|
|
61
|
+
const [fromOffsetY, toOffsetY] = useMemo(() => {
|
|
62
62
|
const endY = typeof fadeInEndY === 'function'
|
|
63
63
|
? fadeInEndY(appBarHeight)
|
|
64
64
|
: fadeInEndY;
|
|
@@ -74,24 +74,25 @@ export default function useFadeInAppBar(userOptions: Options = defaultOptions):
|
|
|
74
74
|
const lastOffsetY = useSharedValue<number>(0);
|
|
75
75
|
const normalized = useSharedValue<number>(0);
|
|
76
76
|
|
|
77
|
-
const
|
|
78
|
-
const
|
|
77
|
+
const originalBackgroundColor = theme.palette.background.default;
|
|
78
|
+
const rgbValues = useMemo(() => rgb(originalBackgroundColor), [originalBackgroundColor]);
|
|
79
79
|
|
|
80
80
|
const animatedAppBarStyle = useAnimatedStyle(() => {
|
|
81
|
+
const [r, g, b] = rgbValues;
|
|
82
|
+
const backgroundColor = `rgba(${r}, ${g}, ${b}, ${normalized.value})`;
|
|
83
|
+
|
|
81
84
|
if (Platform.OS === 'web') {
|
|
82
|
-
return {
|
|
83
|
-
backgroundColor: `rgba(${r}, ${g}, ${b}, ${normalized.value})`,
|
|
84
|
-
};
|
|
85
|
+
return { backgroundColor };
|
|
85
86
|
}
|
|
86
87
|
if (Platform.OS === 'android') {
|
|
87
88
|
return {
|
|
88
|
-
backgroundColor
|
|
89
|
+
backgroundColor,
|
|
89
90
|
elevation: normalized.value >= 1 ? 6 : 0,
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
if (Platform.OS === 'ios') {
|
|
93
94
|
return {
|
|
94
|
-
backgroundColor
|
|
95
|
+
backgroundColor,
|
|
95
96
|
shadowColor: '#000',
|
|
96
97
|
shadowOffset,
|
|
97
98
|
shadowRadius: 4.65,
|
|
@@ -99,11 +100,11 @@ export default function useFadeInAppBar(userOptions: Options = defaultOptions):
|
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
return {};
|
|
102
|
-
});
|
|
103
|
+
}, [rgbValues]);
|
|
103
104
|
|
|
104
105
|
const animatedTitleStyle = useAnimatedStyle(() => ({
|
|
105
106
|
opacity: normalized.value,
|
|
106
|
-
}));
|
|
107
|
+
}), []);
|
|
107
108
|
|
|
108
109
|
const scrollHandler = useAnimatedScrollHandler({
|
|
109
110
|
onBeginDrag: () => {
|
|
@@ -127,7 +128,7 @@ export default function useFadeInAppBar(userOptions: Options = defaultOptions):
|
|
|
127
128
|
onMomentumEnd: (event) => {
|
|
128
129
|
lastOffsetY.value = event.contentOffset.y;
|
|
129
130
|
},
|
|
130
|
-
});
|
|
131
|
+
}, [keyboardDismissMode]);
|
|
131
132
|
|
|
132
133
|
const appBarStyle = [
|
|
133
134
|
animatedAppBarStyle,
|