-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTranscactionView.swift
More file actions
64 lines (54 loc) · 1.96 KB
/
TranscactionView.swift
File metadata and controls
64 lines (54 loc) · 1.96 KB
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
//
// TranscactionView.swift
// ExpenseTracker
//
// Created by ojohnpepsi on 2023-11-08.
//
import SwiftUI
import SwiftUIFontIcon
struct TranscactionView: View {
var transaction: Transaction
var body: some View {
HStack(spacing: 20) {
// MARK: Transaction Category Icon
RoundedRectangle(cornerRadius: 20, style: .continuous)
.fill(Color.icon.opacity(0.3))
.frame(width: 44, height: 44)
.overlay {
FontIcon.text(.awesome5Solid(code: transaction.icon), fontsize: 24, color:
Color.icon)
}
VStack(alignment: .leading, spacing: 6) {
// MARK: Transaction Merchant
Text(transaction.merchant)
.font(.subheadline)
.bold()
.lineLimit(1)
// MARK: Transaction Category
Text(transaction.category)
.font(.footnote)
.opacity(0.7)
.lineLimit(1)
// MARK: Transaction Date
Text(transaction.dateParsed, format: .dateTime.year().month().day())
.font(.footnote)
.foregroundColor(.secondary)
}
Spacer()
// MARK: Transaction Amount
Text(transaction.signedAmount, format: .currency(code: "CAD"))
.bold()
.foregroundColor(transaction.type == TransactionType.credit.rawValue ? Color.text : .primary)
}
.padding([.top, .bottom], 8)
}
}
struct TransactionView_Previews: PreviewProvider {
static var previews: some View {
Group {
TranscactionView(transaction: transactionPreviewData)
TranscactionView(transaction: transactionPreviewData)
.preferredColorScheme(.dark)
}
}
}