-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransactionList.swift
57 lines (52 loc) · 1.62 KB
/
TransactionList.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
//
// TransactionList.swift
// ExpenseTracker
//
// Created by ojohnpepsi on 2023-11-08.
//
import SwiftUI
struct TransactionList: View {
@EnvironmentObject var transactionListVM: TransactionListViewModel
var body: some View {
VStack {
List {
// MARK: Transaction Groups
ForEach(Array(transactionListVM.groupTransactionsByMonth()), id: \.key) { month, transactions in
Section {
// MARK:: Transaction List
ForEach(transactions) { transaction in
TranscactionView(transaction: transaction)
}
} header: {
// MARK: Transaction Month
Text(month)
}
.listSectionSeparator(.hidden)
}
}
.listStyle(.plain
)
}
.navigationTitle("Transactions")
.navigationBarTitleDisplayMode(.inline)
}
}
struct TransactionList_Previews: PreviewProvider {
static let transactionListVM: TransactionListViewModel = {
let transactionListVM = TransactionListViewModel()
transactionListVM.transactions = transactionListPreviewData
return transactionListVM
}()
static var previews: some View {
Group {
NavigationView {
TransactionList()
}
NavigationView {
TransactionList()
.preferredColorScheme(.dark)
}
}
.environmentObject(transactionListVM)
}
}