Skip to content

Dialog and Modal fix for web #2450

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

Merged
merged 22 commits into from
Mar 13, 2023
Merged

Dialog and Modal fix for web #2450

merged 22 commits into from
Mar 13, 2023

Conversation

adids1221
Copy link
Contributor

@adids1221 adids1221 commented Feb 7, 2023

Description

The picker component supports the web, fixed issues: useDialog mode, Multi-select mode, and TopBar icons fixed.

Changelog

The picker component supports the web, fixed issues: useDialog mode, Multi-select mode, and TopBar icons fixed.

@adids1221 adids1221 requested a review from ethanshar March 8, 2023 15:51
@adids1221 adids1221 marked this pull request as ready for review March 8, 2023 16:39
@@ -290,6 +291,11 @@ class Button extends PureComponent<Props, ButtonState> {
if (typeof iconSource === 'function') {
return iconSource(iconStyle);
} else {
if (Constants.isWeb) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason we're not using Icon all of the time? both for web and mobile?

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, if we will user Icon and the user don't pass any tintColor the Icon will get the default color.
So if we change it to Icon it will break some users.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, we need to migrate to Icon IMO, we can do it v8.
Can you add it to the v8 spreadsheet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done added to the spreadsheet.

Comment on lines 58 to 75
if (typeof source === 'string' && isBase64ImageContent(source) && Constants.isWeb) {
return (
<Image
{...others}
ref={ref}
source={iconSource}
style={[
style,
margins,
iconSize,
shouldFlipRTL && styles.rtlFlipped,
!!tintColor && {
tintColor
}
]}
/>
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this render is exactly the same as the default render at the bottom..

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'll move it into renderImage function.
Should I move the Svg into renderSvg function also?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, it can make a little more organized 👌

Comment on lines 43 to 48
const iconSize = size ? {width: size, height: size} : undefined;
const webIconSize = Constants.isWeb
? {width: size || defaultWebIconSize, height: size || defaultWebIconSize}
: undefined;
const iconSize = size ? {width: size, height: size} : webIconSize;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest encapsulating this logic under a hook for useIconSize. It will handle all the logic and return the final size.
Right now it's getting a little unreadable

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'm not sure if we need to have a hook for this case.

I did refactor to this logic:
const iconSize = Constants.isWeb ? size || defaultWebIconSize : size; return {width: iconSize, height: iconSize};

Since the width and the height get the same size the only thing that matters is the web environment.

If the user is using the web platform let's try to get the size else will get the defaultWebIconSize.

Copy link
Collaborator

@ethanshar ethanshar Mar 13, 2023

Choose a reason for hiding this comment

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

See if you can do something like that when you destruct the size prop from props with a default prop

const {
  size = Constants.isWeb ? defaultWebIconSize : undefined,
  tintColor,
  style,
  .....
} = props;

@adids1221 adids1221 requested a review from ethanshar March 9, 2023 14:27
Copy link
Collaborator

@ethanshar ethanshar left a comment

Choose a reason for hiding this comment

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

I replied to some of the comments, small stuff.
Anyway, approved.

@adids1221 adids1221 merged commit 7d7c8d3 into master Mar 13, 2023
@adids1221 adids1221 deleted the fix/Picker_web_dialog branch March 29, 2023 07:38
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