Skip to content

Commit b782472

Browse files
author
Stephan Dilly
committed
more fancy spinner, cleanup tabs
1 parent a34bab2 commit b782472

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

src/app.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ use crossterm::event::{Event, KeyEvent};
2121
use std::{cell::Cell, cell::RefCell, rc::Rc};
2222
use tui::{
2323
backend::Backend,
24-
layout::{Constraint, Direction, Layout, Rect},
25-
style::Modifier,
26-
style::Style,
24+
layout::{Constraint, Direction, Layout, Margin, Rect},
2725
widgets::{Block, Borders, Tabs},
2826
Frame,
2927
};
@@ -489,21 +487,28 @@ impl App {
489487

490488
//TODO: make this dynamic
491489
fn draw_tabs<B: Backend>(&self, f: &mut Frame<B>, r: Rect) {
490+
let r = r.inner(&Margin {
491+
vertical: 0,
492+
horizontal: 1,
493+
});
494+
495+
let tabs = &[
496+
strings::TAB_STATUS,
497+
strings::TAB_LOG,
498+
strings::TAB_STASHING,
499+
strings::TAB_STASHES,
500+
];
501+
492502
f.render_widget(
493503
Tabs::default()
494-
.block(Block::default().borders(Borders::BOTTOM))
495-
.titles(&[
496-
strings::TAB_STATUS,
497-
strings::TAB_LOG,
498-
strings::TAB_STASHING,
499-
strings::TAB_STASHES,
500-
])
501-
.style(Style::default())
502-
.highlight_style(
503-
self.theme
504-
.tab(true)
505-
.modifier(Modifier::UNDERLINED),
504+
.block(
505+
Block::default()
506+
.borders(Borders::BOTTOM)
507+
.border_style(self.theme.block(false)),
506508
)
509+
.titles(tabs)
510+
.style(self.theme.tab(false))
511+
.highlight_style(self.theme.tab(true))
507512
.divider(strings::TAB_DIVIDER)
508513
.select(self.tab),
509514
r,

src/spinner.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::io;
22
use tui::{backend::Backend, buffer::Cell, Terminal};
33

4-
static SPINNER_CHARS: &[char] = &['|', '/', '-', '\\'];
4+
// static SPINNER_CHARS: &[char] = &['◢', '◣', '◤', '◥'];
5+
// static SPINNER_CHARS: &[char] = &['⢹', '⢺', '⢼', '⣸', '⣇', '⡧', '⡗', '⡏'];
6+
static SPINNER_CHARS: &[char] =
7+
&['⣷', '⣯', '⣟', '⡿', '⢿', '⣻', '⣽', '⣾'];
58

69
///
710
#[derive(Default)]

src/strings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub static TAB_STATUS: &str = "Status [1]";
66
pub static TAB_LOG: &str = "Log [2]";
77
pub static TAB_STASHING: &str = "Stashing [3]";
88
pub static TAB_STASHES: &str = "Stashes [4]";
9-
pub static TAB_DIVIDER: &str = " | ";
9+
pub static TAB_DIVIDER: &str = " | ";
1010

1111
pub static CMD_SPLITTER: &str = " ";
1212

src/ui/style.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ impl Theme {
6969

7070
pub fn tab(&self, selected: bool) -> Style {
7171
if selected {
72-
Style::default().fg(self.selected_tab)
72+
self.text(true, false).modifier(Modifier::UNDERLINED)
7373
} else {
74-
Style::default()
74+
self.text(false, false)
7575
}
7676
}
7777

0 commit comments

Comments
 (0)