ez_tui/components/concrete/
state_debugger.rs1use crate::{
2 AttrValue, Attribute, Component, DebugWidgetMock, EzArgs, EzCptIds, EzEvent, EzMsg, EzState,
3 MockProps, State,
4};
5use eztui_derive::DecoratedMockComponent;
6use ratatui::layout::Alignment;
7use std::fmt::Debug;
8
9#[derive(DecoratedMockComponent, Debug)]
13pub struct AppStateCpt<CS>
14where
15 CS: EzState,
16{
17 component: DebugWidgetMock<State<CS>>,
18}
19
20impl<CID, CA, CS, CM> Component<CID, CA, CS, CM> for AppStateCpt<CS>
21where
22 CID: EzCptIds,
23 CA: EzArgs,
24 CS: EzState,
25 CM: EzMsg,
26{
27 fn tick(&mut self, state: &mut State<CS>) -> Vec<EzEvent<CID, CM>> {
28 self.component.set((*state).clone());
29 vec![]
30 }
31
32 fn focusable(&self) -> bool {
33 true
34 }
35}
36
37impl<CS> Default for AppStateCpt<CS>
38where
39 CS: EzState,
40{
41 fn default() -> Self {
42 let mut mock = DebugWidgetMock::empty();
43 mock.props_mut().expect("Debug widget has props").set(
44 Attribute::Title,
45 AttrValue::Title(("State".to_string(), Alignment::Center)),
46 );
47 Self { component: mock }
48 }
49}