8000 PM-18861: Added title accessory content view for BitwardenMenuField by ezimet-livefront · Pull Request #1406 · bitwarden/ios · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PM-18861: Added title accessory content view for BitwardenMenuField #1406

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 3 commits into from
Mar 13, 2025

Conversation

ezimet-livefront
Copy link
Collaborator
@ezimet-livefront ezimet-livefront commented Mar 5, 2025

🎟️ Tracking

PM-18861

📔 Objective

  • Refactored BitwardenMenuField to add accessory content right next to title.
  • Added chevron icon next to the selected username type.
  • Added help icon next to Username type

📸 Screenshots

Before After
before after

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

Copy link
Collaborator Author
@ezimet-livefront ezimet-livefront Mar 5, 2025

Choose a reason for hiding this comment

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

I couldn't make snapshot testing to wait/delay for BitwardenMenuField to calculate the title width.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can make this work if you record the snapshot in the key window.

When we build the config:

static var defaultPortrait: Snapshotting {
.image(
precision: defaultPrecision,
perceptualPrecision: defaultPerceptualPrecision,
layout: .device(config: .iPhone13(.portrait)),
traits: UITraitCollection(userInterfaceStyle: .light)
)
}

You can add drawHierarchyInKeyWindow: true as a parameter to .image(...):

        .image(
            drawHierarchyInKeyWindow: true,
            precision: defaultPrecision,
            perceptualPrecision: defaultPerceptualPrecision,
            layout: .device(config: .iPhone13(.portrait)),
            traits: UITraitCollection(userInterfaceStyle: .light)
        )

We probably don't want to do this for all snapshots though. So maybe we could add it as a parameter to the portrait()/portraitDark()/tallPortraitAX5() functions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this did work! thanks!

Copy link
Contributor
github-actions bot commented Mar 5, 2025

Logo
Checkmarx One – Scan Summary & Details997a81c5-499c-4c1f-a6c5-6b667848d2fd

Great job, no security vulnerabilities found in this Pull Request

Copy link
codecov bot commented Mar 5, 2025

Codecov Report

Attention: Patch coverage is 64.10256% with 28 lines in your changes missing coverage. Please review.

Project coverage is 85.81%. Comparing base (c6374c5) to head (c9db119).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
...plication/Views/FormFields/FormMenuFieldView.swift 50.00% 17 Missing ⚠️
...latform/Application/Views/BitwardenMenuField.swift 72.50% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1406      +/-   ##
==========================================
- Coverage   89.67%   85.81%   -3.87%     
==========================================
  Files         766      983     +217     
  Lines       48109    58446   +10337     
==========================================
+ Hits        43141    50154    +7013     
- Misses       4968     8292    +3324     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +158 to +168
.overlay {
if let titleAccessoryContent {
titleAccessoryContent
.frame(
maxWidth: .infinity,
maxHeight: .infinity,
alignment: .topLeading
)
.offset(x: titleWidth + 4, y: 12)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

❓ Why does this need to be in overlay? Can't it be just a HStack with the title Text and the title Accessory Content?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fedemkr in this case, the titleAccessory contains a button, and placing a button inside a Menu's label: {} does not trigger the click action.

Comment on lines +159 to +166
if let titleAccessoryContent {
titleAccessoryContent
.frame(
maxWidth: .infinity,
maxHeight: .infinity,
alignment: .topLeading
)
.offset(x: titleWidth + 4, y: 12)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎨 Could we align this so it's vertically center aligned with the title? As the font sizes get larger it looks a little out of place being top-aligned.

Screenshot 2025-03-12 at 9 39 17 AM

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is overlay and it is not in the same HStack with the title, one thing I could try is get the height of the title as we get the width, and try to manually make it aligned with title.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@matt-livefront now after doing couple of testing, I don't believe that manually aligning is a good approach. We can't determine the actual height of the titleAccessoryContent, and I prefer not to hard code the height of the icon.

Copy link
Member

Choose a reason for hiding this comment

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

I think maybe you could change the button style for a similar one to have the size based on the font size, so the icon gets bigger on large accessibility fonts thus appearing more aligned with the text.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can make this work if you record the snapshot in the key window.

When we build the config:

static var defaultPortrait: Snapshotting {
.image(
precision: defaultPrecision,
perceptualPrecision: defaultPerceptualPrecision,
layout: .device(config: .iPhone13(.portrait)),
traits: UITraitCollection(userInterfaceStyle: .light)
)
}

You can add drawHierarchyInKeyWindow: true as a parameter to .image(...):

        .image(
            drawHierarchyInKeyWindow: true,
            precision: defaultPrecision,
            perceptualPrecision: defaultPerceptualPrecision,
            layout: .device(config: .iPhone13(.portrait)),
            traits: UITraitCollection(userInterfaceStyle: .light)
        )

We probably don't want to do this for all snapshots though. So maybe we could add it as a parameter to the portrait()/portraitDark()/tallPortraitAX5() functions?

@ezimet-livefront ezimet-livefront merged commit 2d1afd9 into main Mar 13, 2025
11 checks passed
@ezimet-livefront ezimet-livefront deleted the PM-18861/fix-username-type branch March 13, 2025 16:07
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
0