@@ -67,29 +67,29 @@ pub struct InspectCommitPopup {
6767
6868impl DrawableComponent for InspectCommitPopup {
6969 fn draw ( & self , f : & mut Frame , rect : Rect ) -> Result < ( ) > {
70- if self . is_visible ( ) {
71- let percentages = if self . diff . focused ( ) {
72- ( 0 , 100 )
73- } else {
74- ( 50 , 50 )
75- } ;
76-
77- let chunks = Layout :: default ( )
78- . direction ( Direction :: Horizontal )
79- . constraints (
80- [
81- Constraint :: Percentage ( percentages. 0 ) ,
82- Constraint :: Percentage ( percentages. 1 ) ,
83- ]
84- . as_ref ( ) ,
85- )
86- . split ( rect) ;
87-
88- f. render_widget ( Clear , rect) ;
89-
90- self . details . draw ( f, chunks[ 0 ] ) ?;
91- self . diff . draw ( f, chunks[ 1 ] ) ?;
70+ if !self . is_visible ( ) {
71+ return Ok ( ( ) ) ;
9272 }
73+ let constraints = match rect. width {
74+ ..80 => [
75+ Constraint :: Percentage ( 50 ) ,
76+ Constraint :: Percentage ( 50 ) ,
77+ ] ,
78+ 80 ..100 => [ Constraint :: Max ( 32 ) , Constraint :: Fill ( 1 ) ] ,
79+ 100 ..120 => [ Constraint :: Max ( 40 ) , Constraint :: Fill ( 1 ) ] ,
80+ 120 ..140 => [ Constraint :: Max ( 48 ) , Constraint :: Fill ( 1 ) ] ,
81+ _ => [ Constraint :: Max ( 52 ) , Constraint :: Fill ( 1 ) ] ,
82+ } ;
83+
84+ let chunks = Layout :: default ( )
85+ . direction ( Direction :: Horizontal )
86+ . constraints ( constraints)
87+ . split ( rect) ;
88+
89+ f. render_widget ( Clear , rect) ;
90+
91+ self . details . draw ( f, chunks[ 0 ] ) ?;
92+ self . diff . draw ( f, chunks[ 1 ] ) ?;
9393
9494 Ok ( ( ) )
9595 }
0 commit comments