Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying Sizes and Numbers using Humanize #2762

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

insomnious
Copy link
Collaborator

It's been a long time coming but here goes...

Size (NexusMods.Paths.Size) now has a ReactiveUI IBindingTypeConverter which is globally registered. Whenever a Size is bound to a UI control (normally a TextBlock's Text property) it automatically kicks in.

When SizeComponent is used in a TreeDataGrid, Humanize is directly used without the above converter.

Humanize returns either a single decimal point if 1 GB in size or greater, no decimal points if not.

Numbers can be formatted either by Humanize (if need it to say 1.1k instead of 1123) or by using "N0" format for it to have thousand separators. Generally applied in the code-behind in the OneWayBind's

Should we also be using Humanize if we just want thousand separators ?

image

image

Closes #2372

@insomnious insomnious added this to the SDV Beta Release milestone Feb 27, 2025
@insomnious insomnious requested a review from a team February 27, 2025 15:32
@insomnious insomnious self-assigned this Feb 27, 2025
@insomnious insomnious marked this pull request as ready for review February 27, 2025 15:32
private static string _FormatValue(Size value)
{
var byteSize = ByteSize.FromBytes(value.Value);
return byteSize.Gigabytes < 1 ? byteSize.Humanize("0") : byteSize.Humanize("0.0");
Copy link
Member

@erri120 erri120 Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the expected result here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the size is a gigabyte or more it has 1 decimal place and if not then it displays no decimal places.

@erri120 erri120 removed this from the SDV Beta Release milestone Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Review
Development

Successfully merging this pull request may close these issues.

Use localized string representation of numbers
2 participants