From b782472a63f995887b31e4dfa860da1a50bfb611 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sat, 4 Jul 2020 12:55:40 +0200 Subject: [PATCH] more fancy spinner, cleanup tabs --- src/app.rs | 35 ++++++++++++++++++++--------------- src/spinner.rs | 5 ++++- src/strings.rs | 2 +- src/ui/style.rs | 4 ++-- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/app.rs b/src/app.rs index 920d6e9b..cebacfe5 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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(&self, f: &mut Frame, 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, diff --git a/src/spinner.rs b/src/spinner.rs index 13371ad4..f0e994c1 100644 --- a/src/spinner.rs +++ b/src/spinner.rs @@ -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)] diff --git a/src/strings.rs b/src/strings.rs index eb1070aa..edb047d3 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -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 = " "; diff --git a/src/ui/style.rs b/src/ui/style.rs index 2d15544e..d45cce61 100644 --- a/src/ui/style.rs +++ b/src/ui/style.rs @@ -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) } }