mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 16:31:18 +00:00
cargo fmt
This commit is contained in:
parent
ce4b4c72df
commit
bb30c41573
@ -273,7 +273,6 @@ pub(super) fn render_plain(
|
||||
|
||||
pub(super) fn render_profile_link(app: &mut GossipUi, ui: &mut Ui, pubkey: &PublicKey) {
|
||||
let nam = gossip_lib::names::best_name_from_pubkey_lookup(pubkey);
|
||||
let nam = nam.to_string();
|
||||
if ui.link(&nam).clicked() {
|
||||
app.set_page(Page::Person(pubkey.to_owned()));
|
||||
};
|
||||
|
@ -7,17 +7,17 @@ use std::rc::Rc;
|
||||
use super::notedata::{NoteData, RepostType};
|
||||
|
||||
use super::FeedNoteParams;
|
||||
use crate::ui::widgets::{CopyButton, self, AvatarSize};
|
||||
use crate::ui::widgets::{self, AvatarSize, CopyButton};
|
||||
use crate::ui::{GossipUi, Page};
|
||||
use crate::{AVATAR_SIZE_F32,AVATAR_SIZE_REPOST_F32};
|
||||
use gossip_lib::comms::ToOverlordMessage;
|
||||
use gossip_lib::DmChannel;
|
||||
use gossip_lib::FeedKind;
|
||||
use gossip_lib::{ZapState, GLOBALS};
|
||||
use crate::{AVATAR_SIZE_F32, AVATAR_SIZE_REPOST_F32};
|
||||
use eframe::egui::{self, Margin};
|
||||
use egui::{
|
||||
Align, Context, Frame, Label, Layout, RichText, Sense, Separator, Stroke, TextStyle, Ui,
|
||||
};
|
||||
use gossip_lib::comms::ToOverlordMessage;
|
||||
use gossip_lib::DmChannel;
|
||||
use gossip_lib::FeedKind;
|
||||
use gossip_lib::{ZapState, GLOBALS};
|
||||
use nostr_types::{Event, EventDelegation, EventKind, EventPointer, IdHex, NostrUrl, UncheckedUrl};
|
||||
|
||||
pub struct NoteRenderData {
|
||||
@ -266,9 +266,7 @@ fn render_note_inner(
|
||||
ui.add_space(avatar_margin_left);
|
||||
|
||||
// render avatar
|
||||
if widgets::paint_avatar(ui, ¬e.author, &avatar, avatar_size)
|
||||
.clicked()
|
||||
{
|
||||
if widgets::paint_avatar(ui, ¬e.author, &avatar, avatar_size).clicked() {
|
||||
app.set_page(Page::Person(note.author.pubkey));
|
||||
};
|
||||
|
||||
|
@ -9,9 +9,9 @@ use egui_winit::egui::text::CCursor;
|
||||
use egui_winit::egui::text_edit::{CCursorRange, TextEditOutput};
|
||||
use egui_winit::egui::Id;
|
||||
use gossip_lib::comms::ToOverlordMessage;
|
||||
use gossip_lib::{DmChannel, Person};
|
||||
use gossip_lib::Relay;
|
||||
use gossip_lib::GLOBALS;
|
||||
use gossip_lib::{DmChannel, Person};
|
||||
use memoize::memoize;
|
||||
use nostr_types::{ContentSegment, NostrBech32, NostrUrl, ShatteredContent, Tag};
|
||||
use std::collections::HashMap;
|
||||
@ -563,11 +563,14 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
|
||||
}
|
||||
});
|
||||
ui.add_space(20.0);
|
||||
if ui.button(RichText::new("🥩"))
|
||||
if ui
|
||||
.button(RichText::new("🥩"))
|
||||
.on_hover_text("raw content preview")
|
||||
.clicked() {
|
||||
.clicked()
|
||||
{
|
||||
if app.draft_data.raw.is_empty() {
|
||||
let raw = do_replacements(&app.draft_data.draft, &app.draft_data.replacements);
|
||||
let raw =
|
||||
do_replacements(&app.draft_data.draft, &app.draft_data.replacements);
|
||||
app.draft_data.raw = raw.to_owned();
|
||||
} else {
|
||||
app.draft_data.raw = "".to_owned();
|
||||
@ -658,7 +661,7 @@ fn calc_tagging_search(app: &mut GossipUi) {
|
||||
.people
|
||||
.search_people_to_tag(search)
|
||||
.unwrap_or(vec![]);
|
||||
pairs.sort_by(|(_,ak), (_,bk)| {
|
||||
pairs.sort_by(|(_, ak), (_, bk)| {
|
||||
let af = GLOBALS
|
||||
.storage
|
||||
.is_person_in_list(ak, gossip_lib::PersonList::Followed)
|
||||
@ -754,11 +757,18 @@ fn show_tagging_result(
|
||||
if is_selected {
|
||||
app.theme.on_accent_style(ui.style_mut())
|
||||
}
|
||||
let person = GLOBALS.storage.read_person(&pair.1)
|
||||
let person = GLOBALS
|
||||
.storage
|
||||
.read_person(&pair.1)
|
||||
.unwrap_or(Some(Person::new(pair.1)))
|
||||
.unwrap_or(Person::new(pair.1));
|
||||
ui.horizontal(|ui| {
|
||||
widgets::paint_avatar(ui, &person, &avatar, widgets::AvatarSize::Mini);
|
||||
widgets::paint_avatar(
|
||||
ui,
|
||||
&person,
|
||||
&avatar,
|
||||
widgets::AvatarSize::Mini,
|
||||
);
|
||||
ui.vertical(|ui| {
|
||||
widgets::truncated_label(
|
||||
ui,
|
||||
@ -766,18 +776,18 @@ fn show_tagging_result(
|
||||
widgets::TAGG_WIDTH - 33.0,
|
||||
);
|
||||
|
||||
let mut nip05 =
|
||||
RichText::new(person.nip05().unwrap_or_default())
|
||||
.weak()
|
||||
.small();
|
||||
if !person.nip05_valid {
|
||||
nip05 = nip05.strikethrough()
|
||||
}
|
||||
widgets::truncated_label(
|
||||
ui,
|
||||
nip05,
|
||||
widgets::TAGG_WIDTH - 33.0,
|
||||
);
|
||||
let mut nip05 =
|
||||
RichText::new(person.nip05().unwrap_or_default())
|
||||
.weak()
|
||||
.small();
|
||||
if !person.nip05_valid {
|
||||
nip05 = nip05.strikethrough()
|
||||
}
|
||||
widgets::truncated_label(
|
||||
ui,
|
||||
nip05,
|
||||
widgets::TAGG_WIDTH - 33.0,
|
||||
);
|
||||
});
|
||||
})
|
||||
};
|
||||
|
@ -176,9 +176,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
} else {
|
||||
app.placeholder_avatar.clone()
|
||||
};
|
||||
if widgets::paint_avatar(ui, person, &avatar, widgets::AvatarSize::Feed)
|
||||
.clicked()
|
||||
{
|
||||
if widgets::paint_avatar(ui, person, &avatar, widgets::AvatarSize::Feed).clicked() {
|
||||
app.set_page(Page::Person(person.pubkey));
|
||||
};
|
||||
|
||||
|
@ -166,9 +166,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
} else {
|
||||
app.placeholder_avatar.clone()
|
||||
};
|
||||
if widgets::paint_avatar(ui, person, &avatar, widgets::AvatarSize::Feed)
|
||||
.clicked()
|
||||
{
|
||||
if widgets::paint_avatar(ui, person, &avatar, widgets::AvatarSize::Feed).clicked() {
|
||||
app.set_page(Page::Person(person.pubkey));
|
||||
};
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::{GossipUi, Page, widgets};
|
||||
use super::{widgets, GossipUi, Page};
|
||||
use eframe::{egui, Frame};
|
||||
use egui::widgets::Button;
|
||||
use egui::{Context, Label, RichText, Sense, Ui};
|
||||
|
@ -1,6 +1,6 @@
|
||||
use egui_winit::egui::{Ui, Image, Vec2, self, vec2, TextureHandle, Response};
|
||||
use gossip_lib::{Person, PersonList};
|
||||
use crate::{AVATAR_SIZE_F32, AVATAR_SIZE_REPOST_F32};
|
||||
use egui_winit::egui::{self, vec2, Image, Response, TextureHandle, Ui, Vec2};
|
||||
use gossip_lib::{Person, PersonList};
|
||||
|
||||
pub(crate) enum AvatarSize {
|
||||
Profile,
|
||||
@ -27,11 +27,20 @@ impl AvatarSize {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_size(&self) -> Vec2{
|
||||
fn get_size(&self) -> Vec2 {
|
||||
match self {
|
||||
AvatarSize::Profile => Vec2{ x: AVATAR_SIZE_F32 * 3.0, y: AVATAR_SIZE_F32 * 3.0},
|
||||
AvatarSize::Feed => Vec2 { x: AVATAR_SIZE_F32, y: AVATAR_SIZE_F32 },
|
||||
AvatarSize::Mini => Vec2 { x: AVATAR_SIZE_REPOST_F32, y: AVATAR_SIZE_REPOST_F32 },
|
||||
AvatarSize::Profile => Vec2 {
|
||||
x: AVATAR_SIZE_F32 * 3.0,
|
||||
y: AVATAR_SIZE_F32 * 3.0,
|
||||
},
|
||||
AvatarSize::Feed => Vec2 {
|
||||
x: AVATAR_SIZE_F32,
|
||||
y: AVATAR_SIZE_F32,
|
||||
},
|
||||
AvatarSize::Mini => Vec2 {
|
||||
x: AVATAR_SIZE_REPOST_F32,
|
||||
y: AVATAR_SIZE_REPOST_F32,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +61,12 @@ impl AvatarSize {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn paint_avatar(ui: &mut Ui, person: &Person, avatar: &TextureHandle, avatar_size: AvatarSize) -> Response {
|
||||
pub(crate) fn paint_avatar(
|
||||
ui: &mut Ui,
|
||||
person: &Person,
|
||||
avatar: &TextureHandle,
|
||||
avatar_size: AvatarSize,
|
||||
) -> Response {
|
||||
let followed = person.is_in_list(PersonList::Followed);
|
||||
let muted = person.is_in_list(PersonList::Muted);
|
||||
let on_list = person.is_in_list(PersonList::Custom(2)); // TODO: change to any list
|
||||
@ -67,37 +81,39 @@ pub(crate) fn paint_avatar(ui: &mut Ui, person: &Person, avatar: &TextureHandle,
|
||||
|
||||
let status_color = match (followed, on_list, muted) {
|
||||
(true, _, false) => ui.visuals().hyperlink_color, // followed
|
||||
(false, true, false) => egui::Color32::GREEN, // on-list
|
||||
(_, _, true) => ui.visuals().warn_fg_color, // muted
|
||||
(false, true, false) => egui::Color32::GREEN, // on-list
|
||||
(_, _, true) => ui.visuals().warn_fg_color, // muted
|
||||
(false, false, false) => egui::Color32::TRANSPARENT,
|
||||
};
|
||||
if status_color != egui::Color32::TRANSPARENT {
|
||||
let center = avatar_response.rect.right_top() + vec2(-0.139*size.x, 0.139*size.y);
|
||||
let center = avatar_response.rect.right_top() + vec2(-0.139 * size.x, 0.139 * size.y);
|
||||
ui.painter().circle(
|
||||
center,
|
||||
avatar_size.get_status_size(),
|
||||
status_color,
|
||||
egui::Stroke::new(avatar_size.get_status_stroke_width(), ui.visuals().panel_fill),
|
||||
egui::Stroke::new(
|
||||
avatar_size.get_status_stroke_width(),
|
||||
ui.visuals().panel_fill,
|
||||
),
|
||||
);
|
||||
let rect = egui::Rect::from_center_size(center, vec2(avatar_size.get_status_size(), avatar_size.get_status_size()));
|
||||
ui.interact(
|
||||
rect,
|
||||
ui.auto_id_with("status-circle"),
|
||||
egui::Sense::hover(),
|
||||
)
|
||||
.on_hover_text({
|
||||
let mut stat: Vec<&str> = Vec::new();
|
||||
if followed {
|
||||
stat.push("followed")
|
||||
}
|
||||
if on_list {
|
||||
stat.push("priority")
|
||||
}
|
||||
if muted {
|
||||
stat.push("muted")
|
||||
}
|
||||
stat.join(", ")
|
||||
});
|
||||
let rect = egui::Rect::from_center_size(
|
||||
center,
|
||||
vec2(avatar_size.get_status_size(), avatar_size.get_status_size()),
|
||||
);
|
||||
ui.interact(rect, ui.auto_id_with("status-circle"), egui::Sense::hover())
|
||||
.on_hover_text({
|
||||
let mut stat: Vec<&str> = Vec::new();
|
||||
if followed {
|
||||
stat.push("followed")
|
||||
}
|
||||
if on_list {
|
||||
stat.push("priority")
|
||||
}
|
||||
if muted {
|
||||
stat.push("muted")
|
||||
}
|
||||
stat.join(", ")
|
||||
});
|
||||
}
|
||||
avatar_response
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user