router implementation
This commit is contained in:
3
client/src/pages/mod.rs
Normal file
3
client/src/pages/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
// src/pages/mod.rs
|
||||
|
||||
pub mod routing;
|
||||
5
client/src/pages/routing/mod.rs
Normal file
5
client/src/pages/routing/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
// src/pages/routing/mod.rs
|
||||
|
||||
pub mod router;
|
||||
|
||||
pub use router::{Page, Router};
|
||||
36
client/src/pages/routing/router.rs
Normal file
36
client/src/pages/routing/router.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
// src/pages/routing/router.rs
|
||||
use crate::state::pages::{
|
||||
admin::AdminState,
|
||||
auth::{AuthState, LoginState, RegisterState},
|
||||
form::FormState,
|
||||
intro::IntroState,
|
||||
add_logic::AddLogicState,
|
||||
add_table::AddTableState,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Page {
|
||||
Intro(IntroState),
|
||||
Login(LoginState),
|
||||
Register(RegisterState),
|
||||
Admin(AdminState),
|
||||
AddLogic(AddLogicState),
|
||||
AddTable(AddTableState),
|
||||
Form(FormState),
|
||||
}
|
||||
|
||||
pub struct Router {
|
||||
pub current: Page,
|
||||
}
|
||||
|
||||
impl Router {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
current: Page::Intro(IntroState::default()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn navigate(&mut self, page: Page) {
|
||||
self.current = page;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user