import React, { Component } from 'react' import { StyleSheet, View, Text, Image, Animated } from 'react-native' import { height, px2dp, width } from '../../utils/base'; import RefreshAnimateHeader from '../SmartRefresh/src/RefreshAnimateHeader'; export interface Props { renderHeader: (any?: any) => JSX.Element | Function renderCeilContainer: (any?: any) => JSX.Element | Function renderContainer: (any?: any) => JSX.Element onRefresh: (any?: any) => void | Function onMomentumScrollEnd: (any?: any) => void refreshing: boolean headerHeight?: number } export interface State { scrollY: Animated.Value headHeight: number } export default class CeilingHeaderList extends React.Component { constructor(props: Props | Readonly) { super(props); } componentDidMount() { } componentWillUnmount() { } public readonly state: Readonly = { scrollY: new Animated.Value(0), headHeight: 0 } render() { let { children, renderHeader, renderContainer, renderCeilContainer, onRefresh, onMomentumScrollEnd, headerHeight, refreshing } = this.props; let { scrollY, headHeight } = this.state; let translateY = scrollY.interpolate({ inputRange: [-1, 0, headHeight, headHeight + 1], outputRange: [0, 0, 0, 1], }); return ( } // automaticallyAdjustContentInsets={false} //是否新显示滚动条 showsVerticalScrollIndicator={false} scrollsToTop={true} onMomentumScrollEnd={onMomentumScrollEnd} automaticallyAdjustContentInsets={false} scrollEventThrottle={1}> { let { height } = e.nativeEvent.layout; this.setState({ headHeight: height }); // 给头部高度赋值 }}> { renderHeader() } {/* */} {renderCeilContainer()} {/* */} {renderContainer()} ); } } const styles = StyleSheet.create({ main: { }, mainBackgroundStyle: { // flex: 1, width: width, height: height, // position: "absolute", top: 0, left: 0, // zIndex: -999 }, })