-
Notifications
You must be signed in to change notification settings - Fork 572
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
feat(CX-3636): create add to my collection bottom sheet #8631
Conversation
ab4074a
to
558bac0
Compare
@@ -454,6 +454,7 @@ export const modules = defineModules({ | |||
MyProfile, | |||
{ | |||
isRootViewForTabName: "profile", | |||
fullBleed: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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> | ||
)} |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
58bf644
to
f125c7c
Compare
There was a problem hiding this 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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 🤔
src/app/Components/MenuItem.tsx
Outdated
<Text variant="sm-display">{title}</Text> | ||
{!!icon && <Flex flex={1}>{icon}</Flex>} | ||
<Flex flex={7}> | ||
{/* Description */} |
There was a problem hiding this comment.
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...
{/* Description */} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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....
src/app/Components/MenuItem.tsx
Outdated
@@ -59,6 +85,7 @@ export const MenuItem: React.FC<{ | |||
|
|||
<Spacer x={2} /> | |||
|
|||
{/* Value */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
// replace with the right mock | ||
// expect(console.log).toHaveBeenCalledWith("Add Artists") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.log
s will be removed at some point. Probably it's only me who always forgets to remove them 😄
There was a problem hiding this comment.
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. 😆
5357198
to
ba012c9
Compare
There was a problem hiding this 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}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
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 ⬇️ .
Screen Recording
Screen.Recording.2023-05-05.at.16.38.31.mov
PR Checklist
To the reviewers 👀
Changelog updates
Changelog updates
Cross-platform user-facing changes
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.