* simplify footer

* improve: &T vs. &mut T

* remove header

* adjust table space

* update README
This commit is contained in:
Jens K.
2024-12-23 14:24:15 +01:00
committed by GitHub
parent 98ee2bc16b
commit d86f8905f2
7 changed files with 71 additions and 109 deletions

View File

@@ -7,8 +7,7 @@ use crate::{
widgets::{
clock::{self, Clock, ClockArgs, Style},
countdown::{Countdown, CountdownWidget},
footer::{Footer, FooterArgs},
header::Header,
footer::Footer,
pomodoro::{Mode as PomodoroMode, Pomodoro, PomodoroArgs, PomodoroWidget},
timer::{Timer, TimerWidget},
},
@@ -166,10 +165,10 @@ impl App {
self.mode != Mode::Quit
}
fn is_edit_mode(&mut self) -> bool {
fn is_edit_mode(&self) -> bool {
match self.content {
Content::Countdown => self.countdown.get_clock().clone().is_edit_mode(),
Content::Timer => self.timer.get_clock().clone().is_edit_mode(),
Content::Countdown => self.countdown.get_clock().is_edit_mode(),
Content::Timer => self.timer.get_clock().is_edit_mode(),
Content::Pomodoro => self.pomodoro.get_clock().is_edit_mode(),
}
}
@@ -250,24 +249,21 @@ impl AppWidget {
impl StatefulWidget for AppWidget {
type State = App;
fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) {
let vertical = Layout::vertical([
Constraint::Length(1),
let [v0, v1] = Layout::vertical([
Constraint::Percentage(100),
Constraint::Length(if state.show_menu { 5 } else { 1 }),
]);
let [v0, v1, v2] = vertical.areas(area);
Constraint::Length(if state.show_menu { 4 } else { 1 }),
])
.areas(area);
// header
Header::new(true).render(v0, buf);
// content
self.render_content(v1, buf, state);
self.render_content(v0, buf, state);
// footer
Footer::new(FooterArgs {
Footer {
show_menu: state.show_menu,
running_clock: state.clock_is_running(),
selected_content: state.content,
edit_mode: state.is_edit_mode(),
})
.render(v2, buf);
}
.render(v1, buf);
}
}