commit ee94f279871b882ee8f3bc771b34627e7f502412
parent 893fd582dcba072cf6b305700a7bad94db82d145
Author: William Casarin <jb55@jb55.com>
Date: Sun, 21 Apr 2024 16:28:12 -0700
profile: add about and username to profile previews
Also adjust colors to match design
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
3 files changed, 38 insertions(+), 25 deletions(-)
diff --git a/src/colors.rs b/src/colors.rs
@@ -2,7 +2,7 @@ use egui::Color32;
pub const PURPLE: Color32 = Color32::from_rgb(0xCC, 0x43, 0xC5);
//pub const DARK_BG: Color32 = egui::Color32::from_rgb(40, 44, 52);
-const GRAY_SECONDARY: Color32 = Color32::from_rgb(0x8A, 0x8A, 0x8A);
+pub const GRAY_SECONDARY: Color32 = Color32::from_rgb(0x8A, 0x8A, 0x8A);
const BLACK: Color32 = Color32::from_rgb(0x00, 0x00, 0x00);
const RED_700: Color32 = Color32::from_rgb(0xC7, 0x37, 0x5A);
const GREEN_700: Color32 = Color32::from_rgb(0x24, 0xEC, 0xC9);
@@ -16,7 +16,7 @@ const DARK_ISH_BG: Color32 = Color32::from_rgb(0x22, 0x22, 0x22);
const SEMI_DARK_BG: Color32 = Color32::from_rgb(0x44, 0x44, 0x44);
const LIGHT_GRAY: Color32 = Color32::from_rgb(0xc8, 0xc8, 0xc8); // 78%
-const MID_GRAY: Color32 = Color32::from_rgb(0xba, 0xba, 0xba); // 72%
+pub const MID_GRAY: Color32 = Color32::from_rgb(0xbd, 0xbd, 0xbd);
const DARKER_GRAY: Color32 = Color32::from_rgb(0xa5, 0xa5, 0xa5); // 65%
const EVEN_DARKER_GRAY: Color32 = Color32::from_rgb(0x89, 0x89, 0x89); // 54%
@@ -93,11 +93,11 @@ pub fn light_color_theme() -> ColorTheme {
selection_color: GREEN_700,
// WINDOW
- window_fill: MID_GRAY,
+ window_fill: Color32::WHITE,
window_stroke_color: DARKER_GRAY,
// NONINTERACTIVE WIDGET
- noninteractive_bg_fill: MID_GRAY,
+ noninteractive_bg_fill: Color32::WHITE,
noninteractive_weak_bg_fill: EVEN_DARKER_GRAY,
noninteractive_bg_stroke_color: DARKER_GRAY,
noninteractive_fg_stroke_color: GRAY_SECONDARY,
diff --git a/src/ui/note/mod.rs b/src/ui/note/mod.rs
@@ -4,8 +4,8 @@ pub mod options;
pub use contents::NoteContents;
pub use options::NoteOptions;
-use crate::{ui, Damus};
-use egui::{Color32, Label, RichText, Sense, TextureHandle, Vec2};
+use crate::{colors, ui, Damus};
+use egui::{Label, RichText, Sense, TextureHandle, Vec2};
pub struct Note<'a> {
app: &'a mut Damus,
@@ -237,17 +237,20 @@ fn render_reltime(
puffin::profile_function!();
ui.horizontal(|ui| {
- let color = Color32::from_rgb(0x8A, 0x8A, 0x8A);
if before {
- ui.add(Label::new(RichText::new("⋅").size(10.0).color(color)));
+ ui.add(Label::new(
+ RichText::new("⋅").size(10.0).color(colors::GRAY_SECONDARY),
+ ));
}
ui.add(Label::new(
RichText::new(note_cache.reltime_str())
.size(10.0)
- .color(color),
+ .color(colors::GRAY_SECONDARY),
));
if !before {
- ui.add(Label::new(RichText::new("⋅").size(10.0).color(color)));
+ ui.add(Label::new(
+ RichText::new("⋅").size(10.0).color(colors::GRAY_SECONDARY),
+ ));
}
})
}
diff --git a/src/ui/profile/preview.rs b/src/ui/profile/preview.rs
@@ -1,6 +1,5 @@
use crate::app_style::NotedeckTextStyle;
-use crate::images;
-use crate::DisplayName;
+use crate::{colors, images, DisplayName};
use egui::load::TexturePoll;
use egui::{RichText, Sense};
use egui_extras::Size;
@@ -66,22 +65,33 @@ impl<'a> ProfilePreview<'a> {
DisplayName::One("??")
};
- match name {
- DisplayName::One(n) => {
- ui.label(RichText::new(n).text_style(NotedeckTextStyle::Heading3.text_style()));
+ crate::ui::padding(12.0, ui, |ui| {
+ match name {
+ DisplayName::One(n) => {
+ ui.label(RichText::new(n).text_style(NotedeckTextStyle::Heading3.text_style()));
+ }
+
+ DisplayName::Both {
+ display_name,
+ username,
+ } => {
+ ui.label(
+ RichText::new(display_name)
+ .text_style(NotedeckTextStyle::Heading3.text_style()),
+ );
+
+ ui.label(
+ RichText::new(format!("@{}", username))
+ .size(12.0)
+ .color(colors::MID_GRAY),
+ );
+ }
}
- DisplayName::Both {
- display_name,
- username,
- } => {
- ui.label(
- RichText::new(display_name)
- .text_style(NotedeckTextStyle::Heading3.text_style()),
- );
- ui.label(RichText::new(format!("@{}", username)));
+ if let Some(about) = profile.record().profile().and_then(|p| p.about()) {
+ ui.label(about);
}
- }
+ });
}
}