introduce View and Previews traits

In this commit we refactor the preview mechanism, and switch to
responsive views by default.

To create a preview, your view now has to implement the Preview trait.
This is very similar to SwiftUI's preview mechanism.

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-04-19 14:09:19 -07:00
parent a5e1fbf328
commit a71e8206fb
11 changed files with 313 additions and 284 deletions

View File

@@ -6,6 +6,7 @@ use crate::imgcache::ImageCache;
use crate::notecache::NoteCache;
use crate::timeline;
use crate::ui;
use crate::ui::is_mobile;
use crate::Result;
use egui::containers::scroll_area::ScrollBarVisibility;
@@ -87,12 +88,6 @@ pub struct Damus {
frame_history: crate::frame_history::FrameHistory,
}
pub fn is_mobile(ctx: &egui::Context) -> bool {
//true
let screen_size = ctx.screen_rect().size();
screen_size.x < 550.0
}
fn relay_setup(pool: &mut RelayPool, ctx: &egui::Context) {
let ctx = ctx.clone();
let wakeup = move || {