This splits notedeck into: - notedeck - notedeck_chrome - notedeck_columns The `notedeck` crate is the library that `notedeck_chrome` and `notedeck_columns`, use. It contains common functionality related to notedeck apps such as the NoteCache, ImageCache, etc. The `notedeck_chrome` crate is the binary and ui chrome. It is responsible for managing themes, user accounts, signing, data paths, nostrdb, image caches etc. It will eventually have its own ui which has yet to be determined. For now it just manages the browser data, which is passed to apps via a new struct called `AppContext`. `notedeck_columns` is our columns app, with less responsibility now that more things are handled by `notedeck_chrome` There is still much work left to do before this is a proper browser: - process isolation - sandboxing - etc This is the beginning of a new era! We're just getting started. Signed-off-by: William Casarin <jb55@jb55.com>
86 lines
3.5 KiB
Rust
86 lines
3.5 KiB
Rust
use egui::{vec2, Button, Label, Layout, RichText};
|
|
use tracing::error;
|
|
|
|
use crate::{colors::PINK, support::Support};
|
|
|
|
use super::padding;
|
|
use notedeck::{NamedFontFamily, NotedeckTextStyle};
|
|
|
|
pub struct SupportView<'a> {
|
|
support: &'a mut Support,
|
|
}
|
|
|
|
impl<'a> SupportView<'a> {
|
|
pub fn new(support: &'a mut Support) -> Self {
|
|
Self { support }
|
|
}
|
|
|
|
pub fn show(&mut self, ui: &mut egui::Ui) {
|
|
padding(8.0, ui, |ui| {
|
|
ui.spacing_mut().item_spacing = egui::vec2(0.0, 8.0);
|
|
let font = egui::FontId::new(
|
|
notedeck::fonts::get_font_size(ui.ctx(), &NotedeckTextStyle::Body),
|
|
egui::FontFamily::Name(NamedFontFamily::Bold.as_str().into()),
|
|
);
|
|
ui.add(Label::new(RichText::new("Running into a bug?").font(font)));
|
|
ui.label(RichText::new("Step 1").text_style(NotedeckTextStyle::Heading3.text_style()));
|
|
padding(8.0, ui, |ui| {
|
|
ui.label("Open your default email client to get help from the Damus team");
|
|
let size = vec2(120.0, 40.0);
|
|
ui.allocate_ui_with_layout(size, Layout::top_down(egui::Align::Center), |ui| {
|
|
let font_size =
|
|
notedeck::fonts::get_font_size(ui.ctx(), &NotedeckTextStyle::Body);
|
|
let button_resp = ui.add(open_email_button(font_size, size));
|
|
if button_resp.clicked() {
|
|
if let Err(e) = open::that(self.support.get_mailto_url()) {
|
|
error!(
|
|
"Failed to open URL {} because: {}",
|
|
self.support.get_mailto_url(),
|
|
e
|
|
);
|
|
};
|
|
};
|
|
button_resp.on_hover_text_at_pointer(self.support.get_mailto_url());
|
|
})
|
|
});
|
|
|
|
ui.add_space(8.0);
|
|
|
|
if let Some(logs) = self.support.get_most_recent_log() {
|
|
ui.label(
|
|
RichText::new("Step 2").text_style(NotedeckTextStyle::Heading3.text_style()),
|
|
);
|
|
let size = vec2(80.0, 40.0);
|
|
let copy_button = Button::new(RichText::new("Copy").size(
|
|
notedeck::fonts::get_font_size(ui.ctx(), &NotedeckTextStyle::Body),
|
|
))
|
|
.fill(PINK)
|
|
.min_size(size);
|
|
padding(8.0, ui, |ui| {
|
|
ui.add(Label::new("Press the button below to copy your most recent logs to your system's clipboard. Then paste it into your email.").wrap());
|
|
ui.allocate_ui_with_layout(size, Layout::top_down(egui::Align::Center), |ui| {
|
|
if ui.add(copy_button).clicked() {
|
|
ui.output_mut(|w| {
|
|
w.copied_text = logs.to_string();
|
|
});
|
|
}
|
|
});
|
|
});
|
|
} else {
|
|
ui.label(
|
|
egui::RichText::new("ERROR: Could not find logs on system")
|
|
.color(egui::Color32::RED),
|
|
);
|
|
}
|
|
ui.label(format!("Notedeck {}", env!("CARGO_PKG_VERSION")));
|
|
ui.label(format!("Commit hash: {}", env!("GIT_COMMIT_HASH")));
|
|
});
|
|
}
|
|
}
|
|
|
|
fn open_email_button(font_size: f32, size: egui::Vec2) -> impl egui::Widget {
|
|
Button::new(RichText::new("Open Email").size(font_size))
|
|
.fill(PINK)
|
|
.min_size(size)
|
|
}
|