added logic to remember tabview but it doesnt work
This commit is contained in:
Trey t
2022-01-30 19:49:43 -06:00
parent 566c48ab01
commit 9afbfb2e8e
3 changed files with 21 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ struct ContentView: View {
@Environment(\.managedObjectContext) private var viewContext
@AppStorage(UserDefaultsStore.Keys.needsOnboarding.rawValue, store: GroupUserDefaults.groupDefaults) private var needsOnboarding = true
@AppStorage(UserDefaultsStore.Keys.deleteEnable.rawValue, store: GroupUserDefaults.groupDefaults) private var deleteEnabled = true
@AppStorage(UserDefaultsStore.Keys.mainViewTopHeaderIndex.rawValue, store: GroupUserDefaults.groupDefaults) private var mainViewTopHeaderIndex = 0
@State private var showingSheet = false
@State private var showTodayInput = true
@@ -256,7 +257,8 @@ struct ContentView: View {
.frame(height: headerHeight)
.frame(minWidth: 0, maxWidth: .infinity)
} else {
TabView {
// selection hre doesn't work ...
TabView(selection: $mainViewTopHeaderIndex) {
SwitchableView(daysBack: 30)
.frame(height: headerHeight)
.frame(minWidth: 0, maxWidth: .infinity)
@@ -272,10 +274,6 @@ struct ContentView: View {
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor.label
UIPageControl.appearance().pageIndicatorTintColor = UIColor.black.withAlphaComponent(0.2)
}
.background(
Color(UIColor.systemBackground)
)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.padding([.trailing, .leading])
}
}

View File

@@ -23,6 +23,19 @@ struct SwitchableView: View {
HeaderPercView(fakeData: false, backDays: daysBack)
.opacity(currentViewIdx == 1 ? 1 : 0)
.allowsHitTesting(false)
VStack {
HStack {
Spacer()
Image(systemName: "arrow.triangle.2.circlepath.circle")
.resizable()
.frame(width: 25, height: 25, alignment: .trailing)
}
Spacer()
}
.padding(.trailing, 8)
.padding(.top, 8)
.allowsHitTesting(false)
}
.padding(.top, -7)
@@ -32,6 +45,10 @@ struct SwitchableView: View {
.frame(maxWidth: .infinity, alignment: .center)
.padding(.top, -12)
}
.background(
Color(UIColor.systemBackground)
)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.contentShape(Rectangle())
.padding(.bottom, 30)
.onTapGesture {