-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathRefreshHeader.js
61 lines (50 loc) · 1.24 KB
/
RefreshHeader.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
/**
* Author: Shi(bolan0000@icloud.com)
* Date: 2019/1/18
* Copyright (c) 2018, AoTang, Inc.
*
* Description:
*/
import React from "react";
import { ActivityIndicator, Animated, Image, Text, View } from "react-native";
export class RefreshHeader extends React.Component<
HeaderPropType,
HeaderStateType
> {
static height = 80;
static style = "stickyContent";
constructor(props: HeaderPropType) {
super(props);
this.state = { status: "waiting" };
}
changeToState(newStatus: HeaderStatus) {
this.state.status !== newStatus &&
this.onStateChange(this.state.status, newStatus);
}
onStateChange(oldStatus: HeaderStatus, newStatus: HeaderStatus) {
// console.log("newStatus", newStatus);
this.setState({ status: newStatus });
}
render() {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text style={{ fontSize:18 }}>{this.state.status}</Text>
</View>
);
}
}
export type HeaderStatus =
| "waiting"
| "pulling"
| "pullingEnough"
| "pullingCancel"
| "refreshing"
| "rebound";
interface HeaderPropType {
offset?: Animated.Value;
maxHeight?: number;
bottomOffset?: number;
}
interface HeaderStateType {
status?: HeaderStatus;
}