8000 BIT-678: create UI for identity by ezimet-livefront · Pull Request #199 · bitwarden/ios · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

BIT-678: create UI for identity #199

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
Dec 18, 2023
Merged

Conversation

ezimet-livefront
Copy link
Collaborator

🎟️ Tracking

BIT-678

🚧 Type of change

  • 🚀 New feature development

📔 Objective

  • Implemented UI for adding Identity item
  • added unit and snapshot tests

📋 Code changes

  • AddEditItemView.swift: Added AddEditIdentityItemView for Identity.
  • AddEditIdentityItemView.swift: UI for Identity related fields.
  • TitleType.swift: Enum for identity title.
  • DefaultableType.swift added customizable localized name for default case

📸 Screenshots

Screen Shots

test_snapshot_add_identity_full_fieldsVisible 1

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation 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

Comment on lines +9 to +21
case mr = "Mr"

/// Mrs title for married or widowed women.
case mrs = "Mrs"

/// Ms title for women regardless of marital status.
case ms = "Ms"

/// Mx title for individuals who prefer not to specify their gender or identify as non-binary.
case mx = "Mx"

/// Dr title for individuals with a doctoral degree.
case dr = "Dr"
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 Could you review these values and compare them to what are we saving in the live app?
Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

For context, @fedemkr , I was wondering if this should just be a text field, as honorific abbreviations vary wildly by language.
A more complex approach would be localizing the enum.

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 I found an issue with this on our apps, I'll let you know as soon as I have a proper answer for this. Just in case to the user this should be presented localized but I see you have localizedName below so I guess that's already sorted out.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, I also did quick test around live Xamarin app, looks like it saves localized value directly, if user change the locale, it will show the old localized value, and when we try to edit identity, it will fail to preselect the title as new locale does not match the old one.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, exactly. We're discussing it internally on how we are going to handle that. I'll let you know as soon as I have the path forward.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks, I think it would be better to merge this PR and follow up with new ticket for that.

Copy link
Member

Choose a reason for hiding this comment

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

@ezimet-livefront the value saved for the title will be the English version of it so I think those values should be correct 😄

@bitwarden-bot
Copy link
bitwarden-bot commented Dec 14, 2023

Logo
Checkmarx One – Scan Summary & Detailsfc75594c-8ce1-4cda-8407-5857db4eb0d3

No New Or Fixed Issues Found

@eliot-livefront eliot-livefront self-assigned this Dec 14, 2023
case `default`
/// placeholder default value of the type like `default` or `--select--`
/// - Parameter string: custom localizable title value for this default case, defaults to `Default`.
case `default`(String? = nil)
Copy link
Collaborator

Choose a reason for hiding this comment

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

< 8000 button type="submit" data-view-component="true" class="Button--secondary Button--medium Button d-inline-block"> Hide comment

🤔 I think instead of adding the default value as an associated value, you could add it to the Menuable protocol as a static var like defaultValueLocalizedName (and a default value in an extension). This would be more consistent with how the localized name is for the custom values and you'd be able to use the default allCases value for types with a custom default value name.

/// A protocol that defines an object that can be represented and selected in
/// a `BitwardenMenuField`.
protocol Menuable: Equatable, Hashable {
    /// A localized name value. This value is displayed in the Menu when the user
    /// is making a selection between multiple options.
    var localizedName: String { get }

    static var defaultValueLocalizedName: String { get }
}

extension Menuable {
    static var defaultValueLocalizedName: String {
        Localizations.default
    }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Worked like a charm! 💯
Thanks!

Copy link
Contributor
github-actions bot commented Dec 14, 2023
4 Warnings
⚠️ Ignoring duplicate libraries: '-lbitwarden_uniffi'
⚠️ BitwardenShared/Core/Vault/Models/Enum/TitleType.swift has less than 80% code coverage
⚠️ BitwardenShared/UI/Platform/Application/Views/BitwardenMenuField.swift has less than 80% code coverage
⚠️ BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditIdentityItem/IdentityItemState.swift has less than 80% code coverage

Bitwarden code coverage

Total coverage: 84.82%

File Coverage
BitwardenShared/Core/Platform/Models/Domain/DefaultableType.swift 100.00%
BitwardenShared/Core/Vault/Models/Enum/TitleType.swift 42.86%
BitwardenShared/UI/Platform/Application/Views/BitwardenMenuField.swift 45.65%
BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditIdentityItem/AddEditIdentityItemView.swift 88.76%
BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditIdentityItem/IdentityItemState.swift 40.91%
BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemProcessor.swift 95.18%
BitwardenShared/UI/Vault/VaultItem/AddEditItem/AddEditItemView.swift 99.28%
BitwardenShared/UI/Vault/VaultItem/CipherItemState.swift 98.04%
BitwardenShared/UI/Vault/VaultItem/ViewItem/ViewLoginItem/Extensions/CipherView+Update.swift 98.51%

Powered by Slather

Generated by 🚫 Danger

…warden/ios into BIT-678/create-ui-for-identity
@ezimet-livefront ezimet-livefront force-pushed the BIT-678/create-ui-for-identity branch from 4704f51 to 9b0101b Compare December 15, 2023 00:11
Comment on lines +9 to +21
case mr = "Mr"

/// Mrs title for married or widowed women.
case mrs = "Mrs"

/// Ms title for women regardless of marital status.
case ms = "Ms"

/// Mx title for individuals who prefer not to specify their gender or identify as non-binary.
case mx = "Mx"

/// Dr title for individuals with a doctoral degree.
case dr = "Dr"
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 I found an issue with this on our apps, I'll let you know as soon as I have a proper answer for this. Just in case to the user this should be presented localized but I see you have localizedName below so I guess that's already sorted out.

6DAF

Comment on lines 26 to 51
BitwardenTextField(
title: Localizations.firstName,
text: store.binding(
get: \.firstName,
send: AddEditIdentityItemAction.firstNameChanged
)
)
.textFieldConfiguration(.username)

BitwardenTextField(
title: Localizations.middleName,
text: store.binding(
get: \.middleName,
send: AddEditIdentityItemAction.middleNameChanged
)
)
.textFieldConfiguration(.username)

BitwardenTextField(
title: Localizations.lastName,
text: store.binding(
get: \.lastName,
send: AddEditIdentityItemAction.lastNameChanged
)
)
.textFieldConfiguration(.username)
Copy link
Member
@fedemkr fedemkr Dec 15, 2023

Choose a reason for hiding this comment

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

🤔 I see these are using configuration .username but that has textInputAutocapitalization: .never which I think shouldn't be used in these cases given that usually first/middle/lastnames starts with capital letter so it would be a nice UX to have it automatically.

}

/// Tests the add state with identity item filled with large text.
func test_snapshot_add_identity_full_fieldsFilled_largeText() {
Copy link
Member

Choose a reason for hiding this comment

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

🤔 I see not all fields are very long to exceed the size of the field box, could a test be added with very long texts for each property?
🤔 I see that the fields that are exceeding the size of the field box are being trimmed and I think that is not very accessible for people who use large text sizes, how would they read the whole text field? I think we should allow multiline to avoid these issues but check with design first if you can just in case they think differently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @fedemkr, I think there is an issue with snapshot testing configuration with extra large accessibility font,
it actually allows multi line when I test it on simulator.
Simulator Screenshot - iPhone 15 Pro - 2023-12-18 at 09 49 25

Comment on lines 16 to 17
/// The first name for this item.
var lastName: String = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// The first name for this item.
var lastName: String = ""
/// The last name for this item.
var lastName: String = ""

Comment on lines 64 to 65
/// The identity field was changed.
case identityFieldChanged(AddEditIdentityItemAction)
Copy link
Collaborator

Choose a reason for hiding this comment

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

⛏️ Could you alphabetize this relative to the other actions?

Comment on lines 108 to 115
case let .identityFieldChanged(action):
switch action {
case let .firstNameChanged(firstName):
state.identityState.firstName = firstName
case let .middleNameChanged(middleName):
state.identityState.middleName = middleName
case let .titleChanged(title):
state.identityState.title = title
Copy link
Collaborator

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 breaking out this switch into another function since it's already pretty long?

Comment on lines 42 to 46
/// The state for a login type item.
var loginState: LoginItemState

/// The state for a identity type item.
var identityState: IdentityItemState
Copy link
Collaborator

Choose a reason for hiding this comment

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

⛏️ Can you alphabetize this relative to the other properties?

Comment on lines 32 to 35
let type: CipherType = .login
var type: CipherType
Copy link
Collaborator

Choose a reason for hiding this comment

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

❓ Does this need to be a var? I don't think we have a reason to change this after it's initialized for the view screen.

Copy link
Collaborator
@matt-livefront matt-livefront left a comment

Choose a reason for hiding this comment

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

Looks good!

@ezimet-livefront ezimet-livefront merged commit 3c17097 into main Dec 18, 2023
@ezimet-livefront ezimet-livefront deleted the BIT-678/create-ui-for-identity branch December 18, 2023 16:25
vvolkgang pushed a commit that referenced this pull request Feb 24, 2025
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Katherine Bertelsen <kbertelsen@bitwarden.com>
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.

5 participants
0