UNPKG

react-native-img-browser

Version:

此组件基于react-native-photo-browser@0.4.0进行修改,主要修复其大量图片时,滑动动画不流畅;图片多时打开大图加载卡顿或加载不出来,将react-native-photo-browser中的FullScreenContainer文件中的ListView组件替换成FlatList组件

94 lines (83 loc) 1.87 kB
import React from 'react'; import PropTypes from 'prop-types'; import { Image, Text, StyleSheet, TouchableOpacity, Platform, } from 'react-native'; import { BarContainer } from './BarContainer'; export default class TopBar extends React.Component { static propTypes = { displayed: PropTypes.bool, title: PropTypes.string, height: PropTypes.number, backTitle: PropTypes.string, backImage: PropTypes.any, onBack: PropTypes.func, }; static defaultProps = { displayed: false, title: '', // backTitle: 'Back', backTitle: '返回', backImage: require('../../Assets/angle-left.png'), }; renderBackButton() { const { onBack, backImage } = this.props; // do not display back button if there isn't a press handler if (onBack) { return ( <TouchableOpacity style={styles.backContainer} onPress={onBack}> <Image source={backImage} /> {Platform.OS === 'ios' && <Text style={[styles.text, styles.backText]}> {this.props.backTitle} </Text>} </TouchableOpacity> ); } return null; } render() { const { displayed, title, height, } = this.props; return ( <BarContainer style={styles.container} displayed={displayed} height={height} > {this.renderBackButton()} <Text style={styles.text}>{title}</Text> </BarContainer> ); } } const styles = StyleSheet.create({ container: { flex: 1, flexDirection: 'row', justifyContent: 'center', paddingTop: 30, }, text: { fontSize: 18, color: 'white', }, backContainer: { position: 'absolute', flexDirection: 'row', left: 0, top: 16, }, backText: { paddingTop: 14, marginLeft: -10, }, });