generated from GarandPLG/rust-flake-template
Refactor view handling and keybinding API
Move the `View` enum to a dedicated module and implement `Widget` for `&App` there. Rename `default_view_keybindings` to `default_keybindings` and adjust its signature. Redesign `KeybindingsWidget` to accept an explicit list of bindings instead of a `View`. Update imports, function signatures, and rendering logic across the codebase to reflect these changes.
This commit is contained in:
1 parent
d563bbc966
commit
61e9dedfe8
15 files changed
+109
-115
No files matched your search
@@ -0,0 +1,28 @@
|
||||
use crate::app::{
|
||||
App,
|
||||
views::{default_view, main_menu_view, settings_view},
|
||||
};
|
||||
use clap::ValueEnum;
|
||||
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, ValueEnum)]
|
||||
pub enum View {
|
||||
MainMenu,
|
||||
Skirmish,
|
||||
PerkDecks,
|
||||
SkillsConfig,
|
||||
Settings,
|
||||
}
|
||||
|
||||
impl Widget for &App {
|
||||
fn render(self, area: Rect, buf: &mut Buffer)
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
match self.view {
|
||||
View::MainMenu => main_menu_view(self, area, buf),
|
||||
View::Settings => settings_view(self, area, buf),
|
||||
_ => default_view(area, buf),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user