_5_Root.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React ,{useState, useRef, useEffect} from 'react';
  2. // import Tab from '../navigation/TabNavigator';
  3. import C from 'rn-class';
  4. import Main from './_6_Main';
  5. import List from './_7_List';
  6. import TabBar from '../components/TabBar';
  7. import Player from "../components/Player";
  8. //import Player from "./PlayerGesture";
  9. import { PlayerConextProvider } from '../components/PlayerReducer'
  10. C.addColor("#d7d7d7", "color-listbg");
  11. import {BTNS_ORG as BTNS} from '../data/dummy';
  12. const tabPosition = {x:0, y:0, w:0, h:0};
  13. export default (props)=>{
  14. const [ sel_idx, setsel_Idx ] = useState(-1);
  15. const [ targetIdx, setTargetIdx ] = useState(-1);
  16. const [ bPlay, setbPlay] = useState(false);
  17. const [ curPlayInfo, setCurPlayInfo] = useState({});
  18. const onTabPress = (tIdx, i)=>{
  19. setsel_Idx(i);
  20. setTargetIdx(tIdx);
  21. setbPlay(false);
  22. }
  23. const startPlay = (playerData)=>{
  24. setbPlay(true);
  25. setCurPlayInfo(playerData);
  26. }
  27. let Page;
  28. if(sel_idx == -1){
  29. Page = Main;
  30. }else{
  31. Page = List;
  32. }
  33. useEffect(()=>{
  34. },[]);
  35. const setTabPosition = (data) => {
  36. tabPosition.x = data.x;
  37. tabPosition.y = data.y;
  38. tabPosition.w = data.w;
  39. tabPosition.h = data.h;
  40. }
  41. return (
  42. <C.View cls="flx1 bgc-color-white">
  43. <C.Comp.Header {...props}/>
  44. <Page {...props} Pages={sel_idx == -1 ? {} : BTNS[targetIdx][sel_idx]} startPlay={startPlay} bPlay={bPlay}/>
  45. <PlayerConextProvider>
  46. {bPlay ? <Player playerData={curPlayInfo} tabPosition={tabPosition} closePlayer={()=>setbPlay(false)}/> : null}
  47. </PlayerConextProvider>
  48. <TabBar setTabPosition={setTabPosition} onTabPress={onTabPress} BTNS={BTNS}/>
  49. </C.View>
  50. )
  51. }