Няма описание

PlayViewController.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /**
  2. * Created by zack on 2018/4/19.
  3. */
  4. import {
  5. View,
  6. Text,
  7. StyleSheet,
  8. TouchableOpacity,
  9. ScrollView
  10. } from 'react-native'
  11. import React, {Component} from 'react'
  12. import BaseNavigationBar from '../base/BaseNavigationBar'
  13. import HttpTools from '../../network/HttpTools'
  14. import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../utils/DimensionsTools'
  15. import CAGameViewController from './Game/CAGameViewController';
  16. import CAMiningViewController from './Mining/CAMiningViewController';
  17. import CAVideoViewController from './Video/CAVideoViewController';
  18. import {GlobalUserStorageTool, UserStorageKey} from '../../utils/GlobalUserStorageTool'
  19. import BaseNavigationBarStyle from '../base/BaseNavigationBarStyle'
  20. export default class PlayViewController extends Component {
  21. constructor(props) {
  22. super(props)
  23. this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
  24. this.state = {
  25. navigationBarMenu: [
  26. {title: '游戏', index: 0},
  27. {title: '挖矿', index: 1},
  28. {title: '视频', index: 2},
  29. {title: '小麦', index: 3},
  30. {title: '大米', index: 4},
  31. ]
  32. }
  33. }
  34. componentDidMount() {
  35. this.props.navigator.setOnNavigatorEvent(event => {
  36. if (event.type === 'NavBarButtonPress') {
  37. if (event.id === 'add') {
  38. }
  39. }else if (event.type === 'ScreenChangedEvent') {
  40. if (event.id === 'willAppear') {
  41. this.showTabBar()
  42. }else if (event.id === 'willDisappear') {
  43. }
  44. }
  45. })
  46. GlobalUserStorageTool.load(UserStorageKey.UserInfo, (ret) => {
  47. console.log("user info: " + ret)
  48. }, (error) => {
  49. })
  50. }
  51. onNavigatorEvent(event) {
  52. console.log(event.type)
  53. let str = ''
  54. }
  55. hideTabBar() {
  56. this.props.navigator.toggleTabs({
  57. to:'hidden',
  58. animated: true
  59. })
  60. }
  61. showTabBar() {
  62. this.props.navigator.toggleTabs({
  63. to:'shown',
  64. animated: true
  65. })
  66. }
  67. onPressBannerBack(){
  68. this.hideTabBar()
  69. this.props.navigator.push({
  70. screen: 'CAVideoDetailView',
  71. title: '我的',
  72. backButtonTitle: '',
  73. passProps: {
  74. key: 'hahah'
  75. }
  76. })
  77. }
  78. goToMinePage() {
  79. this.hideTabBar()
  80. GlobalUserStorageTool.load(UserStorageKey.UserInfo, (response) => {
  81. if (response && response.nickname) { //已经登录成功
  82. this.props.navigator.push({
  83. screen: 'MineViewController',
  84. title: '基本资料',
  85. backButtonTitle: '',
  86. navigatorStyle: BaseNavigationBarStyle,
  87. passProps: {
  88. UserInfo: response
  89. }
  90. })
  91. } else {
  92. this.props.navigator.push({
  93. screen: 'LoginViewController',
  94. title: '我的',
  95. backButtonTitle: '',
  96. navigatorStyle: {
  97. navBarHidden: true
  98. },
  99. passProps: {}
  100. })
  101. }
  102. }, (error) => {
  103. this.props.navigator.push({
  104. screen: 'LoginByVerificationCodeViewController',
  105. title: '我的',
  106. backButtonTitle: '',
  107. navigatorStyle: {
  108. navBarHidden: true
  109. },
  110. passProps: {}
  111. })
  112. })
  113. }
  114. render() {
  115. return (
  116. <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
  117. <BaseNavigationBar
  118. dataSources = {this.state.navigationBarMenu}
  119. selectedIndex = {0}
  120. didClickedMineItem = {() => {
  121. this.goToMinePage()
  122. }}
  123. didSelectedItem = {(index) => [
  124. console.log("----" + index)
  125. ]}
  126. />
  127. <ScrollView pagingEnabled={true}
  128. horizontal={true}
  129. style={styles.ScrollView}>
  130. <CAVideoViewController onPressBannerBack={this.onPressBannerBack.bind(this)}/>
  131. <CAGameViewController />
  132. <CAMiningViewController />
  133. </ScrollView>
  134. </View>
  135. );
  136. }
  137. }
  138. const styles = StyleSheet.create({
  139. View: {
  140. width: ScreenDimensions.width,
  141. height: ScreenDimensions.height,
  142. backgroundColor: 'white'
  143. },
  144. ScrollView: {
  145. marginTop: NavigationBarHeight.height,
  146. width: ScreenDimensions.width,
  147. height: ScreenDimensions.height - NavigationBarHeight.height - TabBarHeight.height,
  148. backgroundColor: '#ffffff',
  149. },
  150. })