Game rules screen functional
This commit is contained in:
@ -1,13 +1,16 @@
|
||||
use crate::ui_screens::utils::centered_rect_size;
|
||||
use std::fmt::Display;
|
||||
|
||||
use tui::buffer::Buffer;
|
||||
use tui::layout::Rect;
|
||||
use tui::style::{Color, Style};
|
||||
use tui::widgets::*;
|
||||
|
||||
use crate::ui_screens::utils::centered_rect_size;
|
||||
|
||||
pub struct ButtonWidget {
|
||||
is_hovered: bool,
|
||||
label: String,
|
||||
disabled: bool,
|
||||
}
|
||||
|
||||
impl ButtonWidget {
|
||||
@ -15,8 +18,14 @@ impl ButtonWidget {
|
||||
Self {
|
||||
label: label.to_string(),
|
||||
is_hovered,
|
||||
disabled: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Widget for ButtonWidget {
|
||||
@ -25,9 +34,10 @@ impl Widget for ButtonWidget {
|
||||
|
||||
let area = centered_rect_size(label.len() as u16, 1, area);
|
||||
|
||||
let input = Paragraph::new(label.as_ref()).style(match &self.is_hovered {
|
||||
false => Style::default().bg(Color::DarkGray),
|
||||
true => Style::default().fg(Color::White).bg(Color::Yellow),
|
||||
let input = Paragraph::new(label.as_ref()).style(match (self.disabled, self.is_hovered) {
|
||||
(true, _) => Style::default(),
|
||||
(_, false) => Style::default().bg(Color::DarkGray),
|
||||
(_, true) => Style::default().fg(Color::White).bg(Color::Yellow),
|
||||
});
|
||||
|
||||
input.render(area, buf);
|
||||
|
Reference in New Issue
Block a user