feat: Out-of-Box Experience (#12)

* refactor app view

* feat: onboarding

* add back buttons in onboarding
This commit is contained in:
reya
2025-03-25 12:34:39 +07:00
committed by GitHub
parent e15cbcc22c
commit 00cf7792e5
34 changed files with 1680 additions and 1920 deletions

View File

@@ -1,4 +1,3 @@
pub mod last_seen;
pub mod profile;
pub mod qr;
pub mod utils;

View File

@@ -1,14 +1,12 @@
use global::constants::IMAGE_SERVICE;
use gpui::SharedString;
use nostr_sdk::prelude::*;
use smallvec::SmallVec;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NostrProfile {
pub public_key: PublicKey,
pub avatar: SharedString,
pub name: SharedString,
pub messaging_relays: Option<SmallVec<[RelayUrl; 3]>>,
}
impl NostrProfile {
@@ -20,16 +18,9 @@ impl NostrProfile {
public_key,
name,
avatar,
messaging_relays: None,
}
}
/// Set contact's relays
pub fn relays(mut self, relays: Option<SmallVec<[RelayUrl; 3]>>) -> Self {
self.messaging_relays = relays;
self
}
fn extract_avatar(metadata: &Metadata) -> SharedString {
metadata
.picture

View File

@@ -1,13 +0,0 @@
use std::path::PathBuf;
use dirs::config_dir;
use qrcode_generator::QrCodeEcc;
pub fn create_qr(data: &str) -> Result<PathBuf, anyhow::Error> {
let config_dir = config_dir().expect("Config directory not found");
let path = config_dir.join("Coop/nostr_connect.png");
qrcode_generator::to_png_to_file(data, QrCodeEcc::Low, 512, &path)?;
Ok(path)
}

View File

@@ -1,11 +1,14 @@
use anyhow::Context;
use global::constants::NIP96_SERVER;
use gpui::Image;
use itertools::Itertools;
use nostr_sdk::prelude::*;
use qrcode_generator::QrCodeEcc;
use rnglib::{Language, RNG};
use std::{
collections::HashSet,
hash::{DefaultHasher, Hash, Hasher},
sync::Arc,
};
pub async fn nip96_upload(client: &Client, file: Vec<u8>) -> anyhow::Result<Url, anyhow::Error> {
@@ -57,6 +60,17 @@ pub fn random_name(length: usize) -> String {
rng.generate_names(length, true).join("-").to_lowercase()
}
pub fn create_qr(data: &str) -> Result<Arc<Image>, anyhow::Error> {
let qr = qrcode_generator::to_png_to_vec_from_str(data, QrCodeEcc::Medium, 256)?;
let img = Arc::new(Image {
format: gpui::ImageFormat::Png,
bytes: qr.clone(),
id: 1,
});
Ok(img)
}
pub fn compare<T>(a: &[T], b: &[T]) -> bool
where
T: Eq + Hash,