initial compose note view
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use egui::{Button, Layout, SidePanel, Vec2, Widget};
|
||||
use egui::{Button, InnerResponse, Layout, RichText, SidePanel, Vec2, Widget};
|
||||
|
||||
use crate::{
|
||||
account_manager::AccountsRoute,
|
||||
@@ -26,6 +26,7 @@ pub enum SidePanelAction {
|
||||
Account,
|
||||
Settings,
|
||||
Columns,
|
||||
ComposeNote,
|
||||
}
|
||||
|
||||
pub struct SidePanelResponse {
|
||||
@@ -55,18 +56,56 @@ impl<'a> DesktopSidePanel<'a> {
|
||||
let spacing_amt = 16.0;
|
||||
|
||||
let inner = ui
|
||||
.with_layout(Layout::bottom_up(egui::Align::Center), |ui| {
|
||||
ui.spacing_mut().item_spacing.y = spacing_amt;
|
||||
let pfp_resp = self.pfp_button(ui);
|
||||
let settings_resp = ui.add(settings_button(dark_mode));
|
||||
let column_resp = ui.add(add_column_button(dark_mode));
|
||||
.vertical(|ui| {
|
||||
let top_resp = ui
|
||||
.with_layout(Layout::top_down(egui::Align::Center), |ui| {
|
||||
let compose_resp = ui.add(compose_note_button());
|
||||
|
||||
if pfp_resp.clicked() {
|
||||
egui::InnerResponse::new(SidePanelAction::Account, pfp_resp)
|
||||
} else if settings_resp.clicked() || settings_resp.hovered() {
|
||||
egui::InnerResponse::new(SidePanelAction::Settings, settings_resp)
|
||||
} else if column_resp.clicked() || column_resp.hovered() {
|
||||
egui::InnerResponse::new(SidePanelAction::Columns, column_resp)
|
||||
if compose_resp.clicked() {
|
||||
Some(InnerResponse::new(
|
||||
SidePanelAction::ComposeNote,
|
||||
compose_resp,
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.inner;
|
||||
|
||||
let (pfp_resp, bottom_resp) = ui
|
||||
.with_layout(Layout::bottom_up(egui::Align::Center), |ui| {
|
||||
ui.spacing_mut().item_spacing.y = spacing_amt;
|
||||
let pfp_resp = self.pfp_button(ui);
|
||||
let settings_resp = ui.add(settings_button(dark_mode));
|
||||
let column_resp = ui.add(add_column_button(dark_mode));
|
||||
|
||||
let optional_inner = if pfp_resp.clicked() {
|
||||
Some(egui::InnerResponse::new(
|
||||
SidePanelAction::Account,
|
||||
pfp_resp.clone(),
|
||||
))
|
||||
} else if settings_resp.clicked() || settings_resp.hovered() {
|
||||
Some(egui::InnerResponse::new(
|
||||
SidePanelAction::Settings,
|
||||
settings_resp,
|
||||
))
|
||||
} else if column_resp.clicked() || column_resp.hovered() {
|
||||
Some(egui::InnerResponse::new(
|
||||
SidePanelAction::Columns,
|
||||
column_resp,
|
||||
))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
(pfp_resp, optional_inner)
|
||||
})
|
||||
.inner;
|
||||
|
||||
if let Some(bottom_inner) = bottom_resp {
|
||||
bottom_inner
|
||||
} else if let Some(top_inner) = top_resp {
|
||||
top_inner
|
||||
} else {
|
||||
egui::InnerResponse::new(SidePanelAction::Panel, pfp_resp)
|
||||
}
|
||||
@@ -110,6 +149,13 @@ impl<'a> DesktopSidePanel<'a> {
|
||||
}
|
||||
}
|
||||
SidePanelAction::Columns => (), // TODO
|
||||
SidePanelAction::ComposeNote => {
|
||||
if router.routes().iter().any(|&r| r == Route::ComposeNote) {
|
||||
router.go_back();
|
||||
} else {
|
||||
router.route_to(Route::ComposeNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,6 +191,10 @@ fn add_column_button(dark_mode: bool) -> egui::Button<'static> {
|
||||
egui::Button::image(egui::Image::new(img_data).max_width(32.0)).frame(false)
|
||||
}
|
||||
|
||||
fn compose_note_button() -> Button<'static> {
|
||||
Button::new(RichText::new("+").size(32.0)).frame(false)
|
||||
}
|
||||
|
||||
mod preview {
|
||||
|
||||
use egui_extras::{Size, StripBuilder};
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use crate::draft::Draft;
|
||||
use crate::{
|
||||
actionbar::BarAction, column::Columns, imgcache::ImageCache, notecache::NoteCache,
|
||||
timeline::TimelineId, ui,
|
||||
@@ -6,12 +5,9 @@ use crate::{
|
||||
use egui::containers::scroll_area::ScrollBarVisibility;
|
||||
use egui::{Direction, Layout};
|
||||
use egui_tabs::TabColor;
|
||||
use enostr::FilledKeypair;
|
||||
use nostrdb::{Ndb, Transaction};
|
||||
use tracing::{debug, error, warn};
|
||||
|
||||
use super::note::PostResponse;
|
||||
|
||||
pub struct TimelineView<'a> {
|
||||
timeline_id: TimelineId,
|
||||
columns: &'a mut Columns,
|
||||
@@ -170,27 +166,6 @@ fn timeline_ui(
|
||||
bar_action
|
||||
}
|
||||
|
||||
pub fn postbox_view<'a>(
|
||||
ndb: &'a Ndb,
|
||||
key: FilledKeypair<'a>,
|
||||
draft: &'a mut Draft,
|
||||
img_cache: &'a mut ImageCache,
|
||||
note_cache: &'a mut NoteCache,
|
||||
ui: &'a mut egui::Ui,
|
||||
) -> PostResponse {
|
||||
// show a postbox in the first timeline
|
||||
let txn = Transaction::new(ndb).expect("txn");
|
||||
ui::PostView::new(
|
||||
ndb,
|
||||
draft,
|
||||
crate::draft::DraftSource::Compose,
|
||||
img_cache,
|
||||
note_cache,
|
||||
key,
|
||||
)
|
||||
.ui(&txn, ui)
|
||||
}
|
||||
|
||||
fn tabs_ui(ui: &mut egui::Ui) -> i32 {
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user