react-native-refresh-list2 1.0.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 +67 -0
- package/lib/module/Loading/Loading.js +19 -0
- package/lib/module/Loading/Loading.js.map +1 -0
- package/lib/module/Loading/index.js +5 -0
- package/lib/module/Loading/index.js.map +1 -0
- package/lib/module/RefreshControl/BottomContainer.js +88 -0
- package/lib/module/RefreshControl/BottomContainer.js.map +1 -0
- package/lib/module/RefreshControl/NormalControl.js +94 -0
- package/lib/module/RefreshControl/NormalControl.js.map +1 -0
- package/lib/module/RefreshControl/RefreshContainer.js +53 -0
- package/lib/module/RefreshControl/RefreshContainer.js.map +1 -0
- package/lib/module/RefreshControl/RefreshContext.js +32 -0
- package/lib/module/RefreshControl/RefreshContext.js.map +1 -0
- package/lib/module/RefreshControl/RefreshFlatList.js +291 -0
- package/lib/module/RefreshControl/RefreshFlatList.js.map +1 -0
- package/lib/module/RefreshControl/RefreshScrollView.js +279 -0
- package/lib/module/RefreshControl/RefreshScrollView.js.map +1 -0
- package/lib/module/RefreshControl/index.js +7 -0
- package/lib/module/RefreshControl/index.js.map +1 -0
- package/lib/module/RefreshControl/type.js +39 -0
- package/lib/module/RefreshControl/type.js.map +1 -0
- package/lib/module/icon/CommentIcon.js +32 -0
- package/lib/module/icon/CommentIcon.js.map +1 -0
- package/lib/module/icon/Icon.js +25 -0
- package/lib/module/icon/Icon.js.map +1 -0
- package/lib/module/icon/MoreIcon.js +40 -0
- package/lib/module/icon/MoreIcon.js.map +1 -0
- package/lib/module/icon/Praise.js +23 -0
- package/lib/module/icon/Praise.js.map +1 -0
- package/lib/module/icon/SearchIcon.js +35 -0
- package/lib/module/icon/SearchIcon.js.map +1 -0
- package/lib/module/icon/index.js +5 -0
- package/lib/module/icon/index.js.map +1 -0
- package/lib/module/icon/library.js +20 -0
- package/lib/module/icon/library.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Loading/Loading.d.ts +9 -0
- package/lib/typescript/src/Loading/Loading.d.ts.map +1 -0
- package/lib/typescript/src/Loading/index.d.ts +3 -0
- package/lib/typescript/src/Loading/index.d.ts.map +1 -0
- package/lib/typescript/src/RefreshControl/BottomContainer.d.ts +17 -0
- package/lib/typescript/src/RefreshControl/BottomContainer.d.ts.map +1 -0
- package/lib/typescript/src/RefreshControl/NormalControl.d.ts +20 -0
- package/lib/typescript/src/RefreshControl/NormalControl.d.ts.map +1 -0
- package/lib/typescript/src/RefreshControl/RefreshContainer.d.ts +17 -0
- package/lib/typescript/src/RefreshControl/RefreshContainer.d.ts.map +1 -0
- package/lib/typescript/src/RefreshControl/RefreshContext.d.ts +9 -0
- package/lib/typescript/src/RefreshControl/RefreshContext.d.ts.map +1 -0
- package/lib/typescript/src/RefreshControl/RefreshFlatList.d.ts +20 -0
- package/lib/typescript/src/RefreshControl/RefreshFlatList.d.ts.map +1 -0
- package/lib/typescript/src/RefreshControl/RefreshScrollView.d.ts +20 -0
- package/lib/typescript/src/RefreshControl/RefreshScrollView.d.ts.map +1 -0
- package/lib/typescript/src/RefreshControl/index.d.ts +5 -0
- package/lib/typescript/src/RefreshControl/index.d.ts.map +1 -0
- package/lib/typescript/src/RefreshControl/type.d.ts +70 -0
- package/lib/typescript/src/RefreshControl/type.d.ts.map +1 -0
- package/lib/typescript/src/icon/CommentIcon.d.ts +3 -0
- package/lib/typescript/src/icon/CommentIcon.d.ts.map +1 -0
- package/lib/typescript/src/icon/Icon.d.ts +10 -0
- package/lib/typescript/src/icon/Icon.d.ts.map +1 -0
- package/lib/typescript/src/icon/MoreIcon.d.ts +3 -0
- package/lib/typescript/src/icon/MoreIcon.d.ts.map +1 -0
- package/lib/typescript/src/icon/Praise.d.ts +9 -0
- package/lib/typescript/src/icon/Praise.d.ts.map +1 -0
- package/lib/typescript/src/icon/SearchIcon.d.ts +9 -0
- package/lib/typescript/src/icon/SearchIcon.d.ts.map +1 -0
- package/lib/typescript/src/icon/index.d.ts +3 -0
- package/lib/typescript/src/icon/index.d.ts.map +1 -0
- package/lib/typescript/src/icon/library.d.ts +17 -0
- package/lib/typescript/src/icon/library.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +168 -0
- package/src/Loading/Loading.tsx +15 -0
- package/src/Loading/index.tsx +5 -0
- package/src/RefreshControl/BottomContainer.tsx +112 -0
- package/src/RefreshControl/NormalControl.tsx +118 -0
- package/src/RefreshControl/RefreshContainer.tsx +74 -0
- package/src/RefreshControl/RefreshContext.tsx +30 -0
- package/src/RefreshControl/RefreshFlatList.tsx +372 -0
- package/src/RefreshControl/RefreshScrollView.tsx +359 -0
- package/src/RefreshControl/index.tsx +5 -0
- package/src/RefreshControl/type.ts +74 -0
- package/src/icon/CommentIcon.tsx +29 -0
- package/src/icon/Icon.tsx +26 -0
- package/src/icon/MoreIcon.tsx +38 -0
- package/src/icon/Praise.tsx +21 -0
- package/src/icon/SearchIcon.tsx +36 -0
- package/src/icon/index.tsx +3 -0
- package/src/icon/library.ts +30 -0
- package/src/index.tsx +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 tangfeifan
|
|
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,67 @@
|
|
|
1
|
+
# react-native-refresh-flatlist
|
|
2
|
+
|
|
3
|
+
reactnative 下拉刷新统一android/ios 样式ios样式
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install react-native-refresh-flatlist
|
|
10
|
+
npm install react-native-reanimated@^4.1.0 react-native-worklets@0.7
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
并在业务项目的 Babel 配置中增加:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
plugins: [
|
|
17
|
+
'@babel/plugin-transform-export-namespace-from',
|
|
18
|
+
'react-native-worklets/plugin',
|
|
19
|
+
];
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### RefreshFlatList
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { RefreshFlatList, NormalControl } from 'react-native-refresh-flatlist';
|
|
29
|
+
|
|
30
|
+
<RefreshFlatList
|
|
31
|
+
data={data}
|
|
32
|
+
renderItem={renderItem}
|
|
33
|
+
keyExtractor={(item) => item.id}
|
|
34
|
+
refreshing={refreshing}
|
|
35
|
+
onRefresh={onRefresh}
|
|
36
|
+
refreshComponent={() => <NormalControl position="bottom" />}
|
|
37
|
+
/>;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### RefreshScrollView
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import { RefreshScrollView, NormalControl } from 'react-native-refresh-flatlist';
|
|
44
|
+
|
|
45
|
+
<RefreshScrollView
|
|
46
|
+
refreshing={refreshing}
|
|
47
|
+
onRefresh={onRefresh}
|
|
48
|
+
refreshComponent={() => <NormalControl position="bottom" />}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</RefreshScrollView>;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Contributing
|
|
56
|
+
|
|
57
|
+
- [Development workflow](CONTRIBUTING.md#development-workflow)
|
|
58
|
+
- [Sending a pull request](CONTRIBUTING.md#sending-a-pull-request)
|
|
59
|
+
- [Code of conduct](CODE_OF_CONDUCT.md)
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ActivityIndicator } from 'react-native';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const Loading = props => {
|
|
7
|
+
const {
|
|
8
|
+
color,
|
|
9
|
+
size,
|
|
10
|
+
animating = true
|
|
11
|
+
} = props;
|
|
12
|
+
return /*#__PURE__*/_jsx(ActivityIndicator, {
|
|
13
|
+
color,
|
|
14
|
+
size,
|
|
15
|
+
animating
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
export default Loading;
|
|
19
|
+
//# sourceMappingURL=Loading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","ActivityIndicator","jsx","_jsx","Loading","props","color","size","animating"],"sourceRoot":"..\\..\\..\\src","sources":["Loading/Loading.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,cAAc;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQjD,MAAMC,OAA+B,GAAIC,KAAK,IAAK;EACjD,MAAM;IAAEC,KAAK;IAAEC,IAAI;IAAEC,SAAS,GAAG;EAAK,CAAC,GAAGH,KAAK;EAC/C,oBAAOF,IAAA,CAACF,iBAAiB;IAAOK,KAAK;IAAEC,IAAI;IAAEC;EAAS,CAAK,CAAC;AAC9D,CAAC;AAED,eAAeJ,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Loading"],"sourceRoot":"..\\..\\..\\src","sources":["Loading/index.tsx"],"mappings":";;AAAA,OAAOA,OAAO,MAAM,cAAW;AAE/B,SACIA,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Refresh Control Implement
|
|
5
|
+
* Every Control can get props from useRefresh()
|
|
6
|
+
*/
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
import { View, Text, StyleSheet } from 'react-native';
|
|
9
|
+
import Animated, { useAnimatedStyle, useAnimatedReaction, runOnJS, withTiming, useSharedValue } from 'react-native-reanimated';
|
|
10
|
+
import { RefreshStatus, useRefreshScroll } from "./type.js";
|
|
11
|
+
import { Icon } from "../icon/index.js";
|
|
12
|
+
import { Loading } from "../Loading/index.js";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const NormalControl = props => {
|
|
15
|
+
const {
|
|
16
|
+
textConfig = {
|
|
17
|
+
normal: '下拉刷新',
|
|
18
|
+
release: '释放以刷新',
|
|
19
|
+
refresing: '努力刷新中',
|
|
20
|
+
done: '刷新成功'
|
|
21
|
+
},
|
|
22
|
+
position
|
|
23
|
+
} = props;
|
|
24
|
+
const {
|
|
25
|
+
transitionY,
|
|
26
|
+
triggleHeight,
|
|
27
|
+
refreshStatus
|
|
28
|
+
} = useRefreshScroll();
|
|
29
|
+
const [refreshText, setRefreshText] = useState(textConfig.normal);
|
|
30
|
+
const [loading, setLoading] = useState(false);
|
|
31
|
+
const degree = useSharedValue(0);
|
|
32
|
+
const setRefreshTextByStatus = text => {
|
|
33
|
+
setRefreshText(text);
|
|
34
|
+
};
|
|
35
|
+
useAnimatedReaction(() => refreshStatus.value, value => {
|
|
36
|
+
if (value === RefreshStatus.Idle) {
|
|
37
|
+
runOnJS(setRefreshTextByStatus)(textConfig.normal);
|
|
38
|
+
}
|
|
39
|
+
if (value === RefreshStatus.Pulling) {
|
|
40
|
+
runOnJS(setRefreshTextByStatus)(textConfig.normal);
|
|
41
|
+
}
|
|
42
|
+
if (value === RefreshStatus.Reached) {
|
|
43
|
+
runOnJS(setRefreshTextByStatus)(textConfig.release);
|
|
44
|
+
}
|
|
45
|
+
if (value === RefreshStatus.Holding) {
|
|
46
|
+
runOnJS(setRefreshTextByStatus)(textConfig.refresing);
|
|
47
|
+
runOnJS(setLoading)(true);
|
|
48
|
+
}
|
|
49
|
+
if (value === RefreshStatus.Done) {
|
|
50
|
+
runOnJS(setRefreshTextByStatus)(textConfig.done);
|
|
51
|
+
runOnJS(setLoading)(false);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const arrowStyle = useAnimatedStyle(() => {
|
|
55
|
+
degree.value = withTiming(transitionY.value >= triggleHeight ? 180 : 0, {
|
|
56
|
+
duration: 200
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
transform: [{
|
|
60
|
+
rotateZ: `${degree.value}deg`
|
|
61
|
+
}]
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
65
|
+
style: styles.container,
|
|
66
|
+
children: [loading ? /*#__PURE__*/_jsx(Loading, {}) : /*#__PURE__*/_jsx(Animated.View, {
|
|
67
|
+
style: arrowStyle,
|
|
68
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
69
|
+
name: position === 'top' ? 'arrow-line-down' : 'arrow-line-up',
|
|
70
|
+
size: 18,
|
|
71
|
+
color: 'grey'
|
|
72
|
+
})
|
|
73
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
74
|
+
style: styles.textStyle,
|
|
75
|
+
children: refreshText
|
|
76
|
+
})]
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const styles = StyleSheet.create({
|
|
80
|
+
container: {
|
|
81
|
+
flexDirection: 'row'
|
|
82
|
+
},
|
|
83
|
+
textStyle: {
|
|
84
|
+
marginHorizontal: 10
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
export default NormalControl;
|
|
88
|
+
//# sourceMappingURL=BottomContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useState","View","Text","StyleSheet","Animated","useAnimatedStyle","useAnimatedReaction","runOnJS","withTiming","useSharedValue","RefreshStatus","useRefreshScroll","Icon","Loading","jsx","_jsx","jsxs","_jsxs","NormalControl","props","textConfig","normal","release","refresing","done","position","transitionY","triggleHeight","refreshStatus","refreshText","setRefreshText","loading","setLoading","degree","setRefreshTextByStatus","text","value","Idle","Pulling","Reached","Holding","Done","arrowStyle","duration","transform","rotateZ","style","styles","container","children","name","size","color","textStyle","create","flexDirection","marginHorizontal"],"sourceRoot":"..\\..\\..\\src","sources":["RefreshControl/BottomContainer.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,OAAOA,KAAK,IAAGC,QAAQ,QAAO,OAAO;AACrC,SAAQC,IAAI,EAAEC,IAAI,EAAEC,UAAU,QAAO,cAAc;AACnD,OAAOC,QAAQ,IACXC,gBAAgB,EAChBC,mBAAmB,EACnBC,OAAO,EACPC,UAAU,EACVC,cAAc,QACX,yBAAyB;AAChC,SAAQC,aA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MAAM,CAAC;EAC7BN,SAAS,EAAE;IACPO,aAAa,EAAE;EACnB,CAAC;EACDF,SAAS,EAAE;IACPG,gBAAgB,EAAE;EACtB;AACJ,CAAC,CAAC;AAEF,eAAetC,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Refresh Control Implement
|
|
5
|
+
* Every Control can get props from useRefresh()
|
|
6
|
+
*/
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
import { View, StyleSheet, Text } from 'react-native';
|
|
9
|
+
import Animated, { useAnimatedStyle, useAnimatedReaction, runOnJS, withTiming, useSharedValue } from 'react-native-reanimated';
|
|
10
|
+
import { RefreshStatus, useRefreshScroll } from "./type.js";
|
|
11
|
+
import { Icon } from "../icon/index.js";
|
|
12
|
+
import { Loading } from "../Loading/index.js";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const NormalControl = props => {
|
|
15
|
+
const {
|
|
16
|
+
textConfig = {
|
|
17
|
+
normal: '下拉刷新',
|
|
18
|
+
release: '释放以刷新',
|
|
19
|
+
refresing: '努力刷新中',
|
|
20
|
+
done: '刷新成功'
|
|
21
|
+
},
|
|
22
|
+
position
|
|
23
|
+
} = props;
|
|
24
|
+
const {
|
|
25
|
+
transitionY,
|
|
26
|
+
triggleHeight,
|
|
27
|
+
refreshStatus
|
|
28
|
+
} = useRefreshScroll();
|
|
29
|
+
const [refreshText, setRefreshText] = useState(textConfig.normal);
|
|
30
|
+
const [loading, setLoading] = useState(false);
|
|
31
|
+
const degree = useSharedValue(0);
|
|
32
|
+
const iconColor = props.iconColor || '#7A6FFA';
|
|
33
|
+
const arrowColor = props.arrowColor || 'grey';
|
|
34
|
+
const setRefreshTextByStatus = text => {
|
|
35
|
+
setRefreshText(text);
|
|
36
|
+
};
|
|
37
|
+
useAnimatedReaction(() => refreshStatus.value, value => {
|
|
38
|
+
if (value === RefreshStatus.Idle) {
|
|
39
|
+
runOnJS(setRefreshTextByStatus)(textConfig.normal);
|
|
40
|
+
}
|
|
41
|
+
if (value === RefreshStatus.Pulling) {
|
|
42
|
+
runOnJS(setRefreshTextByStatus)(textConfig.normal);
|
|
43
|
+
}
|
|
44
|
+
if (value === RefreshStatus.Reached) {
|
|
45
|
+
runOnJS(setRefreshTextByStatus)(textConfig.release);
|
|
46
|
+
}
|
|
47
|
+
if (value === RefreshStatus.Holding) {
|
|
48
|
+
runOnJS(setRefreshTextByStatus)(textConfig.refresing);
|
|
49
|
+
runOnJS(setLoading)(true);
|
|
50
|
+
}
|
|
51
|
+
if (value === RefreshStatus.Done) {
|
|
52
|
+
console.log('done');
|
|
53
|
+
runOnJS(setRefreshTextByStatus)(textConfig.done);
|
|
54
|
+
runOnJS(setLoading)(false);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
const arrowStyle = useAnimatedStyle(() => {
|
|
58
|
+
degree.value = withTiming(transitionY.value >= triggleHeight ? 180 : 0, {
|
|
59
|
+
duration: 200
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
transform: [{
|
|
63
|
+
rotateZ: `${degree.value}deg`
|
|
64
|
+
}]
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
68
|
+
style: styles.container,
|
|
69
|
+
children: [loading ? /*#__PURE__*/_jsx(Loading, {
|
|
70
|
+
color: iconColor
|
|
71
|
+
}) : /*#__PURE__*/_jsx(Animated.View, {
|
|
72
|
+
style: arrowStyle,
|
|
73
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
74
|
+
name: position === 'top' ? 'arrow-line-down' : 'arrow-line-up',
|
|
75
|
+
size: 18,
|
|
76
|
+
color: arrowColor
|
|
77
|
+
})
|
|
78
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
79
|
+
style: [styles.textStyle, props.textStyle],
|
|
80
|
+
children: refreshText
|
|
81
|
+
})]
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
const styles = StyleSheet.create({
|
|
85
|
+
container: {
|
|
86
|
+
flexDirection: 'row',
|
|
87
|
+
alignItems: 'center'
|
|
88
|
+
},
|
|
89
|
+
textStyle: {
|
|
90
|
+
marginHorizontal: 10
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
export default NormalControl;
|
|
94
|
+
//# sourceMappingURL=NormalControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useState","View","StyleSheet","Text","Animated","useAnimatedStyle","useAnimatedReaction","runOnJS","withTiming","useSharedValue","RefreshStatus","useRefreshScroll","Icon","Loading","jsx","_jsx","jsxs","_jsxs","NormalControl","props","textConfig","normal","release","refresing","done","position","transitionY","triggleHeight","refreshStatus","refreshText","setRefreshText","loading","setLoading","degree","iconColor","arrowColor","setRefreshTextByStatus","text","value","Idle","Pulling","Reached","Holding","Done","console","log","arrowStyle","duration","transform","rotateZ","style","styles","container","children","color","name","size","textStyle","create","flexDirection","alignItems","marginHorizontal"],"sourceRoot":"..\\..\\..\\src","sources":["RefreshControl/NormalControl.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,IAAI,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AACrD,OAAOC,QAAQ,IACXC,gBAAgB,EAChBC,mBAAmB,EACnBC,OAAO,EACPC,UAAU,EACVC,cAAc,QACX,yBAAyB;AAChC,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,WAAQ;AACxD,SAASC,IAAI,QAAQ,kBAAS;AAC9B,SAASC,OAAO,QAAQ,qBAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAerC,MAAMC,aAA2C,GAAIC,KAAK,IAAK;EAC3D,MAAM;IACFC,UAAU,GAAG;MACTC,MAAM,EAAE,MAAM;MACdC,O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AAS,EAAE;IACPO,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE;EAChB,CAAC;EACDH,SAAS,EAAE;IACPI,gBAAgB,EAAE;EACtB;AACJ,CAAC,CAAC;AAEF,eAAe3C,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext } from 'react';
|
|
4
|
+
import { StyleSheet, Dimensions } from 'react-native';
|
|
5
|
+
import Animated, { interpolate, useAnimatedStyle } from 'react-native-reanimated';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
const {
|
|
8
|
+
width
|
|
9
|
+
} = Dimensions.get('window');
|
|
10
|
+
export const RefreshContainerContext = /*#__PURE__*/createContext({});
|
|
11
|
+
export const useRefresh = () => useContext(RefreshContainerContext);
|
|
12
|
+
const RefreshContainer = props => {
|
|
13
|
+
const {
|
|
14
|
+
children,
|
|
15
|
+
transitionY,
|
|
16
|
+
triggleHeight,
|
|
17
|
+
refreshStatus
|
|
18
|
+
} = props;
|
|
19
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
20
|
+
if (transitionY.value <= 0 + (props.offsetTop || 0)) {
|
|
21
|
+
return {
|
|
22
|
+
opacity: 0,
|
|
23
|
+
height: 0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
height: transitionY.value,
|
|
28
|
+
opacity: interpolate(transitionY.value, [0, triggleHeight / 3, triggleHeight], [0, 0, 1])
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
return /*#__PURE__*/_jsx(RefreshContainerContext.Provider, {
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
value: {
|
|
34
|
+
transitionY,
|
|
35
|
+
triggleHeight,
|
|
36
|
+
refreshStatus
|
|
37
|
+
},
|
|
38
|
+
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
39
|
+
style: [styles.container, animatedStyle],
|
|
40
|
+
children: children
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const styles = StyleSheet.create({
|
|
45
|
+
container: {
|
|
46
|
+
width,
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
justifyContent: 'center',
|
|
49
|
+
position: 'absolute'
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
export default RefreshContainer;
|
|
53
|
+
//# sourceMappingURL=RefreshContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","createContext","useContext","StyleSheet","Dimensions","Animated","interpolate","useAnimatedStyle","jsx","_jsx","width","get","RefreshContainerContext","useRefresh","RefreshContainer","props","children","transitionY","triggleHeight","refreshStatus","animatedStyle","value","offsetTop","opacity","height","Provider","View","style","styles","container","create","alignItems","justifyContent","position"],"sourceRoot":"..\\..\\..\\src","sources":["RefreshControl/RefreshContainer.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACxD,SAASC,UAAU,EAAEC,UAAU,QAAQ,cAAc;AACrD,OAAOC,QAAQ,IACXC,WAAW,EACXC,gBAAgB,QACb,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAIjC,MAAM;EAAEC;AAAM,CAAC,GAAGN,UAAU,CAACO,GAAG,CAAC,QAAQ,CAAC;AAK1C,OAAO,MAAMC,uBAAuB,gBAChCX,aAAa,CACT,CAAC,CACL,CAAC;AACL,OAAO,MAAMY,UAAU,GAAGA,CAAA,KAAMX,UAAU,CAACU,uBAAuB,CAAC;AAUnE,MAAME,gBAAiD,GAAIC,KAAK,IAAK;EACjE,MAAM;IAAEC,QAAQ;IAAEC,WAAW;IAAEC,aAAa;IAAEC;EAAc,CAAC,GAAGJ,KAAK;EAErE,MAAMK,aAAa,GAAGb,gBAAgB,CAAC,MAAM;IACzC,IAAIU,WAAW,CAACI,KAAK,IAAK,CAAC,IAAIN,KAAK,CAACO,SAAS,IAAI,CAAC,CAAE,EAAE;MACnD,OAAO;QACHC,OAAO,EAAE,CAAC;QACVC,MAAM,EAAE;MACZ,CAAC;IACL;IACA,OAAO;MACHA,MAAM,EAAEP,WAAW,CAACI,KAAK;MACzBE,OAAO,EAAEjB,WAAW,CAChBW,WAAW,CAACI,KAAK,EACjB,CAAC,CAAC,EAAEH,aAAa,GAAG,CAAC,EAAEA,aAAa,CAAC,EACrC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CACZ;IACJ,CAAC;EACL,CAAC,CAAC;EAEF,oBACIT,IAAA,CAACG,uBAAuB,CAACa,QAAQ;IAC7B;IACAJ,KAAK,EAAE;MACHJ,WAAW;MACXC,aAAa;MACbC;IACJ,CAAE;IAAAH,QAAA,eAEFP,IAAA,CAACJ,QAAQ,CAACqB,IAAI;MAACC,KAAK,EAAE,CAACC,MAAM,CAACC,SAAS,EAAET,aAAa,CAAE;MAAAJ,QAAA,EACnDA;IAAQ,CACE;EAAC,CACc,CAAC;AAE3C,CAAC;AAED,MAAMY,MAAM,GAAGzB,UAAU,CAAC2B,MAAM,CAAC;EAC7BD,SAAS,EAAE;IACPnB,KAAK;IACLqB,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE,QAAQ;IACxBC,QAAQ,EAAE;EACd;AACJ,CAAC,CAAC;AAEF,eAAenB,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext, useState } from 'react';
|
|
4
|
+
|
|
5
|
+
// 定义上下文类型
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
// 创建上下文
|
|
8
|
+
const RefreshContext = /*#__PURE__*/createContext(undefined);
|
|
9
|
+
|
|
10
|
+
// 提供上下文的 Provider 组件
|
|
11
|
+
export const RefreshProvider = ({
|
|
12
|
+
children
|
|
13
|
+
}) => {
|
|
14
|
+
const [isRefreshing, setIsRefreshing] = useState(false);
|
|
15
|
+
return /*#__PURE__*/_jsx(RefreshContext.Provider, {
|
|
16
|
+
value: {
|
|
17
|
+
isRefreshing,
|
|
18
|
+
setIsRefreshing
|
|
19
|
+
},
|
|
20
|
+
children: children
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// 自定义 Hook 用于消费上下文
|
|
25
|
+
export const useRefresh = () => {
|
|
26
|
+
const context = useContext(RefreshContext);
|
|
27
|
+
if (!context) {
|
|
28
|
+
throw new Error('useRefresh must be used within a RefreshProvider');
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=RefreshContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","createContext","useContext","useState","jsx","_jsx","RefreshContext","undefined","RefreshProvider","children","isRefreshing","setIsRefreshing","Provider","value","useRefresh","context","Error"],"sourceRoot":"..\\..\\..\\src","sources":["RefreshControl/RefreshContext.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAGC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,QAAO,OAAO;;AAEhE;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAMA;AACA,MAAMC,cAAc,gBAAGL,aAAa,CAAiCM,SAAS,CAAC;;AAE/E;AACA,OAAO,MAAMC,eAAyB,GAAGA,CAAC;EAACC;AAAa,CAAC,KAAK;EAC1D,MAAM,CAACC,YAAY,EAAEC,eAAe,CAAC,GAAGR,QAAQ,CAAU,KAAK,CAAC;EAEhE,oBACIE,IAAA,CAACC,cAAc,CAACM,QAAQ;IAACC,KAAK,EAAE;MAACH,YAAY;MAAEC;IAAe,CAAE;IAAAF,QAAA,EAC3DA;EAAQ,CACY,CAAC;AAElC,CAAC;;AAED;AACA,OAAO,MAAMK,UAAU,GAAGA,CAAA,KAA0B;EAChD,MAAMC,OAAO,GAAGb,UAAU,CAACI,cAAc,CAAC;EAC1C,IAAI,CAACS,OAAO,EAAE;IACV,MAAM,IAAIC,KAAK,CAAC,kDAAkD,CAAC;EACvE;EACA,OAAOD,OAAO;AAClB,CAAC","ignoreList":[]}
|