-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
NavigationCapsule.swift
67 lines (57 loc) · 1.97 KB
/
NavigationCapsule.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
//
// NavigationCapsule.swift
// Strongbox
//
// Created by Strongbox on 26/07/2024.
// Copyright © 2024 Mark McGuill. All rights reserved.
//
import Foundation
import SwiftUI
struct NavigationCapsule: View {
@Environment(\.colorScheme) var colorScheme
@ObservedObject
var model: DatabaseHomeViewModel
var title: LocalizedStringKey
var image: String
var count: String
var imageBackgroundColor: Color
var destination: DatabaseNavigationDestination
var body: some View {
Button(action: {
model.navigateTo(destination: destination)
}, label: {
ZStack(alignment: .topTrailing) {
HStack {
VStack(alignment: .leading, spacing: 6) {
Image(systemName: image)
.padding(8)
.foregroundColor(.white)
.background(imageBackgroundColor)
.clipShape(.circle)
.frame(height: 32)
Text(title)
.font(.subheadline)
.lineLimit(1)
}
Spacer()
}
HStack(alignment: .firstTextBaseline, spacing: 2) {
Text(count)
.font(.subheadline)
.foregroundStyle(.secondary)
Image(systemName: "chevron.right")
.font(.subheadline)
.foregroundStyle(.secondary)
}
}
.padding(10)
.background(Color(white: colorScheme == .dark ? 0.1 : 0.9))
.cornerRadius(8.0)
.shadow(radius: 0.5)
})
.buttonStyle(PlainButtonStyle())
}
}
#Preview {
NavigationCapsule(model: DatabaseHomeViewModel(), title: "Title", image: "key.fill", count: "1", imageBackgroundColor: .blue, destination: .allEntries)
}