-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
88 lines (71 loc) · 2.23 KB
/
App.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
/**
* Copyright (c) 2018-present, xiaoyuzheng
*
* @flow
*/
import React, { PureComponent } from 'react'
import { View, Text, StyleSheet, StatusBar, Image, ListView, TouchableOpacity, ScrollView, RefreshControl, Animated } from 'react-native'
import ScrollableTabView, { ScrollableTabBar } from 'react-native-scrollable-tab-view'
import FirstPage from './src/FirstPage'
import SecondPage from './src/SecondPage'
const marginTop = 78
class App extends PureComponent<Props, State> {
constructor(props) {
super(props)
this.state = {
scrollY: 0,
}
}
buttonPressed() {
}
render() {
// let style = {
// transform: [{
// translateY: this.state.scrollY
// }]
// }
return (
<View style={{ flex: 1 }}>
<Animated.View style={[styles.container,{
top: this.state.scrollY
}]} >
<Text>测试</Text>
<Text>测试</Text>
<Text>测试</Text>
<Text>测试</Text>
<Text style={styles.buttonStyle} onPress={this.buttonPressed.bind(this)}>
按我
</Text>
<ScrollableTabView renderTabBar={() => <ScrollableTabBar />}
prerenderingSiblingsNumber={Infinity}>
<FirstPage tabLabel="FirstPage" />
<SecondPage ref='secondpage' tabLabel="SecondPage" />
</ScrollableTabView>
</Animated.View>
</View>
)
}
componentDidMount() {
let { scrollY } = this.refs.secondpage.state
this.setState(
{
scrollY: scrollY.interpolate({ inputRange: [0, marginTop,marginTop], outputRange: [0,-marginTop,-marginTop] }),
}
)
}
}
const styles = StyleSheet.create({
container: {
position: "absolute",
left: 0,
top: 0,
right: 0,
bottom: 0,
backgroundColor: 'white',
},
buttonStyle: { //文本组件样式,定义简单的按钮
fontSize: 20,
backgroundColor: 'grey'
},
})
export default App