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

IOS-9356 Adjust crouton constraints above the tabbar or the safe area #422

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

L-Trujillo26
Copy link
Contributor

@L-Trujillo26 L-Trujillo26 commented Jan 29, 2025

Warning

Should a designer need to review/verify this PR?

🎟️ Jira ticket

IOS-9356
image-2024-11-07-16-49-23-770

🥅 What's the goal?

The Crouton design is deprecated and replaced with a new design that matches the appearance and behavior of the snackbar, as specified in the Figma:

https://www.figma.com/design/yCHLIfy4WMfRdlADwyL4kZ/%F0%9F%94%B8-Snackbar-Specs?t=bb57Dv8A0XsJVGqF-0

The component name has not yet been changed, but a floating design is implemented that respects the safe area and elements like the TabBar ensuring proper display in the view hierarchy.

🚧 How do we do it?

Design changes have been made(behavior is aligns with the Figma specifications)

🧪 How can I verify this?

MisticaCatalog -> Crouton (UIKit)-> show Crouton

This screenshot shows the Snackbar in SwiftUI and the Crouton in UIKit.
crouton

animationSnackbar.mov

🏑 AppCenter build

https://appcenter.ms/orgs/Tuenti-Organization/apps/Mistica-SwiftUI-iOS/distribute/releases

Copy link

github-actions bot commented Jan 29, 2025

Screenshot tests report

✔️ All passing

@L-Trujillo26
Copy link
Contributor Author

L-Trujillo26 commented Jan 31, 2025

Record screenshots on PR comment: succeeded ✅
https://github.com/Telefonica/mistica-ios/actions/runs/13077931349

Copy link
Contributor

@amegias amegias left a comment

Choose a reason for hiding this comment

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

Really good work!!


directionalLayoutMargins = Constants.margins
private func findTabBar(in view: UIView) -> UITabBar? {
for subview in view.subviews {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid of finding the new tabBar in iPad...
image

https://developer.apple.com/documentation/uikit/elevating-your-ipad-app-with-a-tab-bar-and-sidebar

Could we check if it's a bottom tabBar?

Copy link
Contributor Author

@L-Trujillo26 L-Trujillo26 Feb 13, 2025

Choose a reason for hiding this comment

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

It’s possible to implement a logic to check if a tabBar exists and if it is positioned at the bottom of the device. If this condition isn't met, it would continue searching. I am going to add this logic to prevent cases like this.

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 and added tests


directionalLayoutMargins = Constants.marginsWhenUsingSafeArea
if let tabBar = tabBar, !tabBar.isHidden {
bottomConstraint = bottomAnchor.constraint(equalTo: container.bottomAnchor, constant: -(tabBar.bounds.height + 8))
Copy link
Contributor

Choose a reason for hiding this comment

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

A lot of 8's, I would move it to enum Constants 😄

Comment on lines 268 to 269
} else if hasSafeArea {
bottomConstraint = bottomAnchor.constraint(equalTo: container.safeAreaLayoutGuide.bottomAnchor, constant: -8)
Copy link
Contributor

Choose a reason for hiding this comment

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

this case is repeated in else. Could we merge it?

} else {
let bottomConstraint: NSLayoutConstraint
bottomConstraint = bottomAnchor.constraint(equalTo: container.safeAreaLayoutGuide.bottomAnchor, constant: -8)
Copy link
Contributor

Choose a reason for hiding this comment

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

curious... let me check

Comment on lines +88 to +89
for: [BrandStyle.movistar],
and: [.light],
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks!

}

private extension CroutonTests {
func makeCrouton(withText text: String, actionTitle: String? = nil, style: CroutonStyle) -> UIViewController {
let viewController = CroutonTestViewController(
func makeCrouton(withText text: String, actionTitle: String? = nil, style: CroutonStyle, withTabBar: Bool = false) -> UIViewController {
Copy link
Contributor

Choose a reason for hiding this comment

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

withTabBar: Bool is a bad practice.

  1. It makes you to add an if inside the method -> create two methods then!
  2. we should avoid having if/guard/... in tests. Otherwise we should test our tests 😄

@amegias
Copy link
Contributor

amegias commented Feb 13, 2025

An extra point:
I would remove "all brands" from existing Crouton tests. IMHO, it is more difficult to verify screenshots in the PR. wdyt David/Laura?

@DavidMarinCalleja
Copy link
Contributor

An extra point: I would remove "all brands" from existing Crouton tests. IMHO, it is more difficult to verify screenshots in the PR. wdyt David/Laura?

I don't really have a strong opinion about this because testing “all brand” increases the size of the repo, makes it difficult to check the PR but I'm afraid that removing it will hide some bug. But if you agree we can remove it.

@amegias
Copy link
Contributor

amegias commented Feb 14, 2025

An extra point: I would remove "all brands" from existing Crouton tests. IMHO, it is more difficult to verify screenshots in the PR. wdyt David/Laura?

I don't really have a strong opinion about this because testing “all brand” increases the size of the repo, makes it difficult to check the PR but I'm afraid that removing it will hide some bug. But if you agree we can remove it.

then, we should add test to the palette, etc

Copy link
Contributor

Choose a reason for hiding this comment

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

@L-Trujillo26 I have a doubt, where the crouton is fixed at the end? I mean the view is added to the current view and therefore disappears if we navigate to another site or on the other hand is fixed to the root view of the app and therefore the crouton is fixed even after browsing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a exact UIViewController isn't specified, the crouton will be add to the RootViewController making it visible during navigation. Its persistence depends on the configuration set in the initialization. This behavior has been confirmed with the design team.

Copy link
Contributor

@DavidMarinCalleja DavidMarinCalleja left a comment

Choose a reason for hiding this comment

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

Great job!!

@amegias
Copy link
Contributor

amegias commented Feb 17, 2025

I've created a pet project to test this from UIKit.
It works with:

  • TabBar
  • TabBar where tab1 presents a modal
  • TabBar where tab1 push a VC hidding the tabBar
  • TabBar where tab1 push a VC keeping the tabBar
  • ViewController

I just found this glitch, could you check it please:

bug_dismiss.mp4

@amegias amegias self-requested a review February 17, 2025 11:41
@L-Trujillo26
Copy link
Contributor Author

I've created a pet project to test this from UIKit. It works with:

  • TabBar
  • TabBar where tab1 presents a modal
  • TabBar where tab1 push a VC hidding the tabBar
  • TabBar where tab1 push a VC keeping the tabBar
  • ViewController

I just found this glitch, could you check it please:

bug_dismiss.mp4

This is the animation for the crouton positioned at the bottom. I have updated it to match the snackbar animation (it fades in and out gradually).

Attached video of the Snackbar animation in SwiftUI and UIKit.

animationSnackbar.mov

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.

4 participants