Merge commit '7792737da7602afd0ddd77ae869758d988b558a3' into unstable

This commit is contained in:
Mike Dilger 2024-04-15 10:00:22 +12:00
commit 6b5305603c
6 changed files with 40 additions and 15 deletions

View File

@ -36,7 +36,7 @@ impl AuthRequest {
}
}
const TRUNC: f32 = 280.0;
const TRUNC: f32 = 320.0;
impl<'a> Notification<'a> for AuthRequest {
fn timestamp(&self) -> u64 {
@ -76,7 +76,7 @@ impl<'a> Notification<'a> for AuthRequest {
.horizontal(|mut strip| {
strip.cell(|ui| {
// FIXME pull account name with self.account once multiple keys are supported
ui.label("Authenticate to");
ui.label("Authenticate to:");
if widgets::relay_url(ui, theme, &self.relay)
.on_hover_text("Edit this Relay in your Relay settings")
.clicked()

View File

@ -38,6 +38,14 @@ impl ConnRequest {
/// width needed for action section
const TRUNC: f32 = 280.0;
fn reasons_color(theme: &Theme) -> Color32 {
if theme.dark_mode {
theme.amber_400()
} else {
theme.amber_500()
}
}
impl<'a> Notification<'a> for ConnRequest {
fn timestamp(&self) -> u64 {
self.timestamp
@ -74,13 +82,14 @@ impl<'a> Notification<'a> for ConnRequest {
.map(|j| format!("{:?}", j.reason))
.collect();
let panel_width = ui.available_width();
StripBuilder::new(ui)
.size(Size::remainder())
.size(Size::initial(TRUNC))
.cell_layout(Layout::left_to_right(Align::Center).with_main_wrap(true))
.horizontal(|mut strip| {
strip.cell(|ui| {
ui.label("Connect to");
ui.label("Connect to:");
if widgets::relay_url(ui, theme, &self.relay)
.on_hover_text("Edit this Relay in your Relay settings")
.clicked()
@ -88,6 +97,11 @@ impl<'a> Notification<'a> for ConnRequest {
new_page = Some(Page::RelaysKnownNetwork(Some(self.relay.clone())));
}
if panel_width < 720.0 {
ui.end_row();
} else {
ui.add_space(20.0);
}
if self.jobs.len() > 1 {
ui.label(RichText::new("Reasons:"));
} else {
@ -98,10 +112,10 @@ impl<'a> Notification<'a> for ConnRequest {
if i + 1 < jobstrs.len() {
ui.label(
RichText::new(format!("{},", job))
.color(theme.accent_complementary_color()),
.color(reasons_color(theme)),
);
} else {
ui.label(RichText::new(job).color(theme.accent_complementary_color()));
ui.label(RichText::new(job).color(reasons_color(theme)));
}
}
});

View File

@ -236,7 +236,7 @@ pub(super) fn draw_icons(app: &mut GossipUi, ui: &mut Ui) {
FontSelection::Default,
Align::LEFT,
);
RichText::new(format!("{:3}", num_notifications))
RichText::new(format!("{:2}", num_notifications))
.color(num_color)
.append_to(
&mut layout_job,
@ -282,7 +282,7 @@ pub(super) fn draw_icons(app: &mut GossipUi, ui: &mut Ui) {
FontSelection::Default,
Align::LEFT,
);
RichText::new(format!("{:3}", app.notification_data.num_notif_relays))
RichText::new(format!("{:2}", app.notification_data.num_notif_relays))
.color(num_color)
.append_to(
&mut layout_job,
@ -328,7 +328,7 @@ pub(super) fn draw_icons(app: &mut GossipUi, ui: &mut Ui) {
FontSelection::Default,
Align::LEFT,
);
RichText::new(format!("{:3}", app.notification_data.num_notif_pending))
RichText::new(format!("{:2}", app.notification_data.num_notif_pending))
.color(num_color)
.append_to(
&mut layout_job,

View File

@ -83,6 +83,9 @@ impl ThemeDef for DefaultTheme {
fn amber_400() -> Color32 {
Color32::from_rgb(0xfb, 0xbf, 0x24)
} // #FBBF24
fn amber_500() -> Color32 {
Color32::from_rgb(0xf5, 0x92, 0x0b)
} // #f59e0b
fn accent_color(dark_mode: bool) -> Color32 {
if dark_mode {

View File

@ -206,6 +206,12 @@ macro_rules! theme_dispatch {
}
}
pub fn amber_500(&self) -> Color32 {
match self.variant {
$( $variant => $class::amber_500(), )+
}
}
pub fn accent_color(&self) -> Color32 {
match self.variant {
$( $variant => $class::accent_color(self.dark_mode), )+
@ -537,6 +543,7 @@ pub trait ThemeDef: Send + Sync {
fn lime_500() -> Color32;
fn amber_100() -> Color32;
fn amber_400() -> Color32;
fn amber_500() -> Color32;
// Used for strokes, lines, and text in various places
fn accent_color(dark_mode: bool) -> Color32;

View File

@ -116,13 +116,14 @@ pub fn truncated_label(ui: &mut Ui, text: impl Into<WidgetText>, max_width: f32)
/// Display a relay-URL
pub fn relay_url(ui: &mut Ui, theme: &Theme, url: &RelayUrl) -> Response {
let (symbol, color) = if url.as_url_crate_url().scheme() == "wss" {
("\u{1F512}", theme.accent_color())
let (symbol, color, spacer) = if url.as_url_crate_url().scheme() != "wss" {
("\u{00A0}\u{00A0}\u{1F513}", theme.red_500(), "\u{00A0}\u{00A0}\u{00A0}")
} else {
("\u{1F513}", theme.red_500())
("", theme.accent_color(), "")
};
let text = format!(
"\u{00A0}\u{00A0}{}",
"{}{}",
spacer,
url.as_url_crate_url().domain().unwrap_or_default()
);
let response = ui.link(text);