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:
@@ -1,11 +1,17 @@
|
||||
pub mod note;
|
||||
pub mod preview;
|
||||
pub mod username;
|
||||
|
||||
pub use note::Note;
|
||||
pub use preview::{Preview, PreviewApp};
|
||||
pub use username::Username;
|
||||
|
||||
use egui::Margin;
|
||||
|
||||
pub trait View {
|
||||
fn ui(&mut self, ui: &mut egui::Ui);
|
||||
}
|
||||
|
||||
pub fn padding<R>(
|
||||
amount: impl Into<Margin>,
|
||||
ui: &mut egui::Ui,
|
||||
@@ -15,3 +21,9 @@ pub fn padding<R>(
|
||||
.inner_margin(amount)
|
||||
.show(ui, add_contents)
|
||||
}
|
||||
|
||||
pub fn is_mobile(ctx: &egui::Context) -> bool {
|
||||
//true
|
||||
let screen_size = ctx.screen_rect().size();
|
||||
screen_size.x < 550.0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user