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

Paul/asset gradient #4702

Merged
merged 6 commits into from
Jan 13, 2024
Merged

Paul/asset gradient #4702

merged 6 commits into from
Jan 13, 2024

Conversation

paullinator
Copy link
Member

@paullinator paullinator commented Jan 11, 2024

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

@paullinator paullinator force-pushed the paul/assetGradient branch 2 times, most recently from a29ebbd to 2e80d7c Compare January 12, 2024 09:25
src/types/Theme.ts Show resolved Hide resolved
Comment on lines -6 to -9
// The accent color will override the dot color when it is present.
// To change this behavior, use 'keep' to preserve the dot color or
// 'drop' to remove the dot completely:
accent?: 'keep' | 'drop'
Copy link
Contributor

Choose a reason for hiding this comment

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

Per our discussion, it seems the better approach to lending the theme files the control it may need to respond to certain scene changes is to have background declarations per scene assetBackground, marketsBackground, etc. Each declaration can declare if it wants to use some values provided by the scene such as asset color or some other variables that the scene may procure. If it doesn't make sense that the scene can procure such a value, then the Theme.ts file should parameterize the different background fields with respect to their capabilities; this can be done with a generic prop to ThemeDot.

src/components/ui4/DotsBackground.tsx Outdated Show resolved Hide resolved
src/types/Theme.ts Show resolved Hide resolved
src/util/utils.ts Show resolved Hide resolved
Comment on lines 276 to 279
const scaledColor = multiplyHexColor(iconColor, theme.assetBackgroundColorScale)
backgroundColors[0] = scaledColor
Copy link
Contributor

Choose a reason for hiding this comment

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

This scaling seems like a change rather than a refactor.

Copy link
Member Author

Choose a reason for hiding this comment

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

The scale was hard coded and now is in the theme. The old scaling was based on alpha because there was a flat black background underneath. Now the background is only the gradient so we can't apply an alpha to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see, so it's a way to achieve the ability to darken the background color from the theme file (because it's currently set to #00000000, transparent black). Now we can darken or lighten the value...wait, we can lighten the value if we pass a scale > 1, so clipping is still an issue that should be handled in the "darkenHexColor" function. I'd argue "scaleHexColor" might be a better name because darkening isn't the only use.

src/components/ui4/DotsBackground.tsx Show resolved Hide resolved
src/components/scenes/RequestScene.tsx Show resolved Hide resolved
import { EdgeAsset } from '../types/types'
import { getCurrencyIconUris } from '../util/CdnUris'

export const useIconColor = (edgeAsset: EdgeAsset): string | undefined => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why aren't we using this this TransactionListScene for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because we'd be grabbing the icon color twice. The TxListScene already loads the icon for other purposes so we get the color then.

Copy link
Contributor

Choose a reason for hiding this comment

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

My suggestion was to gut the icon grab out of the CyptoIconUi4 in favor of this hook. But, no worries if not.

Copy link
Contributor

@samholmes samholmes left a comment

Choose a reason for hiding this comment

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

I'm approving this as I think it's ready. The only concern I have is with the hex color function which doesn't clip the color values.

src/types/Theme.ts Show resolved Hide resolved
* @param scaleFactor 0-1 with 0 being black, 1 is unchanged
* @returns darkened hex color string
*/
export const darkenHexColor = (hexColor: string, scaleFactor: number): string => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah this makes a lot more sense. Can we keep the alpha channel for the hexColor?

src/components/ui4/DotsBackground.tsx Show resolved Hide resolved
Comment on lines 276 to 279
const scaledColor = multiplyHexColor(iconColor, theme.assetBackgroundColorScale)
backgroundColors[0] = scaledColor
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see, so it's a way to achieve the ability to darken the background color from the theme file (because it's currently set to #00000000, transparent black). Now we can darken or lighten the value...wait, we can lighten the value if we pass a scale > 1, so clipping is still an issue that should be handled in the "darkenHexColor" function. I'd argue "scaleHexColor" might be a better name because darkening isn't the only use.

src/types/Theme.ts Show resolved Hide resolved
src/components/ui4/DotsBackground.tsx Outdated Show resolved Hide resolved
import { EdgeAsset } from '../types/types'
import { getCurrencyIconUris } from '../util/CdnUris'

export const useIconColor = (edgeAsset: EdgeAsset): string | undefined => {
Copy link
Contributor

Choose a reason for hiding this comment

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

My suggestion was to gut the icon grab out of the CyptoIconUi4 in favor of this hook. But, no worries if not.

@paullinator
Copy link
Member Author

/rebase

paullinator and others added 3 commits January 13, 2024 06:35
This let's specific scenes override the background with a gradient of their choice.

TransactionList overrides by taking the iconColor and scaling it down
This matches more nicely with all the variable/identifier names.
@paullinator paullinator enabled auto-merge January 13, 2024 06:37
@paullinator paullinator disabled auto-merge January 13, 2024 15:36
@paullinator paullinator merged commit 39af328 into develop Jan 13, 2024
1 check passed
@paullinator paullinator deleted the paul/assetGradient branch January 13, 2024 15:36
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.

2 participants