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

Wallet Switcher v2 #6318

Open
wants to merge 52 commits into
base: develop
Choose a base branch
from
Open

Wallet Switcher v2 #6318

wants to merge 52 commits into from

Conversation

maxbbb
Copy link
Contributor

@maxbbb maxbbb commented Dec 10, 2024

Fixes APP-2081

Spec: https://www.notion.so/135b001b85b4808cae11f62380e8fc5c

What changed (plus any additional context for devs)

  • Extensions and fixes to the drag and drop component (originally based on this: https://github.com/mgcrea/react-native-dnd).
    • Adds DraggableScrollView and the useDraggableScroll hook that handles auto scrolling when dragging items at the visible edge of the scroll.
    • Refactors offset calculation for DraggableGrid to fix bug related to offsets drifting when interacting too quickly with different draggable items. This fix needs to also be applied to the DraggableScrollView but it would currently break auto scrolling
    • Fixes gesture blocking issues
  • Main changes to previously existing files are to ChangeWalletSheet, WalletList, and AddressRow
  • Adds PinnedWalletsGrid for the grid of up to 6 pinned wallets.
  • Adds zustand store for managing pinned wallets pinnedWalletsStore
  • Extends DropdownMenu component to be usable for non checkmark type items
  • Adds FeatureHintTooltip for general feature hints, API loosely based on Radix Tooltip component.

Review Notes

  • Some of the renaming / file movement didn't get tracked properly. Most everything is new code, but the core functions in the ChangeWalletSheet related to removing, editing, etc. a wallet did not change.

Known Issues

  • When scrolled down at all, the header is not draggable to dismiss the sheet. This problem exists in the current version as well and other panel sheets in the app, don't know why it happens.
  • The dropdown menu steals the onLongPress callback and haptic somehow from the button press animation
  • I cannot reproduce consistently, but a couple times when removing a wallet, the others would get stuck in a state of "balance loading" for the balance label. This is likely not a newly introduced bug, but I have not tested for this in prod.
  • Scroll indicator bottom inset not working
  • The easing gradient on the footer is a stand in for the variable blur on iOS, but is what it will be on Android. Currently the total balance text does not stand out enough on top of it, the design of this should be rethought a little.

Potential follow up improvements

  • Calculate exact height of sheet and animate height changes when pinned / unpinned sections change in length.
  • Add feature to drag and drop component that clones children and animates away removed children and animates remaining children to new resting offsets. Currently, when the number of children in a Draggable changes, all the offsets of the remaining children are reset with no animation.
  • Use useSyncSharedValue for editMode so AddressRow layout transitions can be smoothly animated
  • Custom gesture handler to animate height from initial smaller snap point to large snap point before the scrollview gesture can begin activation
  • Integrate variable blur package and replace the footer's EasingGradient with a BlurView on iOS.
  • The "Wallet Settings" option in the Dropdown menu currently takes you to the general wallets and backup setting page, as that page is not currently setup to handle deep linking to a specific wallet.
  • Copy toast when context menu copy address is pressed
  • The DndProvider currently does some custom handling of the pan gesture starting, which it should not. This is the source of some issues where pressing on the item gives haptic feedback indicating its ready to drag but it cannot be dragged because the gesture actually failed.

Screen recordings / screenshots

RPReplay_Final1734630484.MP4

What to test

  • You should start off with an initial set of pinned wallets (if you have any that you have imported). Which ones get default pinned is based on rainbow originated transactions, which is currently returned as a placeholder number from the backend until it is implemented.
  • Switching to different wallets
  • Adding new wallet
  • Pinning & unpinning
  • Long pressing wallet items in non edit mode for new context menu
  • Dragging around different accounts then unpinning / pinning them

Copy link

linear bot commented Dec 10, 2024

@maxbbb maxbbb marked this pull request as ready for review December 19, 2024 17:55
@brunobar79
Copy link
Member

Launch in simulator or device for ad15b67

@brunobar79 brunobar79 added the release for release blockers and release candidate branches label Dec 19, 2024
@derHowie derHowie self-requested a review December 19, 2024 22:23
@maxbbb maxbbb requested a review from walmat December 19, 2024 22:30
@brunobar79
Copy link
Member

Launch in simulator or device for e540cc4

Copy link
Contributor

@walmat walmat left a comment

Choose a reason for hiding this comment

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

this is some great work. Noticed a couple things while messing around with it. Some are nitpicks, only one major issue I saw.

Comment on lines +94 to +98
if (data !== undefined) {
(onPressMenuItem as (actionKey: T, data: U) => void)(actionKey, data);
} else {
(onPressMenuItem as (actionKey: T) => void)(actionKey);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nice 💯

Copy link
Contributor

Choose a reason for hiding this comment

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

Great animation! Unrelated to this PR, but just popped into my head. We should come up with a strategy for reducing animations when a user has Accessibility > Reduced Motion toggled to on.

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 believe reanimated handles the reduced motion system setting by default: https://docs.swmansion.com/react-native-reanimated/docs/guides/accessibility/

Comment on lines +103 to +104
const MenuItemComponent = menuItemType === 'checkbox' ? DropdownMenuCheckboxItem : DropdownMenuItem;

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm actually not sure we ever need to use the bare DropdownMenuItem. Can't we optimistically assume it's a DropdownMenuCheckboxItem and just not show the checkmark by setting value={undefined}? Unsure, but worth trying if it simplifies this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On Android an empty checkbox gets automatically added when using the DropdownMenuCheckboxItem. The value prop is required for DropdownMenuCheckboxItem and can't be set to undefined. I could change it to assume undefined value types should use the other component, but I don't think there is a way tot get around needing to conditionally use the DropdownMenuCheckboxItem or DropdownMenuItem

return (
<Animated.ScrollView
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
/>
);
}}
viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}
// viewabilityConfig={{ itemVisiblePercentThreshold: 50 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

commented out on purpose?

Copy link
Contributor Author

@maxbbb maxbbb Dec 20, 2024

Choose a reason for hiding this comment

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

Yeah this component actually isn't used at all, and if you wanted to use it with the viewability exposed properly there would need to be some more work so just commented out to better indicate that

@walmat
Copy link
Contributor

walmat commented Dec 20, 2024

#nitpick but the snapping back to origin seems slow to me and the spring seems spongy.
https://github.com/user-attachments/assets/1ae3c3de-0397-447a-ba55-a86cffc2d945

@walmat
Copy link
Contributor

walmat commented Dec 20, 2024

Not sure if intentional, but I had 2 wallets that weren't read only, and 2 that were, and only 2 wallets got pinned.
Screenshot 2024-12-20 at 10 24 34 AM

@walmat
Copy link
Contributor

walmat commented Dec 20, 2024

Only blocker, total wallet balance at the bottom for me is $NaN. Happy to help investigate if needed!
Screenshot 2024-12-20 at 10 24 10 AM

@maxbbb
Copy link
Contributor Author

maxbbb commented Dec 20, 2024

  1. Agreed, tweaked it
  2. Yes that is intentional, was in the spec to not auto pin watched wallets
  3. Fixed the NaN thing, was a bug in the addDisplay utility function

@brunobar79
Copy link
Member

Launch in simulator or device for 35bd715

@brunobar79
Copy link
Member

Launch in simulator or device for e425d4b

@jinchung jinchung removed the release for release blockers and release candidate branches label Dec 20, 2024
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