Launch.js 2.2 KB

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