24
src/nav.rs
24
src/nav.rs
@@ -3,8 +3,10 @@ use crate::{
|
|||||||
relay_pool_manager::RelayPoolManager,
|
relay_pool_manager::RelayPoolManager,
|
||||||
route::Route,
|
route::Route,
|
||||||
thread::thread_unsubscribe,
|
thread::thread_unsubscribe,
|
||||||
timeline::route::{render_timeline_route, TimelineRoute, TimelineRouteResponse},
|
timeline::route::{render_timeline_route, AfterRouteExecution, TimelineRoute},
|
||||||
ui::{self, note::PostAction, RelayView, View},
|
ui::{
|
||||||
|
self, add_column::{AddColumnResponse, AddColumnView}, note::PostAction, RelayView, View
|
||||||
|
},
|
||||||
Damus,
|
Damus,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -73,12 +75,15 @@ pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) {
|
|||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
Route::AddColumn => AddColumnView::new(app.accounts.get_selected_account())
|
||||||
|
.ui(ui)
|
||||||
|
.map(AfterRouteExecution::AddColumn),
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Some(reply_response) = nav_response.inner {
|
if let Some(after_route_execution) = nav_response.inner {
|
||||||
// start returning when we're finished posting
|
// start returning when we're finished posting
|
||||||
match reply_response {
|
match after_route_execution {
|
||||||
TimelineRouteResponse::Post(resp) => {
|
AfterRouteExecution::Post(resp) => {
|
||||||
if let Some(action) = resp.action {
|
if let Some(action) = resp.action {
|
||||||
match action {
|
match action {
|
||||||
PostAction::Post(_) => {
|
PostAction::Post(_) => {
|
||||||
@@ -87,6 +92,15 @@ pub fn render_nav(col: usize, app: &mut Damus, ui: &mut egui::Ui) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AfterRouteExecution::AddColumn(add_column_resp) => {
|
||||||
|
match add_column_resp {
|
||||||
|
AddColumnResponse::Timeline(timeline) => {
|
||||||
|
app.columns_mut().add_timeline(timeline);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
app.columns_mut().column_mut(col).router_mut().go_back();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ pub enum Route {
|
|||||||
Accounts(AccountsRoute),
|
Accounts(AccountsRoute),
|
||||||
Relays,
|
Relays,
|
||||||
ComposeNote,
|
ComposeNote,
|
||||||
|
AddColumn,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Route {
|
impl Route {
|
||||||
@@ -125,6 +126,8 @@ impl fmt::Display for Route {
|
|||||||
AccountsRoute::AddAccount => write!(f, "Add Account"),
|
AccountsRoute::AddAccount => write!(f, "Add Account"),
|
||||||
},
|
},
|
||||||
Route::ComposeNote => write!(f, "Compose Note"),
|
Route::ComposeNote => write!(f, "Compose Note"),
|
||||||
|
|
||||||
|
Route::AddColumn => write!(f, "Add Column"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use crate::{
|
|||||||
timeline::TimelineId,
|
timeline::TimelineId,
|
||||||
ui::{
|
ui::{
|
||||||
self,
|
self,
|
||||||
|
add_column::AddColumnResponse,
|
||||||
note::{
|
note::{
|
||||||
post::{PostAction, PostResponse},
|
post::{PostAction, PostResponse},
|
||||||
QuoteRepostView,
|
QuoteRepostView,
|
||||||
@@ -26,13 +27,14 @@ pub enum TimelineRoute {
|
|||||||
Quote(NoteId),
|
Quote(NoteId),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum TimelineRouteResponse {
|
pub enum AfterRouteExecution {
|
||||||
Post(PostResponse),
|
Post(PostResponse),
|
||||||
|
AddColumn(AddColumnResponse),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TimelineRouteResponse {
|
impl AfterRouteExecution {
|
||||||
pub fn post(post: PostResponse) -> Self {
|
pub fn post(post: PostResponse) -> Self {
|
||||||
TimelineRouteResponse::Post(post)
|
AfterRouteExecution::Post(post)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +52,7 @@ pub fn render_timeline_route(
|
|||||||
col: usize,
|
col: usize,
|
||||||
textmode: bool,
|
textmode: bool,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
) -> Option<TimelineRouteResponse> {
|
) -> Option<AfterRouteExecution> {
|
||||||
match route {
|
match route {
|
||||||
TimelineRoute::Timeline(timeline_id) => {
|
TimelineRoute::Timeline(timeline_id) => {
|
||||||
if let Some(bar_action) =
|
if let Some(bar_action) =
|
||||||
@@ -111,7 +113,7 @@ pub fn render_timeline_route(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(TimelineRouteResponse::post(response.inner))
|
Some(AfterRouteExecution::post(response.inner))
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineRoute::Quote(id) => {
|
TimelineRoute::Quote(id) => {
|
||||||
@@ -140,7 +142,7 @@ pub fn render_timeline_route(
|
|||||||
np.to_quote(seckey, ¬e)
|
np.to_quote(seckey, ¬e)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Some(TimelineRouteResponse::post(response.inner))
|
Some(AfterRouteExecution::post(response.inner))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
43
src/ui/add_column.rs
Normal file
43
src/ui/add_column.rs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
use egui::{RichText, Ui};
|
||||||
|
use nostrdb::FilterBuilder;
|
||||||
|
|
||||||
|
use crate::{app_style::NotedeckTextStyle, timeline::Timeline, user_account::UserAccount};
|
||||||
|
|
||||||
|
pub enum AddColumnResponse {
|
||||||
|
Timeline(Timeline),
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct AddColumnView<'a> {
|
||||||
|
cur_account: Option<&'a UserAccount>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> AddColumnView<'a> {
|
||||||
|
pub fn new(cur_account: Option<&'a UserAccount>) -> Self {
|
||||||
|
Self { cur_account }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ui(&mut self, ui: &mut Ui) -> Option<AddColumnResponse> {
|
||||||
|
ui.label(RichText::new("Add column").text_style(NotedeckTextStyle::Heading.text_style()));
|
||||||
|
|
||||||
|
if ui.button("create global timeline").clicked() {
|
||||||
|
Some(AddColumnResponse::Timeline(create_global_timeline()))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_global_timeline() -> Timeline {
|
||||||
|
let filter = FilterBuilder::new().kinds([1]).build();
|
||||||
|
Timeline::new(
|
||||||
|
crate::timeline::TimelineKind::Generic,
|
||||||
|
crate::filter::FilterState::Ready(vec![filter]),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// struct ColumnOption {
|
||||||
|
// title: &'static str,
|
||||||
|
// description: &'static str,
|
||||||
|
// icon: Box::<dyn Widget>,
|
||||||
|
// route: Route,
|
||||||
|
// }
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
pub mod account_login_view;
|
pub mod account_login_view;
|
||||||
pub mod account_management;
|
pub mod account_management;
|
||||||
|
pub mod add_column;
|
||||||
pub mod anim;
|
pub mod anim;
|
||||||
pub mod mention;
|
pub mod mention;
|
||||||
pub mod note;
|
pub mod note;
|
||||||
|
|||||||
@@ -186,8 +186,11 @@ impl<'a> DesktopSidePanel<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SidePanelAction::Columns => {
|
SidePanelAction::Columns => {
|
||||||
// TODO
|
if router.routes().iter().any(|&r| r == Route::AddColumn) {
|
||||||
info!("Clicked columns button");
|
router.go_back();
|
||||||
|
} else {
|
||||||
|
router.route_to(Route::AddColumn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SidePanelAction::ComposeNote => {
|
SidePanelAction::ComposeNote => {
|
||||||
if router.routes().iter().any(|&r| r == Route::ComposeNote) {
|
if router.routes().iter().any(|&r| r == Route::ComposeNote) {
|
||||||
|
|||||||
Reference in New Issue
Block a user