1- import { Platform , StyleSheet , View , type ViewProps } from 'react-native' ;
2- import refs , { PanelState } from '../../../core/refs' ;
1+ import { Animated , Platform , StyleSheet , View , type ViewProps } from 'react-native' ;
2+ import refs , { HeaderState , PanelState } from '../../../core/refs' ;
33import IndexedStack from '../common/IndexedStack' ;
44import LogMessageDetails from '../details/LogMessageDetails' ;
55import NetworkRequestDetails from '../details/NetworkRequestDetails' ;
66import ConsolePanel from './ConsolePanel' ;
77import NetworkPanel from './NetworkPanel' ;
88import colors from '../../../theme/colors' ;
9- import { forwardRef , useContext , useMemo } from 'react' ;
9+ import { forwardRef , useContext , useEffect , useMemo } from 'react' ;
1010import Header from '../headers/Header' ;
1111import { SafeAreaProvider } from 'react-native-safe-area-context' ;
1212import SafeArea from '../common/SafeArea' ;
1313import { MainContext } from '../../../contexts' ;
14+ import Handle from '../handle/Handle' ;
15+ import { DebuggerPanel } from '../../../types' ;
1416
1517interface PanelProps extends ViewProps { }
1618
1719const Panel = forwardRef < View , PanelProps > ( ( { style, ...props } , ref ) => {
1820 const {
19- debuggerState : { position } ,
20- dimensions : { width : screenWidth , height : screenHeight } ,
21+ debuggerState : { position, detailsData } ,
2122 } = useContext ( MainContext ) ! ;
2223
2324 const containerStyle = useMemo (
24- ( ) => [ styles . container , { [ position ] : 0 , height : Math . min ( screenWidth , screenHeight ) * 0.75 } ] ,
25- [ position , screenWidth , screenHeight ] ,
25+ ( ) => [
26+ styles . container ,
27+ { [ position ] : 0 , width : refs . panelSize . current ?. x , height : refs . panelSize . current ?. y } ,
28+ ] ,
29+ [ position ] ,
2630 ) ;
2731
32+ useEffect ( ( ) => {
33+ switch ( detailsData ?. type ) {
34+ case DebuggerPanel . Network :
35+ refs . header . current ?. setCurrentIndex ( HeaderState . Network ) ;
36+ refs . panel . current ?. setCurrentIndex ( PanelState . NetworkDetail ) ;
37+ break ;
38+ case DebuggerPanel . Console :
39+ refs . header . current ?. setCurrentIndex ( HeaderState . Console ) ;
40+ refs . panel . current ?. setCurrentIndex ( PanelState . ConsoleDetail ) ;
41+ break ;
42+ }
43+ } , [ detailsData ?. type ] ) ;
44+
2845 return (
29- < View style = { [ containerStyle , style ] } ref = { ref } { ...props } >
46+ < Animated . View style = { [ containerStyle , style ] } ref = { ref } { ...props } >
3047 < SafeAreaProvider >
48+ { position === 'bottom' && < Handle /> }
3149 { position === 'top' && < SafeArea inset = "top" /> }
3250
3351 < Header />
@@ -39,9 +57,10 @@ const Panel = forwardRef<View, PanelProps>(({ style, ...props }, ref) => {
3957 < LogMessageDetails />
4058 </ IndexedStack >
4159
60+ { position === 'top' && < Handle /> }
4261 { position === 'bottom' && < SafeArea inset = "bottom" /> }
4362 </ SafeAreaProvider >
44- </ View >
63+ </ Animated . View >
4564 ) ;
4665} ) ;
4766
0 commit comments