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

Get environment and select resource by qualifiers #4018

Merged
merged 12 commits into from
Dec 20, 2023

Conversation

terrakok
Copy link
Member

@terrakok terrakok commented Dec 8, 2023

No description provided.

@terrakok terrakok force-pushed the k.tskh/res-qualifiers branch from e88fa3d to 5208ef6 Compare December 11, 2023 13:39
@terrakok terrakok force-pushed the k.tskh/res-qualifiers branch from 5208ef6 to 3f0c12e Compare December 12, 2023 16:26
internal actual fun getResourceEnvironment(): ResourceEnvironment {
val locale = Intl.Locale(window.navigator.language)
val isDarkTheme = window.matchMedia("(prefers-color-scheme: dark)").matches
val dpi: Int = (window.devicePixelRatio * 96).toInt()
Copy link
Member

Choose a reason for hiding this comment

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

Let's make 96 a constant, not just magic number. Or extension function for conversion

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add just a comment here. Constant with the only usage is overkill

val displaySizePX = CGDisplayPixelsWide(screenNumber).toFloat() * backingScaleFactor
val displaySizeMM = CGDisplayScreenSize(screenNumber).useContents { width }

//1 inch = 25.4 mm
Copy link
Member

Choose a reason for hiding this comment

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

The same. It's better to have named constant or explicit conversion function

Copy link
Member Author

Choose a reason for hiding this comment

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

why?

Copy link
Member Author

Choose a reason for hiding this comment

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

there is no a reason to have such small granularity

Copy link
Member Author

Choose a reason for hiding this comment

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

Function should be easy readable. Granularity and cleanness are tools for achieve that, not otherwise

items = setOf(ResourceItem(emptySet(), path))
)

/**
* Retrieves a [Painter] using the specified image resource.
* Retrieves a [Painter] using the specified drawable resource.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add more details about file types (extensions) we support.

qualifiersMap[regionQualifier]?.let { q ->
val lang = qualifiersMap[languageQualifier]
if (lang == null) {
error("Region qualifier must be used only with language")
Copy link
Contributor

Choose a reason for hiding this comment

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

May we provide a context here for users to understand where they did mistake?

Copy link
Member Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add dot to the end of the sentence

@terrakok terrakok merged commit 27915cb into master Dec 20, 2023
6 checks passed
@terrakok terrakok deleted the k.tskh/res-qualifiers branch December 20, 2023 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants