use cursive::{view::Nameable, views::Dialog, Cursive}; pub use credentials::{AddCredentialsScreen, EditCredentialsScreen}; pub use home::HomeScreen; pub use login::LoginScreen; pub use signup::SignupScreen; pub use totp::TOTPScreen; use crate::ClientBox; mod credentials; mod home; mod login; mod signup; mod totp; pub trait Screen { const NAME: &'static str; fn new(client: &ClientBox) -> Self where Self: Sized, { Self::construct(client.clone()) } fn construct(client: ClientBox) -> Self; fn render_dialog(&self) -> Dialog; fn replace(&self, s: &mut Cursive) { s.pop_layer(); self.print(s); } fn print(&self, s: &mut Cursive) { let dialog = self.render_dialog(); s.add_layer(dialog.with_name(format!("{}_screen", Self::NAME))); } }