react-native-animated-header-flat-list 1.1.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/LICENSE +20 -0
- package/README.md +224 -0
- package/lib/commonjs/components/AnimatedHeaderFlatList.js +195 -0
- package/lib/commonjs/components/AnimatedHeaderFlatList.js.map +1 -0
- package/lib/commonjs/hooks/useAnimatedHeaderFlatListAnimatedStyles.js +102 -0
- package/lib/commonjs/hooks/useAnimatedHeaderFlatListAnimatedStyles.js.map +1 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/components/AnimatedHeaderFlatList.js +189 -0
- package/lib/module/components/AnimatedHeaderFlatList.js.map +1 -0
- package/lib/module/hooks/useAnimatedHeaderFlatListAnimatedStyles.js +97 -0
- package/lib/module/hooks/useAnimatedHeaderFlatListAnimatedStyles.js.map +1 -0
- package/lib/module/index.js +5 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/components/AnimatedHeaderFlatList.d.ts +18 -0
- package/lib/typescript/commonjs/src/components/AnimatedHeaderFlatList.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useAnimatedHeaderFlatListAnimatedStyles.d.ts +24 -0
- package/lib/typescript/commonjs/src/hooks/useAnimatedHeaderFlatListAnimatedStyles.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +3 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/components/AnimatedHeaderFlatList.d.ts +18 -0
- package/lib/typescript/module/src/components/AnimatedHeaderFlatList.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useAnimatedHeaderFlatListAnimatedStyles.d.ts +24 -0
- package/lib/typescript/module/src/hooks/useAnimatedHeaderFlatListAnimatedStyles.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +3 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +199 -0
- package/src/components/AnimatedHeaderFlatList.tsx +299 -0
- package/src/hooks/useAnimatedHeaderFlatListAnimatedStyles.ts +179 -0
- package/src/index.tsx +3 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Karen
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# react-native-animated-header-flat-list
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/react-native-animated-header-flat-list)
|
|
4
|
+
[](https://www.npmjs.com/package/react-native-animated-header-flat-list)
|
|
5
|
+
[](https://www.npmjs.com/package/react-native-animated-header-flat-list)
|
|
6
|
+
[](https://expo.dev/)
|
|
7
|
+
|
|
8
|
+
A React Native FlatList component with an animated collapsible header, featuring parallax effects, smooth title transitions, sticky component support, and customizable styles. Built with TypeScript and separate background/content layers in header.
|
|
9
|
+
|
|
10
|
+
English | [简体中文](./README_zh.md)
|
|
11
|
+
|
|
12
|
+
## Preview
|
|
13
|
+
|
|
14
|
+
<div align="center">
|
|
15
|
+
<table style='width:100%;'>
|
|
16
|
+
<tr>
|
|
17
|
+
<td><h4 align='center'>iOS</h4></td>
|
|
18
|
+
<td><h4 align='center'>Android</h4></td>
|
|
19
|
+
<td><h4 align='center'>Web</h4></td>
|
|
20
|
+
</tr>
|
|
21
|
+
<tr>
|
|
22
|
+
<td><img width="296" height="640" src="./assets/iOS.gif" alt="iOS"></td>
|
|
23
|
+
<td><img width="311" height="640" src="./assets/Android.gif" alt="Android"></td>
|
|
24
|
+
<td><img width="296" height="640" src="./assets/Web.gif" alt="Web"></td>
|
|
25
|
+
</tr>
|
|
26
|
+
</table>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- Animated collapsible header with parallax effect
|
|
32
|
+
- Smooth title transition from header to navigation bar
|
|
33
|
+
- Optional sticky component support
|
|
34
|
+
- Fully customizable header and title styles
|
|
35
|
+
- Separate background and content layers in header
|
|
36
|
+
- TypeScript support
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm install react-native-animated-header-flat-list
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Required Peer Dependencies
|
|
45
|
+
|
|
46
|
+
This library requires the following peer dependencies to be installed in your project:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npm install @react-navigation/native @react-navigation/native-stack @react-navigation/elements react-native-reanimated react-native-safe-area-context
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Make sure to follow the installation instructions for each dependency:
|
|
53
|
+
|
|
54
|
+
- [React Navigation](https://reactnavigation.org/docs/getting-started)
|
|
55
|
+
- [React Native Reanimated](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started)
|
|
56
|
+
- [React Native Safe Area Context](https://github.com/th3rdwave/react-native-safe-area-context#getting-started)
|
|
57
|
+
|
|
58
|
+
### Additional Setup
|
|
59
|
+
|
|
60
|
+
For React Native Reanimated, add this to your `babel.config.js`:
|
|
61
|
+
```js
|
|
62
|
+
module.exports = {
|
|
63
|
+
plugins: [
|
|
64
|
+
'react-native-reanimated/plugin',
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import { useNavigation } from '@react-navigation/native';
|
|
73
|
+
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
74
|
+
import { useCallback } from 'react';
|
|
75
|
+
import { Image, ImageBackground, StyleSheet, Text, View } from 'react-native';
|
|
76
|
+
import { AnimatedHeaderFlatList } from 'react-native-animated-header-flat-list';
|
|
77
|
+
|
|
78
|
+
export default function HomeScreen() {
|
|
79
|
+
const navigation = useNavigation<NativeStackNavigationProp<any>>();
|
|
80
|
+
const data = Array.from({ length: 50 }, (_, index) => ({
|
|
81
|
+
id: `item-${index}`,
|
|
82
|
+
title: `Item ${index + 1}`,
|
|
83
|
+
description: 'Lorem ipsum dolor sit amet',
|
|
84
|
+
}));
|
|
85
|
+
const title = 'Animated Title';
|
|
86
|
+
const backgroundImageUrl =
|
|
87
|
+
'https://images.unsplash.com/photo-1579546929518-9e396f3cc809';
|
|
88
|
+
const avatarUrl = 'https://api.dicebear.com/7.x/avataaars/png?seed=John';
|
|
89
|
+
|
|
90
|
+
const HeaderBackground = useCallback(
|
|
91
|
+
() => (
|
|
92
|
+
<ImageBackground
|
|
93
|
+
source={{ uri: backgroundImageUrl }}
|
|
94
|
+
style={styles.headerBackground}
|
|
95
|
+
/>
|
|
96
|
+
),
|
|
97
|
+
[backgroundImageUrl]
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
const HeaderContent = useCallback(
|
|
101
|
+
() => (
|
|
102
|
+
<View style={styles.headerContent}>
|
|
103
|
+
<Image source={{ uri: avatarUrl }} style={styles.avatar} />
|
|
104
|
+
</View>
|
|
105
|
+
),
|
|
106
|
+
[avatarUrl]
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const StickyComponent = useCallback(
|
|
110
|
+
() => <Text style={styles.stickyComponent}>Sticky Item</Text>,
|
|
111
|
+
[]
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const renderItem = useCallback(
|
|
115
|
+
({
|
|
116
|
+
item,
|
|
117
|
+
}: {
|
|
118
|
+
item: { id: string; title: string; description: string };
|
|
119
|
+
}) => (
|
|
120
|
+
<View style={styles.listItem}>
|
|
121
|
+
<Text style={styles.itemTitle}>{item.title}</Text>
|
|
122
|
+
<Text style={styles.itemDescription}>{item.description}</Text>
|
|
123
|
+
</View>
|
|
124
|
+
),
|
|
125
|
+
[]
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<AnimatedHeaderFlatList
|
|
130
|
+
navigation={navigation}
|
|
131
|
+
title={title}
|
|
132
|
+
headerTitleStyle={styles.headerTitle}
|
|
133
|
+
navigationTitleStyle={styles.navigationTitle}
|
|
134
|
+
HeaderBackground={HeaderBackground}
|
|
135
|
+
HeaderContent={HeaderContent}
|
|
136
|
+
StickyComponent={StickyComponent}
|
|
137
|
+
data={data}
|
|
138
|
+
renderItem={renderItem}
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const styles = StyleSheet.create({
|
|
144
|
+
headerBackground: {
|
|
145
|
+
backgroundColor: 'white',
|
|
146
|
+
height: 300,
|
|
147
|
+
width: '100%',
|
|
148
|
+
},
|
|
149
|
+
headerContent: {
|
|
150
|
+
height: 300,
|
|
151
|
+
width: '100%',
|
|
152
|
+
},
|
|
153
|
+
avatar: {
|
|
154
|
+
position: 'absolute',
|
|
155
|
+
top: 80,
|
|
156
|
+
left: 10,
|
|
157
|
+
backgroundColor: 'white',
|
|
158
|
+
width: 120,
|
|
159
|
+
height: 120,
|
|
160
|
+
borderRadius: 60,
|
|
161
|
+
borderWidth: 2,
|
|
162
|
+
borderColor: 'white',
|
|
163
|
+
},
|
|
164
|
+
headerTitle: {
|
|
165
|
+
position: 'absolute',
|
|
166
|
+
top: 200,
|
|
167
|
+
left: 10,
|
|
168
|
+
fontSize: 30,
|
|
169
|
+
fontWeight: 'bold',
|
|
170
|
+
color: 'white',
|
|
171
|
+
},
|
|
172
|
+
navigationTitle: {
|
|
173
|
+
fontSize: 18,
|
|
174
|
+
fontWeight: '600',
|
|
175
|
+
color: 'white',
|
|
176
|
+
},
|
|
177
|
+
stickyComponent: {
|
|
178
|
+
backgroundColor: 'white',
|
|
179
|
+
padding: 15,
|
|
180
|
+
borderWidth: 1,
|
|
181
|
+
borderColor: '#EEEEEE',
|
|
182
|
+
},
|
|
183
|
+
listItem: {
|
|
184
|
+
padding: 15,
|
|
185
|
+
borderBottomWidth: 1,
|
|
186
|
+
borderBottomColor: '#EEEEEE',
|
|
187
|
+
backgroundColor: 'white',
|
|
188
|
+
},
|
|
189
|
+
itemTitle: {
|
|
190
|
+
fontSize: 16,
|
|
191
|
+
fontWeight: '600',
|
|
192
|
+
},
|
|
193
|
+
itemDescription: {
|
|
194
|
+
fontSize: 14,
|
|
195
|
+
color: '#666666',
|
|
196
|
+
marginTop: 4,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Props
|
|
202
|
+
|
|
203
|
+
| Prop | Type | Required | Description |
|
|
204
|
+
| ------------------- | ------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
205
|
+
| `navigation` | NavigationProp<any> | Yes | React Navigation navigation prop |
|
|
206
|
+
| `title` | string | Yes | The title text that will animate between header and navigation bar |
|
|
207
|
+
| `headerTitleStyle` | StyleProp<TextStyle> | No | Style object for the title in the header. Supports all Text style props. Position is relative to header container |
|
|
208
|
+
| `navigationTitleStyle` | StyleProp<TextStyle> | No | Style object for the title in the navigation bar. Supports all Text style props except position-related properties |
|
|
209
|
+
| `HeaderBackground` | React.ComponentType | Yes | Component to be rendered as the header background |
|
|
210
|
+
| `HeaderContent` | React.ComponentType | No | Component to be rendered on top of the header background. Its opacity will automatically animate based on scroll position |
|
|
211
|
+
| `StickyComponent` | React.ComponentType | No | Optional component that sticks below the navigation bar |
|
|
212
|
+
| `...FlatListProps` | FlatListProps | - | All standard FlatList props are supported |
|
|
213
|
+
|
|
214
|
+
## Contributing
|
|
215
|
+
|
|
216
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
217
|
+
|
|
218
|
+
## License
|
|
219
|
+
|
|
220
|
+
MIT
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AnimatedHeaderFlatList = AnimatedHeaderFlatList;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _useAnimatedHeaderFlatListAnimatedStyles = require("../hooks/useAnimatedHeaderFlatListAnimatedStyles.js");
|
|
10
|
+
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
// Types
|
|
16
|
+
|
|
17
|
+
function AnimatedHeaderFlatList({
|
|
18
|
+
navigation,
|
|
19
|
+
title,
|
|
20
|
+
headerTitleStyle,
|
|
21
|
+
navigationTitleStyle,
|
|
22
|
+
HeaderBackground,
|
|
23
|
+
HeaderContent,
|
|
24
|
+
StickyComponent,
|
|
25
|
+
style,
|
|
26
|
+
...flatListProps
|
|
27
|
+
}) {
|
|
28
|
+
const getFontSizeFromStyle = (0, _react.useCallback)(textStyle => {
|
|
29
|
+
if (!textStyle) return undefined;
|
|
30
|
+
if (Array.isArray(textStyle)) {
|
|
31
|
+
for (const styleItem of textStyle) {
|
|
32
|
+
if (styleItem && typeof styleItem === 'object' && 'fontSize' in styleItem) {
|
|
33
|
+
return styleItem.fontSize;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} else if (typeof textStyle === 'object' && 'fontSize' in textStyle) {
|
|
37
|
+
return textStyle.fontSize;
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}, []);
|
|
41
|
+
const {
|
|
42
|
+
scrollHandler,
|
|
43
|
+
navigationBarHeight,
|
|
44
|
+
headerLayout,
|
|
45
|
+
setHeaderLayout,
|
|
46
|
+
setHeaderTitleLayout,
|
|
47
|
+
stickyComponentLayout,
|
|
48
|
+
setStickyComponentLayout,
|
|
49
|
+
navigationTitleAnimatedStyle,
|
|
50
|
+
headerTitleAnimatedStyle,
|
|
51
|
+
stickyHeaderAnimatedStyle,
|
|
52
|
+
headerContentAnimatedStyle,
|
|
53
|
+
headerBackgroundAnimatedStyle
|
|
54
|
+
} = (0, _useAnimatedHeaderFlatListAnimatedStyles.useAnimatedHeaderFlatListAnimatedStyles)({
|
|
55
|
+
headerTitleFontSize: getFontSizeFromStyle(headerTitleStyle),
|
|
56
|
+
navigationTitleFontSize: getFontSizeFromStyle(navigationTitleStyle)
|
|
57
|
+
});
|
|
58
|
+
const navigationTitle = (0, _react.useCallback)(() => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.Text, {
|
|
59
|
+
style: [navigationTitleAnimatedStyle, navigationTitleStyle, styles.titleStyle],
|
|
60
|
+
numberOfLines: 1,
|
|
61
|
+
children: title
|
|
62
|
+
}), [navigationTitleAnimatedStyle, navigationTitleStyle, title]);
|
|
63
|
+
(0, _react.useLayoutEffect)(() => {
|
|
64
|
+
navigation.setOptions({
|
|
65
|
+
headerShown: true,
|
|
66
|
+
headerStyle: styles.navigationBar,
|
|
67
|
+
headerShadowVisible: false,
|
|
68
|
+
headerTransparent: true,
|
|
69
|
+
headerTitle: navigationTitle,
|
|
70
|
+
headerTitleAlign: 'center'
|
|
71
|
+
});
|
|
72
|
+
}, [navigationTitle, navigation]);
|
|
73
|
+
const ListHeaderComponent = (0, _react.useMemo)(() => {
|
|
74
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
75
|
+
style: styles.headerWrapper,
|
|
76
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
77
|
+
style: [styles.headerContainer, {
|
|
78
|
+
top: -navigationBarHeight
|
|
79
|
+
}],
|
|
80
|
+
onLayout: event => {
|
|
81
|
+
setHeaderLayout({
|
|
82
|
+
...event.nativeEvent.layout,
|
|
83
|
+
height: event.nativeEvent.layout.height + navigationBarHeight
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
87
|
+
style: headerBackgroundAnimatedStyle,
|
|
88
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HeaderBackground, {})
|
|
89
|
+
}), HeaderContent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
90
|
+
style: [headerContentAnimatedStyle, styles.headerContentContainer],
|
|
91
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HeaderContent, {})
|
|
92
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.Text, {
|
|
93
|
+
onLayout: event => {
|
|
94
|
+
setHeaderTitleLayout(event.nativeEvent.layout);
|
|
95
|
+
},
|
|
96
|
+
numberOfLines: 1,
|
|
97
|
+
style: [headerTitleAnimatedStyle, styles.headerTitle, headerTitleStyle],
|
|
98
|
+
children: title
|
|
99
|
+
})]
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
}, [navigationBarHeight, headerBackgroundAnimatedStyle, HeaderBackground, HeaderContent, headerContentAnimatedStyle, headerTitleAnimatedStyle, headerTitleStyle, title, setHeaderLayout, setHeaderTitleLayout]);
|
|
103
|
+
const renderItem = (0, _react.useCallback)(({
|
|
104
|
+
item
|
|
105
|
+
}) => {
|
|
106
|
+
if (item === 'HEADER') {
|
|
107
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
108
|
+
style: [styles.stickyHeaderContainer, {
|
|
109
|
+
height: navigationBarHeight + stickyComponentLayout.height
|
|
110
|
+
}],
|
|
111
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
112
|
+
style: [stickyHeaderAnimatedStyle, styles.stickyHeader, {
|
|
113
|
+
bottom: headerLayout.height - navigationBarHeight * 2 + stickyComponentLayout.height
|
|
114
|
+
}],
|
|
115
|
+
children: ListHeaderComponent
|
|
116
|
+
}), StickyComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
117
|
+
style: styles.stickyComponentContainer,
|
|
118
|
+
onLayout: event => {
|
|
119
|
+
setStickyComponentLayout(event.nativeEvent.layout);
|
|
120
|
+
},
|
|
121
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StickyComponent, {})
|
|
122
|
+
})]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return flatListProps.renderItem && typeof flatListProps.renderItem === 'function' ? flatListProps.renderItem({
|
|
126
|
+
item
|
|
127
|
+
}) : null;
|
|
128
|
+
}, [flatListProps, navigationBarHeight, stickyComponentLayout.height, stickyHeaderAnimatedStyle, headerLayout.height, ListHeaderComponent, StickyComponent, setStickyComponentLayout]);
|
|
129
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.FlatList, {
|
|
130
|
+
...flatListProps,
|
|
131
|
+
style: style,
|
|
132
|
+
stickyHeaderHiddenOnScroll: false,
|
|
133
|
+
stickyHeaderIndices: [1],
|
|
134
|
+
ListHeaderComponent: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
|
|
135
|
+
style: [styles.mainHeaderContainer, {
|
|
136
|
+
height: headerLayout.height - navigationBarHeight * 2,
|
|
137
|
+
transform: [{
|
|
138
|
+
translateY: navigationBarHeight
|
|
139
|
+
}]
|
|
140
|
+
}],
|
|
141
|
+
children: ListHeaderComponent
|
|
142
|
+
}),
|
|
143
|
+
onScroll: scrollHandler,
|
|
144
|
+
data: ['HEADER', ...(Array.isArray(flatListProps.data) ? flatListProps.data : [])],
|
|
145
|
+
renderItem: renderItem
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const styles = _reactNative.StyleSheet.create({
|
|
149
|
+
navigationBar: {
|
|
150
|
+
backgroundColor: 'transparent'
|
|
151
|
+
},
|
|
152
|
+
titleStyle: {
|
|
153
|
+
left: 0,
|
|
154
|
+
right: 0,
|
|
155
|
+
top: 0,
|
|
156
|
+
bottom: 0
|
|
157
|
+
},
|
|
158
|
+
headerWrapper: {
|
|
159
|
+
overflow: 'visible'
|
|
160
|
+
},
|
|
161
|
+
headerContainer: {
|
|
162
|
+
left: 0,
|
|
163
|
+
right: 0,
|
|
164
|
+
overflow: 'visible',
|
|
165
|
+
position: 'absolute'
|
|
166
|
+
},
|
|
167
|
+
stickyHeaderContainer: {
|
|
168
|
+
overflow: 'scroll'
|
|
169
|
+
},
|
|
170
|
+
stickyHeader: {
|
|
171
|
+
position: 'absolute',
|
|
172
|
+
left: 0,
|
|
173
|
+
right: 0
|
|
174
|
+
},
|
|
175
|
+
mainHeaderContainer: {
|
|
176
|
+
overflow: 'visible'
|
|
177
|
+
},
|
|
178
|
+
headerTitle: {
|
|
179
|
+
position: 'absolute'
|
|
180
|
+
},
|
|
181
|
+
stickyComponentContainer: {
|
|
182
|
+
position: 'absolute',
|
|
183
|
+
bottom: 0,
|
|
184
|
+
left: 0,
|
|
185
|
+
right: 0
|
|
186
|
+
},
|
|
187
|
+
headerContentContainer: {
|
|
188
|
+
position: 'absolute',
|
|
189
|
+
top: 0,
|
|
190
|
+
left: 0,
|
|
191
|
+
right: 0,
|
|
192
|
+
bottom: 0
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
//# sourceMappingURL=AnimatedHeaderFlatList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_useAnimatedHeaderFlatListAnimatedStyles","_reactNativeReanimated","_interopRequireDefault","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AnimatedHeaderFlatList","navigation","title","headerTitleStyle","navigationTitleStyle","HeaderBackground","HeaderContent","StickyComponent","style","flatListProps","getFontSizeFromStyle","useCallback","textStyle","undefined","Array","isArray","styleItem","fontSize","scrollHandler","navigationBarHeight","headerLayout","setHeaderLayout","setHeaderTitleLayout","stickyComponentLayout","setStickyComponentLayout","navigationTitleAnimatedStyle","headerTitleAnimatedStyle","stickyHeaderAnimatedStyle","headerContentAnimatedStyle","headerBackgroundAnimatedStyle","useAnimatedHeaderFlatListAnimatedStyles","headerTitleFontSize","navigationTitleFontSize","navigationTitle","jsx","Text","styles","titleStyle","numberOfLines","children","useLayoutEffect","setOptions","headerShown","headerStyle","navigationBar","headerShadowVisible","headerTransparent","headerTitle","headerTitleAlign","ListHeaderComponent","useMemo","View","headerWrapper","jsxs","headerContainer","top","onLayout","event","nativeEvent","layout","height","headerContentContainer","renderItem","item","stickyHeaderContainer","stickyHeader","bottom","stickyComponentContainer","FlatList","stickyHeaderHiddenOnScroll","stickyHeaderIndices","mainHeaderContainer","transform","translateY","onScroll","data","StyleSheet","create","backgroundColor","left","right","overflow","position"],"sourceRoot":"../../../src","sources":["components/AnimatedHeaderFlatList.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAYA,IAAAE,wCAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAA+C,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAI,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CA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AE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRzB,GAAG,EAAE,CAAC;IACNW,MAAM,EAAE;EACV,CAAC;EACDd,aAAa,EAAE;IACb6B,QAAQ,EAAE;EACZ,CAAC;EACD3B,eAAe,EAAE;IACfyB,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,QAAQ,EAAE,SAAS;IACnBC,QAAQ,EAAE;EACZ,CAAC;EACDlB,qBAAqB,EAAE;IACrBiB,QAAQ,EAAE;EACZ,CAAC;EACDhB,YAAY,EAAE;IACZiB,QAAQ,EAAE,UAAU;IACpBH,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE;EACT,CAAC;EACDT,mBAAmB,EAAE;IACnBU,QAAQ,EAAE;EACZ,CAAC;EACDlC,WAAW,EAAE;IACXmC,QAAQ,EAAE;EACZ,CAAC;EACDf,wBAAwB,EAAE;IACxBe,QAAQ,EAAE,UAAU;IACpBhB,MAAM,EAAE,CAAC;IACTa,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE;EACT,CAAC;EACDnB,sBAAsB,EAAE;IACtBqB,QAAQ,EAAE,UAAU;IACpB3B,GAAG,EAAE,CAAC;IACNwB,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRd,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAnimatedHeaderFlatListAnimatedStyles = void 0;
|
|
7
|
+
var _elements = require("@react-navigation/elements");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
var _reactNativeReanimated = require("react-native-reanimated");
|
|
11
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
12
|
+
const useAnimatedHeaderFlatListAnimatedStyles = ({
|
|
13
|
+
headerTitleFontSize,
|
|
14
|
+
navigationTitleFontSize
|
|
15
|
+
}) => {
|
|
16
|
+
const {
|
|
17
|
+
width: windowWidth
|
|
18
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
19
|
+
const scrollY = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
20
|
+
const navigationBarHeight = (0, _elements.useHeaderHeight)();
|
|
21
|
+
const safeAreaInsets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
22
|
+
const [headerLayout, setHeaderLayout] = (0, _react.useState)({
|
|
23
|
+
x: 0,
|
|
24
|
+
y: 0,
|
|
25
|
+
width: 0,
|
|
26
|
+
height: 0
|
|
27
|
+
});
|
|
28
|
+
const [headerTitleLayout, setHeaderTitleLayout] = (0, _react.useState)({
|
|
29
|
+
x: 0,
|
|
30
|
+
y: 0,
|
|
31
|
+
width: 0,
|
|
32
|
+
height: 0
|
|
33
|
+
});
|
|
34
|
+
const [stickyComponentLayout, setStickyComponentLayout] = (0, _react.useState)({
|
|
35
|
+
x: 0,
|
|
36
|
+
y: 0,
|
|
37
|
+
width: 0,
|
|
38
|
+
height: 0
|
|
39
|
+
});
|
|
40
|
+
const distanceBetweenTitleAndNavigationBar = (navigationBarHeight - safeAreaInsets.top + headerTitleLayout.height) / 2 + headerTitleLayout.y - navigationBarHeight;
|
|
41
|
+
const navigationTitleOpacity = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
42
|
+
const stickyHeaderOpacity = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
43
|
+
const navigationTitleAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
44
|
+
return {
|
|
45
|
+
opacity: navigationTitleOpacity.value
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
const headerTitleAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
49
|
+
return {
|
|
50
|
+
opacity: 1 - navigationTitleOpacity.value,
|
|
51
|
+
transform: [{
|
|
52
|
+
translateX: (0, _reactNativeReanimated.interpolate)(scrollY.value, [0, distanceBetweenTitleAndNavigationBar], [0, windowWidth / 2 - headerTitleLayout.x - headerTitleLayout.width / 2], 'clamp')
|
|
53
|
+
}, {
|
|
54
|
+
scale: (0, _reactNativeReanimated.interpolate)(scrollY.value, [0, distanceBetweenTitleAndNavigationBar], [1, navigationTitleFontSize && headerTitleFontSize ? navigationTitleFontSize / headerTitleFontSize : 1], 'clamp')
|
|
55
|
+
}]
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
const stickyHeaderAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
59
|
+
return {
|
|
60
|
+
opacity: stickyHeaderOpacity.value
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
const headerContentAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
64
|
+
return {
|
|
65
|
+
opacity: (0, _reactNativeReanimated.interpolate)(scrollY.value, [0, headerLayout.height - navigationBarHeight * 2], [1, 0], 'clamp')
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const headerBackgroundAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
69
|
+
if (scrollY.value >= 0) {
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
transform: [{
|
|
74
|
+
translateY: (0, _reactNativeReanimated.interpolate)(scrollY.value, [scrollY.value, 0], [scrollY.value / 2, 0], 'clamp')
|
|
75
|
+
}, {
|
|
76
|
+
scale: (0, _reactNativeReanimated.interpolate)(scrollY.value, [scrollY.value, 0], [1 - scrollY.value / (headerLayout.height - navigationBarHeight), 1, 1], 'clamp')
|
|
77
|
+
}]
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
const scrollHandler = (0, _reactNativeReanimated.useAnimatedScrollHandler)(event => {
|
|
81
|
+
scrollY.value = event.contentOffset.y;
|
|
82
|
+
navigationTitleOpacity.value = event.contentOffset.y >= distanceBetweenTitleAndNavigationBar ? 1 : 0;
|
|
83
|
+
stickyHeaderOpacity.value = event.contentOffset.y >= headerLayout.height - navigationBarHeight * 2 ? 1 : 0;
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
scrollHandler,
|
|
87
|
+
navigationBarHeight,
|
|
88
|
+
headerLayout,
|
|
89
|
+
setHeaderLayout,
|
|
90
|
+
headerTitleLayout,
|
|
91
|
+
setHeaderTitleLayout,
|
|
92
|
+
stickyComponentLayout,
|
|
93
|
+
setStickyComponentLayout,
|
|
94
|
+
navigationTitleAnimatedStyle,
|
|
95
|
+
headerTitleAnimatedStyle,
|
|
96
|
+
stickyHeaderAnimatedStyle,
|
|
97
|
+
headerContentAnimatedStyle,
|
|
98
|
+
headerBackgroundAnimatedStyle
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
exports.useAnimatedHeaderFlatListAnimatedStyles = useAnimatedHeaderFlatListAnimatedStyles;
|
|
102
|
+
//# sourceMappingURL=useAnimatedHeaderFlatListAnimatedStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_elements","require","_react","_reactNative","_reactNativeReanimated","_reactNativeSafeAreaContext","useAnimatedHeaderFlatListAnimatedStyles","headerTitleFontSize","navigationTitleFontSize","width","windowWidth","useWindowDimensions","scrollY","useSharedValue","navigationBarHeight","useHeaderHeight","safeAreaInsets","useSafeAreaInsets","headerLayout","setHeaderLayout","useState","x","y","height","headerTitleLayout","setHeaderTitleLayout","stickyComponentLayout","setStickyComponentLayout","distanceBetweenTitleAndNavigationBar","top","navigationTitleOpacity","stickyHeaderOpacity","navigationTitleAnimatedStyle","useAnimatedStyle","opacity","value","headerTitleAnimatedStyle","transform","translateX","interpolate","scale","stickyHeaderAnimatedStyle","headerContentAnimatedStyle","headerBackgroundAnimatedStyle","translateY","scrollHandler","useAnimatedScrollHandler","event","contentOffset","exports"],"sourceRoot":"../../../src","sources":["hooks/useAnimatedHeaderFlatListAnimatedStyles.ts"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BAAwB;IACxBK,yBAAyB;IACzBC,0BAA0B;IAC1BC;EACF,CAAC;AACH,CAAC;AAACM,OAAA,CAAA3C,uCAAA,GAAAA,uCAAA","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AnimatedHeaderFlatList", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _AnimatedHeaderFlatList.AnimatedHeaderFlatList;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _AnimatedHeaderFlatList = require("./components/AnimatedHeaderFlatList.js");
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_AnimatedHeaderFlatList","require"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;AAAA,IAAAA,uBAAA,GAAAC,OAAA","ignoreList":[]}
|