Pomodoro (editable) (#11)
This commit is contained in:
@@ -23,6 +23,10 @@ impl Countdown {
|
||||
pub const fn new(headline: String, clock: Clock<clock::Countdown>) -> Self {
|
||||
Self { headline, clock }
|
||||
}
|
||||
|
||||
pub fn is_edit_mode(&mut self) -> bool {
|
||||
self.clock.is_edit_mode()
|
||||
}
|
||||
}
|
||||
|
||||
impl EventHandler for Countdown {
|
||||
@@ -48,17 +52,17 @@ impl StatefulWidget for CountdownWidget {
|
||||
type State = Countdown;
|
||||
fn render(self, area: Rect, buf: &mut Buffer, state: &mut Self::State) {
|
||||
let clock = ClockWidget::new();
|
||||
let headline = Line::raw(state.headline.clone());
|
||||
let headline = Line::raw(state.headline.to_uppercase());
|
||||
|
||||
let area = center(
|
||||
area,
|
||||
Constraint::Length(max(clock.get_width(), headline.width() as u16)),
|
||||
Constraint::Length(clock.get_height() + 2),
|
||||
Constraint::Length(clock.get_height() + 1 /* height of headline */),
|
||||
);
|
||||
let [v1, _, v2] =
|
||||
Layout::vertical(Constraint::from_lengths([clock.get_height(), 1, 1])).areas(area);
|
||||
let [v1, v2] =
|
||||
Layout::vertical(Constraint::from_lengths([clock.get_height(), 1])).areas(area);
|
||||
|
||||
clock.render(v1, buf, &mut state.clock);
|
||||
headline.centered().render(v2, buf);
|
||||
headline.render(v2, buf);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user