Reduce time text's size for 12 hour clock

This commit is contained in:
Josh Megnauth 2024-09-01 00:49:42 -04:00
parent 5a7f5dc3b5
commit 70b8cae87e
No known key found for this signature in database
GPG key ID: 70813183462EFAD3

View file

@ -1042,9 +1042,7 @@ impl cosmic::Application for App {
column = column column = column
.push(widget::text::title2(format!("{}", date)).style(style::Text::Accent)); .push(widget::text::title2(format!("{}", date)).style(style::Text::Accent));
// xxx It may be prudent to store the index of the selected user to avoid let (time, time_size) = if self
// searches. This would also simplify logic elsewhere.
let time = if self
.selected_username .selected_username
.data_idx .data_idx
.and_then(|i| { .and_then(|i| {
@ -1055,13 +1053,16 @@ impl cosmic::Application for App {
}) })
.unwrap_or_default() .unwrap_or_default()
{ {
dt.format_localized("%R", locale) (dt.format_localized("%R", locale), 112.0)
} else { } else {
dt.format_localized("%I:%M %P", locale) // xxx format_localized doesn't seem to show am/pm for some languages, such as
// French or Hungarian. This is apparently correct
// Also, time size needs to be reduced a bit here so that it fits on one line
(dt.format_localized("%I:%M %p", locale), 75.0)
}; };
column = column.push( column = column.push(
widget::text(format!("{}", time)) widget::text(format!("{}", time))
.size(112.0) .size(time_size)
.style(style::Text::Accent), .style(style::Text::Accent),
); );