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

Es/chore replace toast with modal #310

Closed
wants to merge 5 commits into from

Conversation

ErikSin
Copy link
Contributor

@ErikSin ErikSin commented May 1, 2024

Replaces android native toast with a bottom sheet.

image

@ErikSin ErikSin requested a review from achou11 May 1, 2024 00:09
Comment on lines -54 to +62
}, [prevRouteNameInStack, CustomHeaderLeft, CustomHeaderLeftClose]);
}, [prevRouteNameInStack, openSheet, navigation]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

eslint told me to take out CustomHeaderLeft and CustomHeaderLeftClose....?

Copy link
Member

Choose a reason for hiding this comment

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

that's correct - they are stable functions under the hood

Copy link
Member

@achou11 achou11 left a comment

Choose a reason for hiding this comment

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

Think there's a good opportunity here to clean up the way that our custom bottom sheet modal is used. It's never been clearly documented, but the original design of the component when i implemented it long ago is that it the BottomSheetModal should (almost) always be co-located with the usage of the useBottomSheetModal() hook. Instead, i'm noticing that custom bottom sheet modal components are including the BottomSheetModal and unnecessarily accepting and passing props that come from the hook in the consuming component. what should be happening is that the bottom sheet contents can/should be componentized when appropriate, and then used as a child of the BottomSheetModal that's being used in the consuming component.

I added a patch that lives on a different branch to demonstrate the ideal usage i'm describing. Diff between this PR and that patch can be found here. the summary of changes in that patch are:

  1. Create a directory called contentVariants that lives in sharedComponents/BottomSheet/. This serves as a collection of sheet content implementations that are geared towards specific usages based on common patterns.
  2. Implement contentVariants/Destructive.tsx, which is a "foundational" sheet content component that is only opinionated about the icons being used to match our design patterns (in this case, the error icon at the top and the delete icon within the destructive button)
  3. Implement contentVariants/ObservationDiscard.tsx, which uses Destructive but is opinionated about the content (e.g. title, description, text in buttons). It accepts callback props that are more semantically meaningful but not functionally different than Destructive (just passed along directly).
  4. Update ObservationEdit/index.tsx and PresetChooser.tsx to use BottomSheetModal and ObservationDiscard
  5. Update SaveTrackScreen.tsx to use BottomSheetModal and Destructive
  6. Remove DiscardModal in its entirety. In its current form (aka prior to this PR), it's a non-useful wrapper. Should've caught that in previous PRs

Comment on lines -54 to +62
}, [prevRouteNameInStack, CustomHeaderLeft, CustomHeaderLeftClose]);
}, [prevRouteNameInStack, openSheet, navigation]);
Copy link
Member

Choose a reason for hiding this comment

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

that's correct - they are stable functions under the hood

Comment on lines +89 to +91
// const handleDetailsPress = React.useCallback(() => {
// navigation.navigate('ObservationDetails', {question: 1});
// }, [navigation]);
Copy link
Member

Choose a reason for hiding this comment

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

remove?

Suggested change
// const handleDetailsPress = React.useCallback(() => {
// navigation.navigate('ObservationDetails', {question: 1});
// }, [navigation]);

@@ -61,17 +27,20 @@ interface SharedBackButtonProps {

type CustomHeaderLeftCloseProps = {
observationId?: string;
openDiscardModal: () => void;
Copy link
Member

Choose a reason for hiding this comment

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

seeing this being added is making me notice the scope creep of this component, but i think addressing that is outside the scope of this PR. can create an issue to provide more details of what a refactor could entail

Comment on lines 121 to 129
<DiscardModal
bottomSheetRef={sheetRef}
isOpen={isOpen}
closeSheet={closeSheet}
title={deleteObservationMessages.discardObservation}
description={deleteObservationMessages.discardObservationDescription}
discardButtonText={deleteObservationMessages.discardObservationButton}
handleDiscard={handleDiscard}
/>
Copy link
Member

Choose a reason for hiding this comment

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

won't this cause issues with the error modal that's also used in this component?

@ErikSin
Copy link
Contributor Author

ErikSin commented May 1, 2024

Closing this to reimplement in a cleaner way.

@ErikSin ErikSin closed this May 1, 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.

2 participants