Skip to content

Commit 6045d0c

Browse files
example: add button to show splash screen again
1 parent 601a293 commit 6045d0c

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

examples/App.js

+43-23
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
Text,
1818
TouchableOpacity,
1919
Linking,
20+
Button,
21+
Platform,
2022
} from 'react-native'
2123
import SplashScreen from 'react-native-splash-screen'
2224

@@ -26,30 +28,41 @@ export default class example extends Component {
2628
SplashScreen.hide();
2729
}
2830

29-
3031
render() {
3132
return (
32-
<TouchableOpacity
33-
style={styles.container}
34-
onPress={(e)=> {
35-
Linking.openURL('https://coding.imooc.com/class/304.html');
36-
}}
37-
>
38-
<View >
39-
<Text style={styles.item}>
40-
SplashScreen 启动屏
41-
</Text>
42-
<Text style={styles.item}>
43-
@:http://www.devio.org/
44-
</Text>
45-
<Text style={styles.item}>
46-
GitHub:https://github.com/crazycodeboy
47-
</Text>
48-
<Text style={styles.item}>
49-
50-
</Text>
51-
</View>
52-
</TouchableOpacity>
33+
<View style={styles.container}>
34+
<TouchableOpacity
35+
onPress={(e)=> {
36+
Linking.openURL('https://coding.imooc.com/class/304.html');
37+
}}
38+
>
39+
<View >
40+
<Text style={styles.item}>
41+
SplashScreen 启动屏
42+
</Text>
43+
<Text style={styles.item}>
44+
@:http://www.devio.org/
45+
</Text>
46+
<Text style={styles.item}>
47+
GitHub:https://github.com/crazycodeboy
48+
</Text>
49+
<Text style={styles.item}>
50+
51+
</Text>
52+
</View>
53+
</TouchableOpacity>
54+
{
55+
// Show splash screen again on Windows and Android, for 3s.
56+
(Platform.OS === 'windows' || Platform.OS === 'android') &&
57+
<View style={styles.showSplashButtonView}>
58+
<Button
59+
title={"Show splash screen again"}
60+
testID={"ShowSplashScreenButton"}
61+
onPress={()=> {SplashScreen.show(); setTimeout(()=> SplashScreen.hide(), 3000)}}
62+
/>
63+
</View>
64+
}
65+
</View>
5366
)
5467
}
5568

@@ -59,7 +72,10 @@ const styles = StyleSheet.create({
5972
container: {
6073
flex: 1,
6174
backgroundColor: '#f3f2f2',
62-
marginTop: 30
75+
paddingTop: 30,
76+
paddingBottom: 30,
77+
paddingLeft: 30,
78+
paddingRight: 30,
6379
},
6480
item: {
6581
fontSize: 20,
@@ -69,4 +85,8 @@ const styles = StyleSheet.create({
6985
height: 0.3,
7086
backgroundColor: 'darkgray',
7187
},
88+
showSplashButtonView: {
89+
marginTop:30,
90+
alignSelf: 'baseline',
91+
}
7292
})

0 commit comments

Comments
 (0)