45 lines
1.4 KiB
Swift
45 lines
1.4 KiB
Swift
import SwiftUI
|
|
|
|
struct ContentView: View {
|
|
@State private var subs: [Subscription] = []
|
|
|
|
init() {
|
|
self._subs = State(initialValue: [
|
|
Subscription(name: "Test", payments: [Payment(amount: 9.99, intervall: .monthly, startDate: getDate(from: "2023-01-01"))], color: .blue),
|
|
Subscription(name: "Fitness First", payments: [
|
|
Payment(amount: 7.9, intervall: .weekly, startDate: getDate(from: "2023-01-23")),
|
|
Payment(amount: 29, intervall: .quarter, startDate: getDate(from: "2023-04-03"))
|
|
], color: .red)
|
|
])
|
|
}
|
|
|
|
var body: some View {
|
|
TabView {
|
|
HomeView(subs: $subs)
|
|
.tabItem {
|
|
Image(systemName: "house.fill")
|
|
Text("Home")
|
|
}
|
|
|
|
PaymentCalendarView(subs: $subs)
|
|
.tabItem {
|
|
Image(systemName: "calendar")
|
|
Text("Calendar")
|
|
}
|
|
}
|
|
.background(Color.gray.opacity(0.2))
|
|
}
|
|
|
|
private func getDate(from dateString: String) -> Date {
|
|
let formatter = DateFormatter()
|
|
formatter.dateFormat = "yyyy-MM-dd"
|
|
return formatter.date(from: dateString) ?? Date()
|
|
}
|
|
}
|
|
|
|
struct ContentView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
ContentView()
|
|
}
|
|
}
|