/** * Created by zack on 2018/4/19. */ import { View, Text, StyleSheet, Platform, ScrollView } from 'react-native' import React, {Component} from 'react' import BaseNavigationBar from '../base/BaseNavigationBar' import AnswerPageView from './Answer/AnswerPageView' import {NavigationBarHeight, TabBarHeight, ScreenDimensions} from '../../utils/DimensionsTools' import FollowPageView from './Follow/FollowPageView' import SmallVideoViewController from "./SmallVideo/SmallVideoViewController" import HttpTools from '../../network/HttpTools' import {auth, question} from '../../network/API' import {GlobalUserStorageTool, UserStorageKey} from '../../utils/GlobalUserStorageTool' import {UserInfo} from '../../utils/GlobalKey' import PicAndTextPageView from './PicAndTextViewController/PicAndTextPageView' import BaseNavigationBarStyle from '../base/BaseNavigationBarStyle' import ShortVideoListControll from "./ShortVideo/ShortVideoListControll" export default class CommunityViewController extends Component { static navigatorButtons = { leftButtons: [ { icon: require('../../resources/images/left.png'), // for icon button, provide the local image asset name id: 'add' //Android has four type of left button,you sure specify the button type. }, ] }; constructor(props) { super(props) this.state = { navigationBarMenu: [ {title: '小视频', index: 0}, {title: '短视频', index: 1}, {title: '直播', index: 2}, {title: '图文', index: 3}, {title: '问答', index: 4}, {title: '关注', index: 5}, ], questionList: [] } } 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') { } } }) this.getUserInfo(() => { }) } getUserInfo(callback) { const param = JSON.stringify({ username: '15303737970', password: '471155401' }) HttpTools.postUserInfo(auth, param, (response) => { global.token = response.token GlobalUserStorageTool.save(UserInfo, response) callback && callback() }, (error) => { }) } hideTabBar() { this.props.navigator.toggleTabs({ to:'hidden', animated: true }) } showTabBar() { this.props.navigator.toggleTabs({ to:'shown', animated: true }) } 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: { } }) }) } didClickTagButton(index) { this.hideTabBar() if (index === 0) { if (Platform.OS === 'ios') { this.props.navigator.showModal({ screen: 'QuestionCreateViewController', backButtonTitle: '', title: '提问', passProps: { }, navigatorStyle: BaseNavigationBarStyle }) }else { this.props.navigator.push({ screen: 'QuestionCreateViewController', backButtonTitle: '', title: '提问', passProps: { }, navigatorStyle: BaseNavigationBarStyle }) } }else if (index === 1) { this.props.navigator.push({ screen: 'FindViewController', backButtonTitle: '', passProps: { }, navigatorStyle: BaseNavigationBarStyle }) }else{ this.props.navigator.push({ screen: 'MoreViewController', backButtonTitle: '', passProps: { }, navigatorStyle: BaseNavigationBarStyle }) } } didClickUserHeaderView() { this.hideTabBar() this.props.navigator.push({ screen: 'MyAnswerViewController', backButtonTitle: '', title: '回答', passProps: { }, navigatorStyle: BaseNavigationBarStyle }) } didClickFollowMoreButton() { let navigatorStyle = Object.assign({navBarHidden: true,}, BaseNavigationBarStyle) this.props.navigator.push({ screen: 'FollowListViewController', backButtonTitle: '', title: '', passProps: { }, navigatorStyle: navigatorStyle }) } callSmallback(){ this.hideTabBar() this.props.navigator.push({ screen: 'VideoDetailsViewContorller', title: '', backButtonTitle: '', navigatorStyle:{ navBarHidden: true, }, passProps: { data:"hahaha" }, }) } didSelectedNavigationBarItem(index) { //点击导航器顶部的menu } //跳转到问题详情 didSelectedQuestionItem(itemId) { this.hideTabBar() this.props.navigator.push({ screen: 'AnswerDetailViewController', title: '问题详情', backButtonTitle: '', navigatorStyle:BaseNavigationBarStyle, passProps: { questionId: itemId }, }) } //跳转到图文详情 didSelectedPicAndTextItem(itemId) { this.hideTabBar() this.props.navigator.push({ screen: 'PicAndTextDetailViewController', backButtonTitle: '', navigatorStyle:{ navBarHidden: true, drawUnderNavBar: true, drawUnderTabBar: true, }, passProps: { itemId: itemId, }, }) } //跳转到图片查看器 didClickImageViewContainer(imageUrls) { this.hideTabBar() this.props.navigator.push({ screen: 'PicAndTextImageSwiperViewController', backButtonTitle: '', navigatorStyle:{ navBarHidden: true, drawUnderNavBar: true, drawUnderTabBar: true, }, passProps: { imageUrls: imageUrls }, }) } render() { return ( { this.goToMinePage() }} didSelectedItem = {(index) => [ ]} /> { this.callSmallback() }}/> { this.didClickTagButton(index) }} didClickUserHeaderView = {() => { this.didClickUserHeaderView() }} didSelectedItem = {(itemId) => { this.didSelectedQuestionItem(itemId) }} /> { this.didClickFollowMoreButton() }} /> { this.didSelectedPicAndTextItem(itemId) }} didClickImageViewContainer = {() => { this.didClickImageViewContainer() }} /> ); } } 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', }, })