1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- //
- // BudgetCells.swift
- // ydnab
- //
- // Created by Andrea Franceschini on 03/10/2020.
- //
- import SwiftUI
- /// Budget category, allows to view and edit a budget category.
- struct BudgetCategoryCell: View {
- /// The budget category being represented
- @State var category: BudgetCategory
- /// A formatted string of the amount budgeted for the category
- @State var amountText: String
- /// A positive/negative color to apply to the `amountText`
- @State var color: Color
- var body: some View {
- HStack {
- Text(category.name)
- Spacer()
- Text(amountText)
- .bold()
- .foregroundColor(color)
- }
- }
- }
- /// Budget section, aggregates the budgeted amounts for this section.
- struct BudgetSectionCell: View {
- /// The budget section being represented
- @State var section: BudgetSection
- /// A formatted string of the aggregated amount budgeted in this section
- @State var amountText: String
- /// A positive/negative color to apply to the `amountText`
- @State var color: Color
- @Environment(\.editMode) var editMode
- var body: some View {
- HStack {
- Text(section.name)
- .textCase(.none)
- Spacer()
- if editMode?.wrappedValue == .inactive {
- Text(amountText)
- .foregroundColor(color)
- }
- }
- .padding(.vertical, 11)
- }
- }
|