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

Android-13783 Improve Callout buttons margin #304

Merged
merged 4 commits into from
Sep 26, 2023

Conversation

haynlo
Copy link
Contributor

@haynlo haynlo commented Sep 25, 2023

🥅 What's the goal?

Improve Callout buttons margin. Check 'How can I test this?' section to see the main differences.

🚧 How do we do it?

  • Improve Margins definition for Callout compose Component
  • Remove link buttons horizontal margin

☑️ Checks

  • I updated the documentation, including readmes and wikis. If this is a breaking change, update UPGRADING.md to inform users how to proceed. If no updates are necessary, indicate so.
  • Tested with dark mode.
  • Tested with API 23.

🧪 How can I test this?

Before After Touch target size
actual_bad after_good after_touch_area

@github-actions
Copy link

📱 New catalog for testing generated: Download

Comment on lines +90 to +96
NONE(CalloutView.BUTTONS_CONFIG_NONE),
PRIMARY(CalloutView.BUTTONS_CONFIG_PRIMARY),
PRIMARY_AND_LINK(CalloutView.BUTTONS_CONFIG_PRIMARY_LINK),
PRIMARY_AND_SECONDARY(CalloutView.BUTTONS_CONFIG_PRIMARY_SECONDARY),
SECONDARY(CalloutView.BUTTONS_CONFIG_SECONDARY),
SECONDARY_AND_LINK(CalloutView.BUTTONS_CONFIG_SECONDARY_LINK),
LINK(CalloutView.BUTTONS_CONFIG_LINK),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Align DropDown option names with the catalog Compose ones in order to make it more readable.
https://github.com/Telefonica/mistica-android/blob/main/library/src/main/java/com/telefonica/mistica/compose/callout/Callout.kt#L170

val textStyle: TextStyle,
val height: Dp,
val minWidth: Dp,
val iconSize: Dp,
val progressBarSize: Dp,
val progressBarStroke: Dp,
val contentPadding: Dp,
val horizontalPadding: Dp,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change it to a more accurate name.

ButtonStyle.LINK,
ButtonStyle.LINK_INVERSE,
-> getSmallButtonSizeConfig()
-> getSmallButtonSizeConfig().copy(horizontalPadding = 0.dp)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is one of the reasons why the link button was not fully displayed.
We don't need to apply a horizontal padding because link buttons don't have a drawable background.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this for removing always the horizontal padding of links? Are we sure this is the expected behaviour?

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 should be without padding the first time it was defined, but now I'm thinking that this change can lead to some kind of breaking change... Some people can be using this Button link keeping in mind this padding :(

As you can see in here, the link button doesn't need any extra padding. This is a wrong initial implementation, but you are right, maybe changing this to zero directly is a bit risky.. I'd better comment this in the Teams channel

@github-actions
Copy link

📱 New catalog for testing generated: Download

@@ -117,10 +131,9 @@ fun Callout(
if (dismissable) {
Image(
modifier = Modifier
.padding(start = 16.dp)
Copy link
Contributor Author

@haynlo haynlo Sep 25, 2023

Choose a reason for hiding this comment

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

This was other of the reasons... if close image takes 16dp of start padding, then the entire column will have this padding and therefore affecting to the link button space to be displayed.

In addition, I have verified that this Image don't need an additional start padding it will be space enough between the title and the image.

PrimaryButton(primaryButtonText, onPrimaryButtonClick)
SecondaryButton(secondaryButtonText, onSecondaryButtonClick)
PrimaryButton(
modifier = Modifier.padding(end = 16.dp),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another reason is that we were applying an end padding to all the buttons in Callout (primaries and secondaries).

Now we only apply this padding if there's another button to be displayed on the right, so the secondary button or secondary link button don't need to apply this padding and they can use this space to display de text completely.

@@ -109,7 +109,7 @@ fun ListRowItem(

@ExperimentalMaterialApi
@Composable
fun ListRowItemImp(
private fun ListRowItemImp(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Component implementations should be private.
I will notify other people to check possible breaking changes with that (Latch, Smart-Wifi and Novum have been checked and don't have any).

@haynlo haynlo requested review from a team, dagonco and jeprubio and removed request for a team September 25, 2023 16:37
Comment on lines 145 to 147
modifier: Modifier = Modifier,
text: String?,
onClick: (() -> Unit)? = null
onClick: (() -> Unit)? = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

There are few places in this pr that the optional modifier is set as the first parameter, is this some kind of rule in this project or something? I'm used to set it as the first parameter which is optional but I prefer to set non optional parameters on top, like the Text Composable for example, I would expect to see the text parameter on top.

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 don't think we have a rule here. I always set the optional Modifier first for convenience but I don't have a strong opinion about that; your rule (non-optional first) makes more sense :)

ButtonStyle.LINK,
ButtonStyle.LINK_INVERSE,
-> getSmallButtonSizeConfig()
-> getSmallButtonSizeConfig().copy(horizontalPadding = 0.dp)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this for removing always the horizontal padding of links? Are we sure this is the expected behaviour?

Copy link
Contributor

@jeprubio jeprubio left a comment

Choose a reason for hiding this comment

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

Nice

Copy link
Member

@dagonco dagonco left a comment

Choose a reason for hiding this comment

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

Nice @haynlo! 😇

@haynlo haynlo requested a review from jeprubio September 26, 2023 11:33
@github-actions
Copy link

📱 New catalog for testing generated: Download

Copy link
Contributor

@jeprubio jeprubio left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@@ -62,6 +62,7 @@ fun Button(
enabled: Boolean = true,
@DrawableRes icon: Int? = null,
withChevron: Boolean = false,
invalidatePaddings: Boolean = false,
Copy link
Contributor

@jeprubio jeprubio Sep 26, 2023

Choose a reason for hiding this comment

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

My understanding was that we were going to set a parameter for padding values with a default value and this way it would allow that value to be set from outside, but as that padding value depends on the type of the button that makes everything more messy. I guess this invalidatePaddings makes sense having that into account.

@haynlo haynlo merged commit 641911e into main Sep 26, 2023
4 checks passed
@haynlo haynlo deleted the haynlo/ANDROID-13783_callout_margins branch September 26, 2023 12:06
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.

3 participants