Skip to content

Commit

Permalink
refactor(app): improve variable naming consistency in render method
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenMian committed Jan 3, 2025
1 parent 5ea8a4b commit 0aab4ac
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,26 @@ impl App {
pub fn render(&mut self) -> Result<()> {
self.tui.terminal.draw(|frame| {
let horizontal = Layout::horizontal([Constraint::Percentage(80), Constraint::Min(25)]);
let [left, right] = horizontal.areas(frame.area());
let [left_area, right_area] = horizontal.areas(frame.area());
let vertical = Layout::vertical([Constraint::Percentage(60), Constraint::Fill(1)]);
let [top_right, bottom_right] = vertical.areas(right);
let [top_right_area, right_bottom_area] = vertical.areas(right_area);

let world_map = WorldMap {
satellites_state: &self.satellites_state,
};
frame.render_stateful_widget(world_map, left, &mut self.world_map_state);
frame.render_stateful_widget(world_map, left_area, &mut self.world_map_state);

let object_information = ObjectInformation {
satellites_state: &self.satellites_state,
world_map_state: &self.world_map_state,
};
frame.render_stateful_widget(
object_information,
top_right,
top_right_area,
&mut self.object_information_state,
);

frame.render_stateful_widget(Satellites, bottom_right, &mut self.satellites_state);
frame.render_stateful_widget(Satellites, right_bottom_area, &mut self.satellites_state);
})?;
Ok(())
}
Expand All @@ -103,6 +103,11 @@ impl App {
}
}

/// Set running to false to quit the application.
pub fn request_exit(&mut self) {
self.running = false;
}

async fn handle_key_events(&mut self, event: KeyEvent) -> Result<()> {
match event.code {
// Exit application on `ESC`
Expand All @@ -126,9 +131,4 @@ impl App {
satellites::handle_mouse_events(event, self).await?;
Ok(())
}

/// Set running to false to quit the application.
pub fn request_exit(&mut self) {
self.running = false;
}
}

0 comments on commit 0aab4ac

Please sign in to comment.