From 3adf3f9697c4e2beb10e652947046d5fddda2ed4 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 12 Feb 2022 16:57:19 +0100 Subject: Say when the next card will be available --- src/gui/util.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/gui/util.rs (limited to 'src/gui/util.rs') diff --git a/src/gui/util.rs b/src/gui/util.rs new file mode 100644 index 0000000..38ed1e7 --- /dev/null +++ b/src/gui/util.rs @@ -0,0 +1,21 @@ +use tui::{ + layout::{Alignment, Rect}, + style::{Color, Modifier, Style}, + widgets::Paragraph, +}; + +pub fn title(str: &str) -> Paragraph { + Paragraph::new(str).alignment(Alignment::Center).style( + Style::default() + .fg(Color::Blue) + .add_modifier(Modifier::BOLD), + ) +} + +pub fn center_vertically(chunk: Rect, text: &String) -> String { + let text_lines = text.lines().count(); + let chunk_inner_lines: usize = (chunk.height - 2).into(); + let blank_lines = chunk_inner_lines - text_lines; + let newlines = "\n".repeat(blank_lines / 2); + format!("{}{}", newlines, text) +} -- cgit v1.2.3