forked from bolan9999/react-native-spring-scrollview
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNormalFooter.js
109 lines (101 loc) · 2.42 KB
/
NormalFooter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Author: Shi([email protected])
* Date: 2019/1/18
* Copyright (c) 2018, AoTang, Inc.
*
* Description:
*/
import React from "react";
import { LoadingFooter, FooterStatus } from "./LoadingFooter";
import {
ActivityIndicator,
Animated,
View,
StyleSheet,
Text
} from "react-native";
export class NormalFooter extends LoadingFooter {
static height = 80;
static style = "stickyContent";
render() {
if (this.state.status === "allLoaded")
return (
<View style={styles.container}>
<Text style={styles.text}>{this.getTitle()}</Text>
</View>
);
return (
<View style={styles.container}>
{this._renderIcon()}
<View style={styles.rContainer}>
<Text style={styles.text}>{this.getTitle()}</Text>
{this.renderContent()}
</View>
</View>
);
}
_renderIcon() {
const s = this.state.status;
if (s === "loading" || s === "cancelLoading" || s === "rebound") {
return <ActivityIndicator color={"gray"}/>;
}
const { maxHeight, offset, bottomOffset } = this.props;
return (
<Animated.Image
source={require("./Customize/res/arrow.png")}
style={{
transform: [
{
rotate: offset.interpolate({
inputRange: [
bottomOffset - 1 + 45,
bottomOffset + 45,
bottomOffset + maxHeight,
bottomOffset + maxHeight + 1
],
outputRange: ["180deg", "180deg", "0deg", "0deg"]
})
}
]
}}
/>
);
}
renderContent(){
return null;
}
getTitle() {
const s = this.state.status;
if (s === "dragging" || s === "waiting") {
return "Drag up to load";
} else if (s === "draggingEnough") {
return "Release to load";
} else if (s === "loading") {
return "Loading ...";
} else if (s === "draggingCancel") {
return "Give up loading";
} else if (s === "rebound") {
return "Load completed";
} else if (s === "allLoaded") {
return "No more data";
}
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
flexDirection: "row"
},
rContainer: {
marginLeft: 20
},
text: {
marginVertical: 5,
fontSize: 15,
color: "#666",
textAlign: "center",
width: 140
}
});