Launch.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. // 确保状态更新完成后再导航
  43. startPage(PageList.home);
  44. });
  45. }, time);
  46. }
  47. render() {
  48. return (
  49. this.state.isShow
  50. ? isIOS
  51. ? <View style={styles.iosContent}></View>
  52. : <View style={styles.container}>
  53. <Animated.View style={[styles.content, {opacity: this.state.opacity}]}>
  54. <Image
  55. style={styles.logo}
  56. resizeMode='contain'
  57. source={require('../images/app-logo.png')}/>
  58. {/* <Text style={styles.slogan}>Feel The Green Energy</Text> */}
  59. </Animated.View>
  60. </View>
  61. : <View style={styles.loaded}></View>
  62. );
  63. }
  64. }
  65. export default Launch
  66. const styles = StyleSheet.create({
  67. container: {
  68. alignItems: 'center',
  69. backgroundColor: colorLight,
  70. ...StyleSheet.absoluteFillObject
  71. },
  72. iosContent: {
  73. flex: 1,
  74. backgroundColor: colorLight
  75. },
  76. loaded: {
  77. flex: 1,
  78. backgroundColor: '#eee'
  79. },
  80. content: {
  81. alignItems: 'center',
  82. paddingTop: $vh(30)
  83. },
  84. logo: {
  85. width: 240,
  86. height: 120,
  87. marginLeft: 0,
  88. //top: $vh(25),
  89. //bottom: $vh(25),
  90. //position: 'absolute'
  91. },
  92. slogan: {
  93. color: textPrimary,
  94. fontSize: 14,
  95. fontStyle: 'italic',
  96. fontWeight: 'bold'
  97. }
  98. });