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

feat(CX-3636): create add to my collection bottom sheet #8631

Merged

Conversation

MounirDhahri
Copy link
Member

@MounirDhahri MounirDhahri commented May 5, 2023

This PR resolves CX-3636

Description

This PR adds "Add to my collection" bottom sheet inside my collection. It also lays the foundation of the future work around the bottom sheet modal.

For easier review, I recommend hiding spaces like below ⬇️ .
Screenshot 2023-05-05 at 16 47 44


Screen Recording

Screen.Recording.2023-05-05.at.16.38.31.mov

PR Checklist

  • I have tested my changes on iOS and Android.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos, or I have not changed the UI.
  • I have added tests, or my changes don't require any.
  • I added an app state migration, or my changes do not require one.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added a changelog entry below, or my changes do not require one.

To the reviewers 👀

  • I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates

Changelog updates

Cross-platform user-facing changes

  • Create Add to my collection bottom sheet - mounir

iOS user-facing changes

Android user-facing changes

Dev changes

Need help with something? Have a look at our docs, or get in touch with us.

@MounirDhahri MounirDhahri force-pushed the feat/CX-3636/create-add-to-my-collection-bottom-sheet branch 2 times, most recently from ab4074a to 558bac0 Compare May 5, 2023 14:41
@@ -454,6 +454,7 @@ export const modules = defineModules({
MyProfile,
{
isRootViewForTabName: "profile",
fullBleed: true,
Copy link
Member Author

Choose a reason for hiding this comment

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

this was needed to avoid having a white status bar as we have inside the career highlights.
Example:
Screenshot 2023-05-05 at 16 50 37

Fwiw, I added a top padding later inside the screen to make sure we don't cover the sticky tabs header

@@ -1,5 +1,5 @@
import { BottomSheetModal, BottomSheetModalProps } from "@gorhom/bottom-sheet"
import { ArtworkListsBottomSheetBackdrop } from "app/Components/ArtworkLists/components/ArtworkListsBottomSheetBackdrop"
import { DefaultBottomSheetBackdrop } from "app/Components/BottomSheet/DefaultBottomSheetBackdrop"
Copy link
Member Author

Choose a reason for hiding this comment

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

Since we no longer use this only inside artwork list, I extracted the component outside

import Animated, { Extrapolate, interpolate, useAnimatedStyle } from "react-native-reanimated"

const MAX_OPACITY = 0.5
const MAX_OPACITY = 0.4
Copy link
Member Author

Choose a reason for hiding this comment

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

this was not following the design requirements - I fixed it

interface DefaultBottomSheetBackdrop extends BottomSheetBackdropProps {
onClose?: () => void
// set to "close" to close the bottom sheet when the backdrop is pressed
pressBehavior?: "close"
Copy link
Member Author

Choose a reason for hiding this comment

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

using this behavior here to match the default BottomSheetBackdrop from the bottom sheet package. probably an overkill but I see no harm and it doesn't affect the code readability

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea 👍

@@ -30,5 +39,15 @@ export const ArtworkListsBottomSheetBackdrop = ({
[style, containerAnimatedStyle]
)

return <Animated.View style={containerStyle} />
return (
<TouchableWithoutFeedback
Copy link
Member Author

Choose a reason for hiding this comment

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

using a touchable without feedback here because it's a common pattern for drawers

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should use Palette's Touchable component with noFeedback prop set to true here 🤔

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 actually used that initially but reverted it later. Main reason behind my thinking was that we currently use Touchable for buttons and the backdrop in this case is a view that accepts touches. I wanted therefore to not use any abstraction around it to avoid changing its behaviour in case we extend the Touchable component later.
This seems to be the pattern used in Instagram as well

RPReplay_Final1683533203.1.mp4

<Flex ml={1} justifyContent="center">
{chevron}
</Flex>
)}
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 tested all the changes above in the surface areas that I know we are using the menu item and nothing seems to have break


it("renders nothing", () => {
const { getByText } = renderWithWrappers(<TestRenderer />)
expect(() => getByText("Add to My Collection")).toThrow()
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 think this has potential to be improved but I would rather do that later when we add the remaining code the bottom sheet modal


export const MyCollectionTabsStore = createContextStore((injections) => ({
...myCollectionTabsStoreModel,
...injections,
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 needed injections here to make testing the component easier

selectedTab: null,
view: null,
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 trigger showing the modal from the stickytabs + we need the bottomsheet to be next to the main page (my collection), I am using a store here to display the right content.
As we build more on top of this, we might need to switch to inject jsx into this context store as we do for the sticky tab page but I will leave that to when we get there

@MounirDhahri MounirDhahri changed the title feat(CX-3636): create add to my collection bottom sheet [WIP] feat(CX-3636): create add to my collection bottom sheet May 5, 2023
@MounirDhahri MounirDhahri force-pushed the feat/CX-3636/create-add-to-my-collection-bottom-sheet branch from 58bf644 to f125c7c Compare May 5, 2023 15:16
@MounirDhahri MounirDhahri marked this pull request as ready for review May 5, 2023 15:16
olerichter00
olerichter00 previously approved these changes May 8, 2023
Copy link
Contributor

@olerichter00 olerichter00 left a comment

Choose a reason for hiding this comment

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

Great work 🌟

interface DefaultBottomSheetBackdrop extends BottomSheetBackdropProps {
onClose?: () => void
// set to "close" to close the bottom sheet when the backdrop is pressed
pressBehavior?: "close"
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea 👍

@@ -30,5 +39,15 @@ export const ArtworkListsBottomSheetBackdrop = ({
[style, containerAnimatedStyle]
)

return <Animated.View style={containerStyle} />
return (
<TouchableWithoutFeedback
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should use Palette's Touchable component with noFeedback prop set to true here 🤔

<Text variant="sm-display">{title}</Text>
{!!icon && <Flex flex={1}>{icon}</Flex>}
<Flex flex={7}>
{/* Description */}
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably not needed and it's followed by the title...

Suggested change
{/* Description */}

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 always find it easier to use blocks of comments to separate large pieces of logic inside big components. I feel it makes it easier for the next dev to know what is what without reading the code (which is why I added these comments). I will remove it here since we would like to get this out before sprint starting, can discuss it further tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense 👍 I was just confused because the comment {/* Description */} is followed by the implementation of the title and not the description....

@@ -59,6 +85,7 @@ export const MenuItem: React.FC<{

<Spacer x={2} />

{/* Value */}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Comment on lines 26 to 27
// replace with the right mock
// expect(console.log).toHaveBeenCalledWith("Add Artists")
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: What do you think about adding TODO: here? This would give some editors the change to highlight the comment to make it more visible (+ Jira integration etc.).

Screenshot 2023-05-08 at 09 47 14

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea - will do it now. I have the same integration as well, it's useful to take advtange of it


fireEvent(addArworksButton, "onPress")

// Will add this test later
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, this is a todo for the next person building the add artworks flow 😄

title="Add Artists"
description="List the artists in your collection."
onPress={() => {
console.log("Add Artists")
Copy link
Contributor

Choose a reason for hiding this comment

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

👀

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 have this intentionally here Ole to make it easier to find it for future work by looking in the project. @dariakoko is already working on it. None of this code is available in prod of course.
I sometimes use TODO:// or simple console log it to make it easier to look for the button. I can gladly change this of course

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, this will be implemented in the next step anyway 💡

I like the idea of adding an additional TODO: to make sure these console.logs will be removed at some point. Probably it's only me who always forgets to remove them 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Same. I always forget these logs. 😆

@MounirDhahri MounirDhahri force-pushed the feat/CX-3636/create-add-to-my-collection-bottom-sheet branch from 5357198 to ba012c9 Compare May 8, 2023 08:28
@MounirDhahri MounirDhahri added the Squash On Green A label to indicate that Peril should squash-merge this PR when all statuses are green label May 8, 2023
@artsy-peril artsy-peril bot merged commit 7231d31 into main May 8, 2023
@artsy-peril artsy-peril bot deleted the feat/CX-3636/create-add-to-my-collection-bottom-sheet branch May 8, 2023 08:38
Copy link
Contributor

@lordkiz lordkiz left a comment

Choose a reason for hiding this comment

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

🚢 🚀

<Flex>
<Text variant="sm-display">{title}</Text>
{!!icon && <Flex flex={1}>{icon}</Flex>}
<Flex flex={7}>
Copy link
Member

Choose a reason for hiding this comment

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

I believe this change broke the Account Settings screen 😬

image

Was the flex={7} intentional? or would it be okay to remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

it was intentional to define how much screen estate to cover

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Jira Synced Squash On Green A label to indicate that Peril should squash-merge this PR when all statuses are green
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants