1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! Ratatui component implementations
//!
//! This module provides concrete implementations of composable UI components
//! for the ratatui backend.
//!
//! # Component Architecture
//!
//! Components are higher-level UI abstractions that combine data access and rendering.
//! They are trait-based and composable, making it easy to build complex UIs from
//! smaller, reusable pieces.
//!
//! # Available Components
//!
//! - **HeaderComponent**: Turn counter and game mode display
//! - **DistrictsComponent**: Scrollable list of locations with stats
//! - **StatisticsComponent**: Statistics panel with key metrics
//! - **LogComponent**: Event log with control hints
//!
//! # Usage Example
//!
//! ```ignore
//! use issun::ui::ratatui::components::*;
//! use issun::ui::core::{Component, MultiResourceComponent};
//! use issun::ui::ratatui::RatatuiLayer;
//! use issun::ui::layer::UILayoutPresets;
//!
//! // In your render function:
//! fn render_game(frame: &mut Frame, resources: &ResourceContext, selected: usize) {
//! // Create layout
//! let layout = RatatuiLayer::three_panel();
//! let chunks = layout.apply(frame.area());
//!
//! // Render header
//! let header = HeaderComponent::<GameContext>::new();
//! if let Some(widget) = header.render(resources) {
//! frame.render_widget(widget, chunks[0]);
//! }
//!
//! // Render districts
//! let districts = DistrictsComponent::<CityMap>::new();
//! if let Some(widget) = districts.render_with_selection(resources, selected) {
//! frame.render_widget(widget, chunks[1]);
//! }
//!
//! // Render log
//! let log = LogComponent::<GameLog>::new();
//! if let Some(widget) = log.render_multi(resources) {
//! frame.render_widget(widget, chunks[2]);
//! }
//! }
//! ```
//!
//! # Implementing Component Traits
//!
//! To use these components with your game data, implement the required traits:
//!
//! ```ignore
//! use issun::ui::ratatui::components::*;
//!
//! // For HeaderComponent
//! impl HeaderContext for MyGameContext {
//! fn turn(&self) -> u32 { self.current_turn }
//! fn max_turns(&self) -> u32 { self.total_turns }
//! fn mode(&self) -> String { format!("{:?}", self.game_mode) }
//! }
//!
//! // For DistrictsComponent
//! impl DistrictData for MyDistrict {
//! fn id(&self) -> &str { &self.district_id }
//! fn name(&self) -> &str { &self.district_name }
//! fn format_line(&self) -> String {
//! format!("{}: {} citizens", self.name(), self.population)
//! }
//! }
//!
//! impl DistrictsProvider for MyCityMap {
//! type District = MyDistrict;
//! fn districts(&self) -> &[Self::District] { &self.all_districts }
//! }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;