2021-12-08 03:22:06 +00:00
|
|
|
//
|
|
|
|
// RecurringTransactionDetailsView.swift
|
|
|
|
// Twigs
|
|
|
|
//
|
|
|
|
// Created by William Brawner on 12/7/21.
|
|
|
|
// Copyright © 2021 William Brawner. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
2022-01-03 17:56:43 +00:00
|
|
|
import TwigsCore
|
2021-12-08 03:22:06 +00:00
|
|
|
|
|
|
|
struct RecurringTransactionDetailsView: View {
|
2022-05-18 01:04:27 +00:00
|
|
|
@EnvironmentObject var dataStore: DataStore
|
2021-12-08 03:22:06 +00:00
|
|
|
|
|
|
|
var body: some View {
|
2022-05-18 01:04:27 +00:00
|
|
|
if let transaction = dataStore.selectedRecurringTransaction {
|
2022-01-05 02:51:38 +00:00
|
|
|
ScrollView {
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Text(transaction.title)
|
|
|
|
.font(.title)
|
|
|
|
Text(transaction.amount.toCurrencyString())
|
|
|
|
.font(.headline)
|
|
|
|
.foregroundColor(transaction.expense ? .red : .green)
|
|
|
|
.multilineTextAlignment(.trailing)
|
|
|
|
if let description = transaction.description {
|
|
|
|
Text(description)
|
|
|
|
}
|
|
|
|
Text(transaction.frequency.naturalDescription)
|
|
|
|
Spacer().frame(height: 10)
|
|
|
|
LabeledField(label: "start", value: transaction.start.toLocaleString(), loading: .constant(false), showDivider: true)
|
2022-05-29 04:25:12 +00:00
|
|
|
LabeledField(label: "end", value: transaction.finish?.toLocaleString(), loading: .constant(false), showDivider: true)
|
2022-01-05 02:51:38 +00:00
|
|
|
// CategoryLineItem()
|
|
|
|
// BudgetLineItem()
|
|
|
|
// UserLineItem()
|
|
|
|
}.padding()
|
|
|
|
}
|
2022-05-29 04:25:12 +00:00
|
|
|
.toolbar {
|
|
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
|
|
Button(action: {
|
|
|
|
Task {
|
|
|
|
await dataStore.edit(transaction)
|
|
|
|
}
|
|
|
|
}) {
|
|
|
|
Text("edit")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-08 03:22:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
struct RecurringTransactionDetailsView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
2022-01-05 02:51:38 +00:00
|
|
|
RecurringTransactionDetailsView()
|
2021-12-08 03:22:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|