-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathFavouriteCapsuleView.swift
80 lines (64 loc) · 2.55 KB
/
FavouriteCapsuleView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// FavouriteCapsuleView.swift
// Strongbox
//
// Created by Strongbox on 27/07/2024.
// Copyright © 2024 Mark McGuill. All rights reserved.
//
import Foundation
import SwiftUI
struct FavouriteCapsuleView: View {
@Environment(\.colorScheme) var colorScheme
@ObservedObject
var model: DatabaseHomeViewModel
var entry: any SwiftEntryModelInterface
var easyReadSeparator: Bool
var body: some View {
Button(action: {
model.actions.navigateTo(destination: .entryDetail(uuid: entry.uuid), homeModel: model)
}, label: {
HStack {
if model.showIcons {
Image(uiImage: entry.image)
.resizable()
.scaledToFit()
.frame(width: 32, height: 32)
.cornerRadius(3.0)
.shadow(radius: 3)
.foregroundStyle(.blue)
}
VStack(alignment: .leading, spacing: 2) {
HStack {
Text(entry.title)
.font(.headline)
Spacer()
if let totp = entry.totp {
TotpView(totp: totp, easyReadSeparator: easyReadSeparator)
}
}
Text(entry.username)
.font(.caption2)
.foregroundStyle(.secondary)
}
Spacer()
}
.foregroundColor(.primary)
.padding(EdgeInsets(top: 8, leading: 8, bottom: 8, trailing: 0))
.frame(width: 220, height: 50)
.background(Color(white: colorScheme == .dark ? 0.1 : 0.9))
.cornerRadius(8.0)
.shadow(radius: 0.5)
})
}
}
#Preview {
let foo = UIImage(systemName: "lock.fill")!
let nodeIcon = NodeIcon.withPreset(0)
let url = "otpauth:
return VStack {
FavouriteCapsuleView(model: DatabaseHomeViewModel(), entry: SwiftDummyEntryModel(title: "Test with a long title", imageSystemName: "lock.fill", totpUrl: url), easyReadSeparator: true)
FavouriteCapsuleView(model: DatabaseHomeViewModel(), entry: SwiftDummyEntryModel(title: "Test1"), easyReadSeparator: true)
FavouriteCapsuleView(model: DatabaseHomeViewModel(), entry: SwiftDummyEntryModel(title: "Test2"), easyReadSeparator: true)
FavouriteCapsuleView(model: DatabaseHomeViewModel(), entry: SwiftDummyEntryModel(title: "Test3"), easyReadSeparator: true)
}
}