Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

feat(@StatusSmartIdenticon): Add support for color rings in StatusSmartIdenticon #553

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

noeliaSD
Copy link
Contributor

@noeliaSD noeliaSD commented Feb 9, 2022

Closes #517

What does the PR do

It has been created a new control StatusIdenticonRing and added it into StatusSmartIdenticon component.

To test the component, the needed properties have been added in sandbox models to display the StatusIdenticonRing control.

NOTE: StatusIdenticonRing provides the following API as a first approach (since we don't have the back-end specs clearly defined yet, when they have it clear we can decide if it is better to manage the data in another format):

  • property var ringSpec: Expected ListModel object to iterate through ring segments. Each segment (ListElement) contains:

    1. The colorId: from 0 to 31 corresponding with the 32 distinctive segment defined in figma and with the order defined there (it should be defined as well in specs).
    2. The segmentType: from 1 to 5 being these integer values the number of units the segment contains.
  • property real totalRingUnits: Total number of units in the segment

  • property real initalAngleRad: Initial angle value in radians

  • property real ringPxSize: Ring thickness

Affected areas

StatusSmartIdenticon component

Screenshot of functionality

Added example in Sandbox:
Screenshot 2022-02-09 at 11 01 48

Copy link
Contributor

@alexandraB99 alexandraB99 left a comment

Choose a reason for hiding this comment

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

lovely PR @noeliaSD ! :) just left a few comment, mostly stuff related to beautification :)


implicitWidth: 40
implicitHeight: 40
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering if this is needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No needed! Removed!

@@ -357,6 +368,8 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I
nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC"
image.isIdenticon: true
isOnline: true
statusListItemIcon.identiconRing.ringSpec: identiconRing1
statusListItemIcon.identiconRing.totalRingUnits: 25
Copy link
Contributor

Choose a reason for hiding this comment

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

just for the sake of beautifying: I imagine that statusListItemIcon is part of StatusListItem and not of StatusMemberListItem because of Mouse events and z order reasons? I was wondering, is there any case we could avoid 'dotdotting' like statusListItemIcon.identiconRing.totalRingUnits: and have something more straight forward like totalRingUnits: instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree with your point of view, however... I don't know which is the best point to expose these properties but giving as much flexibility as possible to the component. StatusListItem is a super flexible component that exposes, I don't know if all, but most of its components and allows you to design a super custom list item.

I'm open to proposals! Maybe it could have sense to add all StatusIdenticonRingproperties as well in StatusSmartIdenticon so in this particular case we'd have something like this:

  • statusListItemIcon.ringSpecs or statusListItemIcon.totalRingUnits

WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

One other way to go about this is to redefine dedicated settings on that higher level comopnent.

For example, right now we do statusListItemIcon.identiconRing.[...], because the SmartIdenticon is exposed on StatusListItem as statusListItemIcon.
To avoid having that very first level required to dot into deeper properties, we could introduce:

// StatusMemberListItem
StatusListItem {
  StatusIdenticonRingSettings identiconRingSettings: StatusIdenticonRingSettings {
    ...
  }
}

Analogue to how we do it for StatusIconSettings and StatusImageSettings.

Inside StatusMemberListItem we then need to delegate the top level IdenticonRingSettings to the underlying statusListItemIcon.identiconRingSettings

^ This also implies that StatusSmartIdenticon would make use StatusIdenticonRingSettings as well.

We're doing this pattern in a few other components already where dotting into object members gets a bit cumbersome.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! It sound like a good idea. Going for that! :)

@@ -347,6 +347,17 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I
requestsCount: 3
}

ListModel {
id: identiconRing1
Copy link
Contributor

Choose a reason for hiding this comment

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

is this model used / going to be used elsewhere? If not, could we assign it directly to the component that's using it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it could be assigned directly!

Copy link
Member

@0x-r4bbit 0x-r4bbit left a comment

Choose a reason for hiding this comment

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

Super cool @noeliaSD !

As @alexandraB99 there's probably room for improvement with regards to developer ergonomics. I've left some thoughts there on how we solved this in other components.

In addition, I think the color ring colors should live in Theme for a few reasons: a) that's just the place where colors are defined and b) we want to ensure these colors work across themes, so every theme should probably be able to define their own ring colors (needed to ensure things like contrast ratio)

@@ -357,6 +368,8 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I
nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC"
image.isIdenticon: true
isOnline: true
statusListItemIcon.identiconRing.ringSpec: identiconRing1
statusListItemIcon.identiconRing.totalRingUnits: 25
Copy link
Member

Choose a reason for hiding this comment

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

One other way to go about this is to redefine dedicated settings on that higher level comopnent.

For example, right now we do statusListItemIcon.identiconRing.[...], because the SmartIdenticon is exposed on StatusListItem as statusListItemIcon.
To avoid having that very first level required to dot into deeper properties, we could introduce:

// StatusMemberListItem
StatusListItem {
  StatusIdenticonRingSettings identiconRingSettings: StatusIdenticonRingSettings {
    ...
  }
}

Analogue to how we do it for StatusIconSettings and StatusImageSettings.

Inside StatusMemberListItem we then need to delegate the top level IdenticonRingSettings to the underlying statusListItemIcon.identiconRingSettings

^ This also implies that StatusSmartIdenticon would make use StatusIdenticonRingSettings as well.

We're doing this pattern in a few other components already where dotting into object members gets a bit cumbersome.

@@ -266,6 +266,8 @@ StatusAppThreePanelLayout {
image.source: model.source
image.isIdenticon: model.isIdenticon
isOnline: model.isOnline
statusListItemIcon.identiconRing.ringSpec: model.ringSpec
statusListItemIcon.identiconRing.totalRingUnits: model.totalRingUnits
Copy link
Member

Choose a reason for hiding this comment

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

This can be reduced to something like

identiconRingSettings.totalRingUnits  // or identicon.totalRingUnits

Depending on how you wanna call that property, using the pattern described in the comment above.


// Badge color properties must be set if badgeItem.visible = true
property alias badge: statusBadge
property alias identiconRing: statusIdenticonRing
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned in the first comment, how about we introduce StatusIdenticonRIngSettings or, alternatively, we extend StatusIconSettings (if we do that, we need to ensure existing usages of StatusIconSettings don't break)

Then we don't need to alias statusIdenticonRing and we can reuse StatusIdenticonRingSettings in StatusMemberListItem and other component that want to leverage those properties.

"#FFFFB0", "#FF5733", "#FF0000", "#9A0000", "#FF9D9D", "#FF0099",
"#C80078", "#FF00FF", "#900090", "#FFB0FF", "#9E00FF", "#0000FF",
"#000086", "#9B81FF", "#3FAEF9", "#9A6600", "#00FFFF", "#008694",
"#C2FFFF", "#00F0B6"]
Copy link
Member

Choose a reason for hiding this comment

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

How do these work across different themes? Have things like contrast ratio been taken into account?

If we know there'll be a max of 32 colors, it probably makes sense for each individual theme to define those, so it's ensured they work well in the theme.

Once that is done, these color would need to be moved to Core.Theme

Copy link
Member

Choose a reason for hiding this comment

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

Oh and they should be added to the design system figma then. We already have a color palette system there. Could introduce an additional section for "verified" colors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is something we should ask @John-44 because as far as I know, colored ring should be unique so don't know if it could be changed, in the perspective of identification, depending on the theme. But surely, these colores are not correct for both views, so yes, it makes more sense to have a pair for each.

Copy link

Choose a reason for hiding this comment

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

@noeliaSD the colours should be the exactly the same across themes e.g. the ring colours shouldn't change when the user changes themes.

Copy link
Contributor Author

@noeliaSD noeliaSD Feb 14, 2022

Choose a reason for hiding this comment

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

Oh and they should be added to the design system figma then. We already have a color palette system there. Could introduce an additional section for "verified" colors.

I think @davholik is working on introducing these colours into the design system file. We can keep it now just as it is and when he finishes, we can create a new task for doing the refactor! WDYT?

And he is working as well in updating these 32 colours to work througth themes without altering them to keep the same identicon ring.

Copy link
Member

Choose a reason for hiding this comment

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

If we really want to tweak the properties by theme it should be done by appropriate client's transform function, e.g. Qt.darker(identiconRingColors[0], 1.15).

So the thing with this is that it really depends on what's the impact of tweaks needed to have those colors work in different themes. Lemme elaborate:

  1. Often times, a color in one theme can't be mapped to another color in a different theme using calculated rules (.e.g Qt.darker(...)). In those cases, the color red in light mode isn't just the same red in a different shade in darkmode, it's actually a different red. We have a good amount of such cases in our color palette which is why our Theme system is so explicit.
  2. I think there's plans to eventually support custom themes, so users will be able to install themes for Status Desktop, in which case the colors provided by status-go might not go well with the theme at all.

I think we have a handful of options with their trade-offs:

  1. We make color rings look exactly the same regardless of what the theme looks like (proposed by @John-44), at the cost of it possibly not being pleasant to the eye in any other theme that wasn't designed with those colors in mind (even in darkmode already those colors look too sharp, which is probably why @davholik wants to tweak them on a per theme basis).
  2. We let the theme decide what those ring colors are, ensuring all colors work well in every theme, however, at the cost of the rings to be hard to recognize/verify across themes (as they might look different)
  3. We drop the idea of supporting custom themes in the future entirely, at which point we'll only need to support light and darkmode colors which can then be either defined in our themes on the client side, or come from status-go (doesn't really matter)

The argument that this can cause inconsistencies across apps (desktop, mobile, etc..) is a good one. Which probably means we'll have to go with 1) or 3)

Copy link
Contributor

@osmaczko osmaczko Feb 15, 2022

Choose a reason for hiding this comment

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

  1. Often times, a color in one theme can't be mapped to another color in a different theme using calculated rules (.e.g Qt.darker(...)).

Yes, that's obvious, but it is not what I meant. I put it in the context, what I wanted to state is:
All colors should come from status-go (and so be the same for every theme) ONLY THEN

If we really want to tweak the properties by theme it should be done by appropriate client's transform function, e.g. Qt.darker(identiconRingColors[0], 1.15).

EDIT:
I am aware that transform functions are not ideal and will bring complexity/platform inconsistency, but I simply see no other way to keep base colors the same and yet make them look good on every theme. Because of that, I would avoid any transformations on identicons' colors palette. Maybe we could come up with a universal color set that will look acceptable on every theme.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. We make color rings look exactly the same regardless of what the theme looks like (proposed by @John-44), at the cost of it possibly not being pleasant to the eye in any other theme that wasn't designed with those colors in mind (even in darkmode already those colors look too sharp, which is probably why @davholik wants to tweak them on a per theme basis).

I opt for this one. Identicon ring is a mechanism for visual Identity representation, it is meant to be consumed subconsciously by the Users. In my opinion, if colors will differ per Theme human brain will not handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taking into account all your comments and since we still have some solutions open, I suggest the following:

  • To make StatusIdenticonRing the most flexible StatusQ component, we can expose the distinctiveColors property as a required property to be set by the consumer. Then we can close the component itself as it is.
  • To manage colors/themes, we can now add the list of colors (all 32 defined in figma) in the Themes (now the same for light and dark) and when we use the component in the demo app, just like we are configuring the model in case of ringSpecsModel property, we can set up an array of the 32 colors (using Themes) we've now defined. So, we will have prepared the definition of colors in different themes (just waiting for the dark mode updates) and we will leave the door open to give the responsibility to the backend to decide which colors are passed to the ring.

WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like a good "best-of-both-worlds" solution - I like it

@iurimatias
Copy link
Member

it looks like blurred, is this an artifact of the screenshot?

@noeliaSD
Copy link
Contributor Author

Pushed some updates adding a ring settings object. Please review @alexandraB99 and @PascalPrecht!

@noeliaSD
Copy link
Contributor Author

it looks like blurred, is this an artifact of the screenshot?

I'm not sure.. It is true that I can see a considerable difference between looking at it in my laptop screen (that it is perfectly defined) but, in the other support screen I have, it seems the pixels are more visible. What about you @alexandraB99 @PascalPrecht ?

Here a test with a ring px size of 2 (instead of the previous one that is 1.5):
Screenshot 2022-02-11 at 10 58 17
Do you appreciate any improvement?

Copy link
Contributor

@alexandraB99 alexandraB99 left a comment

Choose a reason for hiding this comment

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

Looks good to me! (don't hate me for this please :) ) should we already add documentation?

@noeliaSD
Copy link
Contributor Author

Looks good to me! (don't hate me for this please :) ) should we already add documentation?

:) I think it is the best way! Yes I'll check how to do it and add docu, as well, here!

@@ -20,6 +22,13 @@ Loader {
height: 40
}

property StatusIdenticonRingSettings ringSettings: StatusIdenticonRingSettings {
ringSpec: undefined
Copy link
Member

Choose a reason for hiding this comment

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

Just a nitpic: There's no need to define it as undefined here. Leave it out and it'll be undefined as well.

@0x-r4bbit
Copy link
Member

Changes look good to me now! Just need to clarify #553 (comment)

Copy link
Contributor

@osmaczko osmaczko left a comment

Choose a reason for hiding this comment

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

Looks great, good job! There are only few small things that may be improved, see comments below.

@@ -357,6 +357,17 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I
nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC"
image.isIdenticon: true
isOnline: true
ringSettings.ringSpec:
ListModel {
ListElement {colorId: 13; segmentType: 5}
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 rename it to segmentLength, because it is more readable than segmentType, which yells - "I am enum value" 😛

@@ -357,6 +357,17 @@ CExPynn1gWf9bx498P7/nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2I
nzPcxEzGExhBdJGYihtAYQlO+tUZvqrPbqeudo5iJGEJjCE15a3VtodH3q2ImYgiNITTlTdG1nUZ5a92VITQxITFiJmIIjSE0htAYQrMHAAD//+wwFVpz+yqXAAAAAElFTkSuQmCC"
image.isIdenticon: true
isOnline: true
ringSettings.ringSpec:
ListModel {
Copy link
Contributor

Choose a reason for hiding this comment

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

A identicon ring MUST be composed of 5 color segments

According to feature spec, it should contain 5 elements - please consider updating models in demoapp to better reflect the future. Btw. it is great that StatusIdenticonRing is universal and can handle any number of elements!

QtObject {
id: statusIdenticonRingSettings

property var ringSpec // Expected ListModel object to iterate through ring segments
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
property var ringSpec // Expected ListModel object to iterate through ring segments
property var ringSpecModel // [ListElement {colorId: 0; segmentLength: 1}, ...]

Wouldn't it be more readable than a plain text comment? Also added Model postfix to the name of the variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like it! :)


readonly property real segmentRadLen: 2 * Math.PI / settings.totalRingUnits
// 32 distinctive segment: They are expected to be used using the array index from 0 to 31 and with the order defined in figma (it should be defined as well in specs.)
readonly property var distinctiveColors: ["#000000", "#726F6F", "#C4C4C4", "#E7E7E7", "#FFFFFF", "#00FF00",
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 NOT make it read-only. Clients of StatusQ may want to define their own colors.

"#000086", "#9B81FF", "#3FAEF9", "#9A6600", "#00FFFF", "#008694",
"#C2FFFF", "#00F0B6"]

function printArcSegment(context, xPos, yPos, radius, color, startAngle, arcAngleLen, lineWidth) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It does not make much sense to expose it as a public API. Please consider putting this private function into:

QtObject {
    id: d
    function printArcSegment(...) {...}
}

id: d - detail

or defining it inside Canvas component.

@noeliaSD noeliaSD force-pushed the feat/issue-517 branch 3 times, most recently from bf42f87 to 5d8bd38 Compare February 15, 2022 14:53
@noeliaSD
Copy link
Contributor Author

Pushed all changes following your comments. I've also added documentation for the new components. Please @alexandraB99, @PascalPrecht and @osmaczko, take a look!!

Copy link
Member

@0x-r4bbit 0x-r4bbit left a comment

Choose a reason for hiding this comment

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

Very cool, also nice that it has docs!

Copy link
Contributor

@osmaczko osmaczko left a comment

Choose a reason for hiding this comment

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

Great docs!

…tIdenticon

Created new control `StatusIdenticonRing` and used in `StatusSmartIdenticon` component.

Added property assignments in sandbox models to display the `StatusIdenticonRing` when needed.

Added first documentation approach for `StatusIdenticonRing` and `StatusIdenticonRingSettings`.

Closes #517
@noeliaSD noeliaSD merged commit 3b86d13 into master Feb 17, 2022
@noeliaSD noeliaSD deleted the feat/issue-517 branch February 17, 2022 08:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for color rings in StatusSmartIdenticon
7 participants