Page MenuHomePhabricator

[native] Make `ColorSelector` fully functional
ClosedPublic

Authored by abosh on May 6 2022, 12:28 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jul 5, 3:09 PM
Unknown Object (File)
Fri, Jul 5, 2:38 PM
Unknown Object (File)
Wed, Jul 3, 12:28 AM
Unknown Object (File)
Tue, Jul 2, 9:49 AM
Unknown Object (File)
Sun, Jun 30, 5:56 AM
Unknown Object (File)
Mon, Jun 17, 1:29 PM
Unknown Object (File)
Mon, Jun 17, 9:44 AM
Unknown Object (File)
Thu, Jun 13, 11:32 PM

Details

Summary

Made ColorSelector fully functional: added onPress handling, save buttons for the thread color, and modified the ColorPickerModal height to fit the smaller size of ColorSelector (as opposed to ColorPicker).

Full context in Linear issue. Phasing out ColorPicker can be handled in a future diff. Depends on D3868.

Test Plan

Tested on iOS 15.4 and works as expected:

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

abosh edited the test plan for this revision. (Show Details)
abosh added 1 blocking reviewer(s): atul.
native/chat/settings/color-picker-modal.react.js
58

This is the only change made in ColorPickerModal because it reflects the smaller modal size in the video in the Test Plan.

native/components/color-selector.react.js
37

Opted to make the background color of the button change to the selected color (see in the video in the Test Plan). Currently on web, the button is either #404040 if disabled and purple if not. Not sure if we want to keep it that way (change on native to match web purple) or adopt this style, where the button background color changes based on the selected color.

My rationale was that the color splotch might not be big enough to see the true color, whereas the button provides a larger canvas that a user can use to see the color (with some text in front of it). Plus, it's a color selector — it can be colorful! 😆

native/chat/settings/color-picker-modal.react.js
58

In the final commit, this won't be there because it'll break the current ColorPicker (since it doesn't fit in this new modal size). It's just included so you can see the new size that's in the video in the Test Plan. Not sure if this is the best practice or not, but wanted to include it for transparency.

atul requested changes to this revision.May 9 2022, 11:29 AM

Looks good at a high level, some questions/suggestions inline

native/chat/settings/color-picker-modal.react.js
58

Thanks for pointing this out. We want diffs to be exactly what we plan on landing so it's best to avoid "temporary" accommodating changes.

It's something you should still mention in the "Summary" section or by annotating a line(s) in the diff, but we usually don't want to leave in temporary code changes like this,

native/components/color-selector-button.react.js
10

We actually have a SetState<T> type in lib/types/hook-types.js that we'll want to use here. After importing that type we should have something like:

+setPendingColor: SetState<string>,
19–21

Nice job realizing that we want to memoize this function with the useCallback hook

native/components/color-selector.react.js
33–38

I think we can simplify the logic here:

const saveButtonStyle = React.useMemo(
  () => [
    styles.saveButton,
    { backgroundColor: !saveButtonDisabled ? `#${pendingColor}` : "#404040" },
  ],
  [saveButtonDisabled, pendingColor]
);
40

Should this be onColorSplotchSaved?

This revision now requires changes to proceed.May 9 2022, 11:29 AM
abosh marked 5 inline comments as done.

Address inline feedback

This revision is now accepted and ready to land.May 12 2022, 8:18 AM