Skip to content

Commit 0e29918

Browse files
[PM-27246] Update Authenticator to use ActionCard (#2123)
1 parent 0bebf57 commit 0e29918

12 files changed

+159
-257
lines changed

AuthenticatorShared/UI/Vault/ItemList/ItemList/ItemListCardView+SnapshotTests.swift

Lines changed: 0 additions & 27 deletions
This file was deleted.

AuthenticatorShared/UI/Vault/ItemList/ItemList/ItemListCardView+ViewInspectorTests.swift

Lines changed: 0 additions & 37 deletions
This file was deleted.

AuthenticatorShared/UI/Vault/ItemList/ItemList/ItemListCardView.swift

Lines changed: 0 additions & 136 deletions
This file was deleted.

AuthenticatorShared/UI/Vault/ItemList/ItemList/ItemListView+ViewInspectorTests.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ItemListViewTests: BitwardenTestCase {
4343

4444
/// Test the close taps trigger the associated effect.
4545
@MainActor
46-
func test_itemListCardView_close_download() throws {
46+
func test_actionCard_close_download() async throws {
4747
let state = ItemListState(
4848
itemListCardState: .passwordManagerDownload,
4949
loadingState: .data([ItemListSection.fixture()]),
@@ -54,16 +54,15 @@ class ItemListViewTests: BitwardenTestCase {
5454
timeProvider: timeProvider,
5555
)
5656

57-
try subject.inspect().find(buttonWithAccessibilityLabel: Localizations.close).tap()
58-
59-
waitFor(!processor.effects.isEmpty)
57+
let actionCard = try subject.inspect().find(actionCard: Localizations.downloadTheBitwardenApp)
58+
try await actionCard.find(asyncButton: Localizations.close).tap()
6059

6160
XCTAssertEqual(processor.effects.last, .closeCard(.passwordManagerDownload))
6261
}
6362

6463
/// Test the close taps trigger the associated effect.
6564
@MainActor
66-
func test_itemListCardView_close_sync() throws {
65+
func test_actionCard_close_sync() async throws {
6766
let state = ItemListState(
6867
itemListCardState: .passwordManagerSync,
6968
loadingState: .data([]),
@@ -74,9 +73,8 @@ class ItemListViewTests: BitwardenTestCase {
7473
timeProvider: timeProvider,
7574
)
7675

77-
try subject.inspect().find(buttonWithAccessibilityLabel: Localizations.close).tap()
78-
79-
waitFor(!processor.effects.isEmpty)
76+
let actionCard = try subject.inspect().find(actionCard: Localizations.syncWithTheBitwardenApp)
77+
try await actionCard.find(asyncButton: Localizations.close).tap()
8078

8179
XCTAssertEqual(processor.effects.last, .closeCard(.passwordManagerSync))
8280
}

AuthenticatorShared/UI/Vault/ItemList/ItemList/ItemListView.swift

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import SwiftUI
77
// MARK: - SearchableItemListView
88

99
/// A view that displays the items in a single vault group.
10-
private struct SearchableItemListView: View { // swiftlint:disable:this type_body_length
10+
private struct SearchableItemListView: View {
1111
// MARK: Properties
1212

1313
/// A flag indicating if the search bar is focused.
@@ -131,52 +131,42 @@ private struct SearchableItemListView: View { // swiftlint:disable:this type_bod
131131

132132
/// The Password Manager download card definition.
133133
private var itemListCardPasswordManagerInstall: some View {
134-
ItemListCardView(
135-
bodyText: Localizations.storeAllOfYourLoginsAndSyncVerificationCodesDirectlyWithTheAuthenticatorApp,
136-
buttonText: Localizations.downloadTheBitwardenApp,
137-
leftImage: {
138-
Image(decorative: SharedAsset.Icons.shield24)
139-
.foregroundColor(Asset.Colors.primaryBitwardenLight.swiftUIColor)
140-
.frame(width: 24, height: 24)
141-
},
142-
titleText: Localizations.downloadTheBitwardenApp,
143-
actionTapped: {
134+
ActionCard(
135+
title: Localizations.downloadTheBitwardenApp,
136+
message: Localizations.storeAllOfYourLoginsAndSyncVerificationCodesDirectlyWithTheAuthenticatorApp,
137+
actionButtonState: ActionCard.ButtonState(title: Localizations.downloadTheBitwardenApp) {
144138
openURL(ExternalLinksConstants.passwordManagerLink)
145139
},
146-
closeTapped: {
147-
Task {
148-
await store.perform(.closeCard(.passwordManagerDownload))
149-
}
140+
dismissButtonState: ActionCard.ButtonState(title: Localizations.close) {
141+
await store.perform(.closeCard(.passwordManagerDownload))
150142
},
151-
)
143+
) {
144+
Image(decorative: SharedAsset.Icons.shield24)
145+
.foregroundColor(SharedAsset.Colors.iconSecondary.swiftUIColor)
146+
.frame(width: 24, height: 24)
147+
}
152148
.padding(.top, 16)
153149
}
154150

155151
/// The Password Manager sync card definition.
156152
private var itemListCardSync: some View {
157-
ItemListCardView(
158-
bodyText: Localizations
159-
.allowAuthenticatorAppSyncingInSettingsToViewAllYourVerificationCodesHere,
160-
buttonText: Localizations.takeMeToTheAppSettings,
161-
leftImage: {
162-
Image(decorative: SharedAsset.Icons.arrowSync24)
163-
.foregroundColor(Asset.Colors.primaryBitwardenLight.swiftUIColor)
164-
.frame(width: 24, height: 24)
165-
},
166-
secondaryButtonText: Localizations.learnMore,
167-
titleText: Localizations.syncWithTheBitwardenApp,
168-
actionTapped: {
153+
ActionCard(
154+
title: Localizations.syncWithTheBitwardenApp,
155+
message: Localizations.allowAuthenticatorAppSyncingInSettingsToViewAllYourVerificationCodesHere,
156+
actionButtonState: ActionCard.ButtonState(title: Localizations.takeMeToTheAppSettings) {
169157
openURL(ExternalLinksConstants.passwordManagerSettings)
170158
},
171-
closeTapped: {
172-
Task {
173-
await store.perform(.closeCard(.passwordManagerSync))
174-
}
159+
dismissButtonState: ActionCard.ButtonState(title: Localizations.close) {
160+
await store.perform(.closeCard(.passwordManagerSync))
175161
},
176-
secondaryActionTapped: {
162+
secondaryButtonState: ActionCard.ButtonState(title: Localizations.learnMore) {
177163
openURL(ExternalLinksConstants.totpSyncHelp)
178164
},
179-
)
165+
) {
166+
Image(decorative: SharedAsset.Icons.arrowSync24)
167+
.foregroundColor(SharedAsset.Colors.iconSecondary.swiftUIColor)
168+
.frame(width: 24, height: 24)
169+
}
180170
.padding(.top, 16)
181171
}
182172

@@ -722,6 +712,36 @@ struct ItemListView_Previews: PreviewProvider { // swiftlint:disable:this type_b
722712
timeProvider: PreviewTimeProvider(),
723713
)
724714
}.previewDisplayName("SharedItems")
715+
716+
NavigationView {
717+
ItemListView(
718+
store: Store(
719+
processor: StateProcessor(
720+
state: ItemListState(
721+
itemListCardState: .passwordManagerDownload,
722+
loadingState: .data([]),
723+
),
724+
),
725+
),
726+
timeProvider: PreviewTimeProvider(),
727+
)
728+
}
729+
.previewDisplayName("Password Manager Download Card")
730+
731+
NavigationView {
732+
ItemListView(
733+
store: Store(
734+
processor: StateProcessor(
735+
state: ItemListState(
736+
itemListCardState: .passwordManagerSync,
737+
loadingState: .data([]),
738+
),
739+
),
740+
),
741+
timeProvider: PreviewTimeProvider(),
742+
)
743+
}
744+
.previewDisplayName("Password Manager Sync Card")
725745
}
726746
}
727747
#endif

0 commit comments

Comments
 (0)