/**
* Create by lutn on 2018-04-17
*
*/
'use strict';
import
React,{
Component }
from
'react'
import {
Text,
View,
BackHandler,
ScrollView,
StyleSheet,
AlertIOS,
RefreshControl,
TouchableOpacity,
Image,
TextInput,
Platform,
Dimensions,
ActivityIndicator,
Animated
}
from
'react-native'
import
px2dp
from
'../../utils/Px2dp'
const
isIOS =
Platform.
OS ==
"ios"
const {
width,height } =
Dimensions.
get(
'window')
export
default
class
HomePage3
extends
Component {
constructor(
props){
super(
props)
this.
state = {
location:
"三里屯SOHO",
modalVisible:
false,
searchBtnShow:
true,
isRefreshing:
false
}
}
componentDidMount(){
BackHandler.
addEventListener(
'hardwareBackPress',function () {
return
true
})
}
_renderHeader(){
let
searchY =
this.
state.
scrollY.
interpolate({
})
let
lbsOpaticy =
this.
state.
scrollY.
interpolate({
})
let
keyOpaticy =
this.
state.
scrollY.
interpolate({
})
return (
<
View
style=
{
styles.
header
}
>
<
Animated.View
style=
{[
styles.
lbsWeather,{
opacity:
lbsOpaticy}]
}
>
<
Text
>头
</
Text
>
</
Animated.View
>
<
Animated.View
style=
{{
transform: [{
translateY:
searchY
}]}
}
>
<
Text
>中
</
Text
>
</
Animated.View
>
<
Animated.View
style=
{[
styles.
keywords,{
opacity:
keyOpaticy}]
}
>
<
Text
>底
</
Text
>
</
Animated.View
>
</
View
>
)
}
_renderFixHeader(){
let
showY =
this.
state.
scrollY.
interpolate({
inputRange: [
@H_404_148@0,
})
return (
<
Animated.View
style=
{[
styles.
header,{
position:
"absolute",
left:
@H_404_148@0,
right:
@H_404_148@0,
top:
@H_404_148@0,
bottom:
@H_404_148@0,
transform: [
{
translateY:
showY}
]
}]
}
>
<
Text
>中
</
Text
>
</
Animated.View
>
)
}
_onRefresh(){
this.
setState({
isRefreshing:
true});
setTimeout(()
=> {
this.
setState({
isRefreshing:
false});
},@H_404_148@2000)
}
render(){
return (
<
ScrollView
onScroll=
{
Animated.
event(
[{
nativeEvent: {
contentOffset: {
y:
this.
state.
scrollY}}}]
)
}
refreshControl=
{
<
RefreshControl
refreshing=
{this.
state.
isRefreshing
}
onRefresh=
{this.
_onRefresh.
bind(
this)
}
colors=
{[
'#ddd','#0398ff']
}
progressBackgroundColor=
"#ffffff"
/>
}
>
{this.
_renderHeader()
}
<
Text
>头
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
<
Text
>sdlkfsdklsfkldflskdsdlkkds
</
Text
>
</
View
>
</
ScrollView
>
{this.
_renderFixHeader()
}
</
View
>
)
}
}
const
styles =
StyleSheet.
create({
header: {
backgroundColor:
"#0398ff",
height:
headH,
paddingHorizontal:
@H_404_148@16
},
lbsWeather: {
height:
InputHeight,
overflow:
"hidden",
flexDirection:
"row",
justifyContent:
"space-between"
},
keywords: {
flexDirection:
"row"
},
})
'use strict';
import {
Dimensions}
from
'react-native'
const
deviceH =
Dimensions.
get(
'window').
height
const
deviceW =
Dimensions.
get(
'window').
width
export
default
function
px2dp(
px) {
return
px *
deviceW /
basePx
}