Skip to content

Commit

Permalink
Demonstrate two hard-coded tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
KatherineInCode committed Mar 29, 2024
1 parent f68dc2b commit 04f493c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 68 deletions.
60 changes: 23 additions & 37 deletions AuthenticatorShared/Core/Vault/Repositories/ItemRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,56 +107,42 @@ extension DefaultItemRepository: ItemRepository {
// MARK: Publishers

func vaultListPublisher() async throws -> AsyncThrowingPublisher<AnyPublisher<[VaultListItem], Never>> {
// try await Publishers.
Just([
VaultListItem(
cipherView: .init(
id: UUID().uuidString,
organizationId: nil,
folderId: nil,
collectionIds: [],
key: nil,
name: "Test",
notes: nil,
type: .login,
login: .init(
username: "Username",
password: "Password",
passwordRevisionDate: nil,
uris: nil,
totp: "asdf",
autofillOnPageLoad: false,
fido2Credentials: nil
),
identity: nil,
card: nil,
secureNote: nil,
favorite: false,
reprompt: .none,
organizationUseTotp: false,
edit: false,
viewPassword: false,
localData: nil,
attachments: nil,
fields: nil,
passwordHistory: nil,
creationDate: Date(timeIntervalSinceNow: -1440),
deletedDate: nil,
revisionDate: Date(timeIntervalSinceNow: -1440)
id: UUID().uuidString,
itemType: .totp(
name: "Amazon",
totpModel: VaultListTOTP(
id: UUID().uuidString,
loginView: .init(
username: "Username",
password: "Password",
passwordRevisionDate: nil,
uris: nil,
totp: "amazon",
autofillOnPageLoad: false,
fido2Credentials: nil
),
totpCode: TOTPCodeModel(
code: "123456",
codeGenerationDate: Date(),
period: 30
)
)
)
)!,
),
VaultListItem(
id: UUID().uuidString,
itemType: .totp(
name: "Name",
name: "eBay",
totpModel: VaultListTOTP(
id: UUID().uuidString,
loginView: .init(
username: "Username",
password: "Password",
passwordRevisionDate: nil,
uris: nil,
totp: "asdf",
totp: "ebay",
autofillOnPageLoad: false,
fido2Credentials: nil
),
Expand Down
51 changes: 35 additions & 16 deletions AuthenticatorShared/UI/Vault/Items/Items/ItemsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct ItemsView: View {

var body: some View {
content
.navigationTitle("Verification codes")
.navigationTitle("Item List")
.navigationBarTitleDisplayMode(.inline)
.background(Asset.Colors.backgroundSecondary.swiftUIColor.ignoresSafeArea())
.toolbar {
Expand Down Expand Up @@ -78,23 +78,19 @@ struct ItemsView: View {
@ViewBuilder
private func groupView(with items: [VaultListItem]) -> some View {
ScrollView {
VStack(spacing: 20.0) {
VStack(alignment: .leading, spacing: 7) {
LazyVStack(alignment: .leading, spacing: 0) {
ForEach(items) { item in
Button {
store.send(.itemPressed(item))
} label: {
vaultItemRow(
for: item,
isLastInSection: true
)
}
}
.background(Asset.Colors.backgroundPrimary.swiftUIColor)
.clipShape(RoundedRectangle(cornerRadius: 10))
LazyVStack(alignment: .leading, spacing: 7) {
ForEach(items) { item in
Button {
store.send(.itemPressed(item))
} label: {
vaultItemRow(
for: item,
isLastInSection: true
)
}
}
.background(Asset.Colors.backgroundPrimary.swiftUIColor)
.clipShape(RoundedRectangle(cornerRadius: 10))
}
.padding(16)
}
Expand Down Expand Up @@ -182,6 +178,29 @@ struct ItemsView: View {
)
)
),
.init(
id: "Two",
itemType: .totp(
name: "Two",
totpModel: VaultListTOTP(
id: UUID().uuidString,
loginView: .init(
username: "[email protected]",
password: nil,
passwordRevisionDate: nil,
uris: nil,
totp: "asdf",
autofillOnPageLoad: nil,
fido2Credentials: nil
),
totpCode: TOTPCodeModel(
code: "123456",
codeGenerationDate: Date(),
period: 30
)
)
)
),
]
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ struct ItemListItemRowView: View {
Text("\(count)")
.styleGuide(.body)
.foregroundColor(Asset.Colors.textSecondary.swiftUIColor)
case let .totp(_, model):
totpCodeRow(model)
case let .totp(name, model):
totpCodeRow(name, model)
}
}
.padding(.vertical, 9)
Expand Down Expand Up @@ -137,20 +137,12 @@ struct ItemListItemRowView: View {

/// The row showing the totp code.
@ViewBuilder
private func totpCodeRow(_ model: VaultListTOTP) -> some View {
private func totpCodeRow(_ name: String, _ model: VaultListTOTP) -> some View {
VStack(alignment: .leading, spacing: 0) {
if let uri = model.loginView.uris?.first?.uri {
Text(uri)
.styleGuide(.body)
.lineLimit(1)
.foregroundColor(Asset.Colors.textPrimary.swiftUIColor)
}
if let username = model.loginView.username {
Text(username)
.styleGuide(.subheadline)
.lineLimit(1)
.foregroundColor(Asset.Colors.textSecondary.swiftUIColor)
}
Text(name)
.styleGuide(.headline)
.lineLimit(1)
.foregroundColor(Asset.Colors.textPrimary.swiftUIColor)
}
Spacer()
TOTPCountdownTimerView(
Expand Down

0 comments on commit 04f493c

Please sign in to comment.