Splash.js 1.16 KB
import React from "react"
import {View, StyleSheet, Text, Image, Platform, TouchableWithoutFeedback, ScrollView,AsyncStorage,PixelRatio,Dimensions} from "react-native"
import {observer} from 'mobx-react/native'
import Swiper from 'react-native-swiper'

const width = Dimensions.get("window").width;
const height = Platform.OS === "ios" ? Dimensions.get("window").height : Dimensions.get("window").height - 22
const line = 1 / PixelRatio.get();
const styles = StyleSheet.create({
	container: {
		flex: 1,
	},
	img:{
		height,width,
	}
})
const data=[require("./splashImgs/1.jpg"),require("./splashImgs/2.jpg"),require("./splashImgs/3.jpg"),]
@observer
export default class Splash extends React.Component {
	async onPress(i){
		if(i===data.length-1){
			await AsyncStorage.setItem("hasFirst","1")
			this.props.callback()
		}
	}
	render() {
		return (
			<View style={styles.container}>
				<Swiper width={width} height={height} loop={false}>
					{data.map((v,i)=><TouchableWithoutFeedback onPress={async()=>await this.onPress(i)} key={i}>
						<Image style={styles.img} resizeMode="stretch" source={v} />
						</TouchableWithoutFeedback>
						)}
				</Swiper>
			</View>

		)
	}
}