Splash.js
1.16 KB
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
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>
)
}
}