fix margin in file-tree

This commit is contained in:
Stephan Dilly 2021-05-28 09:49:44 +02:00
parent b8f8081e58
commit 9700f9f5ee
2 changed files with 22 additions and 25 deletions

View file

@ -194,10 +194,20 @@ impl RevisionFilesComponent {
let is_tree_focused = matches!(self.focus, Focus::Tree); let is_tree_focused = matches!(self.focus, Focus::Tree);
let title = format!(
"Files at [{}]",
self.revision
.map(|c| c.get_short_string())
.unwrap_or_default()
);
ui::draw_list_block( ui::draw_list_block(
f, f,
area, area,
Block::default() Block::default()
.title(Span::styled(
title,
self.theme.title(is_tree_focused),
))
.borders(Borders::ALL) .borders(Borders::ALL)
.border_style(self.theme.block(is_tree_focused)), .border_style(self.theme.block(is_tree_focused)),
items, items,
@ -223,7 +233,6 @@ impl DrawableComponent for RevisionFilesComponent {
) -> Result<()> { ) -> Result<()> {
let chunks = Layout::default() let chunks = Layout::default()
.direction(Direction::Horizontal) .direction(Direction::Horizontal)
.margin(1)
.constraints( .constraints(
[ [
Constraint::Percentage(40), Constraint::Percentage(40),

View file

@ -13,17 +13,9 @@ use anyhow::Result;
use asyncgit::{sync::CommitId, AsyncNotification}; use asyncgit::{sync::CommitId, AsyncNotification};
use crossbeam_channel::Sender; use crossbeam_channel::Sender;
use crossterm::event::Event; use crossterm::event::Event;
use tui::{ use tui::{backend::Backend, layout::Rect, widgets::Clear, Frame};
backend::Backend,
layout::Rect,
text::Span,
widgets::{Block, Borders, Clear},
Frame,
};
pub struct RevisionFilesPopup { pub struct RevisionFilesPopup {
title: String,
theme: SharedTheme,
visible: bool, visible: bool,
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
files: RevisionFilesComponent, files: RevisionFilesComponent,
@ -38,14 +30,12 @@ impl RevisionFilesPopup {
key_config: SharedKeyConfig, key_config: SharedKeyConfig,
) -> Self { ) -> Self {
Self { Self {
title: String::new(),
files: RevisionFilesComponent::new( files: RevisionFilesComponent::new(
queue, queue,
sender, sender,
theme.clone(), theme,
key_config.clone(), key_config.clone(),
), ),
theme,
visible: false, visible: false,
key_config, key_config,
} }
@ -54,8 +44,6 @@ impl RevisionFilesPopup {
/// ///
pub fn open(&mut self, commit: CommitId) -> Result<()> { pub fn open(&mut self, commit: CommitId) -> Result<()> {
self.files.set_commit(commit)?; self.files.set_commit(commit)?;
self.title =
format!("Files at [{}]", commit.get_short_string());
self.show()?; self.show()?;
Ok(()) Ok(())
@ -80,16 +68,16 @@ impl DrawableComponent for RevisionFilesPopup {
) -> Result<()> { ) -> Result<()> {
if self.is_visible() { if self.is_visible() {
f.render_widget(Clear, area); f.render_widget(Clear, area);
f.render_widget( // f.render_widget(
Block::default() // Block::default()
.borders(Borders::TOP) // .borders(Borders::TOP)
.title(Span::styled( // .title(Span::styled(
format!(" {}", self.title), // format!(" {}", self.title),
self.theme.title(true), // self.theme.title(true),
)) // ))
.border_style(self.theme.block(true)), // .border_style(self.theme.block(true)),
area, // area,
); // );
self.files.draw(f, area)?; self.files.draw(f, area)?;
} }