refactor: use THEME for all colors, add theme fields, fix forge installer
This commit is contained in:
1 parent
eeb4333b94
commit
d4ffcca61c
12 files changed
+139
-41
No files matched your search
+4
-2
@@ -398,6 +398,7 @@ impl App {
|
||||
}
|
||||
|
||||
fn sync_error_effects(&mut self, events: &[error_buffer::ErrorEvent]) {
|
||||
use crate::tui::theme::THEME;
|
||||
let active_ids: std::collections::HashSet<u64> = events.iter().map(|event| event.id).collect();
|
||||
self.error_effects.retain(|id, _| active_ids.contains(id));
|
||||
|
||||
@@ -407,7 +408,7 @@ impl App {
|
||||
Motion::RightToLeft,
|
||||
8,
|
||||
0,
|
||||
ratatui::style::Color::Reset,
|
||||
THEME.colors.popup_bg,
|
||||
(300, Interpolation::SineOut),
|
||||
))
|
||||
});
|
||||
@@ -421,6 +422,7 @@ impl App {
|
||||
event: &error_buffer::ErrorEvent,
|
||||
elapsed_ms: u128,
|
||||
) {
|
||||
use crate::tui::theme::THEME;
|
||||
const FADE_OUT_MS: u128 = 500;
|
||||
let fade_start_ms = error_buffer::AUTO_DISMISS_MS.saturating_sub(FADE_OUT_MS);
|
||||
|
||||
@@ -428,7 +430,7 @@ impl App {
|
||||
let entry = self.error_effects.entry(event.id).or_insert(ErrorEffectState::Idle);
|
||||
if !matches!(entry, ErrorEffectState::FadingOut(_)) {
|
||||
*entry = ErrorEffectState::FadingOut(tachyonfx::fx::fade_to_fg(
|
||||
ratatui::style::Color::DarkGray,
|
||||
THEME.colors.fade_to,
|
||||
(FADE_OUT_MS as u32, Interpolation::SineIn),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
use ratatui::{
|
||||
layout::Rect,
|
||||
style::{Color, Style},
|
||||
style::Style,
|
||||
widgets::{Block, BorderType, Borders, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
|
||||
use crate::tui::layout::FocusedArea;
|
||||
use crate::tui::theme::THEME;
|
||||
|
||||
use super::styled_title;
|
||||
|
||||
pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) {
|
||||
let color = if focused == FocusedArea::Account {
|
||||
Color::White
|
||||
THEME.colors.border_focused
|
||||
} else {
|
||||
Color::DarkGray
|
||||
THEME.colors.border_unfocused
|
||||
};
|
||||
|
||||
let block = Block::default()
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
use ratatui::{
|
||||
layout::Rect,
|
||||
style::{Color, Style},
|
||||
style::Style,
|
||||
widgets::{Block, BorderType, Borders, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
|
||||
use crate::tui::layout::FocusedArea;
|
||||
use crate::tui::theme::THEME;
|
||||
|
||||
use super::styled_title;
|
||||
|
||||
pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) {
|
||||
let color = if focused == FocusedArea::Content {
|
||||
Color::White
|
||||
THEME.colors.border_focused
|
||||
} else {
|
||||
Color::DarkGray
|
||||
THEME.colors.border_unfocused
|
||||
};
|
||||
|
||||
let block = Block::default()
|
||||
@@ -28,9 +29,9 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) {
|
||||
|
||||
pub fn title(frame: &mut Frame, area: Rect, focused: FocusedArea) {
|
||||
let color = if focused == FocusedArea::Content {
|
||||
Color::White
|
||||
THEME.colors.border_focused
|
||||
} else {
|
||||
Color::DarkGray
|
||||
THEME.colors.border_unfocused
|
||||
};
|
||||
|
||||
let block = Block::default()
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
use ratatui::{
|
||||
layout::Rect,
|
||||
style::{Color, Style},
|
||||
style::Style,
|
||||
widgets::{Block, BorderType, Borders, Paragraph},
|
||||
Frame,
|
||||
};
|
||||
|
||||
use crate::tui::layout::FocusedArea;
|
||||
use crate::tui::theme::THEME;
|
||||
|
||||
use super::styled_title;
|
||||
|
||||
pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea) {
|
||||
let color = if focused == FocusedArea::Details {
|
||||
Color::White
|
||||
THEME.colors.border_focused
|
||||
} else {
|
||||
Color::DarkGray
|
||||
THEME.colors.border_unfocused
|
||||
};
|
||||
|
||||
let block = Block::default()
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use crossterm::event::KeyEvent;
|
||||
use ratatui::{
|
||||
style::{Color, Style},
|
||||
style::Style,
|
||||
text::{Line, Span},
|
||||
};
|
||||
use crate::tui::theme::THEME;
|
||||
|
||||
pub mod account;
|
||||
pub mod content;
|
||||
@@ -20,7 +21,7 @@ pub fn styled_title(title: &str, highlight: bool) -> Line<'_> {
|
||||
let first = chars.next().unwrap_or_default().to_string();
|
||||
let rest: String = chars.collect();
|
||||
Line::from(vec![
|
||||
Span::styled(first, Style::default().fg(Color::Yellow)),
|
||||
Span::styled(first, Style::default().fg(THEME.colors.accent)),
|
||||
Span::raw(rest),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
style::{Color, Modifier, Style},
|
||||
style::{Modifier, Style},
|
||||
text::{Line, Span},
|
||||
widgets::{Paragraph, Widget, Wrap},
|
||||
};
|
||||
@@ -24,15 +24,15 @@ impl ErrorPopup {
|
||||
impl Widget for ErrorPopup {
|
||||
fn render(self, area: Rect, buf: &mut Buffer) {
|
||||
let (border_color, label) = match self.event.level {
|
||||
Level::ERROR => (Color::Red, "ERROR"),
|
||||
Level::WARN => (Color::Yellow, "WARN"),
|
||||
Level::ERROR => (THEME.colors.error, "ERROR"),
|
||||
Level::WARN => (THEME.colors.warn, "WARN"),
|
||||
_ => (THEME.colors.border_focused, "INFO"),
|
||||
};
|
||||
|
||||
let title = Line::from(vec![Span::styled(
|
||||
format!(" {} ", label),
|
||||
Style::default()
|
||||
.fg(Color::Black)
|
||||
.fg(THEME.colors.badge_text)
|
||||
.bg(border_color)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
)]);
|
||||
@@ -41,7 +41,7 @@ impl Widget for ErrorPopup {
|
||||
let popup = PopupFrame {
|
||||
title,
|
||||
border_color,
|
||||
bg: None,
|
||||
bg: Some(THEME.colors.popup_bg),
|
||||
keybinds: None,
|
||||
search_line: None,
|
||||
content: Box::new(move |inner, buf| {
|
||||
|
||||
@@ -152,7 +152,7 @@ pub fn render(frame: &mut Frame, area: Rect, _focused: FocusedArea) {
|
||||
let popup = PopupFrame {
|
||||
title: wizard_title(&snapshot),
|
||||
border_color: THEME.colors.border_focused,
|
||||
bg: None,
|
||||
bg: Some(THEME.colors.popup_bg),
|
||||
keybinds: Some(keybinds),
|
||||
search_line,
|
||||
content: Box::new(move |popup_area, buf| {
|
||||
@@ -511,7 +511,7 @@ fn render_version_step(state: &WizardState, area: Rect, buf: &mut ratatui::buffe
|
||||
LoadState::Error(message) => {
|
||||
Paragraph::new(message.as_str())
|
||||
.wrap(Wrap { trim: true })
|
||||
.style(Style::default().fg(ratatui::style::Color::Red))
|
||||
.style(Style::default().fg(THEME.colors.error))
|
||||
.render(area, buf);
|
||||
}
|
||||
LoadState::Loaded(_) => {
|
||||
@@ -588,7 +588,7 @@ fn render_loader_version_step(
|
||||
LoadState::Error(message) => {
|
||||
Paragraph::new(message.as_str())
|
||||
.wrap(Wrap { trim: true })
|
||||
.style(Style::default().fg(ratatui::style::Color::Red))
|
||||
.style(Style::default().fg(THEME.colors.error))
|
||||
.render(area, buf);
|
||||
}
|
||||
LoadState::Loaded(versions) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use ratatui::{
|
||||
layout::{Constraint, Layout, Rect},
|
||||
style::{Color, Modifier, Style},
|
||||
style::{Modifier, Style},
|
||||
text::Span,
|
||||
widgets::{Block, BorderType, Borders, Gauge, Paragraph},
|
||||
Frame,
|
||||
@@ -20,9 +20,9 @@ pub fn render(
|
||||
throbber_state: &mut ThrobberState,
|
||||
) {
|
||||
let border_color = if focused == FocusedArea::Status {
|
||||
Color::White
|
||||
THEME.colors.border_focused
|
||||
} else {
|
||||
Color::DarkGray
|
||||
THEME.colors.border_unfocused
|
||||
};
|
||||
|
||||
let block = Block::default()
|
||||
@@ -34,14 +34,20 @@ pub fn render(
|
||||
let state = match PROGRESS.lock() {
|
||||
Ok(s) => s.clone(),
|
||||
Err(_) => {
|
||||
let idle = Paragraph::new(Span::styled("Ready", Style::default().fg(Color::DarkGray)));
|
||||
let idle = Paragraph::new(Span::styled(
|
||||
"Ready",
|
||||
Style::default().fg(THEME.colors.text_idle),
|
||||
));
|
||||
frame.render_widget(idle.block(block), area);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
if state.current_action.is_none() {
|
||||
let idle = Paragraph::new(Span::styled("Ready", Style::default().fg(Color::DarkGray)));
|
||||
let idle = Paragraph::new(Span::styled(
|
||||
"Ready",
|
||||
Style::default().fg(THEME.colors.text_idle),
|
||||
));
|
||||
frame.render_widget(idle.block(block), area);
|
||||
return;
|
||||
}
|
||||
@@ -70,8 +76,8 @@ pub fn render(
|
||||
let gauge = Gauge::default()
|
||||
.gauge_style(
|
||||
Style::default()
|
||||
.fg(Color::Green)
|
||||
.bg(Color::DarkGray)
|
||||
.fg(THEME.colors.progress_fill)
|
||||
.bg(THEME.colors.progress_track)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
)
|
||||
.percent(pct);
|
||||
|
||||
Reference in new issue
Block a user