pub(crate) mod render;
mod shape;
mod spin;
use rpi_tui::Component;
pub use spin::{animating, replay, set_enabled};
pub const MARK: &str = "@";
pub fn window_title(status: &str) -> String {
if status.is_empty() {
format!("{MARK} rpi")
} else {
format!("{MARK} rpi {status}")
}
}
pub struct BrandLockup;
impl BrandLockup {
pub fn new() -> Self {
Self
}
}
impl Default for BrandLockup {
fn default() -> Self {
Self::new()
}
}
impl Component for BrandLockup {
fn render(&self, _width: usize) -> Vec<String> {
render::lockup(spin::angle())
}
fn invalidate(&self) {
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn lockup_fits_the_welcome_header() {
let rows = BrandLockup::new().render(80);
assert_eq!(rows.len(), render::ROWS);
}
#[test]
fn title_keeps_the_logo_identity_and_status_last() {
assert_eq!(window_title(""), "@ rpi");
assert_eq!(window_title("⟳"), "@ rpi ⟳");
assert_eq!(window_title("↻"), "@ rpi ↻");
assert!(!window_title("⟳").contains('\n'));
}
}