generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
cfced91
BIT-678 ui for Identity view
ezimet-livefront c375263
added unit tests
ezimet-livefront 4011dd6
BIT-678 BIT-349 added savings Identity
ezimet-livefront a549379
BIT-678 BIT-349 added unit tests for addEditItemViewTests
ezimet-livefront 392e5d0
Merge branch 'main' of ssh://github.com/bitwarden/ios into BIT-678/crβ¦
ezimet-livefront 36a635f
BIT-678 BIT-349 added mote unit tests
ezimet-livefront 137fb1b
BIT-678 BIT-349 separated zip code and state, updated unit tests, addβ¦
ezimet-livefront 74d0a01
BIT-678 BIT-349 updated docs
ezimet-livefront 46dedef
updated doc
ezimet-livefront 4bcc789
added snapshot testing for large text
ezimet-livefront d7d5967
changed to rawValue for saving titleType
ezimet-livefront 66521a4
updated snapshots
ezimet-livefront 208dabf
BIT-678: Update snapshots
matt-livefront 6cd3283
changed DefaultableType, added customizable title to Menuable
ezimet-livefront 9b0101b
Merge branch 'BIT-678/create-ui-for-identity' of ssh://github.com/bitβ¦
ezimet-livefront 1ffdfd5
fix testing
ezimet-livefront 6baf723
address feedback
ezimet-livefront 5348dba
address feedback
ezimet-livefront e427dac
merge main & resolve merge conflict
ezimet-livefront dba48e4
separated identity state update action
ezimet-livefront f9129db
reorder action position
ezimet-livefront c6a6ce5
address feedback
ezimet-livefront File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/// An enum that describes how a Identity title should be matched. | ||
/// | ||
enum TitleType: String, Codable, Equatable, Hashable, Menuable { | ||
// swiftlint:disable identifier_name | ||
|
||
// MARK: Cases | ||
|
||
/// Mr title for adult men. | ||
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" | ||
// swiftlint:enable identifier_name | ||
|
||
// MARK: Type Properties | ||
|
||
/// default state title for title type | ||
static var defaultValueLocalizedName: String { | ||
"--\(Localizations.select)--" | ||
} | ||
|
||
var localizedName: String { | ||
switch self { | ||
case .mr: Localizations.mr | ||
case .mrs: Localizations.mrs | ||
case .ms: Localizations.ms | ||
case .mx: Localizations.mx | ||
case .dr: Localizations.dr | ||
} | ||
} | ||
|
||
// MARK: Initializer | ||
|
||
init?(rawValue: String) { | ||
switch rawValue { | ||
case Localizations.mr: | ||
self = .mr | ||
case Localizations.mrs: | ||
self = .mrs | ||
case Localizations.ms: | ||
self = .ms | ||
case Localizations.mx: | ||
self = .mx | ||
case Localizations.dr: | ||
self = .dr | ||
default: | ||
return nil | ||
} | ||
} | ||
} | ||
|
||
extension TitleType: CaseIterable { | ||
static var allCases: [TitleType] = [.mr, .mrs, .ms, .mx, .dr] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...Shared/UI/Vault/VaultItem/AddEditItem/AddEditIdentityItem/AddEditIdentityItemAction.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// MARK: - AddEditIdentityItemAction | ||
|
||
import BitwardenSdk | ||
|
||
/// Actions that can be handled by an `AddEditItemProcessor`. | ||
enum AddEditIdentityItemAction: Equatable { | ||
/// The title field was changed. | ||
case titleChanged(DefaultableType<TitleType>) | ||
|
||
/// The first name field was changed. | ||
case firstNameChanged(String) | ||
|
||
/// The last name field was changed. | ||
case lastNameChanged(String) | ||
|
||
/// The middle name field was changed. | ||
case middleNameChanged(String) | ||
|
||
/// The user name field was changed. | ||
case userNameChanged(String) | ||
|
||
/// The company field was changed. | ||
case companyChanged(String) | ||
|
||
/// The SSN field was changed. | ||
case socialSecurityNumberChanged(String) | ||
|
||
/// The passport number field was changed. | ||
case passportNumberChanged(String) | ||
|
||
/// The license number field was changed. | ||
case licenseNumberChanged(String) | ||
|
||
/// The email address field was changed. | ||
case emailChanged(String) | ||
|
||
/// The phone number field was changed. | ||
case phoneNumberChanged(String) | ||
|
||
/// The address line 1 field was changed. | ||
case address1Changed(String) | ||
|
||
/// The address line 2 field was changed. | ||
case address2Changed(String) | ||
|
||
/// The address line 3 field was changed. | ||
case address3Changed(String) | ||
|
||
/// The city/town field was changed. | ||
case cityOrTownChanged(String) | ||
|
||
/// The state field was changed. | ||
case stateChanged(String) | ||
|
||
/// The postal code field was changed. | ||
case postalCodeChanged(String) | ||
|
||
/// The country field was changed. | ||
case countryChanged(String) | ||
} |
191 changes: 191 additions & 0 deletions
191
...enShared/UI/Vault/VaultItem/AddEditItem/AddEditIdentityItem/AddEditIdentityItemView.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,191 @@ | ||
import SwiftUI | ||
|
||
// MARK: - AddEditIdentityItemView | ||
|
||
/// A view that allows the user to add or edit Identity part of the cipherItem to a vault. | ||
/// | ||
struct AddEditIdentityItemView: View { | ||
// MARK: Properties | ||
|
||
/// The `Store` for this view. | ||
@ObservedObject var store: Store<IdentityItemState, AddEditIdentityItemAction, AddEditItemEffect> | ||
|
||
// MARK: Views | ||
|
||
var body: some View { | ||
LazyVStack(alignment: .leading, spacing: 16) { | ||
BitwardenMenuField( | ||
title: Localizations.title, | ||
options: DefaultableType<TitleType>.allCases, | ||
selection: store.binding( | ||
get: \.title, | ||
send: AddEditIdentityItemAction.titleChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.firstName, | ||
text: store.binding( | ||
get: \.firstName, | ||
send: AddEditIdentityItemAction.firstNameChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.middleName, | ||
text: store.binding( | ||
get: \.middleName, | ||
send: AddEditIdentityItemAction.middleNameChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.lastName, | ||
text: store.binding( | ||
get: \.lastName, | ||
send: AddEditIdentityItemAction.lastNameChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.username, | ||
text: store.binding( | ||
get: \.userName, | ||
send: AddEditIdentityItemAction.userNameChanged | ||
) | ||
) | ||
.textFieldConfiguration(.username) | ||
|
||
BitwardenTextField( | ||
title: Localizations.company, | ||
text: store.binding( | ||
get: \.company, | ||
send: AddEditIdentityItemAction.companyChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.ssn, | ||
text: store.binding( | ||
get: \.socialSecurityNumber, | ||
send: AddEditIdentityItemAction.socialSecurityNumberChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.passportNumber, | ||
text: store.binding( | ||
get: \.passportNumber, | ||
send: AddEditIdentityItemAction.passportNumberChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.licenseNumber, | ||
text: store.binding( | ||
get: \.licenseNumber, | ||
send: AddEditIdentityItemAction.licenseNumberChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.email, | ||
text: store.binding( | ||
get: \.email, | ||
send: AddEditIdentityItemAction.emailChanged | ||
) | ||
) | ||
.textFieldConfiguration(.email) | ||
|
||
BitwardenTextField( | ||
title: Localizations.phone, | ||
text: store.binding( | ||
get: \.phone, | ||
send: AddEditIdentityItemAction.phoneNumberChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.address1, | ||
text: store.binding( | ||
get: \.address1, | ||
send: AddEditIdentityItemAction.address1Changed | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.address2, | ||
text: store.binding( | ||
get: \.address2, | ||
send: AddEditIdentityItemAction.address2Changed | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.address3, | ||
text: store.binding( | ||
get: \.address3, | ||
send: AddEditIdentityItemAction.address3Changed | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.cityTown, | ||
text: store.binding( | ||
get: \.cityOrTown, | ||
send: AddEditIdentityItemAction.cityOrTownChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.stateProvince, | ||
text: store.binding( | ||
get: \.state, | ||
send: AddEditIdentityItemAction.stateChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.zipPostalCode, | ||
text: store.binding( | ||
get: \.postalCode, | ||
send: AddEditIdentityItemAction.postalCodeChanged | ||
) | ||
) | ||
|
||
BitwardenTextField( | ||
title: Localizations.country, | ||
text: store.binding( | ||
get: \.country, | ||
send: AddEditIdentityItemAction.countryChanged | ||
) | ||
) | ||
} | ||
} | ||
} | ||
|
||
// MARK: Previews | ||
|
||
#if DEBUG | ||
struct AddEditIdentityItemView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
NavigationView { | ||
ScrollView { | ||
LazyVStack(spacing: 20) { | ||
AddEditIdentityItemView( | ||
store: Store( | ||
processor: StateProcessor( | ||
state: IdentityItemState() | ||
) | ||
) | ||
) | ||
} | ||
.padding(16) | ||
} | ||
.background(Asset.Colors.backgroundSecondary.swiftUIColor) | ||
.ignoresSafeArea() | ||
} | ||
.previewDisplayName("Empty Add Edit Identity State") | ||
} | ||
} | ||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 π