mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-30 00:41:42 +00:00
Merge pull request #538 from dtonon/feature/temp-review-profile
Restyle a little the profile page
This commit is contained in:
commit
4e5ed6a708
@ -284,7 +284,7 @@ fn render_note_inner(
|
||||
|
||||
ui.add_space(3.0);
|
||||
|
||||
GossipUi::render_person_name_line(app, ui, ¬e.author);
|
||||
GossipUi::render_person_name_line(app, ui, ¬e.author, false);
|
||||
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
if let Some((irt, _)) = note.event.replies_to() {
|
||||
|
@ -1100,7 +1100,7 @@ impl GossipUi {
|
||||
ui.set_enabled(!relays::is_entry_dialog_active(self));
|
||||
}
|
||||
|
||||
pub fn render_person_name_line(app: &mut GossipUi, ui: &mut Ui, person: &Person) {
|
||||
pub fn render_person_name_line(app: &mut GossipUi, ui: &mut Ui, person: &Person, profile_page: bool) {
|
||||
// Let the 'People' manager know that we are interested in displaying this person.
|
||||
// It will take all actions necessary to make the data eventually available.
|
||||
GLOBALS.people.person_of_interest(person.pubkey);
|
||||
@ -1115,17 +1115,23 @@ impl GossipUi {
|
||||
};
|
||||
|
||||
let tag_name_menu = {
|
||||
let text = match &person.petname {
|
||||
let text = if !profile_page {
|
||||
match &person.petname {
|
||||
Some(pn) => pn.to_owned(),
|
||||
None => gossip_lib::names::tag_name_from_person(person),
|
||||
}
|
||||
} else {
|
||||
"ACTIONS".to_string()
|
||||
};
|
||||
RichText::new(format!("☰ {}", text))
|
||||
};
|
||||
|
||||
ui.menu_button(tag_name_menu, |ui| {
|
||||
if !profile_page {
|
||||
if ui.button("View Person").clicked() {
|
||||
app.set_page(Page::Person(person.pubkey));
|
||||
}
|
||||
}
|
||||
if app.page != Page::Feed(FeedKind::Person(person.pubkey)) {
|
||||
if ui.button("View Their Posts").clicked() {
|
||||
app.set_page(Page::Feed(FeedKind::Person(person.pubkey)));
|
||||
@ -1183,6 +1189,7 @@ impl GossipUi {
|
||||
.on_hover_text("followed");
|
||||
}
|
||||
|
||||
if !profile_page {
|
||||
if let Some(mut nip05) = person.nip05().map(|s| s.to_owned()) {
|
||||
if nip05.starts_with("_@") {
|
||||
nip05 = nip05.get(2..).unwrap().to_string();
|
||||
@ -1201,6 +1208,7 @@ impl GossipUi {
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.label(RichText::new(gossip_lib::names::pubkey_short(&person.pubkey)).weak());
|
||||
GossipUi::render_person_name_line(app, ui, person);
|
||||
GossipUi::render_person_name_line(app, ui, person, false);
|
||||
if !GLOBALS
|
||||
.storage
|
||||
.have_persons_relays(person.pubkey)
|
||||
|
@ -149,7 +149,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.label(RichText::new(gossip_lib::names::pubkey_short(&person.pubkey)).weak());
|
||||
GossipUi::render_person_name_line(app, ui, person);
|
||||
GossipUi::render_person_name_line(app, ui, person, false);
|
||||
|
||||
if ui.button("UNMUTE").clicked() {
|
||||
let _ = GLOBALS.people.mute(&person.pubkey, false);
|
||||
|
@ -34,15 +34,20 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
}
|
||||
|
||||
fn content(app: &mut GossipUi, ctx: &Context, ui: &mut Ui, pubkey: PublicKey, person: Person) {
|
||||
ui.add_space(24.0);
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
// Avatar first
|
||||
ui.vertical(|ui| {
|
||||
ui.add_space(10.0);
|
||||
ui.allocate_ui_with_layout(
|
||||
Vec2::new(ui.available_width(), ui.spacing().interact_size.y),
|
||||
egui::Layout::right_to_left(egui::Align::Center),
|
||||
|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let avatar = if let Some(avatar) = app.try_get_avatar(ctx, &pubkey) {
|
||||
avatar
|
||||
} else {
|
||||
app.placeholder_avatar.clone()
|
||||
};
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(20.0);
|
||||
ui.add(
|
||||
Image::new(&avatar)
|
||||
.max_size(Vec2 {
|
||||
@ -51,14 +56,14 @@ fn content(app: &mut GossipUi, ctx: &Context, ui: &mut Ui, pubkey: PublicKey, pe
|
||||
})
|
||||
.maintain_aspect_ratio(true),
|
||||
);
|
||||
});
|
||||
});
|
||||
ui.vertical(|ui| {
|
||||
let display_name = gossip_lib::names::display_name_from_person(&person);
|
||||
ui.heading(display_name);
|
||||
ui.label(RichText::new(gossip_lib::names::pubkey_short(&pubkey)).weak());
|
||||
GossipUi::render_person_name_line(app, ui, &person);
|
||||
|
||||
ui.label(RichText::new(gossip_lib::names::pubkey_short(&pubkey)));
|
||||
ui.add_space(10.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(12.0);
|
||||
ui.label("Pet name:");
|
||||
if app.editing_petname {
|
||||
let edit_color = app.theme.input_text_color();
|
||||
@ -111,10 +116,41 @@ fn content(app: &mut GossipUi, ctx: &Context, ui: &mut Ui, pubkey: PublicKey, pe
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ui.add_space(10.0);
|
||||
{
|
||||
let visuals = ui.visuals_mut();
|
||||
visuals.widgets.inactive.weak_bg_fill = app.theme.accent_color();
|
||||
visuals.widgets.inactive.fg_stroke.width = 1.0;
|
||||
visuals.widgets.inactive.fg_stroke.color =
|
||||
app.theme.get_style().visuals.extreme_bg_color;
|
||||
visuals.widgets.hovered.weak_bg_fill = app.theme.navigation_text_color();
|
||||
visuals.widgets.hovered.fg_stroke.color = app.theme.accent_color();
|
||||
visuals.widgets.inactive.fg_stroke.color =
|
||||
app.theme.get_style().visuals.extreme_bg_color;
|
||||
GossipUi::render_person_name_line(app, ui, &person, true);
|
||||
}
|
||||
|
||||
if let Some(about) = person.about() {
|
||||
ui.add_space(10.0);
|
||||
ui.separator();
|
||||
ui.add_space(10.0);
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(about);
|
||||
if ui.add(CopyButton {}).on_hover_text("Copy About").clicked() {
|
||||
ui.output_mut(|o| o.copied_text = about.to_owned());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
ui.add_space(12.0);
|
||||
ui.add_space(10.0);
|
||||
ui.separator();
|
||||
ui.add_space(10.0);
|
||||
|
||||
let npub = pubkey.as_bech32_string();
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
@ -143,18 +179,6 @@ fn content(app: &mut GossipUi, ctx: &Context, ui: &mut Ui, pubkey: PublicKey, pe
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(about) = person.about() {
|
||||
ui.label(RichText::new("About: ").strong());
|
||||
Frame::group(ui.style()).show(ui, |ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(about);
|
||||
if ui.add(CopyButton {}).on_hover_text("Copy About").clicked() {
|
||||
ui.output_mut(|o| o.copied_text = about.to_owned());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(picture) = person.picture() {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(RichText::new("Picture: ").strong());
|
||||
|
@ -81,7 +81,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut Frame, ui:
|
||||
ui.label(
|
||||
RichText::new(gossip_lib::names::pubkey_short(&person.pubkey)).weak(),
|
||||
);
|
||||
GossipUi::render_person_name_line(app, ui, person);
|
||||
GossipUi::render_person_name_line(app, ui, person, false);
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -101,7 +101,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut Frame, ui:
|
||||
);
|
||||
|
||||
if let Ok(Some(person)) = GLOBALS.storage.read_person(&event.pubkey) {
|
||||
GossipUi::render_person_name_line(app, ui, &person);
|
||||
GossipUi::render_person_name_line(app, ui, &person, false);
|
||||
} else {
|
||||
ui.label(event.pubkey.as_bech32_string());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user