mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-23 20:16:41 +02:00
WIP
This commit is contained in:
parent
65dbd3e8a3
commit
09d4e8c4d1
4 changed files with 34 additions and 19 deletions
|
@ -14,3 +14,4 @@ group_imports = "StdExternalCrate"
|
|||
tab_spaces = 2
|
||||
use_field_init_shorthand = true
|
||||
use_try_shorthand = true
|
||||
combine_control_expr = false
|
||||
|
|
|
@ -9,6 +9,7 @@ use crate::{
|
|||
tui::{Event, Frame},
|
||||
};
|
||||
|
||||
pub mod task_details;
|
||||
pub mod task_report;
|
||||
|
||||
pub trait Component {
|
||||
|
@ -43,5 +44,5 @@ pub trait Component {
|
|||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||
Ok(None)
|
||||
}
|
||||
fn draw(&mut self, f: &mut Frame<'_>, rect: Rect) -> Result<()>;
|
||||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect) -> Result<()>;
|
||||
}
|
||||
|
|
26
src/components/task_details.rs
Normal file
26
src/components/task_details.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use color_eyre::eyre::Result;
|
||||
use futures::channel::mpsc::UnboundedSender;
|
||||
use ratatui::{prelude::*, widgets::*};
|
||||
use task_hookrs::task::Task;
|
||||
|
||||
use super::{Component, Frame};
|
||||
use crate::{action::Action, config::Config};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct TaskDetails {
|
||||
pub command_tx: Option<UnboundedSender<Action>>,
|
||||
pub config: Config,
|
||||
}
|
||||
|
||||
impl Component for TaskDetails {
|
||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||
match action {
|
||||
Action::TaskDetailsUpdateUuid(uuid) => {},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ use crate::{
|
|||
action::{Action, TaskCommand},
|
||||
config::{Config, KeyBindings},
|
||||
};
|
||||
|
||||
const VIRTUAL_TAGS: [&str; 34] = [
|
||||
"PROJECT",
|
||||
"BLOCKED",
|
||||
|
@ -812,13 +813,13 @@ impl Component for TaskReport {
|
|||
Ok(None)
|
||||
}
|
||||
|
||||
fn draw(&mut self, f: &mut Frame<'_>, rect: Rect) -> Result<()> {
|
||||
fn draw(&mut self, f: &mut Frame<'_>, area: Rect) -> Result<()> {
|
||||
let column_spacing = 1;
|
||||
if self.rows.len() == 0 {
|
||||
f.render_widget(Paragraph::new("No data found").block(Block::new().borders(Borders::all())), rect);
|
||||
f.render_widget(Paragraph::new("No data found").block(Block::new().borders(Borders::all())), area);
|
||||
return Ok(());
|
||||
}
|
||||
let widths = self.calculate_widths(rect.width);
|
||||
let widths = self.calculate_widths(area.width);
|
||||
let constraints: Vec<Constraint> = widths.iter().map(|i| Constraint::Min(*i as u16)).collect();
|
||||
let rows = self.rows.iter().enumerate().map(|(i, row)| {
|
||||
let style = self.style_for_task(&self.tasks[i]);
|
||||
|
@ -841,7 +842,7 @@ impl Component for TaskReport {
|
|||
.highlight_symbol(&self.config.task_report.selection_indicator)
|
||||
.highlight_spacing(HighlightSpacing::Always)
|
||||
.column_spacing(column_spacing);
|
||||
f.render_stateful_widget(table, rect, &mut self.state);
|
||||
f.render_stateful_widget(table, area, &mut self.state);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -967,17 +968,3 @@ pub fn remove_tag(task: &mut Task, tag: &str) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_export() -> Result<()> {
|
||||
let mut tr = TaskReport::new().report("next".into());
|
||||
tr.task_export()?;
|
||||
assert_eq!(tr.tasks.len(), 33);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue