From 55c0912608ba78f44fbcded93621f1c43fd0c376 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Mon, 28 Jul 2025 18:10:37 -0600 Subject: [PATCH] Adjust openweathermap layout --- thecockpit/src/app/mod.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/thecockpit/src/app/mod.rs b/thecockpit/src/app/mod.rs index 5b4f252..7531f55 100644 --- a/thecockpit/src/app/mod.rs +++ b/thecockpit/src/app/mod.rs @@ -203,7 +203,7 @@ impl App { } pub fn draw_first_tab(&mut self, frame: &mut Frame, layout_outer: Rect) { - let layout = Layout::new( + let first_tab_layout = Layout::new( if layout_outer.width < (layout_outer.height * 2) { Direction::Vertical } else { @@ -212,6 +212,7 @@ impl App { [Constraint::Ratio(1, 2), Constraint::Ratio(1, 2)], ) .split(layout_outer); + let weather_area = first_tab_layout[0]; if let Some(weather) = self.weather.get() { frame.render_widget( Block::new() @@ -219,14 +220,14 @@ impl App { .borders(Borders::all()) .fg(Color::Rgb(226, 190, 89)) .bg(Color::Black), - layout[0], + weather_area, ); let layout = Layout::new( Direction::Vertical, [Constraint::Length(12), Constraint::Min(0)], ) - .split(layout[0].inner(Margin::new(2, 2))); + .split(weather_area.inner(Margin::new(2, 2))); let layout_upper = Layout::new( Direction::Horizontal, @@ -262,14 +263,11 @@ impl App { )) .fg(Color::Rgb(226, 190, 89)) .bg(Color::Black), - layout_upper[1], - ); - frame.render_widget( - Block::new() - .borders(Borders::all()) - .fg(Color::Rgb(226, 190, 89)) - .bg(Color::Black), - layout[1], + if weather_area.width < (weather_area.height * 2) { + layout[1] + } else { + layout_upper[1] + }, ); } else { frame.render_widget( @@ -278,7 +276,7 @@ impl App { .fg(Color::Rgb(226, 190, 89)) .bg(Color::Black) .block(Block::new().title("Weather").borders(Borders::all())), - layout[0], + weather_area, ); } frame.render_widget( @@ -287,7 +285,7 @@ impl App { .fg(Color::Rgb(226, 190, 89)) .bg(Color::Black) .block(Block::new().borders(Borders::all())), - layout[1], + first_tab_layout[1], ); }