123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- /**
- * Created by zack on 2018/4/19.
- */
- import {
- View,
- Text,
- StyleSheet,
- TouchableOpacity,
- ScrollView
- } from 'react-native'
- import React, {Component} from 'react'
- import BaseNavigationBar from '../base/BaseNavigationBar'
- import HttpTools from '../../network/HttpTools'
- import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../utils/DimensionsTools'
- import CAGameViewController from './Game/CAGameViewController';
- import CAMiningViewController from './Mining/CAMiningViewController';
- import CAVideoViewController from './Video/CAVideoViewController';
- import {GlobalUserStorageTool, UserStorageKey} from '../../utils/GlobalUserStorageTool'
- import BaseNavigationBarStyle from '../base/BaseNavigationBarStyle'
-
- export default class PlayViewController extends Component {
- constructor(props) {
- super(props)
- this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
- this.state = {
- navigationBarMenu: [
- {title: '游戏', index: 0},
- {title: '挖矿', index: 1},
- {title: '视频', index: 2},
- {title: '小麦', index: 3},
- {title: '大米', index: 4},
- ]
- }
- }
-
- componentDidMount() {
- this.props.navigator.setOnNavigatorEvent(event => {
- if (event.type === 'NavBarButtonPress') {
- if (event.id === 'add') {
-
- }
- }else if (event.type === 'ScreenChangedEvent') {
- if (event.id === 'willAppear') {
- this.showTabBar()
- }else if (event.id === 'willDisappear') {
-
- }
- }
- })
-
- GlobalUserStorageTool.load(UserStorageKey.UserInfo, (ret) => {
- console.log("user info: " + ret)
- }, (error) => {
-
- })
- }
-
- onNavigatorEvent(event) {
- console.log(event.type)
-
- let str = ''
-
- }
-
- hideTabBar() {
- this.props.navigator.toggleTabs({
- to:'hidden',
- animated: true
- })
- }
-
- showTabBar() {
- this.props.navigator.toggleTabs({
- to:'shown',
- animated: true
- })
- }
-
- onPressBannerBack(){
- this.hideTabBar()
- this.props.navigator.push({
- screen: 'CAVideoDetailView',
- title: '我的',
- backButtonTitle: '',
- passProps: {
- key: 'hahah'
- }
- })
- }
-
- goToMinePage() {
- this.hideTabBar()
- GlobalUserStorageTool.load(UserStorageKey.UserInfo, (response) => {
- if (response && response.nickname) { //已经登录成功
- this.props.navigator.push({
- screen: 'MineViewController',
- title: '基本资料',
- backButtonTitle: '',
- navigatorStyle: BaseNavigationBarStyle,
- passProps: {
- UserInfo: response
- }
- })
- } else {
- this.props.navigator.push({
- screen: 'LoginViewController',
- title: '我的',
- backButtonTitle: '',
- navigatorStyle: {
- navBarHidden: true
- },
- passProps: {}
- })
- }
- }, (error) => {
- this.props.navigator.push({
- screen: 'LoginByVerificationCodeViewController',
- title: '我的',
- backButtonTitle: '',
- navigatorStyle: {
- navBarHidden: true
- },
- passProps: {}
- })
- })
- }
-
- render() {
- return (
- <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
- <BaseNavigationBar
- dataSources = {this.state.navigationBarMenu}
- selectedIndex = {0}
- didClickedMineItem = {() => {
- this.goToMinePage()
- }}
- didSelectedItem = {(index) => [
- console.log("----" + index)
- ]}
- />
- <ScrollView pagingEnabled={true}
- horizontal={true}
- style={styles.ScrollView}>
- <CAVideoViewController onPressBannerBack={this.onPressBannerBack.bind(this)}/>
- <CAGameViewController />
- <CAMiningViewController />
- </ScrollView>
- </View>
- );
- }
- }
-
- const styles = StyleSheet.create({
- View: {
- width: ScreenDimensions.width,
- height: ScreenDimensions.height,
- backgroundColor: 'white'
- },
- ScrollView: {
- marginTop: NavigationBarHeight.height,
- width: ScreenDimensions.width,
- height: ScreenDimensions.height - NavigationBarHeight.height - TabBarHeight.height,
- backgroundColor: '#ffffff',
- },
- })
|