Skip to content

Commit

Permalink
project setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ananya190 committed Sep 30, 2021
1 parent d5617c5 commit 33c602c
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 80 deletions.
37 changes: 37 additions & 0 deletions Shared/App/SwiftUIView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// ContentView.swift
// Xpendi (iOS)
//
// Created by Ananya George on 9/30/21.
//

import SwiftUI

struct ContentView: View {
var balanceSheet: [Balance] = [Balance(amount: 567.8, title: "paid for popcorn", action: .withdrawal)]
var body: some View {
List {
ForEach(balanceSheet) {
Text("\($0.title ?? "")")
.foregroundColor($0.action.color)
}
}
.toolbar {
#if os(iOS)
EditButton()
#endif

Button(action: addItem) {
Label("Add Item", systemImage: "plus")
}
}
}
private func addItem() {
}
}

struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
80 changes: 0 additions & 80 deletions Shared/ContentView.swift

This file was deleted.

37 changes: 37 additions & 0 deletions Shared/Model/Balance.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Balance.swift
// Xpendi (iOS)
//
// Created by Ananya George on 9/30/21.
//

import Foundation
import SwiftUI

class Balance: Identifiable {
var amount: Double
var title: String
var action: Action
var date: Date

init(amount: Double, title: String, action: Action) {
self.amount = amount
self.title = title
self.action = action
self.date = Date()
}
}

enum Action {
case withdrawal
case deposit

var color: Color {
switch self {
case .withdrawal:
return .red
case .deposit:
return .green
}
}
}

0 comments on commit 33c602c

Please sign in to comment.