more fancy spinner, cleanup tabs

This commit is contained in:
Stephan Dilly 2020-07-04 12:55:40 +02:00
parent a34bab22fa
commit b782472a63
4 changed files with 27 additions and 19 deletions

View file

@ -21,9 +21,7 @@ use crossterm::event::{Event, KeyEvent};
use std::{cell::Cell, cell::RefCell, rc::Rc};
use tui::{
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
style::Modifier,
style::Style,
layout::{Constraint, Direction, Layout, Margin, Rect},
widgets::{Block, Borders, Tabs},
Frame,
};
@ -489,21 +487,28 @@ impl App {
//TODO: make this dynamic
fn draw_tabs<B: Backend>(&self, f: &mut Frame<B>, r: Rect) {
let r = r.inner(&Margin {
vertical: 0,
horizontal: 1,
});
let tabs = &[
strings::TAB_STATUS,
strings::TAB_LOG,
strings::TAB_STASHING,
strings::TAB_STASHES,
];
f.render_widget(
Tabs::default()
.block(Block::default().borders(Borders::BOTTOM))
.titles(&[
strings::TAB_STATUS,
strings::TAB_LOG,
strings::TAB_STASHING,
strings::TAB_STASHES,
])
.style(Style::default())
.highlight_style(
self.theme
.tab(true)
.modifier(Modifier::UNDERLINED),
.block(
Block::default()
.borders(Borders::BOTTOM)
.border_style(self.theme.block(false)),
)
.titles(tabs)
.style(self.theme.tab(false))
.highlight_style(self.theme.tab(true))
.divider(strings::TAB_DIVIDER)
.select(self.tab),
r,

View file

@ -1,7 +1,10 @@
use std::io;
use tui::{backend::Backend, buffer::Cell, Terminal};
static SPINNER_CHARS: &[char] = &['|', '/', '-', '\\'];
// static SPINNER_CHARS: &[char] = &['◢', '◣', '◤', '◥'];
// static SPINNER_CHARS: &[char] = &['⢹', '⢺', '⢼', '⣸', '⣇', '⡧', '⡗', '⡏'];
static SPINNER_CHARS: &[char] =
&['⣷', '⣯', '⣟', '⡿', '⢿', '⣻', '⣽', '⣾'];
///
#[derive(Default)]

View file

@ -6,7 +6,7 @@ pub static TAB_STATUS: &str = "Status [1]";
pub static TAB_LOG: &str = "Log [2]";
pub static TAB_STASHING: &str = "Stashing [3]";
pub static TAB_STASHES: &str = "Stashes [4]";
pub static TAB_DIVIDER: &str = " | ";
pub static TAB_DIVIDER: &str = " | ";
pub static CMD_SPLITTER: &str = " ";

View file

@ -69,9 +69,9 @@ impl Theme {
pub fn tab(&self, selected: bool) -> Style {
if selected {
Style::default().fg(self.selected_tab)
self.text(true, false).modifier(Modifier::UNDERLINED)
} else {
Style::default()
self.text(false, false)
}
}