waow it works
This commit is contained in:
parent
18458f99eb
commit
81a1df8027
6 changed files with 1013 additions and 15 deletions
901
Cargo.lock
generated
901
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -22,3 +22,6 @@ tracing-subscriber = "0.3.18"
|
||||||
puffin = { version = "0.19.0", optional = true }
|
puffin = { version = "0.19.0", optional = true }
|
||||||
puffin_http = { version = "0.16.0", optional = true }
|
puffin_http = { version = "0.16.0", optional = true }
|
||||||
ewebsock = { version = "0.6.0", features = ["tls"] }
|
ewebsock = { version = "0.6.0", features = ["tls"] }
|
||||||
|
nostrdb = { git = "https://github.com/damus-io/nostrdb-rs", rev = "ee8afeeb0b6695fca6d27dd0b74a8dc159e37b95" }
|
||||||
|
rand = "0.8.5"
|
||||||
|
nostr = "0.32.1"
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -1,2 +1,2 @@
|
||||||
dev:
|
dev:
|
||||||
cargo run --features profiling
|
RUST_BACKTRACE=1 cargo run --features profiling
|
||||||
|
|
79
src/main.rs
79
src/main.rs
|
@ -10,6 +10,8 @@ use tracing::{debug, error, info, Level};
|
||||||
mod relay;
|
mod relay;
|
||||||
mod pool;
|
mod pool;
|
||||||
|
|
||||||
|
mod ui;
|
||||||
|
|
||||||
fn main() -> Result<(), eframe::Error> {
|
fn main() -> Result<(), eframe::Error> {
|
||||||
let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); // add log files in prod one day
|
let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); // add log files in prod one day
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
|
@ -53,17 +55,16 @@ fn main() -> Result<(), eframe::Error> {
|
||||||
enum Page {
|
enum Page {
|
||||||
Inbox,
|
Inbox,
|
||||||
Drafts,
|
Drafts,
|
||||||
Starred,
|
Settings,
|
||||||
Archived,
|
|
||||||
Trash,
|
|
||||||
Post,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Hoot {
|
pub struct Hoot {
|
||||||
current_page: Page,
|
current_page: Page,
|
||||||
focused_post: String,
|
focused_post: String,
|
||||||
status: HootStatus,
|
status: HootStatus,
|
||||||
relays: pool::RelayPool,
|
relays: pool::RelayPool,
|
||||||
|
ndb: nostrdb::Ndb,
|
||||||
|
pub windows: Vec<Box<ui::compose_window::ComposeWindow>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
@ -83,34 +84,96 @@ fn update_app(app: &mut Hoot, ctx: &egui::Context) {
|
||||||
};
|
};
|
||||||
app.relays.add_url("wss://relay.damus.io".to_string(), wake_up);
|
app.relays.add_url("wss://relay.damus.io".to_string(), wake_up);
|
||||||
app.status = HootStatus::Ready;
|
app.status = HootStatus::Ready;
|
||||||
|
info!("Hoot Ready");
|
||||||
}
|
}
|
||||||
|
|
||||||
app.relays.try_recv();
|
app.relays.try_recv();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_app(ctx: &egui::Context) {
|
fn render_app(app: &mut Hoot, ctx: &egui::Context) {
|
||||||
#[cfg(feature = "profiling")]
|
#[cfg(feature = "profiling")]
|
||||||
puffin::profile_function!();
|
puffin::profile_function!();
|
||||||
|
|
||||||
egui::SidePanel::left("Side Navbar").show(ctx, |ui| {
|
egui::SidePanel::left("Side Navbar").show(ctx, |ui| {
|
||||||
ui.heading("Hoot");
|
ui.heading("Hoot");
|
||||||
|
if ui.button("Inbox").clicked() {
|
||||||
|
app.current_page = Page::Inbox;
|
||||||
|
}
|
||||||
|
if ui.button("Drafts").clicked() {
|
||||||
|
app.current_page = Page::Drafts;
|
||||||
|
}
|
||||||
|
if ui.button("Settings").clicked() {
|
||||||
|
app.current_page = Page::Settings;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
egui::TopBottomPanel::top("Search").show(ctx, |ui| {
|
egui::TopBottomPanel::top("Search").show(ctx, |ui| {
|
||||||
ui.heading("Search");
|
ui.heading("Search");
|
||||||
});
|
});
|
||||||
|
|
||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.label("hello there!");
|
// todo: fix
|
||||||
|
for window in &mut app.windows {
|
||||||
|
window.show(ui);
|
||||||
|
}
|
||||||
|
|
||||||
|
if app.current_page == Page::Inbox {
|
||||||
|
ui.label("hello there!");
|
||||||
|
if ui.button("Compose").clicked() {
|
||||||
|
let mut new_window = Box::new(ui::compose_window::ComposeWindow::new());
|
||||||
|
new_window.show(ui);
|
||||||
|
app.windows.push(new_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
TableBuilder::new(ui)
|
||||||
|
.column(Column::auto())
|
||||||
|
.column(Column::auto())
|
||||||
|
.column(Column::remainder())
|
||||||
|
.column(Column::remainder())
|
||||||
|
.column(Column::remainder())
|
||||||
|
.striped(true)
|
||||||
|
.sense(Sense::click())
|
||||||
|
.auto_shrink(Vec2b { x: false, y: false})
|
||||||
|
.header(20.0, |_header| {})
|
||||||
|
.body(|mut body| {
|
||||||
|
body.row(30.0, |mut row| {
|
||||||
|
row.col(|ui| {
|
||||||
|
ui.checkbox(&mut false, "");
|
||||||
|
});
|
||||||
|
row.col(|ui| {
|
||||||
|
ui.checkbox(&mut false, "");
|
||||||
|
});
|
||||||
|
row.col(|ui| {
|
||||||
|
ui.label("Jack Chakany");
|
||||||
|
});
|
||||||
|
row.col(|ui| {
|
||||||
|
ui.label("Message Content");
|
||||||
|
});
|
||||||
|
row.col(|ui| {
|
||||||
|
ui.label("5 minutes ago");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else if app.current_page == Page::Settings {
|
||||||
|
ui.label("Settings");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hoot {
|
impl Hoot {
|
||||||
fn new(cc: &eframe::CreationContext<'_>) -> Self {
|
fn new(cc: &eframe::CreationContext<'_>) -> Self {
|
||||||
|
let storage_dir = eframe::storage_dir("Hoot").unwrap();
|
||||||
|
let mut ndb_config = nostrdb::Config::new();
|
||||||
|
ndb_config.set_ingester_threads(3);
|
||||||
|
|
||||||
|
let ndb = nostrdb::Ndb::new(storage_dir.to_str().unwrap(), &ndb_config).expect("could not load nostrdb");
|
||||||
Self {
|
Self {
|
||||||
current_page: Page::Inbox,
|
current_page: Page::Inbox,
|
||||||
focused_post: "".into(),
|
focused_post: "".into(),
|
||||||
status: HootStatus::Initalizing,
|
status: HootStatus::Initalizing,
|
||||||
relays: pool::RelayPool::new(),
|
relays: pool::RelayPool::new(),
|
||||||
|
ndb,
|
||||||
|
windows: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +189,7 @@ impl eframe::App for Hoot {
|
||||||
}
|
}
|
||||||
|
|
||||||
update_app(self, ctx);
|
update_app(self, ctx);
|
||||||
render_app(ctx);
|
render_app(self, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
src/ui/compose_window.rs
Normal file
36
src/ui/compose_window.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
use crate::Hoot;
|
||||||
|
use eframe::egui::{self, RichText};
|
||||||
|
use rand::random;
|
||||||
|
|
||||||
|
pub struct ComposeWindow {
|
||||||
|
title: Option<RichText>,
|
||||||
|
id: egui::Id,
|
||||||
|
subject: String,
|
||||||
|
to_field: String,
|
||||||
|
content: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ComposeWindow {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
title: None,
|
||||||
|
id: egui::Id::new(random::<u32>()),
|
||||||
|
subject: String::from("New Message"),
|
||||||
|
to_field: String::new(),
|
||||||
|
content: String::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn show(&mut self, ui: &mut egui::Ui) {
|
||||||
|
egui::Window::new(&self.subject)
|
||||||
|
.id(self.id)
|
||||||
|
.show(ui.ctx(), |ui| {
|
||||||
|
ui.label("Hello!");
|
||||||
|
ui.vertical(|ui| {
|
||||||
|
ui.text_edit_singleline(&mut self.to_field);
|
||||||
|
ui.text_edit_singleline(&mut self.subject);
|
||||||
|
ui.add_sized(ui.available_size(), egui::TextEdit::multiline(&mut self.content));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
7
src/ui/mod.rs
Normal file
7
src/ui/mod.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use eframe::egui;
|
||||||
|
|
||||||
|
pub mod compose_window;
|
||||||
|
|
||||||
|
pub trait View {
|
||||||
|
fn ui(&mut self, ui: &mut egui::Ui);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue