lib: Fix columns / table rendering in imUI

This commit is contained in:
Erik Kundt
2024-09-05 10:36:50 +02:00
parent 77d8cb0caf
commit ac9df0fa97
3 changed files with 8 additions and 13 deletions
+1 -1
View File
@@ -15,9 +15,9 @@ use anyhow::Result;
use store::State;
use task::Interrupted;
use ui::im;
use ui::widget::Widget;
use ui::Frontend;
use ui::im;
/// An optional return value.
#[derive(Clone, Debug)]
+1 -1
View File
@@ -1,9 +1,9 @@
pub mod ext;
pub mod im;
pub mod layout;
pub mod span;
pub mod theme;
pub mod widget;
pub mod im;
use std::fmt::Debug;
use std::time::Duration;
+6 -11
View File
@@ -811,15 +811,8 @@ pub mod widget {
.collect();
if has_items {
let [table_area, scroller_area] = Layout::horizontal([
Constraint::Min(1),
if show_scrollbar {
Constraint::Length(1)
} else {
Constraint::Length(0)
},
])
.areas(area);
let [table_area, scroller_area] =
Layout::horizontal([Constraint::Min(1), Constraint::Length(1)]).areas(area);
let rows = self
.items
@@ -830,7 +823,7 @@ pub mod widget {
for cell in item.to_row() {
if let Some(col) = it.next() {
if !col.skip && col.displayed(area.width as usize) {
if !col.skip && col.displayed(table_area.width as usize) {
cells.push(cell.clone())
}
} else {
@@ -997,11 +990,13 @@ pub mod widget {
let cells = self
.columns
.iter()
.filter(|c| !c.skip && c.displayed(area.width as usize))
.map(|c| c.text.clone())
.collect::<Vec<_>>();
let table = ratatui::widgets::Table::default()
.header(Row::new(cells))
.column_spacing(1)
.rows([Row::new(cells)])
.widths(widths);
frame.render_widget(table, area);