fix: normalize settings popup styling
This commit is contained in:
1 parent
5f99de36ba
commit
45d9b85abf
6 files changed
+32
-62
No files matched your search
+1
-2
@@ -734,10 +734,9 @@ impl App {
|
|||||||
widgets::popups::instance_settings::Action::Save(updated, desktop) => {
|
widgets::popups::instance_settings::Action::Save(updated, desktop) => {
|
||||||
self.apply_instance_settings(*updated, desktop, false);
|
self.apply_instance_settings(*updated, desktop, false);
|
||||||
}
|
}
|
||||||
widgets::popups::instance_settings::Action::ConfirmRuntime { name, to } => {
|
widgets::popups::instance_settings::Action::ConfirmRuntime { name } => {
|
||||||
confirm_popup::set_pending(confirm_popup::ConfirmTarget::InstanceRuntime {
|
confirm_popup::set_pending(confirm_popup::ConfirmTarget::InstanceRuntime {
|
||||||
name,
|
name,
|
||||||
to,
|
|
||||||
});
|
});
|
||||||
self.focused = FocusedArea::ConfirmDelete;
|
self.focused = FocusedArea::ConfirmDelete;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -657,7 +657,7 @@ fn runtime_settings_use_the_shared_confirmation_popup() {
|
|||||||
));
|
));
|
||||||
ui.draw();
|
ui.draw();
|
||||||
assert!(ui.screen().contains("Change runtime"));
|
assert!(ui.screen().contains("Change runtime"));
|
||||||
assert!(ui.screen().contains("Target:"));
|
assert!(!ui.screen().contains("Target:"));
|
||||||
assert!(
|
assert!(
|
||||||
ui.screen()
|
ui.screen()
|
||||||
.contains("Some installed mods may be incompatible")
|
.contains("Some installed mods may be incompatible")
|
||||||
@@ -705,7 +705,7 @@ fn settings_use_java_memory_and_resolution_controls() {
|
|||||||
ui.draw();
|
ui.draw();
|
||||||
assert!(ui.screen().contains("Java Runtime"));
|
assert!(ui.screen().contains("Java Runtime"));
|
||||||
assert!(ui.screen().contains("auto"));
|
assert!(ui.screen().contains("auto"));
|
||||||
assert!(ui.screen().contains("custom"));
|
assert!(!ui.screen().contains("custom"));
|
||||||
assert!(!ui.screen().contains("Automatic"));
|
assert!(!ui.screen().contains("Automatic"));
|
||||||
assert!(!ui.screen().contains("Custom path"));
|
assert!(!ui.screen().contains("Custom path"));
|
||||||
assert!(!ui.screen().contains("Manual"));
|
assert!(!ui.screen().contains("Manual"));
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ pub enum ConfirmTarget {
|
|||||||
},
|
},
|
||||||
InstanceRuntime {
|
InstanceRuntime {
|
||||||
name: String,
|
name: String,
|
||||||
to: String,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +93,8 @@ impl ConfirmTarget {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n"),
|
.join("\n"),
|
||||||
ConfirmTarget::InstanceRuntime { to, .. } => {
|
ConfirmTarget::InstanceRuntime { .. } => {
|
||||||
format!("Target: {to}\nSome installed mods may be incompatible")
|
"Some installed mods may be incompatible".to_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,7 +181,6 @@ pub struct ConfirmPopup {
|
|||||||
title: String,
|
title: String,
|
||||||
body: String,
|
body: String,
|
||||||
confirm_label: &'static str,
|
confirm_label: &'static str,
|
||||||
accent_border: bool,
|
|
||||||
runtime_confirmation: bool,
|
runtime_confirmation: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +190,6 @@ impl ConfirmPopup {
|
|||||||
title: target.title(),
|
title: target.title(),
|
||||||
body: target.body(),
|
body: target.body(),
|
||||||
confirm_label: target.confirm_label(),
|
confirm_label: target.confirm_label(),
|
||||||
accent_border: matches!(target, ConfirmTarget::InstanceRuntime { .. }),
|
|
||||||
runtime_confirmation: matches!(target, ConfirmTarget::InstanceRuntime { .. }),
|
runtime_confirmation: matches!(target, ConfirmTarget::InstanceRuntime { .. }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,11 +208,7 @@ impl Widget for ConfirmPopup {
|
|||||||
)]);
|
)]);
|
||||||
let kb = keybind_line(&[("Esc", " cancel"), ("Enter", self.confirm_label)]);
|
let kb = keybind_line(&[("Esc", " cancel"), ("Enter", self.confirm_label)]);
|
||||||
|
|
||||||
let border_color = if self.accent_border {
|
let border_color = theme.text_dim();
|
||||||
theme.accent()
|
|
||||||
} else {
|
|
||||||
theme.text_dim()
|
|
||||||
};
|
|
||||||
let bg_color = theme.surface();
|
let bg_color = theme.surface();
|
||||||
let accent = theme.accent();
|
let accent = theme.accent();
|
||||||
let text = theme.text();
|
let text = theme.text();
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ use crate::{
|
|||||||
},
|
},
|
||||||
instance::models::normalize_memory_value,
|
instance::models::normalize_memory_value,
|
||||||
tui::widgets::popups::settings_controls::{
|
tui::widgets::popups::settings_controls::{
|
||||||
JavaChoice, JavaPicker, adjust_memory, handle_text_area_input, memory_kib,
|
JavaChoice, JavaPicker, adjust_memory, auto_label, handle_text_area_input, memory_kib,
|
||||||
render_memory_gauge, subtle_tag,
|
render_memory_gauge,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -217,10 +217,6 @@ impl State {
|
|||||||
self.toggle_auto_java();
|
self.toggle_auto_java();
|
||||||
self.java_picker_open = false;
|
self.java_picker_open = false;
|
||||||
}
|
}
|
||||||
KeyCode::Char('c') => {
|
|
||||||
self.java_picker_open = false;
|
|
||||||
self.editing = Some(new_text_area(vec![self.value(4)]));
|
|
||||||
}
|
|
||||||
KeyCode::Char('j') | KeyCode::Down if count > 0 => {
|
KeyCode::Char('j') | KeyCode::Down if count > 0 => {
|
||||||
self.java_picker.selected = (self.java_picker.selected + 1).min(count - 1);
|
self.java_picker.selected = (self.java_picker.selected + 1).min(count - 1);
|
||||||
}
|
}
|
||||||
@@ -408,12 +404,7 @@ pub fn render(frame: &mut Frame, area: Rect, state: &mut State) {
|
|||||||
let keybinds = if state.editing.is_some() {
|
let keybinds = if state.editing.is_some() {
|
||||||
super::keybind_line(&[("Enter", " apply"), ("Esc", " cancel")])
|
super::keybind_line(&[("Enter", " apply"), ("Esc", " cancel")])
|
||||||
} else if state.java_picker_open {
|
} else if state.java_picker_open {
|
||||||
super::keybind_line(&[
|
super::keybind_line(&[("a", " auto"), ("h", " back"), ("Enter", " select")])
|
||||||
("a", " auto"),
|
|
||||||
("c", " custom"),
|
|
||||||
("h", " back"),
|
|
||||||
("Enter", " select"),
|
|
||||||
])
|
|
||||||
} else if state.theme_picker {
|
} else if state.theme_picker {
|
||||||
super::keybind_line(&[("h", " back"), ("Enter", " select")])
|
super::keybind_line(&[("h", " back"), ("Enter", " select")])
|
||||||
} else if matches!(state.selected, 2 | 3) {
|
} else if matches!(state.selected, 2 | 3) {
|
||||||
@@ -580,7 +571,7 @@ fn global_field_line(state: &State, index: usize, label: &str) -> Line<'static>
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
if index == 4 && state.config.paths.java_path.is_none() && !editing {
|
if index == 4 && state.config.paths.java_path.is_none() && !editing {
|
||||||
spans.extend([Span::raw(" "), subtle_tag("Auto", theme.info())]);
|
spans.extend([Span::raw(" "), auto_label()]);
|
||||||
}
|
}
|
||||||
Line::from(spans).style(Style::default().bg(if selected {
|
Line::from(spans).style(Style::default().bg(if selected {
|
||||||
theme.stripe()
|
theme.stripe()
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ use crate::{
|
|||||||
popups::{
|
popups::{
|
||||||
LoadState,
|
LoadState,
|
||||||
settings_controls::{
|
settings_controls::{
|
||||||
DisplayResolution, JavaChoice, JavaPicker, adjust_memory, display_resolutions,
|
DisplayResolution, JavaChoice, JavaPicker, adjust_memory, auto_label,
|
||||||
handle_text_area_input, memory_kib, render_memory_gauge, subtle_tag,
|
display_resolutions, handle_text_area_input, memory_kib, render_memory_gauge,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
search::SearchState,
|
search::SearchState,
|
||||||
@@ -106,7 +106,7 @@ pub enum Action {
|
|||||||
None,
|
None,
|
||||||
Save(Box<InstanceConfig>, bool),
|
Save(Box<InstanceConfig>, bool),
|
||||||
Error(String),
|
Error(String),
|
||||||
ConfirmRuntime { name: String, to: String },
|
ConfirmRuntime { name: String },
|
||||||
OpenRaw,
|
OpenRaw,
|
||||||
Close,
|
Close,
|
||||||
}
|
}
|
||||||
@@ -286,10 +286,6 @@ impl State {
|
|||||||
self.toggle_auto_java();
|
self.toggle_auto_java();
|
||||||
self.choice_picker = None;
|
self.choice_picker = None;
|
||||||
}
|
}
|
||||||
KeyCode::Char('c') if self.choice_picker == Some(ChoicePicker::Java) => {
|
|
||||||
self.choice_picker = None;
|
|
||||||
self.editing = Some(new_text_area(vec![self.value(3)]));
|
|
||||||
}
|
|
||||||
KeyCode::Char('d') if self.choice_picker == Some(ChoicePicker::Resolution) => {
|
KeyCode::Char('d') if self.choice_picker == Some(ChoicePicker::Resolution) => {
|
||||||
self.apply_default_resolution();
|
self.apply_default_resolution();
|
||||||
self.choice_picker = None;
|
self.choice_picker = None;
|
||||||
@@ -691,7 +687,6 @@ impl State {
|
|||||||
}
|
}
|
||||||
return Action::ConfirmRuntime {
|
return Action::ConfirmRuntime {
|
||||||
name: self.draft.name.clone(),
|
name: self.draft.name.clone(),
|
||||||
to: runtime_label(&self.draft),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if self.validate_before_save() {
|
if self.validate_before_save() {
|
||||||
@@ -777,19 +772,6 @@ impl State {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn runtime_label(config: &InstanceConfig) -> String {
|
|
||||||
if config.loader == ModLoader::Vanilla {
|
|
||||||
format!("{} / Vanilla", config.game_version)
|
|
||||||
} else {
|
|
||||||
format!(
|
|
||||||
"{} / {} {}",
|
|
||||||
config.game_version,
|
|
||||||
config.loader,
|
|
||||||
config.loader_version.as_deref().unwrap_or("unknown")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn resolution_choices(
|
fn resolution_choices(
|
||||||
current: Option<(u32, u32)>,
|
current: Option<(u32, u32)>,
|
||||||
displays: &[DisplayResolution],
|
displays: &[DisplayResolution],
|
||||||
@@ -883,12 +865,7 @@ pub fn render(frame: &mut Frame, area: Rect, state: &mut State) {
|
|||||||
} else if state.picker.is_some() {
|
} else if state.picker.is_some() {
|
||||||
super::keybind_line(&[("/", " search"), ("h", " back"), ("Enter", " select")])
|
super::keybind_line(&[("/", " search"), ("h", " back"), ("Enter", " select")])
|
||||||
} else if state.choice_picker == Some(ChoicePicker::Java) {
|
} else if state.choice_picker == Some(ChoicePicker::Java) {
|
||||||
super::keybind_line(&[
|
super::keybind_line(&[("a", " auto"), ("h", " back"), ("Enter", " select")])
|
||||||
("a", " auto"),
|
|
||||||
("c", " custom"),
|
|
||||||
("h", " back"),
|
|
||||||
("Enter", " select"),
|
|
||||||
])
|
|
||||||
} else if state.choice_picker == Some(ChoicePicker::Resolution) {
|
} else if state.choice_picker == Some(ChoicePicker::Resolution) {
|
||||||
super::keybind_line(&[("d", " default"), ("h", " back"), ("Enter", " select")])
|
super::keybind_line(&[("d", " default"), ("h", " back"), ("Enter", " select")])
|
||||||
} else if state.choice_picker.is_some() {
|
} else if state.choice_picker.is_some() {
|
||||||
@@ -1047,8 +1024,12 @@ fn field_line(state: &State, index: usize, label: &str) -> Line<'static> {
|
|||||||
Span::styled(
|
Span::styled(
|
||||||
value,
|
value,
|
||||||
Style::default()
|
Style::default()
|
||||||
.fg(if index == 8 && state.desktop {
|
.fg(if index == 8 {
|
||||||
theme.success()
|
if state.desktop {
|
||||||
|
theme.text()
|
||||||
|
} else {
|
||||||
|
theme.text_dim()
|
||||||
|
}
|
||||||
} else if selected {
|
} else if selected {
|
||||||
theme.accent()
|
theme.accent()
|
||||||
} else {
|
} else {
|
||||||
@@ -1062,7 +1043,7 @@ fn field_line(state: &State, index: usize, label: &str) -> Line<'static> {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
if index == 3 && state.draft.java_path.is_none() && !editing {
|
if index == 3 && state.draft.java_path.is_none() && !editing {
|
||||||
spans.extend([Span::raw(" "), subtle_tag("Auto", theme.info())]);
|
spans.extend([Span::raw(" "), auto_label()]);
|
||||||
}
|
}
|
||||||
Line::from(spans)
|
Line::from(spans)
|
||||||
}
|
}
|
||||||
@@ -1508,6 +1489,10 @@ mod tests {
|
|||||||
state.begin_edit();
|
state.begin_edit();
|
||||||
assert_eq!(state.choice_picker, Some(ChoicePicker::Java));
|
assert_eq!(state.choice_picker, Some(ChoicePicker::Java));
|
||||||
state.handle_choice_key(&KeyEvent::from(KeyCode::Char('c')));
|
state.handle_choice_key(&KeyEvent::from(KeyCode::Char('c')));
|
||||||
|
assert_eq!(state.choice_picker, Some(ChoicePicker::Java));
|
||||||
|
assert!(state.editing.is_none());
|
||||||
|
state.handle_choice_key(&KeyEvent::from(KeyCode::Esc));
|
||||||
|
state.handle_key(&KeyEvent::from(KeyCode::Char('c')));
|
||||||
assert!(state.editing.is_some());
|
assert!(state.editing.is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ impl JavaPicker {
|
|||||||
Span::styled(format!(" {path}"), Style::default().fg(theme.text_dim())),
|
Span::styled(format!(" {path}"), Style::default().fg(theme.text_dim())),
|
||||||
];
|
];
|
||||||
if self.current.is_none() && path == self.detected {
|
if self.current.is_none() && path == self.detected {
|
||||||
spans.extend([Span::raw(" "), subtle_tag("Auto", theme.info())]);
|
spans.extend([Span::raw(" "), auto_label()]);
|
||||||
}
|
}
|
||||||
ListItem::new(Line::from(spans))
|
ListItem::new(Line::from(spans))
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ pub(crate) fn render_memory_gauge(
|
|||||||
Style::default().fg(theme.text())
|
Style::default().fg(theme.text())
|
||||||
};
|
};
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
Paragraph::new(Line::from(Span::styled(format!(" {label} "), value_style))),
|
Paragraph::new(Line::from(Span::styled(label, value_style))),
|
||||||
value_area,
|
value_area,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -336,10 +336,12 @@ pub(crate) fn handle_text_area_input(input: &mut TextArea<'_>, key: &KeyEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn subtle_tag(label: impl Into<String>, color: ratatui::style::Color) -> Span<'static> {
|
pub(crate) fn auto_label() -> Span<'static> {
|
||||||
Span::styled(
|
Span::styled(
|
||||||
format!(" {} ", label.into()),
|
"Auto",
|
||||||
Style::default().fg(color).bg(THEME.as_ref().stripe()),
|
Style::default()
|
||||||
|
.fg(THEME.as_ref().text_dim())
|
||||||
|
.add_modifier(Modifier::ITALIC),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user