mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 16:31:18 +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,16 +1115,22 @@ impl GossipUi {
|
||||
};
|
||||
|
||||
let tag_name_menu = {
|
||||
let text = match &person.petname {
|
||||
Some(pn) => pn.to_owned(),
|
||||
None => gossip_lib::names::tag_name_from_person(person),
|
||||
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 ui.button("View Person").clicked() {
|
||||
app.set_page(Page::Person(person.pubkey));
|
||||
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() {
|
||||
@ -1183,23 +1189,25 @@ impl GossipUi {
|
||||
.on_hover_text("followed");
|
||||
}
|
||||
|
||||
if let Some(mut nip05) = person.nip05().map(|s| s.to_owned()) {
|
||||
if nip05.starts_with("_@") {
|
||||
nip05 = nip05.get(2..).unwrap().to_string();
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
ui.with_layout(
|
||||
Layout::left_to_right(Align::Min)
|
||||
.with_cross_align(Align::Center)
|
||||
.with_cross_justify(true),
|
||||
|ui| {
|
||||
if person.nip05_valid {
|
||||
ui.label(RichText::new(nip05).monospace().small());
|
||||
} else {
|
||||
ui.label(RichText::new(nip05).monospace().small().strikethrough());
|
||||
}
|
||||
},
|
||||
);
|
||||
ui.with_layout(
|
||||
Layout::left_to_right(Align::Min)
|
||||
.with_cross_align(Align::Center)
|
||||
.with_cross_justify(true),
|
||||
|ui| {
|
||||
if person.nip05_valid {
|
||||
ui.label(RichText::new(nip05).monospace().small());
|
||||
} else {
|
||||
ui.label(RichText::new(nip05).monospace().small().strikethrough());
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -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,63 +34,51 @@ 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
|
||||
let avatar = if let Some(avatar) = app.try_get_avatar(ctx, &pubkey) {
|
||||
avatar
|
||||
} else {
|
||||
app.placeholder_avatar.clone()
|
||||
};
|
||||
ui.add(
|
||||
Image::new(&avatar)
|
||||
.max_size(Vec2 {
|
||||
x: AVATAR_SIZE_F32 * 3.0,
|
||||
y: AVATAR_SIZE_F32 * 3.0,
|
||||
})
|
||||
.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.horizontal(|ui| {
|
||||
ui.add_space(12.0);
|
||||
ui.label("Pet name:");
|
||||
if app.editing_petname {
|
||||
let edit_color = app.theme.input_text_color();
|
||||
ui.add(TextEdit::singleline(&mut app.petname).text_color(edit_color));
|
||||
if ui.button("save").clicked() {
|
||||
let mut person = person.clone();
|
||||
person.petname = Some(app.petname.clone());
|
||||
if let Err(e) = GLOBALS.storage.write_person(&person, None) {
|
||||
GLOBALS.status_queue.write().write(format!("{}", e));
|
||||
}
|
||||
app.editing_petname = false;
|
||||
app.notes.cache_invalidate_person(&person.pubkey);
|
||||
}
|
||||
if ui.button("cancel").clicked() {
|
||||
app.editing_petname = false;
|
||||
}
|
||||
if ui.button("remove").clicked() {
|
||||
let mut person = person.clone();
|
||||
person.petname = None;
|
||||
if let Err(e) = GLOBALS.storage.write_person(&person, None) {
|
||||
GLOBALS.status_queue.write().write(format!("{}", e));
|
||||
}
|
||||
app.editing_petname = false;
|
||||
app.notes.cache_invalidate_person(&person.pubkey);
|
||||
}
|
||||
} else {
|
||||
match &person.petname {
|
||||
Some(pn) => {
|
||||
ui.label(pn);
|
||||
if ui.button("edit").clicked() {
|
||||
app.editing_petname = true;
|
||||
app.petname = pn.to_owned();
|
||||
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 {
|
||||
x: AVATAR_SIZE_F32 * 3.0,
|
||||
y: AVATAR_SIZE_F32 * 3.0,
|
||||
})
|
||||
.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)));
|
||||
ui.add_space(10.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Pet name:");
|
||||
if app.editing_petname {
|
||||
let edit_color = app.theme.input_text_color();
|
||||
ui.add(TextEdit::singleline(&mut app.petname).text_color(edit_color));
|
||||
if ui.button("save").clicked() {
|
||||
let mut person = person.clone();
|
||||
person.petname = Some(app.petname.clone());
|
||||
if let Err(e) = GLOBALS.storage.write_person(&person, None) {
|
||||
GLOBALS.status_queue.write().write(format!("{}", e));
|
||||
}
|
||||
app.editing_petname = false;
|
||||
app.notes.cache_invalidate_person(&person.pubkey);
|
||||
}
|
||||
if ui.button("cancel").clicked() {
|
||||
app.editing_petname = false;
|
||||
}
|
||||
if ui.button("remove").clicked() {
|
||||
let mut person = person.clone();
|
||||
@ -98,23 +86,71 @@ fn content(app: &mut GossipUi, ctx: &Context, ui: &mut Ui, pubkey: PublicKey, pe
|
||||
if let Err(e) = GLOBALS.storage.write_person(&person, None) {
|
||||
GLOBALS.status_queue.write().write(format!("{}", e));
|
||||
}
|
||||
app.editing_petname = false;
|
||||
app.notes.cache_invalidate_person(&person.pubkey);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
ui.label(RichText::new("none").italics());
|
||||
if ui.button("add").clicked() {
|
||||
app.editing_petname = true;
|
||||
app.petname = "".to_owned();
|
||||
} else {
|
||||
match &person.petname {
|
||||
Some(pn) => {
|
||||
ui.label(pn);
|
||||
if ui.button("edit").clicked() {
|
||||
app.editing_petname = true;
|
||||
app.petname = pn.to_owned();
|
||||
}
|
||||
if ui.button("remove").clicked() {
|
||||
let mut person = person.clone();
|
||||
person.petname = None;
|
||||
if let Err(e) = GLOBALS.storage.write_person(&person, None) {
|
||||
GLOBALS.status_queue.write().write(format!("{}", e));
|
||||
}
|
||||
app.notes.cache_invalidate_person(&person.pubkey);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
ui.label(RichText::new("none").italics());
|
||||
if ui.button("add").clicked() {
|
||||
app.editing_petname = true;
|
||||
app.petname = "".to_owned();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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