route.rs (1376B)
1 use egui::{Response, RichText}; 2 use enostr::NoteId; 3 use std::fmt::{self}; 4 5 use crate::{ui::AccountManagementView, Damus}; 6 7 /// App routing. These describe different places you can go inside Notedeck. 8 #[derive(Clone, Debug)] 9 pub enum Route { 10 Timeline(String), 11 ManageAccount, 12 Thread(NoteId), 13 Reply(NoteId), 14 Relays, 15 } 16 17 impl fmt::Display for Route { 18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 19 match self { 20 Route::ManageAccount => write!(f, "Manage Account"), 21 Route::Timeline(name) => write!(f, "{}", name), 22 Route::Thread(_id) => write!(f, "Thread"), 23 Route::Reply(_id) => write!(f, "Reply"), 24 Route::Relays => write!(f, "Relays"), 25 } 26 } 27 } 28 29 impl Route { 30 pub fn show_global_popup(&self, app: &mut Damus, ui: &mut egui::Ui) -> Option<Response> { 31 match self { 32 Route::ManageAccount => AccountManagementView::ui(app, ui), 33 _ => None, 34 } 35 } 36 37 pub fn title(&self) -> RichText { 38 match self { 39 Route::ManageAccount => RichText::new("Manage Account").size(24.0), 40 Route::Thread(_) => RichText::new("Thread"), 41 Route::Reply(_) => RichText::new("Reply"), 42 Route::Relays => RichText::new("Relays"), 43 Route::Timeline(_) => RichText::new("Timeline"), 44 } 45 } 46 }