bigger header
page will always respond to swipe
This commit is contained in:
@@ -9,6 +9,11 @@ import SwiftUI
|
|||||||
import CoreData
|
import CoreData
|
||||||
import Charts
|
import Charts
|
||||||
|
|
||||||
|
struct ContentViewConstants {
|
||||||
|
static let maxHeaderHeight = 200.0
|
||||||
|
static let minHeaderHeight = 88.0
|
||||||
|
}
|
||||||
|
|
||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
@Environment(\.managedObjectContext) private var viewContext
|
@Environment(\.managedObjectContext) private var viewContext
|
||||||
@AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true
|
@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 showTodayInput = true
|
||||||
@State private var selectedEntry: MoodEntry?
|
@State private var selectedEntry: MoodEntry?
|
||||||
@State private var showUpdateEntryAlert = false
|
@State private var showUpdateEntryAlert = false
|
||||||
@State private var headerHeight: CGFloat = 150
|
@State private var headerHeight: CGFloat = ContentViewConstants.maxHeaderHeight
|
||||||
|
|
||||||
let minHeaderHeight = 88.0
|
let minHeaderHeight = ContentViewConstants.minHeaderHeight
|
||||||
let maxHeaderHeight = 150.0
|
let maxHeaderHeight = ContentViewConstants.maxHeaderHeight
|
||||||
@State private var headerOpacity: Double = 1.0
|
@State private var headerOpacity: Double = 1.0
|
||||||
|
|
||||||
@ObservedObject var viewModel = ContentModeViewModel()
|
@ObservedObject var viewModel = ContentModeViewModel()
|
||||||
@@ -178,8 +183,9 @@ struct ContentView: View {
|
|||||||
)
|
)
|
||||||
.coordinateSpace(name: "scroll")
|
.coordinateSpace(name: "scroll")
|
||||||
.onPreferenceChange(ViewOffsetKey.self) { value in
|
.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 {
|
private func SectionHeaderView(month: Int, year: Int) -> some View {
|
||||||
@@ -266,7 +272,11 @@ struct ContentView: View {
|
|||||||
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor.label
|
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor.label
|
||||||
UIPageControl.appearance().pageIndicatorTintColor = UIColor.black.withAlphaComponent(0.2)
|
UIPageControl.appearance().pageIndicatorTintColor = UIColor.black.withAlphaComponent(0.2)
|
||||||
}
|
}
|
||||||
.padding(.bottom, 12)
|
.background(
|
||||||
|
Color(UIColor.systemBackground)
|
||||||
|
)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
||||||
|
.padding([.trailing, .leading])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,23 +18,22 @@ struct SwitchableView: View {
|
|||||||
ZStack {
|
ZStack {
|
||||||
HeaderStatsView(fakeData: false, backDays: daysBack)
|
HeaderStatsView(fakeData: false, backDays: daysBack)
|
||||||
.opacity(currentViewIdx == 0 ? 1 : 0)
|
.opacity(currentViewIdx == 0 ? 1 : 0)
|
||||||
|
.allowsHitTesting(false)
|
||||||
|
|
||||||
HeaderPercView(fakeData: false, backDays: daysBack)
|
HeaderPercView(fakeData: false, backDays: daysBack)
|
||||||
.opacity(currentViewIdx == 1 ? 1 : 0)
|
.opacity(currentViewIdx == 1 ? 1 : 0)
|
||||||
|
.allowsHitTesting(false)
|
||||||
}
|
}
|
||||||
.padding([.top, .bottom], -7)
|
.padding(.top, -7)
|
||||||
|
|
||||||
Text(String(format: String(localized: "content_view_header_title"), daysBack))
|
Text(String(format: String(localized: "content_view_header_title"), daysBack))
|
||||||
.font(.body)
|
.font(.body)
|
||||||
.foregroundColor(Color(UIColor.systemGray))
|
.foregroundColor(Color(UIColor.systemGray))
|
||||||
.frame(maxWidth: .infinity, alignment: .center)
|
.frame(maxWidth: .infinity, alignment: .center)
|
||||||
.padding(.bottom, 15)
|
.padding(.top, -12)
|
||||||
}
|
}
|
||||||
.background(
|
.contentShape(Rectangle())
|
||||||
Color(UIColor.systemBackground)
|
.padding(.bottom, 30)
|
||||||
)
|
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
|
|
||||||
.padding()
|
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
currentViewIdx += 1
|
currentViewIdx += 1
|
||||||
if currentViewIdx == 2 {
|
if currentViewIdx == 2 {
|
||||||
|
|||||||
Reference in New Issue
Block a user