Launch.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * 开屏页面
  3. * @邠心vbe on 2021/03/22
  4. */
  5. import React from 'react'
  6. import { Animated, Easing, Image, StyleSheet, View } from 'react-native'
  7. import {InitSomething} from '../components/Dialog';
  8. import MyStatusBar from '../components/MyStatusBar';
  9. import { PageList } from './Router';
  10. class Launch extends React.Component {
  11. constructor(props) {
  12. super(props);
  13. this.state = {
  14. isShow: true,
  15. opacity: new Animated.Value(0)
  16. };
  17. }
  18. componentDidMount() {
  19. this.init();
  20. //MyStatusBar.setStatusBarThemes(MyStatusBar.DARK_STYLE, colorLight);
  21. InitSomething();
  22. if (isIOS) {
  23. this.goHome(100);
  24. } else {
  25. this.goHome(2500);
  26. }
  27. }
  28. init() {
  29. Animated.timing(this.state.opacity, {
  30. toValue: 1,
  31. duration: 1500,
  32. easing: Easing.linear,
  33. useNativeDriver: true
  34. }).start(() => {
  35. });
  36. }
  37. goHome(time) {
  38. setTimeout(() => {
  39. this.setState({
  40. isShow: false
  41. });
  42. startPage(PageList.home);
  43. }, time);
  44. }
  45. render() {
  46. return (
  47. this.state.isShow
  48. ? isIOS
  49. ? <View style={styles.iosContent}></View>
  50. : <View style={styles.container}>
  51. <Animated.View style={[styles.content, {opacity: this.state.opacity}]}>
  52. <Image
  53. style={styles.logo}
  54. resizeMode='contain'
  55. source={require('../images/app-logo.png')}/>
  56. {/* <Text style={styles.slogan}>Feel The Green Energy</Text> */}
  57. </Animated.View>
  58. </View>
  59. : <View style={styles.loaded}></View>
  60. );
  61. }
  62. }
  63. export default Launch
  64. const styles = StyleSheet.create({
  65. container: {
  66. alignItems: 'center',
  67. backgroundColor: colorLight,
  68. ...StyleSheet.absoluteFillObject
  69. },
  70. iosContent: {
  71. flex: 1,
  72. backgroundColor: colorLight
  73. },
  74. loaded: {
  75. flex: 1,
  76. backgroundColor: '#eee'
  77. },
  78. content: {
  79. alignItems: 'center',
  80. paddingTop: $vh(30)
  81. },
  82. logo: {
  83. width: 240,
  84. height: 120,
  85. marginLeft: 0,
  86. //top: $vh(25),
  87. //bottom: $vh(25),
  88. //position: 'absolute'
  89. },
  90. slogan: {
  91. color: textPrimary,
  92. fontSize: 14,
  93. fontStyle: 'italic',
  94. fontWeight: 'bold'
  95. }
  96. });