dave: prepare for android
This commit is contained in:
@@ -3,7 +3,7 @@ name = "notedeck_chrome"
|
||||
version = { workspace = true }
|
||||
authors = ["William Casarin <jb55@jb55.com>", "kernelkind <kernelkind@gmail.com>"]
|
||||
edition = "2021"
|
||||
default-run = "notedeck"
|
||||
#default-run = "notedeck"
|
||||
#rust-version = "1.60"
|
||||
license = "GPLv3"
|
||||
description = "The nostr browser"
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
use egui_winit::winit::platform::android::activity::AndroidApp;
|
||||
use notedeck_columns::Damus;
|
||||
use notedeck_dave::Dave;
|
||||
|
||||
use crate::setup::setup_chrome;
|
||||
use crate::{setup::setup_chrome, chrome::Chrome};
|
||||
use notedeck::Notedeck;
|
||||
use serde_json::Value;
|
||||
use std::fs;
|
||||
@@ -13,7 +14,7 @@ use std::path::PathBuf;
|
||||
#[no_mangle]
|
||||
#[tokio::main]
|
||||
pub async fn android_main(app: AndroidApp) {
|
||||
use tracing_logcat::{LogcatMakeWriter, LogcatTag};
|
||||
//use tracing_logcat::{LogcatMakeWriter, LogcatTag};
|
||||
use tracing_subscriber::{prelude::*, EnvFilter};
|
||||
|
||||
std::env::set_var("RUST_BACKTRACE", "full");
|
||||
@@ -24,8 +25,8 @@ pub async fn android_main(app: AndroidApp) {
|
||||
// "enostr=debug,notedeck_columns=debug,notedeck_chrome=debug",
|
||||
//);
|
||||
|
||||
let writer =
|
||||
LogcatMakeWriter::new(LogcatTag::Target).expect("Failed to initialize logcat writer");
|
||||
//let writer =
|
||||
//LogcatMakeWriter::new(LogcatTag::Target).expect("Failed to initialize logcat writer");
|
||||
|
||||
let fmt_layer = tracing_subscriber::fmt::layer()
|
||||
.with_level(false)
|
||||
@@ -62,12 +63,15 @@ pub async fn android_main(app: AndroidApp) {
|
||||
let mut notedeck = Notedeck::new(ctx, path, &app_args);
|
||||
setup_chrome(ctx, ¬edeck.args(), notedeck.theme());
|
||||
|
||||
let damus = Damus::new(&mut notedeck.app_context(), &app_args);
|
||||
let context = &mut notedeck.app_context();
|
||||
let dave = Dave::new(cc.wgpu_render_state.as_ref());
|
||||
let columns = Damus::new(context, &app_args);
|
||||
let mut chrome = Chrome::new();
|
||||
|
||||
// ensure we recognized all the arguments
|
||||
let completely_unrecognized: Vec<String> = notedeck
|
||||
.unrecognized_args()
|
||||
.intersection(damus.unrecognized_args())
|
||||
.intersection(columns.unrecognized_args())
|
||||
.cloned()
|
||||
.collect();
|
||||
assert!(
|
||||
@@ -76,7 +80,13 @@ pub async fn android_main(app: AndroidApp) {
|
||||
completely_unrecognized
|
||||
);
|
||||
|
||||
notedeck.set_app(damus);
|
||||
chrome.add_app(columns);
|
||||
chrome.add_app(dave);
|
||||
|
||||
// test dav
|
||||
chrome.set_active(1);
|
||||
|
||||
notedeck.set_app(chrome);
|
||||
|
||||
Ok(Box::new(notedeck))
|
||||
}),
|
||||
|
||||
37
crates/notedeck_chrome/src/chrome.rs
Normal file
37
crates/notedeck_chrome/src/chrome.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
// Entry point for wasm
|
||||
//#[cfg(target_arch = "wasm32")]
|
||||
//use wasm_bindgen::prelude::*;
|
||||
|
||||
pub struct Chrome {
|
||||
active: i32,
|
||||
apps: Vec<Box<dyn notedeck::App>>,
|
||||
}
|
||||
|
||||
impl Chrome {
|
||||
pub fn new() -> Self {
|
||||
Chrome {
|
||||
active: 0,
|
||||
apps: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_app(&mut self, app: impl notedeck::App + 'static) {
|
||||
self.apps.push(Box::new(app));
|
||||
}
|
||||
|
||||
pub fn set_active(&mut self, app: i32) {
|
||||
self.active = app;
|
||||
}
|
||||
}
|
||||
|
||||
impl notedeck::App for Chrome {
|
||||
fn update(&mut self, ctx: &mut notedeck::AppContext, ui: &mut egui::Ui) {
|
||||
let active = self.active;
|
||||
self.apps[active as usize].update(ctx, ui);
|
||||
//for i in 0..self.apps.len() {
|
||||
// self.apps[i].update(ctx, ui);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,3 +4,7 @@ pub mod theme;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
mod android;
|
||||
|
||||
mod chrome;
|
||||
|
||||
pub use chrome::Chrome;
|
||||
|
||||
@@ -1,49 +1,16 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
//#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
// hide console window on Windows in release
|
||||
use notedeck_chrome::setup::{generate_native_options, setup_chrome};
|
||||
|
||||
use notedeck::{DataPath, DataPathType, Notedeck};
|
||||
use notedeck_chrome::{
|
||||
setup::{generate_native_options, setup_chrome},
|
||||
Chrome,
|
||||
};
|
||||
use notedeck_columns::Damus;
|
||||
use notedeck_dave::Dave;
|
||||
use tracing_appender::non_blocking::WorkerGuard;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
// Entry point for wasm
|
||||
//#[cfg(target_arch = "wasm32")]
|
||||
//use wasm_bindgen::prelude::*;
|
||||
|
||||
struct Chrome {
|
||||
active: i32,
|
||||
apps: Vec<Box<dyn notedeck::App>>,
|
||||
}
|
||||
|
||||
impl Chrome {
|
||||
pub fn new() -> Self {
|
||||
Chrome {
|
||||
active: 0,
|
||||
apps: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_app(&mut self, app: impl notedeck::App + 'static) {
|
||||
self.apps.push(Box::new(app));
|
||||
}
|
||||
|
||||
pub fn set_active(&mut self, app: i32) {
|
||||
self.active = app;
|
||||
}
|
||||
}
|
||||
|
||||
impl notedeck::App for Chrome {
|
||||
fn update(&mut self, ctx: &mut notedeck::AppContext, ui: &mut egui::Ui) {
|
||||
let active = self.active;
|
||||
self.apps[active as usize].update(ctx, ui);
|
||||
//for i in 0..self.apps.len() {
|
||||
// self.apps[i].update(ctx, ui);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_logging(path: &DataPath) -> Option<WorkerGuard> {
|
||||
#[allow(unused_variables)] // need guard to live for lifetime of program
|
||||
let (maybe_non_blocking, maybe_guard) = {
|
||||
|
||||
@@ -19,4 +19,4 @@ time = "0.3.41"
|
||||
rand = "0.9.0"
|
||||
bytemuck = "1.22.0"
|
||||
futures = "0.3.31"
|
||||
reqwest = "0.12.15"
|
||||
#reqwest = "0.12.15"
|
||||
|
||||
@@ -394,8 +394,8 @@ impl Dave {
|
||||
});
|
||||
|
||||
if let Some(avatar) = &mut self.avatar {
|
||||
let avatar_size = Vec2::splat(100.0);
|
||||
let pos = Vec2::splat(10.0).to_pos2();
|
||||
let avatar_size = Vec2::splat(300.0);
|
||||
let pos = Vec2::splat(100.0).to_pos2();
|
||||
let pos = Rect::from_min_max(pos, pos + avatar_size);
|
||||
avatar.render(pos, ui);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user