feat: setup notedeck
This commit is contained in:
parent
6efd99018a
commit
c8c5485581
1223
Cargo.lock
generated
1223
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
10
Cargo.toml
10
Cargo.toml
@ -6,6 +6,10 @@ edition = "2021"
|
|||||||
[lib]
|
[lib]
|
||||||
crate-type = ["lib", "cdylib"]
|
crate-type = ["lib", "cdylib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
notedeck = ["dep:notedeck", "dep:notedeck-chrome"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.40.0", features = ["fs", "rt-multi-thread", "rt"] }
|
tokio = { version = "1.40.0", features = ["fs", "rt-multi-thread", "rt"] }
|
||||||
egui = { version = "0.29.1", default-features = false, features = [] }
|
egui = { version = "0.29.1", default-features = false, features = [] }
|
||||||
@ -27,10 +31,10 @@ lru = "0.12.5"
|
|||||||
resvg = { version = "0.44.0", default-features = false }
|
resvg = { version = "0.44.0", default-features = false }
|
||||||
serde = { version = "1.0.214", features = ["derive"] }
|
serde = { version = "1.0.214", features = ["derive"] }
|
||||||
serde_with = { version = "3.11.0", features = ["hex"] }
|
serde_with = { version = "3.11.0", features = ["hex"] }
|
||||||
|
|
||||||
egui-video = { git = "https://github.com/v0l/egui-video.git", rev = "d2ea3b4db21eb870a207db19e4cd21c7d1d24836" }
|
|
||||||
directories = "5.0.1"
|
directories = "5.0.1"
|
||||||
#egui-video = { path = "../egui-video" }
|
egui-video = { git = "https://github.com/v0l/egui-video.git", rev = "d2ea3b4db21eb870a207db19e4cd21c7d1d24836" }
|
||||||
|
notedeck-chrome = { git = "https://git.v0l.io/nostr/notedeck.git", branch = "master", package = "notedeck_chrome", optional = true }
|
||||||
|
notedeck = { git = "https://git.v0l.io/nostr/notedeck.git", branch = "master", package = "notedeck", optional = true }
|
||||||
|
|
||||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||||
eframe = { version = "0.29.1" }
|
eframe = { version = "0.29.1" }
|
||||||
|
31
src/app.rs
31
src/app.rs
@ -1,11 +1,12 @@
|
|||||||
use crate::route::Router;
|
use crate::route::Router;
|
||||||
use eframe::epaint::FontFamily;
|
use eframe::epaint::FontFamily;
|
||||||
use eframe::{App, CreationContext, Frame};
|
use eframe::CreationContext;
|
||||||
use egui::{Color32, Context, FontData, FontDefinitions, Margin};
|
use egui::{Color32, FontData, FontDefinitions, Margin};
|
||||||
|
use nostr_sdk::prelude::MemoryDatabase;
|
||||||
use nostr_sdk::Client;
|
use nostr_sdk::Client;
|
||||||
use nostrdb::{Config, Ndb};
|
use nostrdb::{Config, Ndb};
|
||||||
|
use notedeck::AppContext;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use nostr_sdk::prelude::MemoryDatabase;
|
|
||||||
|
|
||||||
pub struct ZapStreamApp<T: NativeLayerOps> {
|
pub struct ZapStreamApp<T: NativeLayerOps> {
|
||||||
client: Client,
|
client: Client,
|
||||||
@ -85,6 +86,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "notedeck"))]
|
||||||
impl<T> App for ZapStreamApp<T>
|
impl<T> App for ZapStreamApp<T>
|
||||||
where
|
where
|
||||||
T: NativeLayerOps,
|
T: NativeLayerOps,
|
||||||
@ -106,3 +108,26 @@ where
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "notedeck")]
|
||||||
|
impl<T> notedeck::App for ZapStreamApp<T>
|
||||||
|
where
|
||||||
|
T: NativeLayerOps,
|
||||||
|
{
|
||||||
|
fn update(&mut self, ctx: &mut AppContext<'_>) {
|
||||||
|
let mut app_frame = egui::containers::Frame::default();
|
||||||
|
let margin = self.native_layer.frame_margin();
|
||||||
|
|
||||||
|
app_frame.inner_margin = margin;
|
||||||
|
app_frame.stroke.color = Color32::BLACK;
|
||||||
|
|
||||||
|
//ctx.set_debug_on_hover(true);
|
||||||
|
|
||||||
|
egui::CentralPanel::default()
|
||||||
|
.frame(app_frame)
|
||||||
|
.show(ctx.egui, |ui| {
|
||||||
|
ui.visuals_mut().override_text_color = Some(Color32::WHITE);
|
||||||
|
self.router.show(ui);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
|
use eframe::Renderer;
|
||||||
use egui::{Margin, Vec2, ViewportBuilder};
|
use egui::{Margin, Vec2, ViewportBuilder};
|
||||||
use log::error;
|
use log::error;
|
||||||
use nostr_sdk::serde_json;
|
use nostr_sdk::serde_json;
|
||||||
@ -18,6 +19,7 @@ async fn main() -> Result<()> {
|
|||||||
|
|
||||||
let mut options = eframe::NativeOptions::default();
|
let mut options = eframe::NativeOptions::default();
|
||||||
options.viewport = ViewportBuilder::default().with_inner_size(Vec2::new(1300., 900.));
|
options.viewport = ViewportBuilder::default().with_inner_size(Vec2::new(1300., 900.));
|
||||||
|
options.renderer = Renderer::Glow;
|
||||||
|
|
||||||
let data_path = ProjectDirs::from("stream", "zap", "app")
|
let data_path = ProjectDirs::from("stream", "zap", "app")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
@ -25,13 +27,28 @@ async fn main() -> Result<()> {
|
|||||||
.to_path_buf();
|
.to_path_buf();
|
||||||
|
|
||||||
let config = DesktopApp::new(data_path.clone());
|
let config = DesktopApp::new(data_path.clone());
|
||||||
|
#[cfg(feature = "notedeck")]
|
||||||
if let Err(e) = eframe::run_native(
|
if let Err(e) = eframe::run_native(
|
||||||
"zap.stream",
|
"zap.stream",
|
||||||
options,
|
options,
|
||||||
Box::new(move |cc| Ok(Box::new(ZapStreamApp::new(cc, data_path, config)))),
|
Box::new(move |cc| {
|
||||||
|
let args: Vec<String> = std::env::args().collect();
|
||||||
|
let mut notedeck =
|
||||||
|
notedeck_chrome::Notedeck::new(&cc.egui_ctx, data_path.clone(), &args);
|
||||||
|
|
||||||
|
let app = ZapStreamApp::new(cc, data_path, config);
|
||||||
|
notedeck.add_app(app);
|
||||||
|
|
||||||
|
Ok(Box::new(notedeck))
|
||||||
|
}),
|
||||||
) {
|
) {
|
||||||
error!("{}", e);
|
error!("{}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "notedeck"))]
|
||||||
|
if let Err(e) = eframe::run_native("zap.stream", options, Box::new(move |cc| Ok(Box::new()))) {
|
||||||
|
error!("{}", e);
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user