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

Dialog - add showClose #3192

Merged
merged 6 commits into from
Aug 18, 2024
Merged

Dialog - add showClose #3192

merged 6 commits into from
Aug 18, 2024

Conversation

M-i-k-e-l
Copy link
Contributor

Description

Dialog - add showClose

Changelog

⚠️ Dialog - add showClose

Additional info

None

/**
* The close button props
*/
closeProps?: DialogCloseButton;
Copy link
Collaborator

@Inbal-Tish Inbal-Tish Aug 6, 2024

Choose a reason for hiding this comment

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

'buttonProps' (or 'closeButtonProps') is a better name IMO

*/
visible?: boolean;
closeText?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

'label' is a better name IMO

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just 'label' this is the type of the Dialog's 'closeButtonProps' prop (at the same time it can be ButtonProps type)...

*/
headerProps?: DialogHeaderProps;
textProps?: TextProps;
Copy link
Collaborator

Choose a reason for hiding this comment

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

'labelProps' is a better name IMO

Copy link
Collaborator

Choose a reason for hiding this comment

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

just 'labelProps'

/**
* Whether to show the close button or not
*/
showClose?: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

'visible' (or 'showCloseButton') is a better name IMO

<TouchableOpacity paddingB-s2 row onPress={close}>
<Icon source={Assets.icons.xMedium} tintColor={Colors.white} {...closeProps?.iconProps}/>
<Text recorderTag={'unmask'} text70BO white {...closeProps?.textProps}>
{closeProps?.closeText || 'Close'}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will need to be configured in private to pass an i18n string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's why I added the props (text + text style + icon)

} else {
return (
<>
{headerProps && <DialogHeader {...headerProps}/>}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This part can move to a separate render to remove duplications

@@ -202,8 +213,7 @@ const Dialog = (props: DialogProps, ref: ForwardedRef<DialogImperativeMethods>)
<GestureDetector gesture={panGesture}>
{/* @ts-expect-error should be fixed in version 3.5 (https://github.com/software-mansion/react-native-reanimated/pull/4881) */}
<View {...containerProps} reanimated style={style} onLayout={onLayout} ref={setRef} testID={testID}>
{headerProps && <DialogHeader {...headerProps}/>}
{children}
<DialogContent headerProps={headerProps} children={children}/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is confusing... You're passing 'headerProps' as a prop to the DialogContent that you got from the hook that sets 'headerProps' in the 'DialogContent' it returns... Why not just pass it to the hook with the other props and set it there, only rendering the returned component in the Dialog?
Same as 'children'...

@Inbal-Tish Inbal-Tish assigned M-i-k-e-l and unassigned Inbal-Tish Aug 6, 2024
@M-i-k-e-l M-i-k-e-l requested a review from Inbal-Tish August 7, 2024 06:47
@M-i-k-e-l M-i-k-e-l assigned Inbal-Tish and unassigned M-i-k-e-l Aug 7, 2024
@M-i-k-e-l
Copy link
Contributor Author

@Inbal-Tish ping 🙏

close: () => void;
}

const useDialogCloseButton = (props: InternalDialogCloseButtonProps) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please rename it to useDialogContent as you return the whole content and not just the Button

@Inbal-Tish Inbal-Tish assigned M-i-k-e-l and unassigned Inbal-Tish Aug 13, 2024
@M-i-k-e-l M-i-k-e-l merged commit b4aa69a into master Aug 18, 2024
1 check passed
@M-i-k-e-l M-i-k-e-l deleted the feat/dialog-add-close branch August 18, 2024 07:37
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