diff --git a/Shared/views/ContentView.swift b/Shared/views/ContentView.swift index 9b03d38..26793a4 100644 --- a/Shared/views/ContentView.swift +++ b/Shared/views/ContentView.swift @@ -9,6 +9,11 @@ import SwiftUI import CoreData import Charts +struct ContentViewConstants { + static let maxHeaderHeight = 200.0 + static let minHeaderHeight = 88.0 +} + struct ContentView: View { @Environment(\.managedObjectContext) private var viewContext @AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true @@ -18,10 +23,10 @@ struct ContentView: View { @State private var showTodayInput = true @State private var selectedEntry: MoodEntry? @State private var showUpdateEntryAlert = false - @State private var headerHeight: CGFloat = 150 + @State private var headerHeight: CGFloat = ContentViewConstants.maxHeaderHeight - let minHeaderHeight = 88.0 - let maxHeaderHeight = 150.0 + let minHeaderHeight = ContentViewConstants.minHeaderHeight + let maxHeaderHeight = ContentViewConstants.maxHeaderHeight @State private var headerOpacity: Double = 1.0 @ObservedObject var viewModel = ContentModeViewModel() @@ -178,8 +183,9 @@ struct ContentView: View { ) .coordinateSpace(name: "scroll") .onPreferenceChange(ViewOffsetKey.self) { value in - calculateHeight(minHeight: 88, maxHeight: 180, yOffset: value) + calculateHeight(minHeight: ContentViewConstants.minHeaderHeight, maxHeight: ContentViewConstants.maxHeaderHeight, yOffset: value) } + .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) } private func SectionHeaderView(month: Int, year: Int) -> some View { @@ -266,7 +272,11 @@ struct ContentView: View { UIPageControl.appearance().currentPageIndicatorTintColor = UIColor.label UIPageControl.appearance().pageIndicatorTintColor = UIColor.black.withAlphaComponent(0.2) } - .padding(.bottom, 12) + .background( + Color(UIColor.systemBackground) + ) + .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) + .padding([.trailing, .leading]) } } } diff --git a/Shared/views/SwitchableView.swift b/Shared/views/SwitchableView.swift index ed6940b..2d0299d 100644 --- a/Shared/views/SwitchableView.swift +++ b/Shared/views/SwitchableView.swift @@ -18,23 +18,22 @@ struct SwitchableView: View { ZStack { HeaderStatsView(fakeData: false, backDays: daysBack) .opacity(currentViewIdx == 0 ? 1 : 0) + .allowsHitTesting(false) HeaderPercView(fakeData: false, backDays: daysBack) .opacity(currentViewIdx == 1 ? 1 : 0) + .allowsHitTesting(false) } - .padding([.top, .bottom], -7) + .padding(.top, -7) Text(String(format: String(localized: "content_view_header_title"), daysBack)) .font(.body) .foregroundColor(Color(UIColor.systemGray)) .frame(maxWidth: .infinity, alignment: .center) - .padding(.bottom, 15) + .padding(.top, -12) } - .background( - Color(UIColor.systemBackground) - ) - .clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous)) - .padding() + .contentShape(Rectangle()) + .padding(.bottom, 30) .onTapGesture { currentViewIdx += 1 if currentViewIdx == 2 {