mirror of
https://github.com/damus-io/notedeck.git
synced 2024-09-16 11:53:30 +00:00
Apply cargo fmt
Signed-off-by: kernelkind <kernelkind@gmail.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
ff5e5ed74a
commit
c76f322a48
@ -2,8 +2,8 @@ use crate::app_style::NotedeckTextStyle;
|
||||
use crate::key_parsing::{perform_key_retrieval, LoginError};
|
||||
use crate::login_manager::LoginManager;
|
||||
use egui::{
|
||||
Align, Align2, Button, Color32, Frame, Id, LayerId, Margin, Pos2, Rect,
|
||||
RichText, Rounding, Ui, Vec2, Window,
|
||||
Align, Align2, Button, Color32, Frame, Id, LayerId, Margin, Pos2, Rect, RichText, Rounding, Ui,
|
||||
Vec2, Window,
|
||||
};
|
||||
use egui::{Image, TextBuffer, TextEdit};
|
||||
|
||||
@ -149,9 +149,7 @@ impl<'a> DesktopAccountLoginView<'a> {
|
||||
|
||||
ui.add_space(8f32);
|
||||
|
||||
ui.add(
|
||||
login_textedit(&mut self.manager.login_key).min_size(Vec2::new(440.0, 40.0)),
|
||||
);
|
||||
ui.add(login_textedit(&mut self.manager.login_key).min_size(Vec2::new(440.0, 40.0)));
|
||||
|
||||
ui.add_space(8.0);
|
||||
|
||||
@ -193,7 +191,9 @@ impl<'a> DesktopAccountLoginView<'a> {
|
||||
|
||||
fn generate_group(&mut self, ui: &mut egui::Ui) {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(RichText::new("New in nostr?").text_style(NotedeckTextStyle::Heading3.text_style()));
|
||||
ui.label(
|
||||
RichText::new("New in nostr?").text_style(NotedeckTextStyle::Heading3.text_style()),
|
||||
);
|
||||
|
||||
ui.label(
|
||||
RichText::new(" — we got you!")
|
||||
@ -266,7 +266,9 @@ fn login_button() -> Button<'static> {
|
||||
|
||||
fn login_textedit(text: &mut dyn TextBuffer) -> TextEdit {
|
||||
egui::TextEdit::singleline(text)
|
||||
.hint_text(RichText::new("Your key here...").text_style(NotedeckTextStyle::Body.text_style()))
|
||||
.hint_text(
|
||||
RichText::new("Your key here...").text_style(NotedeckTextStyle::Body.text_style()),
|
||||
)
|
||||
.vertical_align(Align::Center)
|
||||
.min_size(Vec2::new(0.0, 40.0))
|
||||
.margin(Margin::same(12.0))
|
||||
|
@ -1,8 +1,7 @@
|
||||
#![warn(clippy::all, rust_2018_idioms)]
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||
use notedeck::Damus;
|
||||
use notedeck::app_creation::generate_native_options;
|
||||
|
||||
use notedeck::Damus;
|
||||
|
||||
// Entry point for wasm
|
||||
//#[cfg(target_arch = "wasm32")]
|
||||
|
@ -1,12 +1,11 @@
|
||||
use crate::error::Error;
|
||||
use crate::result::Result;
|
||||
use crate::imgcache::ImageCache;
|
||||
use crate::result::Result;
|
||||
use egui::{Color32, ColorImage, SizeHint, TextureHandle};
|
||||
use image::imageops::FilterType;
|
||||
use poll_promise::Promise;
|
||||
use tokio::fs;
|
||||
use std::path;
|
||||
|
||||
use tokio::fs;
|
||||
|
||||
//pub type ImageCacheKey = String;
|
||||
//pub type ImageCacheValue = Promise<Result<TextureHandle>>;
|
||||
@ -112,11 +111,15 @@ fn parse_img_response(response: ehttp::Response, size: u32) -> Result<ColorImage
|
||||
}
|
||||
}
|
||||
|
||||
fn fetch_img_from_disk(ctx: &egui::Context, url: &str, path: &path::Path) -> Promise<Result<TextureHandle>> {
|
||||
fn fetch_img_from_disk(
|
||||
ctx: &egui::Context,
|
||||
url: &str,
|
||||
path: &path::Path,
|
||||
) -> Promise<Result<TextureHandle>> {
|
||||
let ctx = ctx.clone();
|
||||
let url = url.to_owned();
|
||||
let path = path.to_owned();
|
||||
Promise::spawn_async(async move {
|
||||
Promise::spawn_async(async move {
|
||||
let data = fs::read(path).await?;
|
||||
let image_buffer = image::load_from_memory(&data)?;
|
||||
|
||||
@ -152,7 +155,12 @@ pub fn fetch_img(
|
||||
// TODO: fetch image from local cache
|
||||
}
|
||||
|
||||
fn fetch_img_from_net(cache_path: &path::Path, ctx: &egui::Context, url: &str, size: u32) -> Promise<Result<TextureHandle>> {
|
||||
fn fetch_img_from_net(
|
||||
cache_path: &path::Path,
|
||||
ctx: &egui::Context,
|
||||
url: &str,
|
||||
size: u32,
|
||||
) -> Promise<Result<TextureHandle>> {
|
||||
let (sender, promise) = Promise::new();
|
||||
let request = ehttp::Request::get(url);
|
||||
let ctx = ctx.clone();
|
||||
@ -166,9 +174,7 @@ fn fetch_img_from_net(cache_path: &path::Path, ctx: &egui::Context, url: &str, s
|
||||
let texture_handle = ctx.load_texture(&cloned_url, img.clone(), Default::default());
|
||||
|
||||
// write to disk
|
||||
std::thread::spawn(move || {
|
||||
ImageCache::write(&cache_path, &cloned_url, img)
|
||||
});
|
||||
std::thread::spawn(move || ImageCache::write(&cache_path, &cloned_url, img));
|
||||
|
||||
texture_handle
|
||||
});
|
||||
|
30
src/lib.rs
30
src/lib.rs
@ -4,24 +4,24 @@ mod error;
|
||||
//mod note;
|
||||
//mod block;
|
||||
mod abbrev;
|
||||
mod fonts;
|
||||
mod images;
|
||||
mod result;
|
||||
mod imgcache;
|
||||
mod filter;
|
||||
mod ui;
|
||||
mod timecache;
|
||||
mod time;
|
||||
mod notecache;
|
||||
mod frame_history;
|
||||
mod timeline;
|
||||
mod colors;
|
||||
mod profile;
|
||||
mod key_parsing;
|
||||
pub mod login_manager;
|
||||
pub mod account_login_view;
|
||||
pub mod app_creation;
|
||||
mod app_style;
|
||||
mod colors;
|
||||
mod filter;
|
||||
mod fonts;
|
||||
mod frame_history;
|
||||
mod images;
|
||||
mod imgcache;
|
||||
mod key_parsing;
|
||||
pub mod login_manager;
|
||||
mod notecache;
|
||||
mod profile;
|
||||
mod result;
|
||||
mod time;
|
||||
mod timecache;
|
||||
mod timeline;
|
||||
mod ui;
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
|
@ -8,7 +8,7 @@ pub struct LoginManager {
|
||||
pub login_key: String,
|
||||
pub promise: Option<Promise<Result<Keys, LoginError>>>,
|
||||
pub error: Option<LoginError>,
|
||||
pub key_on_error: Option<String>
|
||||
pub key_on_error: Option<String>,
|
||||
}
|
||||
|
||||
impl LoginManager {
|
||||
@ -17,7 +17,7 @@ impl LoginManager {
|
||||
login_key: String::new(),
|
||||
promise: None,
|
||||
error: None,
|
||||
key_on_error: None
|
||||
key_on_error: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,4 @@ impl eframe::App for MobileAccountLoginPreview {
|
||||
fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
|
||||
MobileAccountLoginView::new(ctx, &mut self.manager).panel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ mod account_login_preview;
|
||||
mod egui_preview_setup;
|
||||
use account_login_preview::{DesktopAccountLoginPreview, MobileAccountLoginPreview};
|
||||
use egui_preview_setup::{EguiPreviewCase, EguiPreviewSetup};
|
||||
use notedeck::app_creation::{generate_native_options, generate_mobile_emulator_native_options};
|
||||
use notedeck::app_creation::{generate_mobile_emulator_native_options, generate_native_options};
|
||||
use std::env;
|
||||
|
||||
fn run_test_app<F, T, O>(create_supr: F, create_child: O, is_mobile: bool)
|
||||
@ -26,15 +26,16 @@ where
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
if args.len() > 1 {
|
||||
match args[1].as_str() {
|
||||
"DesktopAccountLoginPreview" => {
|
||||
run_test_app(EguiPreviewSetup::new, DesktopAccountLoginPreview::new, false)
|
||||
}
|
||||
"DesktopAccountLoginPreview" => run_test_app(
|
||||
EguiPreviewSetup::new,
|
||||
DesktopAccountLoginPreview::new,
|
||||
false,
|
||||
),
|
||||
"MobileAccountLoginPreview" => {
|
||||
run_test_app(EguiPreviewSetup::new, MobileAccountLoginPreview::new, true)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user