feat(tui): show authenticating throbber on launch
This commit is contained in:
1 parent
2095a00c95
commit
fc5b2cd0bb
4 files changed
+24
No files matched your search
@@ -5,6 +5,7 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum RunState {
|
||||
Authenticating,
|
||||
Starting,
|
||||
Running,
|
||||
Crashed(Option<i32>),
|
||||
|
||||
@@ -532,6 +532,8 @@ impl App {
|
||||
use crate::instance::launch;
|
||||
use crate::running;
|
||||
|
||||
running::set_state(&instance.name, running::RunState::Authenticating);
|
||||
|
||||
let instances_dir = self.instance_manager.instances_dir.clone();
|
||||
let meta_dir = self.instance_manager.meta_dir.clone();
|
||||
|
||||
|
||||
@@ -311,6 +311,23 @@ pub fn title(
|
||||
let run_state = crate::running::get(&inst.name);
|
||||
|
||||
match run_state {
|
||||
Some(RunState::Authenticating) => {
|
||||
let throbber = Throbber::default()
|
||||
.label(format!("{} \u{2022} Authenticating", inst.name.as_str()))
|
||||
.style(
|
||||
Style::default()
|
||||
.fg(THEME.colors.foreground)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
)
|
||||
.throbber_style(
|
||||
Style::default()
|
||||
.fg(THEME.colors.accent)
|
||||
.add_modifier(Modifier::BOLD),
|
||||
)
|
||||
.throbber_set(throbber_widgets_tui::BRAILLE_EIGHT_DOUBLE)
|
||||
.use_type(throbber_widgets_tui::WhichUse::Spin);
|
||||
frame.render_stateful_widget(throbber, left_area, throbber_state);
|
||||
}
|
||||
Some(RunState::Running) | Some(RunState::Starting) => {
|
||||
let throbber = Throbber::default()
|
||||
.label(inst.name.as_str())
|
||||
|
||||
@@ -255,6 +255,10 @@ pub fn render(frame: &mut Frame, area: Rect, focused: FocusedArea, state: &mut S
|
||||
]);
|
||||
|
||||
let (meta_text, meta_text_style) = match get_run_state(&instance.name) {
|
||||
Some(RunState::Authenticating) => (
|
||||
"Authenticating...".to_string(),
|
||||
Style::default().fg(THEME.colors.accent),
|
||||
),
|
||||
Some(RunState::Running) | Some(RunState::Starting) => (
|
||||
"Playing".to_string(),
|
||||
Style::default().fg(THEME.colors.success),
|
||||
|
||||
Reference in new issue
Block a user