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

Add FXIOS-8383 [V124] Add a Custom Autofill Accessory View Supporting Credit Cards and Addresses #18584

Merged
merged 10 commits into from
Feb 7, 2024

Conversation

jnrahme
Copy link
Contributor

@jnrahme jnrahme commented Feb 6, 2024

📜 Tickets

Jira ticket
Github issue

💡 Description

Created a versatile and reusable custom accessory view adhering to Figma designs. The accessory view should allow customization with images, text, and actions, offering flexibility for various use cases.

📝 Checklist

You have to check all boxes before merging

  • Filled in the above information (tickets numbers and description of your work)
  • Updated the PR name to follow our PR naming guidelines
  • Wrote unit tests and/or ensured the tests suite is passing
  • When working on UI, I checked and implemented accessibility (minimum Dynamic Text and VoiceOver)
  • If needed I updated documentation / comments for complex code and public methods

@jnrahme jnrahme requested a review from a team as a code owner February 6, 2024 01:11
@jnrahme jnrahme requested a review from nbhasin2 February 6, 2024 01:11
@jnrahme jnrahme changed the title Add FXIOS-8484 [V124] Add a Custom Autofill Accessory View Supporting Credit Cards and Addresses Add FXIOS-8383 [V124] Add a Custom Autofill Accessory View Supporting Credit Cards and Addresses Feb 6, 2024
@nbhasin2 nbhasin2 requested review from cyndichin, dataports and razvanlitianu and removed request for dataports February 6, 2024 15:31
@cyndichin
Copy link
Contributor

could you also provide screenshots to the PR so I can compare if I see the same? thank you :)

Comment on lines 39 to 47
/// Tint color for the accessory image view.
var accessoryImageViewTintColor: UIColor? {
get {
return accessoryImageView.tintColor
}
set {
accessoryImageView.tintColor = newValue
}
}
Copy link
Contributor

@cyndichin cyndichin Feb 6, 2024

Choose a reason for hiding this comment

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

what do you think about making this view ThemeApplicable and setting the tintColor in applyTheme so that we're following this consistent pattern throughout the app? same for backgroundColor

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 was having the parent View AccessoryViewProvider take care of theming, not sure what the best practices for this is

/// # Methods
/// - `init(image:labelText:tappedAction:)`: Initializes the accessory view with an image, label, and optional tap action.
/// - `tappedAccessoryButton()`: Handles the tap action on the accessory view.
class AutofillAccessoryView: UIBarButtonItem {
Copy link
Contributor

@nbhasin2 nbhasin2 Feb 6, 2024

Choose a reason for hiding this comment

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

@jnrahme This seems like an over-engineered approach to having the button item when we can use a small factory method in the same class.

Not sure how this helps?

Edit: Just saw how you are using this!

Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
class AutofillAccessoryView: UIBarButtonItem {
class AutofillAccessoryViewButtonItem: UIBarButtonItem {

}

self.useAccessoryTextLabel = .build { label in
label.font = DefaultDynamicFontHelper.preferredFont(withTextStyle: .title3, size: UX.fontSize, weight: .medium)
Copy link
Contributor

@cyndichin cyndichin Feb 6, 2024

Choose a reason for hiding this comment

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

I also see this styling in the Figma for "Use saved address": iOS/Regular/Body, where do I confirm that it's title3 and medium?

image

Copy link
Contributor

@nbhasin2 nbhasin2 Feb 6, 2024

Choose a reason for hiding this comment

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

Before After
Before After

This will create a table with two columns, each containing an image. Adjust the image URLs and width as needed.

@cyndichin its funny how I was looking at the same thing but in dark mode ha

Btw we should increase the hit area @jnrahme if possible and also add tint, I believe the button should have a tint when pressed as its current implementation has none

And the alignment seems off 🤔

Copy link
Contributor

@cyndichin cyndichin left a comment

Choose a reason for hiding this comment

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

discussed the rest of the comments live, looks good from my side now! any adjustments from design can be addressed in a new PR~

toolbar.sizeToFit()
// MARK: - UI Elements
private let toolbar: UIToolbar = .build {
$0.sizeToFit()
}

private lazy var previousButton: UIBarButtonItem = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we use .build for UIBarButtonItem or is it not available?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point @jnrahme did the build not work?

Usually build is for standard inits

Copy link
Contributor

Choose a reason for hiding this comment

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

Going to r+ it regardless but try it

@@ -134,19 +118,21 @@ class AccessoryViewProvider: UIView, Themeable {
// Reset showing of credit card when dismissing the view
// This is required otherwise it will always show credit card view
// even if the input isn't of type credit card
showCreditCard = false
currentAccessoryView = nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we use standard as default?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh I see now, we keep the view around and not AccessoryType.

@jnrahme
Copy link
Contributor Author

jnrahme commented Feb 7, 2024

Main branch
Screenshot 2024-02-07 at 12 29 53 PM

this branch
Screenshot 2024-02-07 at 12 49 54 PM

@mobiletest-ci-bot
Copy link

Messages
📖 Project coverage: 33.17%
📖 Edited 3 files
📖 Created 1 files

Client.app: Coverage: 31.9

File Coverage
AutofillAccessoryViewButtonItem.swift 89.9%
AccessoryViewProvider.swift 68.05%

Generated by 🚫 Danger Swift against 4a777f9

@jnrahme jnrahme merged commit 0fbe36c into mozilla-mobile:main Feb 7, 2024
10 checks passed
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.

6 participants