This commit is contained in:
Vladimir Dubovik
2025-02-25 15:25:45 +03:00
parent 9c6515a2f5
commit b719ab300d
21 changed files with 305 additions and 74 deletions

View File

@ -13,12 +13,13 @@ struct MonthTabView: View {
@State private var createMonth: Bool = false
@State private var currentWeekIndex: Int = 0
@ObservedObject var vm: ScheduleViewModel
@Binding var isShowingVPKLabel: Bool
var body: some View {
VStack {
HStack (spacing: 34) {
ForEach(MockData.daysOfWeek.indices, id: \.self) { index in
Text(MockData.daysOfWeek[index])
.font(.custom("Montserrat-SemiBold", size: 14))
.font(.custom("Montserrat-SemiBold", fixedSize: 15))
.foregroundColor(MockData.daysOfWeek[index] == "Вс" ? Color(.red) : Color("customGray2"))
.padding(.top, 13)
.foregroundColor(.gray)
@ -60,7 +61,7 @@ struct MonthTabView: View {
VStack (spacing: 10) {
ForEach(month.indices, id: \.self) { index in
let week = month[index].week
WeekViewForMonth(week: week, vm: vm)
WeekViewForMonth(week: week, vm: vm, isShowingVPKLabel: $isShowingVPKLabel)
}
}
.background {

View File

@ -12,12 +12,13 @@ struct WeekTabView: View {
@State var weekSlider: [[Date.WeekDay]] = []
@State private var createWeek: Bool = false
@ObservedObject var vm: ScheduleViewModel
@Binding var isShowingVPKLabel: Bool
var body: some View {
HStack {
TabView(selection: $currentWeekIndex) {
ForEach(weekSlider.indices, id: \.self) { index in
let week = weekSlider[index]
WeekViewForWeek(weekSlider: $weekSlider, currentWeekIndex: $currentWeekIndex, createWeek: $createWeek, week: week, vm: vm)
WeekViewForWeek(weekSlider: $weekSlider, currentWeekIndex: $currentWeekIndex, createWeek: $createWeek, week: week, vm: vm, isShowingVPKLabel: $isShowingVPKLabel)
.padding(.horizontal, 15)
.tag(index)
}

View File

@ -10,13 +10,14 @@ import SwiftUI
struct WeekViewForMonth: View {
let week: [Date.WeekDay]
@ObservedObject var vm: ScheduleViewModel
@Binding var isShowingVPKLabel: Bool
var body: some View {
HStack(spacing: 23) {
ForEach(week) { day in
VStack {
Text(day.date.format("dd"))
.font(.custom("Montserrat-SemiBold", size: 14))
.font(.custom("Montserrat-SemiBold", fixedSize: 15))
.foregroundStyle(getForegroundColor(day: day))
}
.frame(width: 30, height: 30, alignment: .center)
@ -25,6 +26,7 @@ struct WeekViewForMonth: View {
.cornerRadius(15)
.onTapGesture {
handleTap(day: day)
isShowingVPKLabel = false
}
}
}

View File

@ -13,17 +13,18 @@ struct WeekViewForWeek: View {
@Binding var createWeek: Bool
let week: [Date.WeekDay]
@ObservedObject var vm: ScheduleViewModel
@Binding var isShowingVPKLabel: Bool
var body: some View {
HStack (spacing: 10) {
ForEach(week) { day in
VStack (spacing: 1) {
Text(day.date.format("E"))
.font(.custom("Montserrat-SemiBold", size: 14))
.font(.custom("Montserrat-SemiBold", fixedSize: 15))
.foregroundColor(day.date.format("E") == "Вс" ? Color(.red) : isSameDate(day.date, vm.selectedDay) ? Color("customGray1") : Color("customGray3"))
.padding(.top, 13)
.foregroundColor(.gray)
Text(day.date.format("dd"))
.font(.custom("Montserrat-Semibold", size: 14))
.font(.custom("Montserrat-Semibold", fixedSize: 15))
.foregroundStyle(isSameDate(day.date, vm.selectedDay) ? .white : .black)
.padding(.bottom, 13)
}
@ -52,6 +53,7 @@ struct WeekViewForWeek: View {
)
.cornerRadius(15)
.onTapGesture {
isShowingVPKLabel = false
vm.selectedDay = day.date
vm.updateSelectedDayIndex()
}