🚧 First draw of Calandar month navigation
This commit is contained in:
@@ -6,6 +6,7 @@ struct PaymentCalendarView: View {
|
||||
let dateFormatter = DateFormatter()
|
||||
|
||||
@State private var currentDate = Date()
|
||||
private let initialDate = Date()
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
@@ -13,11 +14,43 @@ struct PaymentCalendarView: View {
|
||||
.font(.title)
|
||||
.padding()
|
||||
|
||||
Text(currentMonthYear())
|
||||
.font(.headline)
|
||||
.padding()
|
||||
HStack {
|
||||
Button(action: {
|
||||
self.currentDate = self.calendar.date(byAdding: .month, value: -1, to: self.currentDate)!
|
||||
}) {
|
||||
Image(systemName: "chevron.left.circle.fill")
|
||||
.font(.title)
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
self.currentDate = self.initialDate
|
||||
}) {
|
||||
Text("Current Month")
|
||||
.font(.headline)
|
||||
}
|
||||
|
||||
Button(action: {
|
||||
self.currentDate = self.calendar.date(byAdding: .month, value: 1, to: self.currentDate)!
|
||||
}) {
|
||||
Image(systemName: "chevron.right.circle.fill")
|
||||
.font(.title)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
|
||||
calendarView()
|
||||
.gesture(
|
||||
DragGesture()
|
||||
.onEnded { gesture in
|
||||
if gesture.translation.width < 0 {
|
||||
// Swipe left -> move to next month
|
||||
self.currentDate = self.calendar.date(byAdding: .month, value: 1, to: self.currentDate)!
|
||||
} else {
|
||||
// Swipe right -> move to previous month
|
||||
self.currentDate = self.calendar.date(byAdding: .month, value: -1, to: self.currentDate)!
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
@@ -77,7 +110,6 @@ struct PaymentCalendarView: View {
|
||||
return date >= startOfWeek && date <= endOfWeek && calendar.component(.weekday, from: payment.startDate) == calendar.component(.weekday, from: date)
|
||||
|
||||
case .monthly:
|
||||
// ToDo: Payment not visible if Payment is at example at 31th of month, but month only has 30 days
|
||||
return calendar.component(.day, from: payment.startDate) == calendar.component(.day, from: date)
|
||||
|
||||
case .quarter:
|
||||
|
||||
Reference in New Issue
Block a user