123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- /**
- * 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 (
- <View style={styles.View}>
- <BaseNavigationBar
- dataSources = {this.state.navigationBarMenu}
- selectedIndex = {0}
- didClickedMineItem = {() => {
- this.goToMinePage()
- }}
- didSelectedItem = {(index) => [
- ]}
- />
-
- <ScrollView pagingEnabled={true} horizontal={true} style={styles.ScrollView}>
- <ShortVideoListControll/>
-
- <SmallVideoViewController callSmallback={()=>{
- this.callSmallback()
- }}/>
-
- <AnswerPageView
- didClickTagButton={(index) => {
- this.didClickTagButton(index)
- }}
- didClickUserHeaderView = {() => {
- this.didClickUserHeaderView()
- }}
-
- didSelectedItem = {(itemId) => {
- this.didSelectedQuestionItem(itemId)
- }}
- />
-
- <FollowPageView
- didClickFollowButton = {() => {
- this.didClickFollowMoreButton()
- }}
- />
-
- <PicAndTextPageView
- didSelectedPicAndTextItem = {(itemId) => {
- this.didSelectedPicAndTextItem(itemId)
- }}
-
- didClickImageViewContainer = {() => {
- this.didClickImageViewContainer()
- }}
- />
-
- </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',
- },
- })
|